Annotation of mstools/h/ntimage.h, revision 1.1

1.1     ! root        1: /*++ BUILD Version: 0004    // Increment this if a change has global effects
        !             2: 
        !             3: Copyright (c) 1989  Microsoft Corporation
        !             4: 
        !             5: Module Name:
        !             6: 
        !             7:     ntimage.h
        !             8: 
        !             9: Abstract:
        !            10: 
        !            11:     This is the include file that describes all image structures.
        !            12: 
        !            13: Author:
        !            14: 
        !            15:     Mike O'Leary (mikeol) 21-Mar-1991
        !            16: 
        !            17: Revision History:
        !            18: 
        !            19: --*/
        !            20: 
        !            21: #ifndef _NTIMAGE_
        !            22: #define _NTIMAGE_
        !            23: 
        !            24: //
        !            25: // Define the linker version number.  This is temporary to aid
        !            26: // in debugging with people trying to load images built with
        !            27: // an older linker.  This is not required in the final product.
        !            28: //
        !            29: 
        !            30: #define IMAGE_MAJOR_LINKER_VERSION 2
        !            31: 
        !            32: // begin_winnt
        !            33: 
        !            34: 
        !            35: //
        !            36: // Image Format
        !            37: //
        !            38: 
        !            39: #ifndef RC_INVOKED
        !            40: #pragma pack (1)
        !            41: #endif // !RC_INVOKED
        !            42: 
        !            43: #define IMAGE_DOS_SIGNATURE                 0x5A4D      // MZ
        !            44: #define IMAGE_OS2_SIGNATURE                 0x454E      // NE
        !            45: #define IMAGE_OS2_SIGNATURE_LE              0x454C      // LE
        !            46: #define IMAGE_NT_SIGNATURE                  0x00004550  // PE00
        !            47: 
        !            48: typedef struct _IMAGE_DOS_HEADER {      // DOS .EXE header
        !            49:     USHORT e_magic;                     // Magic number
        !            50:     USHORT e_cblp;                      // Bytes on last page of file
        !            51:     USHORT e_cp;                        // Pages in file
        !            52:     USHORT e_crlc;                      // Relocations
        !            53:     USHORT e_cparhdr;                   // Size of header in paragraphs
        !            54:     USHORT e_minalloc;                  // Minimum extra paragraphs needed
        !            55:     USHORT e_maxalloc;                  // Maximum extra paragraphs needed
        !            56:     USHORT e_ss;                        // Initial (relative) SS value
        !            57:     USHORT e_sp;                        // Initial SP value
        !            58:     USHORT e_csum;                      // Checksum
        !            59:     USHORT e_ip;                        // Initial IP value
        !            60:     USHORT e_cs;                        // Initial (relative) CS value
        !            61:     USHORT e_lfarlc;                    // File address of relocation table
        !            62:     USHORT e_ovno;                      // Overlay number
        !            63:     USHORT e_res[4];                    // Reserved words
        !            64:     USHORT e_oemid;                     // OEM identifier (for e_oeminfo)
        !            65:     USHORT e_oeminfo;                   // OEM information; e_oemid specific
        !            66:     USHORT e_res2[10];                  // Reserved words
        !            67:     LONG   e_lfanew;                    // File address of new exe header
        !            68:   } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
        !            69: 
        !            70: typedef struct _IMAGE_OS2_HEADER {      // OS/2 .EXE header
        !            71:     USHORT ne_magic;                    // Magic number
        !            72:     CHAR   ne_ver;                      // Version number
        !            73:     CHAR   ne_rev;                      // Revision number
        !            74:     USHORT ne_enttab;                   // Offset of Entry Table
        !            75:     USHORT ne_cbenttab;                 // Number of bytes in Entry Table
        !            76:     LONG   ne_crc;                      // Checksum of whole file
        !            77:     USHORT ne_flags;                    // Flag word
        !            78:     USHORT ne_autodata;                 // Automatic data segment number
        !            79:     USHORT ne_heap;                     // Initial heap allocation
        !            80:     USHORT ne_stack;                    // Initial stack allocation
        !            81:     LONG   ne_csip;                     // Initial CS:IP setting
        !            82:     LONG   ne_sssp;                     // Initial SS:SP setting
        !            83:     USHORT ne_cseg;                     // Count of file segments
        !            84:     USHORT ne_cmod;                     // Entries in Module Reference Table
        !            85:     USHORT ne_cbnrestab;                // Size of non-resident name table
        !            86:     USHORT ne_segtab;                   // Offset of Segment Table
        !            87:     USHORT ne_rsrctab;                  // Offset of Resource Table
        !            88:     USHORT ne_restab;                   // Offset of resident name table
        !            89:     USHORT ne_modtab;                   // Offset of Module Reference Table
        !            90:     USHORT ne_imptab;                   // Offset of Imported Names Table
        !            91:     LONG   ne_nrestab;                  // Offset of Non-resident Names Table
        !            92:     USHORT ne_cmovent;                  // Count of movable entries
        !            93:     USHORT ne_align;                    // Segment alignment shift count
        !            94:     USHORT ne_cres;                     // Count of resource segments
        !            95:     UCHAR  ne_exetyp;                   // Target Operating system
        !            96:     UCHAR  ne_flagsothers;              // Other .EXE flags
        !            97:     USHORT ne_pretthunks;               // offset to return thunks
        !            98:     USHORT ne_psegrefbytes;             // offset to segment ref. bytes
        !            99:     USHORT ne_swaparea;                 // Minimum code swap area size
        !           100:     USHORT ne_expver;                   // Expected Windows version number
        !           101:   } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
        !           102: 
        !           103: //
        !           104: // File header format.
        !           105: //
        !           106: 
        !           107: typedef struct _IMAGE_FILE_HEADER {
        !           108:     USHORT  Machine;
        !           109:     USHORT  NumberOfSections;
        !           110:     ULONG   TimeDateStamp;
        !           111:     ULONG   PointerToSymbolTable;
        !           112:     ULONG   NumberOfSymbols;
        !           113:     USHORT  SizeOfOptionalHeader;
        !           114:     USHORT  Characteristics;
        !           115: } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
        !           116: 
        !           117: #define IMAGE_SIZEOF_FILE_HEADER             20
        !           118: 
        !           119: #define IMAGE_FILE_RELOCS_STRIPPED           0x0001  // Relocation info stripped from file.
        !           120: #define IMAGE_FILE_EXECUTABLE_IMAGE          0x0002  // File is executable  (i.e. no unresolved externel references).
        !           121: #define IMAGE_FILE_LINE_NUMS_STRIPPED        0x0004  // Line nunbers stripped from file.
        !           122: #define IMAGE_FILE_LOCAL_SYMS_STRIPPED       0x0008  // Local symbols stripped from file.
        !           123: #define IMAGE_FILE_MINIMAL_OBJECT            0x0010  // Reserved.
        !           124: #define IMAGE_FILE_UPDATE_OBJECT             0x0020  // Reserved.
        !           125: #define IMAGE_FILE_16BIT_MACHINE             0x0040  // 16 bit word machine.
        !           126: #define IMAGE_FILE_BYTES_REVERSED_LO         0x0080  // Bytes of machine word are reversed.
        !           127: #define IMAGE_FILE_32BIT_MACHINE             0x0100  // 32 bit word machine.
        !           128: #define IMAGE_FILE_PATCH                     0x0400  // Reserved.
        !           129: #define IMAGE_FILE_SYSTEM                    0x1000  // System File.
        !           130: #define IMAGE_FILE_DLL                       0x2000  // File is a DLL.
        !           131: #define IMAGE_FILE_BYTES_REVERSED_HI         0x8000  // Bytes of machine word are reversed.
        !           132: 
        !           133: #define IMAGE_FILE_MACHINE_UNKNOWN           0
        !           134: #define IMAGE_FILE_MACHINE_I860              0x14d   // Intel 860.
        !           135: #define IMAGE_FILE_MACHINE_I386              0x14c   // Intel 386.
        !           136: #define IMAGE_FILE_MACHINE_R3000             0x162   // MIPS little-endian, 0540 big-endian
        !           137: #define IMAGE_FILE_MACHINE_R4000             0x166   // MIPS little-endian
        !           138: 
        !           139: //
        !           140: // Directory format.
        !           141: //
        !           142: 
        !           143: typedef struct _IMAGE_DATA_DIRECTORY {
        !           144:     ULONG   VirtualAddress;
        !           145:     ULONG   Size;
        !           146: } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
        !           147: 
        !           148: #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES    16
        !           149: 
        !           150: //
        !           151: // Optional header format.
        !           152: //
        !           153: 
        !           154: typedef struct _IMAGE_OPTIONAL_HEADER {
        !           155:     //
        !           156:     // Standard fields.
        !           157:     //
        !           158: 
        !           159:     USHORT  Magic;
        !           160:     UCHAR   MajorLinkerVersion;
        !           161:     UCHAR   MinorLinkerVersion;
        !           162:     ULONG   SizeOfCode;
        !           163:     ULONG   SizeOfInitializedData;
        !           164:     ULONG   SizeOfUninitializedData;
        !           165:     ULONG   AddressOfEntryPoint;
        !           166:     ULONG   BaseOfCode;
        !           167:     ULONG   BaseOfData;
        !           168: 
        !           169:     //
        !           170:     // NT additional fields.
        !           171:     //
        !           172: 
        !           173:     ULONG   ImageBase;
        !           174:     ULONG   SectionAlignment;
        !           175:     ULONG   FileAlignment;
        !           176:     USHORT  MajorOperatingSystemVersion;
        !           177:     USHORT  MinorOperatingSystemVersion;
        !           178:     USHORT  MajorImageVersion;
        !           179:     USHORT  MinorImageVersion;
        !           180:     USHORT  MajorSubsystemVersion;
        !           181:     USHORT  MinorSubsystemVersion;
        !           182:     ULONG   Reserved1;
        !           183:     ULONG   SizeOfImage;
        !           184:     ULONG   SizeOfHeaders;
        !           185:     ULONG   CheckSum;
        !           186:     USHORT  Subsystem;
        !           187:     USHORT  DllCharacteristics;
        !           188:     ULONG   SizeOfStackReserve;
        !           189:     ULONG   SizeOfStackCommit;
        !           190:     ULONG   SizeOfHeapReserve;
        !           191:     ULONG   SizeOfHeapCommit;
        !           192:     ULONG   AddressOfTlsIndex;
        !           193:     ULONG   NumberOfRvaAndSizes;
        !           194:     IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
        !           195: } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
        !           196: 
        !           197: #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER      28
        !           198: #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER      224
        !           199: 
        !           200: typedef struct _IMAGE_NT_HEADERS {
        !           201:     ULONG Signature;
        !           202:     IMAGE_FILE_HEADER FileHeader;
        !           203:     IMAGE_OPTIONAL_HEADER OptionalHeader;
        !           204: } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
        !           205: 
        !           206: #define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER)        \
        !           207:     ((ULONG)ntheader +                                                  \
        !           208:      FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) +                 \
        !           209:      ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader   \
        !           210:     ))
        !           211: 
        !           212: 
        !           213: // Subsystem Values
        !           214: 
        !           215: #define IMAGE_SUBSYSTEM_UNKNOWN              0   // Unknown subsystem.
        !           216: #define IMAGE_SUBSYSTEM_NATIVE               1   // Image doesn't require a subsystem.
        !           217: #define IMAGE_SUBSYSTEM_WINDOWS_GUI          2   // Image runs in the Windows GUI subsystem.
        !           218: #define IMAGE_SUBSYSTEM_WINDOWS_CUI          3   // Image runs in the Windows character subsystem.
        !           219: #define IMAGE_SUBSYSTEM_OS2_CUI              5   // image runs in the OS/2 character subsystem.
        !           220: #define IMAGE_SUBSYSTEM_POSIX_CUI            7   // image run  in the Posix character subsystem.
        !           221: 
        !           222: // Dll Characteristics
        !           223: 
        !           224: #define IMAGE_LIBRARY_PROCESS_INIT           1   // Dll has a process initialization routine.
        !           225: #define IMAGE_LIBRARY_PROCESS_TERM           2   // Dll has a thread termination routine.
        !           226: #define IMAGE_LIBRARY_THREAD_INIT            4   // Dll has a thread initialization routine.
        !           227: #define IMAGE_LIBRARY_THREAD_TERM            8   // Dll has a thread termination routine.
        !           228: 
        !           229: // Directory Entries
        !           230: 
        !           231: #define IMAGE_DIRECTORY_ENTRY_EXPORT         0   // Export Directory
        !           232: #define IMAGE_DIRECTORY_ENTRY_IMPORT         1   // Import Directory
        !           233: #define IMAGE_DIRECTORY_ENTRY_RESOURCE       2   // Resource Directory
        !           234: #define IMAGE_DIRECTORY_ENTRY_EXCEPTION      3   // Exception Directory
        !           235: #define IMAGE_DIRECTORY_ENTRY_SECURITY       4   // Security Directory
        !           236: #define IMAGE_DIRECTORY_ENTRY_BASERELOC      5   // Base Relocation Table
        !           237: #define IMAGE_DIRECTORY_ENTRY_DEBUG          6   // Debug Directory
        !           238: #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT      7   // Description String
        !           239: #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR      8   // Machine Value (MIPS GP)
        !           240: #define IMAGE_DIRECTORY_ENTRY_THREAD_SPACE   9   // Thread Local Storage
        !           241: #define IMAGE_DIRECTORY_ENTRY_CALLBACKS     10   // Other interesting entrypoints
        !           242: 
        !           243: //
        !           244: // Section header format.
        !           245: //
        !           246: 
        !           247: #define IMAGE_SIZEOF_SHORT_NAME              8
        !           248: 
        !           249: typedef struct _IMAGE_SECTION_HEADER {
        !           250:     UCHAR   Name[IMAGE_SIZEOF_SHORT_NAME];
        !           251:     union {
        !           252:             ULONG   PhysicalAddress;
        !           253:             ULONG   VirtualSize;
        !           254:     } Misc;
        !           255:     ULONG   VirtualAddress;
        !           256:     ULONG   SizeOfRawData;
        !           257:     ULONG   PointerToRawData;
        !           258:     ULONG   PointerToRelocations;
        !           259:     ULONG   PointerToLinenumbers;
        !           260:     USHORT  NumberOfRelocations;
        !           261:     USHORT  NumberOfLinenumbers;
        !           262:     ULONG   Characteristics;
        !           263: } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
        !           264: 
        !           265: #define IMAGE_SIZEOF_SECTION_HEADER          40
        !           266: 
        !           267: #define IMAGE_SCN_TYPE_REGULAR               0x00000000  //
        !           268: #define IMAGE_SCN_TYPE_DUMMY                 0x00000001  // Reserved.
        !           269: #define IMAGE_SCN_TYPE_NO_LOAD               0x00000002  //
        !           270: #define IMAGE_SCN_TYPE_GROUPED               0x00000004  // Used for 16-bit offset code.
        !           271: #define IMAGE_SCN_TYPE_NO_PAD                0x00000008  // Specifies if section should not be padded to next boundary.
        !           272: #define IMAGE_SCN_TYPE_COPY                  0x00000010  // Reserved.
        !           273: #define IMAGE_SCN_CNT_CODE                   0x00000020  // Section contains code.
        !           274: #define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  // Section contains initialized data.
        !           275: #define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  // Section contains uninitialized data.
        !           276: #define IMAGE_SCN_LNK_OTHER                  0x00000100  // Reserved.
        !           277: #define IMAGE_SCN_LNK_INFO                   0x00000200  // Section contains comments or some other type of information.
        !           278: #define IMAGE_SCN_LNK_OVERLAY                0x00000400  // Section contains an overlay.
        !           279: #define IMAGE_SCN_LNK_REMOVE                 0x00000800  // Section contents will not become part of image.
        !           280: #define IMAGE_SCN_LNK_COMDAT                 0x00001000  // Section contents comdat.
        !           281: #define IMAGE_SCN_MEM_DISCARDABLE            0x02000000  // Section can be discarded.
        !           282: #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  // Section is not cachable.
        !           283: #define IMAGE_SCN_MEM_NOT_PAGED              0x08000000  // Section is not pageable.
        !           284: #define IMAGE_SCN_MEM_SHARED                 0x10000000  // Section is shareable.
        !           285: #define IMAGE_SCN_MEM_EXECUTE                0x20000000  // Section is executable.
        !           286: #define IMAGE_SCN_MEM_READ                   0x40000000  // Section is readable.
        !           287: #define IMAGE_SCN_MEM_WRITE                  0x80000000  // Section is writeable.
        !           288: 
        !           289: //
        !           290: // Symbol format.
        !           291: //
        !           292: 
        !           293: typedef struct _IMAGE_SYMBOL {
        !           294:     union {
        !           295:         UCHAR   ShortName[8];
        !           296:         struct {
        !           297:             ULONG   Short;     // if 0, use LongName
        !           298:             ULONG   Long;      // offset into string table
        !           299:         } Name;
        !           300:         PUCHAR  LongName[2];
        !           301:     } N;
        !           302:     ULONG   Value;
        !           303:     SHORT   SectionNumber;
        !           304:     USHORT  Type;
        !           305:     UCHAR   StorageClass;
        !           306:     UCHAR   NumberOfAuxSymbols;
        !           307: } IMAGE_SYMBOL;
        !           308: typedef IMAGE_SYMBOL UNALIGNED *PIMAGE_SYMBOL;
        !           309: 
        !           310: #define IMAGE_SIZEOF_SYMBOL                  18
        !           311: 
        !           312: //
        !           313: // Section values.
        !           314: //
        !           315: // Symbols have a section number of the section in which they are
        !           316: // defined. Otherwise, section numbers have the following meanings:
        !           317: //
        !           318: 
        !           319: #define IMAGE_SYM_UNDEFINED           (SHORT)0           // Symbol is undefined or is common.
        !           320: #define IMAGE_SYM_ABSOLUTE            (SHORT)-1          // Symbol is an absolute value.
        !           321: #define IMAGE_SYM_DEBUG               (SHORT)-2          // Symbol is a special debug item.
        !           322: 
        !           323: //
        !           324: // Type (fundamental) values.
        !           325: //
        !           326: 
        !           327: #define IMAGE_SYM_TYPE_NULL                  0           // no type.
        !           328: #define IMAGE_SYM_TYPE_VOID                  1           //
        !           329: #define IMAGE_SYM_TYPE_CHAR                  2           // type character.
        !           330: #define IMAGE_SYM_TYPE_SHORT                 3           // type short integer.
        !           331: #define IMAGE_SYM_TYPE_INT                   4           //
        !           332: #define IMAGE_SYM_TYPE_LONG                  5           //
        !           333: #define IMAGE_SYM_TYPE_FLOAT                 6           //
        !           334: #define IMAGE_SYM_TYPE_DOUBLE                7           //
        !           335: #define IMAGE_SYM_TYPE_STRUCT                8           //
        !           336: #define IMAGE_SYM_TYPE_UNION                 9           //
        !           337: #define IMAGE_SYM_TYPE_ENUM                  10          // enumeration.
        !           338: #define IMAGE_SYM_TYPE_MOE                   11          // member of enumeration.
        !           339: #define IMAGE_SYM_TYPE_UCHAR                 12          //
        !           340: #define IMAGE_SYM_TYPE_USHORT                13          //
        !           341: #define IMAGE_SYM_TYPE_UINT                  14          //
        !           342: #define IMAGE_SYM_TYPE_ULONG                 15          //
        !           343: 
        !           344: //
        !           345: // Type (derived) values.
        !           346: //
        !           347: 
        !           348: #define IMAGE_SYM_DTYPE_NULL                 0           // no derived type.
        !           349: #define IMAGE_SYM_DTYPE_POINTER              1           // pointer.
        !           350: #define IMAGE_SYM_DTYPE_FUNCTION             2           // function.
        !           351: #define IMAGE_SYM_DTYPE_ARRAY                3           // array.
        !           352: 
        !           353: //
        !           354: // Storage classes.
        !           355: //
        !           356: 
        !           357: #define IMAGE_SYM_CLASS_END_OF_FUNCTION      (UCHAR)-1
        !           358: #define IMAGE_SYM_CLASS_NULL                 0
        !           359: #define IMAGE_SYM_CLASS_AUTOMATIC            1
        !           360: #define IMAGE_SYM_CLASS_EXTERNAL             2
        !           361: #define IMAGE_SYM_CLASS_STATIC               3
        !           362: #define IMAGE_SYM_CLASS_REGISTER             4
        !           363: #define IMAGE_SYM_CLASS_EXTERNAL_DEF         5
        !           364: #define IMAGE_SYM_CLASS_LABEL                6
        !           365: #define IMAGE_SYM_CLASS_UNDEFINED_LABEL      7
        !           366: #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT     8
        !           367: #define IMAGE_SYM_CLASS_ARGUMENT             9
        !           368: #define IMAGE_SYM_CLASS_STRUCT_TAG           10
        !           369: #define IMAGE_SYM_CLASS_MEMBER_OF_UNION      11
        !           370: #define IMAGE_SYM_CLASS_UNION_TAG            12
        !           371: #define IMAGE_SYM_CLASS_TYPE_DEFINITION      13
        !           372: #define IMAGE_SYM_CLASS_UNDEFINED_STATIC     14
        !           373: #define IMAGE_SYM_CLASS_ENUM_TAG             15
        !           374: #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM       16
        !           375: #define IMAGE_SYM_CLASS_REGISTER_PARAM       17
        !           376: #define IMAGE_SYM_CLASS_BIT_FIELD            18
        !           377: #define IMAGE_SYM_CLASS_BLOCK                100
        !           378: #define IMAGE_SYM_CLASS_FUNCTION             101
        !           379: #define IMAGE_SYM_CLASS_END_OF_STRUCT        102
        !           380: #define IMAGE_SYM_CLASS_FILE                 103
        !           381: // new
        !           382: #define IMAGE_SYM_CLASS_SECTION              104
        !           383: #define IMAGE_SYM_CLASS_WEAK_EXTERNAL        105
        !           384: 
        !           385: // type packing constants
        !           386: 
        !           387: #define N_BTMASK                            017
        !           388: #define N_TMASK                             060
        !           389: #define N_TMASK1                            0300
        !           390: #define N_TMASK2                            0360
        !           391: #define N_BTSHFT                            4
        !           392: #define N_TSHIFT                            2
        !           393: 
        !           394: // MACROS
        !           395: 
        !           396: // Basic Type of  x
        !           397: #define BTYPE(x) ((x) & N_BTMASK)
        !           398: 
        !           399: // Is x a pointer?
        !           400: #ifndef ISPTR
        !           401: #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
        !           402: #endif
        !           403: 
        !           404: // Is x a function?
        !           405: #ifndef ISFCN
        !           406: #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
        !           407: #endif
        !           408: 
        !           409: // Is x an array?
        !           410: 
        !           411: #ifndef ISARY
        !           412: #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
        !           413: #endif
        !           414: 
        !           415: // Is x a structure, union, or enumeration TAG?
        !           416: #ifndef ISTAG
        !           417: #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
        !           418: #endif
        !           419: 
        !           420: #ifndef INCREF
        !           421: #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|(x&N_BTMASK))
        !           422: #endif
        !           423: #ifndef DECREF
        !           424: #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
        !           425: #endif
        !           426: 
        !           427: //
        !           428: // Auxiliary entry format.
        !           429: //
        !           430: 
        !           431: typedef union _IMAGE_AUX_SYMBOL {
        !           432:     struct {
        !           433:         ULONG    TagIndex;                      // struct, union, or enum tag index
        !           434:         union {
        !           435:             struct {
        !           436:                 USHORT  Linenumber;             // declaration line number
        !           437:                 USHORT  Size;                   // size of struct, union, or enum
        !           438:             } LnSz;
        !           439:            ULONG    TotalSize;
        !           440:         } Misc;
        !           441:         union {
        !           442:             struct {                            // if ISFCN, tag, or .bb
        !           443:                 ULONG    PointerToLinenumber;
        !           444:                 ULONG    PointerToNextFunction;
        !           445:             } Function;
        !           446:             struct {                            // if ISARY, up to 4 dimen.
        !           447:                 USHORT   Dimension[4];
        !           448:             } Array;
        !           449:         } FcnAry;
        !           450:         USHORT  TvIndex;                        // tv index
        !           451:     } Sym;
        !           452:     struct {
        !           453:         UCHAR   Name[IMAGE_SIZEOF_SYMBOL];
        !           454:     } File;
        !           455:     struct {
        !           456:         ULONG   Length;                         // section length
        !           457:         USHORT  NumberOfRelocations;            // number of relocation entries
        !           458:         USHORT  NumberOfLinenumbers;            // number of line numbers
        !           459:         ULONG   CheckSum;                       // checksum for communal
        !           460:         SHORT   Number;                         // section number to associate with
        !           461:         UCHAR   Selection;                      // communal selection type
        !           462:     } Section;
        !           463: } IMAGE_AUX_SYMBOL;
        !           464: typedef IMAGE_AUX_SYMBOL UNALIGNED *PIMAGE_AUX_SYMBOL;
        !           465: 
        !           466: #define IMAGE_SIZEOF_AUX_SYMBOL              18
        !           467: 
        !           468: //
        !           469: // Communal selection types.
        !           470: //
        !           471: 
        !           472: #define IMAGE_COMDAT_SELECT_UNKNOWN        0
        !           473: #define IMAGE_COMDAT_SELECT_NODUPLICATES   1
        !           474: #define IMAGE_COMDAT_SELECT_ANY            2
        !           475: #define IMAGE_COMDAT_SELECT_SAME_SIZE      3
        !           476: #define IMAGE_COMDAT_SELECT_EXACT_MATCH    4
        !           477: #define IMAGE_COMDAT_SELECT_ASSOCIATIVE    5
        !           478: 
        !           479: #define IMAGE_WEAK_EXTERN_SEARCH_UNKNOWN   0
        !           480: #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
        !           481: #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY   2
        !           482: 
        !           483: 
        !           484: //
        !           485: // Relocation format.
        !           486: //
        !           487: 
        !           488: typedef struct _IMAGE_RELOCATION {
        !           489:     ULONG   VirtualAddress;
        !           490:     ULONG   SymbolTableIndex;
        !           491:     USHORT  Type;
        !           492: } IMAGE_RELOCATION;
        !           493: typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;
        !           494: 
        !           495: #define IMAGE_SIZEOF_RELOCATION              10
        !           496: 
        !           497: //
        !           498: // I860 relocation types.
        !           499: //
        !           500: 
        !           501: #define IMAGE_REL_I860_ABSOLUTE              0           // Reference is absolute, no relocation is necessary
        !           502: #define IMAGE_REL_I860_DIR32                 06          // Direct 32-bit reference to the symbols virtual address
        !           503: #define IMAGE_REL_I860_DIR32NB               07
        !           504: #define IMAGE_REL_I860_SECTION               012
        !           505: #define IMAGE_REL_I860_SECREL                013
        !           506: #define IMAGE_REL_I860_PAIR                  034
        !           507: #define IMAGE_REL_I860_HIGH                  036
        !           508: #define IMAGE_REL_I860_LOW0                  037
        !           509: #define IMAGE_REL_I860_LOW1                  040
        !           510: #define IMAGE_REL_I860_LOW2                  041
        !           511: #define IMAGE_REL_I860_LOW3                  042
        !           512: #define IMAGE_REL_I860_LOW4                  043
        !           513: #define IMAGE_REL_I860_SPLIT0                044
        !           514: #define IMAGE_REL_I860_SPLIT1                045
        !           515: #define IMAGE_REL_I860_SPLIT2                046
        !           516: #define IMAGE_REL_I860_HIGHADJ               047
        !           517: #define IMAGE_REL_I860_BRADDR                050
        !           518: 
        !           519: //
        !           520: // I386 relocation types.
        !           521: //
        !           522: 
        !           523: #define IMAGE_REL_I386_ABSOLUTE              0           // Reference is absolute, no relocation is necessary
        !           524: #define IMAGE_REL_I386_DIR16                 01          // Direct 16-bit reference to the symbols virtual address
        !           525: #define IMAGE_REL_I386_REL16                 02          // PC-relative 16-bit reference to the symbols virtual address
        !           526: #define IMAGE_REL_I386_DIR32                 06          // Direct 32-bit reference to the symbols virtual address
        !           527: #define IMAGE_REL_I386_DIR32NB               07          // Direct 32-bit reference to the symbols virtual address, base not included
        !           528: #define IMAGE_REL_I386_SEG12                 011         // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
        !           529: #define IMAGE_REL_I386_SECTION               012
        !           530: #define IMAGE_REL_I386_SECREL                013
        !           531: #define IMAGE_REL_I386_REL32                 024         // PC-relative 32-bit reference to the symbols virtual address
        !           532: 
        !           533: //
        !           534: // MIPS relocation types.
        !           535: //
        !           536: 
        !           537: #define IMAGE_REL_MIPS_ABSOLUTE              0           // Reference is absolute, no relocation is necessary
        !           538: #define IMAGE_REL_MIPS_REFHALF               01
        !           539: #define IMAGE_REL_MIPS_REFWORD               02
        !           540: #define IMAGE_REL_MIPS_JMPADDR               03
        !           541: #define IMAGE_REL_MIPS_REFHI                 04
        !           542: #define IMAGE_REL_MIPS_REFLO                 05
        !           543: #define IMAGE_REL_MIPS_GPREL                 06
        !           544: #define IMAGE_REL_MIPS_LITERAL               07
        !           545: #define IMAGE_REL_MIPS_SECTION               012
        !           546: #define IMAGE_REL_MIPS_SECREL                013
        !           547: #define IMAGE_REL_MIPS_REFWORDNB             042
        !           548: #define IMAGE_REL_MIPS_PAIR                  045
        !           549: 
        !           550: //
        !           551: // Based relocation format.
        !           552: //
        !           553: 
        !           554: typedef struct _IMAGE_BASE_RELOCATION {
        !           555:     ULONG   VirtualAddress;
        !           556:     ULONG   SizeOfBlock;
        !           557: //  USHORT  TypeOffset[1];
        !           558: } IMAGE_BASE_RELOCATION, *PIMAGE_BASE_RELOCATION;
        !           559: 
        !           560: #define IMAGE_SIZEOF_BASE_RELOCATION         8
        !           561: 
        !           562: //
        !           563: // Based relocation types.
        !           564: //
        !           565: 
        !           566: #define IMAGE_REL_BASED_ABSOLUTE              0
        !           567: #define IMAGE_REL_BASED_HIGH                  1
        !           568: #define IMAGE_REL_BASED_LOW                   2
        !           569: #define IMAGE_REL_BASED_HIGHLOW               3
        !           570: #define IMAGE_REL_BASED_HIGHADJ               4
        !           571: #define IMAGE_REL_BASED_MIPS_JMPADDR          5
        !           572: #define IMAGE_REL_BASED_I860_BRADDR           6
        !           573: #define IMAGE_REL_BASED_I860_SPLIT            7
        !           574: 
        !           575: //
        !           576: // Line number format.
        !           577: //
        !           578: 
        !           579: typedef struct _IMAGE_LINENUMBER {
        !           580:     union {
        !           581:         ULONG   SymbolTableIndex;                       // Symbol table index of function name if Linenumber is 0.
        !           582:         ULONG   VirtualAddress;                         // Virtual address of line number.
        !           583:     } Type;
        !           584:     USHORT  Linenumber;                                 // Line number.
        !           585: } IMAGE_LINENUMBER;
        !           586: typedef IMAGE_LINENUMBER UNALIGNED *PIMAGE_LINENUMBER;
        !           587: 
        !           588: #define IMAGE_SIZEOF_LINENUMBER              6
        !           589: 
        !           590: //
        !           591: // Archive format.
        !           592: //
        !           593: 
        !           594: #define IMAGE_ARCHIVE_START_SIZE             8
        !           595: #define IMAGE_ARCHIVE_START                  "!<arch>\n"
        !           596: #define IMAGE_ARCHIVE_END                    "`\n"
        !           597: #define IMAGE_ARCHIVE_PAD                    "\n"
        !           598: #define IMAGE_ARCHIVE_LINKER_MEMBER          "/               "
        !           599: #define IMAGE_ARCHIVE_LONGNAMES_MEMBER       "//              "
        !           600: 
        !           601: typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
        !           602:     UCHAR    Name[16];                                  // File member name - `/' terminated.
        !           603:     UCHAR    Date[12];                                  // File member date - decimal.
        !           604:     UCHAR    UserID[6];                                 // File member user id - decimal.
        !           605:     UCHAR    GroupID[6];                                // File member group id - decimal.
        !           606:     UCHAR    Mode[8];                                   // File member mode - octal.
        !           607:     UCHAR    Size[10];                                  // File member size - decimal.
        !           608:     UCHAR    EndHeader[2];                              // String to end header.
        !           609: } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
        !           610: 
        !           611: #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR      60
        !           612: 
        !           613: //
        !           614: // DLL support.
        !           615: //
        !           616: 
        !           617: //
        !           618: // Export Format
        !           619: //
        !           620: 
        !           621: typedef struct _IMAGE_EXPORT_DIRECTORY {
        !           622:     ULONG   Characteristics;
        !           623:     ULONG   TimeDateStamp;
        !           624:     USHORT  MajorVersion;
        !           625:     USHORT  MinorVersion;
        !           626:     ULONG   Name;
        !           627:     ULONG   Base;
        !           628:     ULONG   NumberOfFunctions;
        !           629:     ULONG   NumberOfNames;
        !           630:     PULONG  *AddressOfFunctions;
        !           631:     PULONG  *AddressOfNames;
        !           632:     PUSHORT *AddressOfNameOrdinals;
        !           633: } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
        !           634: 
        !           635: //
        !           636: // Import Format
        !           637: //
        !           638: 
        !           639: typedef struct _IMAGE_IMPORT_BY_NAME {
        !           640:     USHORT  Hint;
        !           641:     UCHAR   Name[1];
        !           642: } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME;
        !           643: 
        !           644: typedef struct _IMAGE_THUNK_DATA {
        !           645:     union {
        !           646:         PULONG Function;
        !           647:         ULONG Ordinal;
        !           648:         PIMAGE_IMPORT_BY_NAME AddressOfData;
        !           649:     } u1;
        !           650: } IMAGE_THUNK_DATA, *PIMAGE_THUNK_DATA;
        !           651: 
        !           652: #define IMAGE_ORDINAL_FLAG 0x80000000
        !           653: #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
        !           654: #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
        !           655: 
        !           656: typedef struct _IMAGE_IMPORT_DESCRIPTOR {
        !           657:     ULONG   Characteristics;
        !           658:     ULONG   TimeDateStamp;
        !           659:     USHORT  MajorVersion;
        !           660:     USHORT  MinorVersion;
        !           661:     ULONG   Name;
        !           662:     PIMAGE_THUNK_DATA FirstThunk;
        !           663: } IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR;
        !           664: 
        !           665: //
        !           666: // Resource Format.
        !           667: //
        !           668: 
        !           669: //
        !           670: // Resource directory consists of two counts, following by a variable length
        !           671: // array of directory entries.  The first count is the number of entries at
        !           672: // beginning of the array that have actual names associated with each entry.
        !           673: // The entries are in ascending order, case insensitive strings.  The second
        !           674: // count is the number of entries that immediately follow the named entries.
        !           675: // This second count identifies the number of entries that have 31-bit integer
        !           676: // Ids as their name.  These entries are also sorted in ascending order.
        !           677: //
        !           678: // This structure allows fast lookup by either name or number, but for any
        !           679: // given resource entry only one form of lookup is supported, not both.
        !           680: // This is consistant with the syntax of the .RC file and the .RES file.
        !           681: //
        !           682: 
        !           683: typedef struct _IMAGE_RESOURCE_DIRECTORY {
        !           684:     ULONG   Characteristics;
        !           685:     ULONG   TimeDateStamp;
        !           686:     USHORT  MajorVersion;
        !           687:     USHORT  MinorVersion;
        !           688:     USHORT  NumberOfNamedEntries;
        !           689:     USHORT  NumberOfIdEntries;
        !           690: //  IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
        !           691: } IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY;
        !           692: 
        !           693: #define IMAGE_RESOURCE_NAME_IS_STRING        0x80000000
        !           694: #define IMAGE_RESOURCE_DATA_IS_DIRECTORY     0x80000000
        !           695: 
        !           696: //
        !           697: // Each directory contains the 32-bit Name of the entry and an offset,
        !           698: // relative to the beginning of the resource directory of the data associated
        !           699: // with this directory entry.  If the name of the entry is an actual text
        !           700: // string instead of an integer Id, then the high order bit of the name field
        !           701: // is set to one and the low order 31-bits are an offset, relative to the
        !           702: // beginning of the resource directory of the string, which is of type
        !           703: // IMAGE_RESOURCE_DIRECTORY_STRING.  Otherwise the high bit is clear and the
        !           704: // low-order 31-bits are the integer Id that identify this resource directory
        !           705: // entry. If the directory entry is yet another resource directory (i.e. a
        !           706: // subdirectory), then the high order bit of the offset field will be
        !           707: // set to indicate this.  Otherwise the high bit is clear and the offset
        !           708: // field points to a resource data entry.
        !           709: //
        !           710: 
        !           711: typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
        !           712:     ULONG   Name;
        !           713:     ULONG   OffsetToData;
        !           714: } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
        !           715: 
        !           716: //
        !           717: // For resource directory entries that have actual string names, the Name
        !           718: // field of the directory entry points to an object of the following type.
        !           719: // All of these string objects are stored together after the last resource
        !           720: // directory entry and before the first resource data object.  This minimizes
        !           721: // the impact of these variable length objects on the alignment of the fixed
        !           722: // size directory entry objects.
        !           723: //
        !           724: 
        !           725: typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
        !           726:     USHORT  Length;
        !           727:     CHAR    NameString[ 1 ];
        !           728: } IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING;
        !           729: 
        !           730: 
        !           731: typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
        !           732:     USHORT  Length;
        !           733:     WCHAR   NameString[ 1 ];
        !           734: } IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U;
        !           735: 
        !           736: 
        !           737: //
        !           738: // Each resource data entry describes a leaf node in the resource directory
        !           739: // tree.  It contains an offset, relative to the beginning of the resource
        !           740: // directory of the data for the resource, a size field that gives the number
        !           741: // of bytes of data at that offset, a CodePage that should be used when
        !           742: // decoding code point values within the resource data.  Typically for new
        !           743: // applications the code page would be the unicode code page.
        !           744: //
        !           745: 
        !           746: typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
        !           747:     ULONG   OffsetToData;
        !           748:     ULONG   Size;
        !           749:     ULONG   CodePage;
        !           750:     ULONG   Reserved;
        !           751: } IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY;
        !           752: 
        !           753: //
        !           754: // Debug Format
        !           755: //
        !           756: 
        !           757: typedef struct _IMAGE_DEBUG_DIRECTORY {
        !           758:     ULONG   Characteristics;
        !           759:     ULONG   TimeDateStamp;
        !           760:     USHORT  MajorVersion;
        !           761:     USHORT  MinorVersion;
        !           762:     ULONG   Type;
        !           763:     ULONG   SizeOfData;
        !           764:     ULONG   AddressOfRawData;
        !           765:     ULONG   PointerToRawData;
        !           766: } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
        !           767: 
        !           768: #define IMAGE_DEBUG_TYPE_UNKNOWN    0
        !           769: #define IMAGE_DEBUG_TYPE_COFF       1
        !           770: #define IMAGE_DEBUG_TYPE_CODEVIEW   2
        !           771: 
        !           772: typedef struct _IMAGE_DEBUG_INFO {
        !           773:     ULONG   NumberOfSymbols;
        !           774:     ULONG   LvaToFirstSymbol;
        !           775:     ULONG   NumberOfLinenumbers;
        !           776:     ULONG   LvaToFirstLinenumber;
        !           777:     ULONG   RvaToFirstByteOfCode;
        !           778:     ULONG   RvaToLastByteOfCode;
        !           779:     ULONG   RvaToFirstByteOfData;
        !           780:     ULONG   RvaToLastByteOfData;
        !           781: } IMAGE_DEBUG_INFO, *PIMAGE_DEBUG_INFO;
        !           782: 
        !           783: #ifndef RC_INVOKED
        !           784: #pragma pack ()
        !           785: #endif  // !RC_INVOKED
        !           786: 
        !           787: //
        !           788: // End Image Format
        !           789: //
        !           790: 
        !           791: // end_winnt
        !           792: 
        !           793: #endif // _NTIMAGE_

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.