Subversion Repositories Kolibri OS

Rev

Rev 1906 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. typedef unsigned short WORD;
  3. typedef unsigned int DWORD;
  4. typedef unsigned int LONG;
  5. typedef unsigned char BYTE;
  6.  
  7. #define IMAGE_DOS_SIGNATURE  0x5A4D
  8. #define IMAGE_NT_SIGNATURE   0x00004550
  9. #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
  10.  
  11. #pragma pack(push,2)
  12. typedef struct _IMAGE_DOS_HEADER
  13. {
  14.     WORD    e_magic;
  15.     WORD    e_cblp;
  16.     WORD    e_cp;
  17.     WORD    e_crlc;
  18.     WORD    e_cparhdr;
  19.     WORD    e_minalloc;
  20.     WORD    e_maxalloc;
  21.     WORD    e_ss;
  22.     WORD    e_sp;
  23.     WORD    e_csum;
  24.     WORD    e_ip;
  25.     WORD    e_cs;
  26.     WORD    e_lfarlc;
  27.     WORD    e_ovno;
  28.     WORD    e_res[4];
  29.     WORD    e_oemid;
  30.     WORD    e_oeminfo;
  31.     WORD    e_res2[10];
  32.     LONG    e_lfanew;
  33. } IMAGE_DOS_HEADER,*PIMAGE_DOS_HEADER;
  34. #pragma pack(pop)
  35.  
  36.  
  37. #pragma pack(push,4)
  38. typedef struct _IMAGE_FILE_HEADER
  39. {
  40.     WORD    Machine;
  41.     WORD    NumberOfSections;
  42.     DWORD   TimeDateStamp;
  43.     DWORD   PointerToSymbolTable;
  44.     DWORD   NumberOfSymbols;
  45.     WORD    SizeOfOptionalHeader;
  46.     WORD    Characteristics;
  47. } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
  48.  
  49. #define IMAGE_FILE_DLL              0x2000
  50.  
  51. #define IMAGE_FILE_MACHINE_I386     0x014c   /* Intel 386 or later processors
  52.                                                 and compatible processors */
  53. typedef struct _IMAGE_DATA_DIRECTORY {
  54.     DWORD   VirtualAddress;
  55.     DWORD   Size;
  56. } IMAGE_DATA_DIRECTORY,*PIMAGE_DATA_DIRECTORY;
  57.  
  58. #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES    16
  59.  
  60. typedef struct _IMAGE_OPTIONAL_HEADER {
  61.     WORD    Magic;
  62.     BYTE    MajorLinkerVersion;
  63.     BYTE    MinorLinkerVersion;
  64.     DWORD   SizeOfCode;
  65.     DWORD   SizeOfInitializedData;
  66.     DWORD   SizeOfUninitializedData;
  67.     DWORD   AddressOfEntryPoint;
  68.     DWORD   BaseOfCode;
  69.     DWORD   BaseOfData;
  70.     DWORD   ImageBase;
  71.     DWORD   SectionAlignment;
  72.     DWORD   FileAlignment;
  73.     WORD    MajorOperatingSystemVersion;
  74.     WORD    MinorOperatingSystemVersion;
  75.     WORD    MajorImageVersion;
  76.     WORD    MinorImageVersion;
  77.     WORD    MajorSubsystemVersion;
  78.     WORD    MinorSubsystemVersion;
  79.     DWORD   Win32VersionValue;
  80.     DWORD   SizeOfImage;
  81.     DWORD   SizeOfHeaders;
  82.     DWORD   CheckSum;
  83.     WORD    Subsystem;
  84.     WORD    DllCharacteristics;
  85.     DWORD   SizeOfStackReserve;
  86.     DWORD   SizeOfStackCommit;
  87.     DWORD   SizeOfHeapReserve;
  88.     DWORD   SizeOfHeapCommit;
  89.     DWORD   LoaderFlags;
  90.     DWORD   NumberOfRvaAndSizes;
  91.         IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
  92. } IMAGE_OPTIONAL_HEADER,*PIMAGE_OPTIONAL_HEADER;
  93.  
  94. #pragma pack(pop)
  95.  
  96.  
  97. #pragma pack(push,4)
  98. typedef struct _IMAGE_NT_HEADERS
  99. {
  100.     DWORD Signature;
  101.         IMAGE_FILE_HEADER FileHeader;
  102.         IMAGE_OPTIONAL_HEADER OptionalHeader;
  103. } IMAGE_NT_HEADERS32,*PIMAGE_NT_HEADERS32;
  104.  
  105. #define IMAGE_SIZEOF_SHORT_NAME    8
  106.  
  107. typedef struct _IMAGE_SECTION_HEADER
  108. {
  109.     BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
  110.     union
  111.     {
  112.         DWORD PhysicalAddress;
  113.         DWORD VirtualSize;
  114.     } Misc;
  115.     DWORD   VirtualAddress;
  116.     DWORD   SizeOfRawData;
  117.     DWORD   PointerToRawData;
  118.     DWORD   PointerToRelocations;
  119.     DWORD   PointerToLinenumbers;
  120.     WORD    NumberOfRelocations;
  121.     WORD    NumberOfLinenumbers;
  122.     DWORD   Characteristics;
  123. } IMAGE_SECTION_HEADER,*PIMAGE_SECTION_HEADER;
  124. #pragma pack(pop)
  125.  
  126. #define IMAGE_SCN_CNT_INITIALIZED_DATA      0x00000040
  127. #define IMAGE_SCN_CNT_UNINITIALIZED_DATA    0x00000080
  128. #define IMAGE_SCN_MEM_SHARED                0x10000000
  129. #define IMAGE_SCN_MEM_EXECUTE               0x20000000
  130. #define IMAGE_SCN_MEM_WRITE                 0x80000000
  131.  
  132. #pragma pack(push,4)
  133. typedef struct _IMAGE_BASE_RELOCATION {
  134.         DWORD VirtualAddress;
  135.         DWORD SizeOfBlock;
  136. } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
  137. #pragma pack(pop)
  138.  
  139. typedef struct _IMAGE_IMPORT_DESCRIPTOR
  140. {
  141.     union
  142.     {
  143.                 DWORD Characteristics;
  144.                 DWORD OriginalFirstThunk;
  145.     };
  146.     DWORD   TimeDateStamp;
  147.     DWORD   ForwarderChain;
  148.     DWORD   Name;
  149.     DWORD   FirstThunk;
  150. } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
  151.  
  152. typedef struct _IMAGE_THUNK_DATA32
  153. {
  154.     union
  155.     {
  156.                 DWORD ForwarderString;
  157.                 DWORD Function;
  158.                 DWORD Ordinal;
  159.                 DWORD AddressOfData;
  160.         } u1;
  161. } IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32;
  162.  
  163. typedef struct _IMAGE_IMPORT_BY_NAME
  164. {
  165.         WORD Hint;
  166.         BYTE Name[1];
  167. } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
  168.  
  169. #define IMAGE_ORDINAL_FLAG 0x80000000
  170.  
  171. typedef struct _IMAGE_EXPORT_DIRECTORY {
  172.         DWORD Characteristics;
  173.         DWORD TimeDateStamp;
  174.         WORD MajorVersion;
  175.         WORD MinorVersion;
  176.         DWORD Name;
  177.         DWORD Base;
  178.         DWORD NumberOfFunctions;
  179.         DWORD NumberOfNames;
  180.         DWORD AddressOfFunctions;
  181.         DWORD AddressOfNames;
  182.         DWORD AddressOfNameOrdinals;
  183. } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
  184.  
  185.  
  186. #define MakePtr( cast, ptr, addValue ) (cast)( (uint32_t)(ptr) + (uint32_t)(addValue) )
  187.  
  188.  
  189.