Skip to content

Instantly share code, notes, and snippets.

@ben221199
Last active July 27, 2024 22:43
Show Gist options
  • Save ben221199/76854761f9198ad9a94b3baf593b8057 to your computer and use it in GitHub Desktop.
Save ben221199/76854761f9198ad9a94b3baf593b8057 to your computer and use it in GitHub Desktop.
Microsoft File Types

Symbol file (.SYM)

Source: https://git.ignuranza.net/Microsoft/WindowsXP-SP1/src/branch/master/sdktools/mapsym/mapsym.h

Hierarchy

  • File (e.g. USER.SYM)
    • Map
      • Constant (Absolute symbol)
      • Segment
        • Symbol
        • Line
          • Record
    • End Map

Structs

Map Definition Struct

Struct name: mapdef_s

Field Type Name Description Comment
md_spmap unsigned short (2) S Pointer Map Pointer to next map or zero if end /* 16 bit SEG ptr to next map (0 if end) */
md_abstype unsigned char (1) Absolutes type Type of absolute symbols /* 8 bit map/abs sym flags */
md_pad unsigned char (1) Padding Seems to be always zero /* 8 bit pad */
md_segentry unsigned short (2) Segment Entry Entry point /* 16 bit entry point segment value */
md_cabs unsigned short (2) Count Absolutes Amount of absolute symbols /* 16 bit count of constants in map */
md_pabsoff unsigned short (2) Pointer Absolutes Offset Pointer offset to absolute symbols /* 16 bit ptr to constant offsets */
md_cseg unsigned short (2) Count Segment Amount of segments /* 16 bit count of segments in map */
md_spseg unsigned short (2) S Pointer Segment Pointer to segments /* 16 bit SEG ptr to segment chain */
md_cbnamemax unsigned char (1) Count Name Maximum Maximum name length /* 8 bit maximum symbol name length */
md_cbname unsigned char (1) Count Byte Name Length of name /* 8 bit symbol table name length */
md_achname unsigned char[] (*) ASCII Character Name The name of the map /* <n> name of symbol table (.sym ) */

End Map Struct

Struct name: endmap_s

Field Type Name Description Comment
em_spmap unsigned short (2) S Pointer Map Pointer to next map or zero if end /* end of map chain (SEG ptr 0) */
em_rel unsigned char (1) Release Release (minor) of the MapSym executable /* release */
em_ver unsigned char (1) Version Version (major) of the MapSym executable /* version */

Segment/Group Definition Struct

Struct name: segdef_s

Field Type Name Description Comment
gd_spsegnext unsigned short (2) S Pointer Segment Next Pointer to next segment /* 16 bit SEG ptr to next segdef (0 if end),
relative to mapdef */
gd_csym unsigned short (2) Count Symbols Amount of symbols /* 16 bit count of symbols in sym list */
gd_psymoff unsigned short (2) Pointer Symbols Offset Pointer offset to symbols /* 16 bit ptr to symbol offsets array,
16 bit SEG ptr if MSF_BIG_GROUP set,
either relative to segdef */
gd_lsa unsigned short (2) Load Segment Address ... /* 16 bit Load Segment address */
gd_in0 unsigned short (2) Instance 0 ... /* 16 bit instance 0 physical address */
gd_in1 unsigned short (2) Instance 1 ... /* 16 bit instance 1 physical address */
gd_in2 unsigned short (2) Instance 2 ... /* 16 bit instance 2 physical address */
gd_type unsigned char (1) Type Type flags /* 16 or 32 bit symbols in group */
gd_pad unsigned char (1) Padding ... /* pad byte to fill space for gd_in3 */
gd_spline unsigned short (2) S Pointer Line Pointer to lines /* 16 bit SEG ptr to linedef,
relative to mapdef */
gd_fload unsigned char (1) F Load ... /* 8 bit boolean 0 if seg not loaded */
gd_curin unsigned char (1) Current Instance ... /* 8 bit current instance */
gd_cbname unsigned char (1) Count Byte Name Length of name /* 8 bit Segment name length */
gd_achname unsigned char[] (*) ASCII Character Name The name of the segment /* <n> name of segment or group */

Symbol Definition 16 Struct

Struct name: symdef16_s

Field Type Name Description Comment
sd16_val unsigned short (2) Value Address value or constant value /* 16 bit symbol addr or const */
sd16_cbname unsigned char (1) Count Byte Name Length of name /* 8 bit symbol name length */
sd16_achname unsigned char[] (*) ASCII Character Name Name of symbol /* <n> symbol name */

Symbol Definition 32 Struct

Struct name: symdef_s

Field Type Name Description Comment
sd_lval unsigned long (4) Long Value Address value or constant value /* 32 bit symbol addr or const */
sd_cbname unsigned char (1) Count Byte Name Length of name /* 8 bit symbol name length */
sd_achname unsigned char[] (*) ASCII Character Name Name of symbol /* <n> symbol name */

Line Definition Struct

Struct name: linedef_s

Field Type Name Description Comment
ld_splinenext unsigned short (2) S Pointer Line Next Pointer to next line /* 16 bit SEG ptr to next (0 if last),
relative to mapdef */
ld_pseg unsigned short (2) Pointer Segment Always zero /* 16 bit ptr to segdef_s (always 0) */
ld_plinerec unsigned short (2) Pointer Line record Pointer to line records /* 16 bit ptr to linerecs,
relative to linedef */
ld_itype unsigned short (2) Integer Type Type of line record /* line rec type 0, 1, or 2 */
ld_cline unsigned short (2) Count Line Amount of lines /* 16 bit count of line numbers */
ld_cbname unsigned char (1) Count Byte Name Length of name /* 8 bit file name length */
ld_achname unsigned char[] (*) ASCII Character Name Name of file /* <n> file name */

Line Record 0 Struct

Struct name: linerec0_s

Field Type Name Description Comment
lr0_codeoffset unsigned short (2) Code Offset Code offset /* start offset for this linenumber */
lr0_fileoffset unsigned long (4) File Offset File offset /* file offset for this linenumber */

Line Record 1 Struct

Struct name: linerec1_s

Field Type Name Description Comment
lr1_codeoffset unsigned short (2) Code Offset Code offset /* start offset for this linenumber */
lr1_linenumber unsigned short (2) Line Number Line number /* linenumber */

Line Record 2 Struct

Struct name: linerec2_s

Field Type Name Description Comment
lr2_codeoffset unsigned long (4) Code Offset Code offset /* start offset for this linenumber */
lr2_linenumber unsigned short (2) Line Number Line number /* linenumber */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment