Click here to Skip to main content
15,885,847 members
Articles / Programming Languages / C++

HexEdit - Window Binary File Editor

Rate me:
Please Sign up or sign in to vote.
4.96/5 (137 votes)
17 Oct 2012MIT45 min read 492.1K   22.3K   321  
Open-source hex editor with powerful binary templates
<?xml version="1.0"?>
<!DOCTYPE binary_file_format SYSTEM "BinaryFileFormat.dtd">
<binary_file_format name="SEG-Y file" type_name="" comment="Refer to &quot;Digital Tape Standards&quot; from the Society of Exploration Geophysicists" default_byte_order="big" default_read_only="false" default_char_set="ansi" allow_editing="false">
	<for name="EBCDIC_header_line" count="40" stop_test="" type_name="" comment="40 lines of text each of 80 EBCDIC characters"><data type="string" name="" format="ebcdic" len="80" display=""/></for><struct name="BINARY_header" type_name="" comment="400 bytes of binary values which describe s what is in the rest of the file (ie the traces).  The values are 16 or 32 bit big-endian numbers."><data type="int" name="JobId" format="unsigned" len="4" display="" comment="Job Identification Number"/><data type="int" name="LineNo" format="unsigned" len="4" display="" comment="Line Number"/><data type="int" name="ReelNo" format="unsigned" len="4" display="" comment="Reel Number"/><data type="int" name="NumTraces" format="unsigned" len="2" display="" comment="Number of data traces per record"/><data type="int" name="NumAuxTraces" format="unsigned" len="2" display="" comment="Number of auxiliary traces per record"/><data type="int" name="SampRate" format="unsigned" len="2" display="" comment="Sample interval in microseconds (for this data)" units="microsecs"/><data type="int" name="SampRateOrig" format="unsigned" len="2" display="" comment="Sample interval (for original field recording)" units="microsecs"/><data type="int" name="NumSamp" format="unsigned" len="2" display="" comment="Number of samples per trace (this data)"/><data type="int" name="NumSampOrig" format="unsigned" len="2" display="" comment="Number of samples per trace (original field data)"/><data type="int" name="FormatCode" format="unsigned" len="2" display="" comment="Sample format code 1 = IBM float (4 bytes), 2 = big-endian integer (4 bytes), 3 = big-endian integer (2 bytes), 4 = special int+gain format (4 bytes)" domain="this &gt;= 1 &amp;&amp; this &lt;= 4"/><data type="int" name="CDPFold" format="unsigned" len="2" display="" comment="Expected number of data traces per CDP ensemble."/><data type="int" name="SortCode" format="unsigned" len="2" domain="this &gt;= 1 &amp;&amp; this &lt;= 4" display="" comment="1 = as rcorded (no sorting), 2 = CDP ensemble, 3 = single fold continuous profile, 4 = horizontally stacked"/><data type="int" name="SumCode" format="unsigned" len="2" domain="this &gt; 0 &amp;&amp; this &lt; 32768" display="" comment="Vertical sum code.
1 = no sum, 2 = 2 sum, ... N = N sum"/><data type="int" name="SweepStart" format="unsigned" len="2" display="" comment="Sweep frequency at start"/><data type="int" name="SweepEnd" format="unsigned" len="2" display="" comment="Sweep frequency at end"/><data type="int" name="SweepLen" format="unsigned" len="2" display="" units="msec" comment="Sweep length"/><data type="int" name="SweepType" format="unsigned" len="2" domain="this &lt;= 4" display="" comment="Sweep type code: 1 = linear, 2 = parabolic, 3 = exponential, 4 = other"/><data type="int" name="TraceNum" format="unsigned" len="2" display="" comment="Trace number of sweep channel"/><data type="int" name="SweepStartTaper" format="unsigned" len="2" display="" units="msec" comment="Sweep trace taper length at start if tapered"/><data type="int" name="SweepEndTaper" format="unsigned" len="2" display="" units="msec" comment="Sweep trace taper length at end if tapered"/><data type="int" name="TaperType" format="unsigned" len="2" display="" comment="1 = linear, 2 = cos squared, 3 = other"/><data type="int" name="CorrCode" format="unsigned" len="2" domain="this &lt;= 2" display="" comment="Correlated data traces 1 = no, 2 = yes"/><data type="int" name="BinaryGain" format="unsigned" len="2" domain="this &lt;= 2" display="" comment="Binary gain recovered 1 = yes, 2 = no"/><data type="int" name="AmplitudeCode" format="unsigned" len="2" display="" comment="Amplitude recovery method: 1 = none, 2 = spherical divergence, 3 = AGC, 4 = other" domain="this &lt;= 4"/><data type="int" name="UnitsCode" format="unsigned" len="2" domain="this == 1 || this == 2" display="" comment="Measurement system: 1 = meters, 2 = feet"/><data type="int" name="ImpulseCode" format="unsigned" len="2" domain="this &lt;= 2" display="" comment="Impulse signal polarity: 1 = increase in pressure or upward geophone case  movement gives negative number on tape, 2 = increase in pressure or upward geophone case movement gives positive number on tape
"/><data type="int" name="VibeCode" format="unsigned" len="2" domain="this &lt;= 8" display="" comment="Vibratory polarity code."/><data type="none" name="Unassigned" len="340" comment="For optional information"/></struct><for name="Trace" count="" stop_test="" type_name="" comment=""><struct name="" type_name="" comment=""><struct name="Header" type_name="" comment="Trace header (240 bytes)"><data type="int" name="TraceNum" format="unsigned" len="4" display="" comment="Trace sequence number within the line"/><data type="int" name="TraceNumReel" format="unsigned" len="4" display="" comment="Trace sequence number within this reel"/><data type="int" name="FFID" format="signed" len="4" display="" comment="Original field record number"/><data type="int" name="TraceNumOrig" format="unsigned" len="4" display="" comment="Trace number within the original field record"/><data type="int" name="PointNum" format="unsigned" len="4" display=""/><data type="int" name="CDPEnsemble" format="unsigned" len="4" display=""/><data type="int" name="TraceCDP" format="unsigned" len="4" display=""/><data type="int" name="TraceId" format="unsigned" len="2" display="" comment="Trace identification code"/><data type="none" name="TBD1" len="42"/><data type="int" name="CoordX" format="signed" len="4" display="" comment="Source coordinate X"/><data type="int" name="CoordY" format="signed" len="4" display="" comment="Source coordinate Y"/><data type="int" name="GroupCoordX" format="signed" len="4" display=""/><data type="int" name="GroupCoordY" format="signed" len="4" display=""/><data type="int" name="CoordUnits" format="unsigned" len="2" display="" comment="1 = length (meters or feet), 2 = seconds of arc (lat/long)" domain="this &lt;= 2"/><data type="none" name="TBD2" len="24"/><data type="int" name="NumSamp" format="unsigned" len="2" display="" comment="Number of samples in this trace"/><data type="int" name="SampRate" format="unsigned" len="2" display="" units="microsecs" comment="Sample interval for this trace"/><data type="none" name="TBD3" len="62"/><data type="none" name="Unassigned" len="60"/></struct><for name="Sample" count="BINARY_header.NumSamp" stop_test="" type_name="" comment=""><data type="none" name="" len="BINARY_header.FormatCode == 2 ? 2 : 4" comment="Sample size depends on the Format Code:
1 = 4 bytes (IBM float)
2 = 2 bytes (big-endian integer)
3 = 4 bytes (big-endian integer)
4 = 4 bytes (special format integer with gain)"/></for></struct></for></binary_file_format>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Australia Australia
Andrew has a BSc (1983) from Sydney University in Computer Science and Mathematics. Andrew began programming professionally in C in 1984 and has since used many languages but mainly C, C++, and C#.

Andrew has a particular interest in STL, .Net, and Agile Development. He has written articles on STL for technical journals such as the C/C++ User's Journal.

In 1997 Andrew began using MFC and released the source code for a Windows binary file editor called HexEdit, which was downloaded more than 1 million times. From 2001 there was a shareware version of HexEdit (later called HexEdit Pro). HexEdit has been updated to uses the new MFC (based on BCG) and is once more open source.

Comments and Discussions