Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
5.8 KiB

  1. /************************************************************************/
  2. /* */
  3. /* FILENAME.H -- Standard C Header File Format */
  4. /* */
  5. /************************************************************************/
  6. /* Author: */
  7. /* Copyright: */
  8. /************************************************************************/
  9. /* File Description: */
  10. /* */
  11. /* */
  12. /************************************************************************/
  13. /* Revision History: */
  14. /* */
  15. /* 03/27/92 (GeneA): modified to conform to version 3.7 of PE format */
  16. /* spec. */
  17. /* */
  18. /************************************************************************/
  19. /* ------------------------------------------------------------ */
  20. /* */
  21. /* ------------------------------------------------------------ */
  22. /* ------------------------------------------------------------ */
  23. /* Fixup Defintions
  24. */
  25. typedef struct _fxr {
  26. DWORD rvaPage;
  27. DWORD cbSize;
  28. WORD rgwOffset[1];
  29. } FXR;
  30. /* Fixup record types
  31. */
  32. #define fxtAbsolute 0
  33. #define fxtHigh 1
  34. #define fxtLow 2
  35. #define fxtHighLow 3
  36. #define fxtHighAdjust 4
  37. #define fxtMax 5
  38. /* ------------------------------------------------------------ */
  39. /* Debug Directory Table */
  40. typedef struct _ddt {
  41. DWORD flFlags;
  42. DWORD idTimeStamp;
  43. WORD verMajor;
  44. WORD verMinor;
  45. DWORD dwType;
  46. DWORD dwSize;
  47. DWORD rva;
  48. DWORD dwSeek;
  49. } DDT;
  50. typedef DDT *PDDT;
  51. /* ------------------------------------------------------------ */
  52. /* Linear EXE Header
  53. */
  54. #define fimgProgram 0x0000
  55. #define fimgExecutable 0x0002
  56. #define fimgFixed 0x0200
  57. #define fimgLibrary 0x2000
  58. #define fdllPrcInit 0x0001
  59. #define fdllPrcTerm 0x0002
  60. #define fdllThdInit 0x0004
  61. #define fdllThdTerm 0x0008
  62. // Subsystem id
  63. // CONBUG these are probably defined elsewhere, but I never found 'em
  64. #define subidWindows 2
  65. #define subidConsole 3
  66. typedef struct _tagLEH {
  67. DWORD Signature; // idExeHdr // "PE\0\0"
  68. WORD Machine; // wCpuType // 0x14c == 386
  69. WORD NumberOfSections; // coteObjTable // # of objects following LEH
  70. DWORD TimeDateStamp; // idTimeStamp
  71. DWORD PointerToSymbolTable; // bReserved1[8]
  72. DWORD NumberOfSymbols;
  73. WORD SizeOfOptionalHeader; // cbOptHdrSize // header from bResv2 until ObjTab
  74. WORD Characteristics; // fsModFlags
  75. //
  76. // Standard fields.
  77. //
  78. WORD Magic; // bReserved2[2]
  79. BYTE MajorLinkerVersion; //verLinkMajor
  80. BYTE MinorLinkerVersion; //verLinkMinor
  81. DWORD SizeOfCode; // bReserved3[12]
  82. DWORD SizeOfInitializedData;
  83. DWORD SizeOfUninitializedData;
  84. DWORD AddressOfEntryPoint; // rvaEntryPoint // or NULL
  85. DWORD BaseOfCode; // bReserved4[8]
  86. DWORD BaseOfData;
  87. //
  88. // NT additional fields.
  89. //
  90. DWORD ImageBase; // dwImageBase // actual value - modified if relocated
  91. DWORD SectionAlignment; // dwObjectAlign
  92. DWORD FileAlignment; // dwFileAlign
  93. WORD MajorOperatingSystemVersion;// verOSMajor
  94. WORD MinorOperatingSystemVersion;// verOSMinor
  95. WORD MajorImageVersion; // verUserMajor
  96. WORD MinorImageVersion; // verUserMinor
  97. WORD MajorSubsystemVersion; // verSubSysMajor
  98. WORD MinorSubsystemVersion; // verSubSysMinor
  99. DWORD Reserved1; // bReserved5[4]
  100. DWORD SizeOfImage; // cbImageSize
  101. DWORD SizeOfHeaders; // cbHeaderSize
  102. DWORD CheckSum; // dwCheckSum
  103. WORD Subsystem; // idSubSystem
  104. WORD DllCharacteristics; // fsDllFlags
  105. DWORD SizeOfStackReserve; // cbStackReserve
  106. DWORD SizeOfStackCommit; // cbStackCommit
  107. DWORD SizeOfHeapReserve; // cbHeapReserve
  108. DWORD SizeOfHeapCommit; // cbHeapCommit
  109. DWORD LoaderFlags; // bReserved6[4]
  110. DWORD NumberOfRvaAndSizes; // dwRVASizeCount
  111. IMAGE_DATA_DIRECTORY // rgrtb[9]
  112. DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
  113. } LEH;
  114. /* ------------------------------------------------------------ */
  115. /* Convert RVA to actual address, based on load address
  116. * of Linear Exe Header and Relative Virtual Address
  117. */
  118. /* Pointer version of macro */
  119. #define RVA(leh, rva) (void *)(leh->ImageBase + (DWORD)(rva))
  120. /* Integer (DWORD) version of macro */
  121. #define RVAW(leh, rva) (DWORD)RVA(leh, rva)
  122. /* ------------------------------------------------------------ */
  123. /* Find start of object table given start of LEH
  124. */
  125. #define POTE(pleh) (OTE *)((char *)&(pleh)->Magic + \
  126. (pleh)->SizeOfOptionalHeader)
  127. /* ------------------------------------------------------------ */
  128. #define RESOURCE_RVA(pleh) (DWORD)((pleh)-> \
  129. DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress)
  130. #define RESOURCE_SIZE(pleh) (DWORD)((pleh)-> \
  131. DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].Size)
  132. /* ------------------------------------------------------------ */
  133. #define OTE IMAGE_SECTION_HEADER
  134. #define EDT IMAGE_EXPORT_DIRECTORY
  135. #define IDT IMAGE_IMPORT_DESCRIPTOR
  136. #define DXH IMAGE_DOS_HEADER
  137. /* ------------------------------------------------------------ */
  138. /* ------------------------------------------------------------ */
  139. /* ------------------------------------------------------------ */
  140. /* ------------------------------------------------------------ */
  141. /* ------------------------------------------------------------ */
  142. /************************************************************************/