Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. unit EXETypes;
  2.  
  3. interface
  4.  
  5. const
  6.   IMAGE_DOS_SIGNATURE    = $5A4D;       { MZ }
  7.   IMAGE_OS2_SIGNATURE    = $454E;       { NE }
  8.   IMAGE_OS2_SIGNATURE_LE = $454C;       { LE }
  9.   IMAGE_VXD_SIGNATURE    = $454C;       { LE }
  10.   IMAGE_NT_SIGNATURE     = $00004550;   { PE00 }
  11.  
  12.   IMAGE_SIZEOF_SHORT_NAME          = 8;
  13.   IMAGE_SIZEOF_SECTION_HEADER      = 40;
  14.   IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16;
  15.   IMAGE_RESOURCE_NAME_IS_STRING    = $80000000;
  16.   IMAGE_RESOURCE_DATA_IS_DIRECTORY = $80000000;
  17.   IMAGE_OFFSET_STRIP_HIGH          = $7FFFFFFF;
  18.  
  19. type
  20.   PIMAGE_DOS_HEADER = ^IMAGE_DOS_HEADER;
  21.   IMAGE_DOS_HEADER = packed record      { DOS .EXE header }
  22.     e_magic         : WORD;             { Magic number }
  23.     e_cblp          : WORD;             { Bytes on last page of file }
  24.     e_cp            : WORD;             { Pages in file }
  25.     e_crlc          : WORD;             { Relocations }
  26.     e_cparhdr       : WORD;             { Size of header in paragraphs }
  27.     e_minalloc      : WORD;             { Minimum extra paragraphs needed }
  28.     e_maxalloc      : WORD;             { Maximum extra paragraphs needed }
  29.     e_ss            : WORD;             { Initial (relative) SS value }
  30.     e_sp            : WORD;             { Initial SP value }
  31.     e_csum          : WORD;             { Checksum }
  32.     e_ip            : WORD;             { Initial IP value }
  33.     e_cs            : WORD;             { Initial (relative) CS value }
  34.     e_lfarlc        : WORD;             { File address of relocation table }
  35.     e_ovno          : WORD;             { Overlay number }
  36.     e_res           : packed array [0..3] of WORD; { Reserved words }
  37.     e_oemid         : WORD;             { OEM identifier (for e_oeminfo) }
  38.     e_oeminfo       : WORD;             { OEM information; e_oemid specific }
  39.     e_res2          : packed array [0..9] of WORD; { Reserved words }
  40.     e_lfanew        : Longint;          { File address of new exe header }
  41.   end;
  42.  
  43.   PIMAGE_FILE_HEADER = ^IMAGE_FILE_HEADER;
  44.   IMAGE_FILE_HEADER = packed record
  45.     Machine              : WORD;
  46.     NumberOfSections     : WORD;
  47.     TimeDateStamp        : DWORD;
  48.     PointerToSymbolTable : DWORD;
  49.     NumberOfSymbols      : DWORD;
  50.     SizeOfOptionalHeader : WORD;
  51.     Characteristics      : WORD;
  52.   end;
  53.  
  54.   PIMAGE_DATA_DIRECTORY = ^IMAGE_DATA_DIRECTORY;
  55.   IMAGE_DATA_DIRECTORY = packed record
  56.     VirtualAddress  : DWORD;
  57.     Size            : DWORD;
  58.   end;
  59.  
  60.   PIMAGE_OPTIONAL_HEADER = ^IMAGE_OPTIONAL_HEADER;
  61.   IMAGE_OPTIONAL_HEADER = packed record
  62.    { Standard fields. }
  63.     Magic           : WORD;
  64.     MajorLinkerVersion : Byte;
  65.     MinorLinkerVersion : Byte;
  66.     SizeOfCode      : DWORD;
  67.     SizeOfInitializedData : DWORD;
  68.     SizeOfUninitializedData : DWORD;
  69.     AddressOfEntryPoint : DWORD;
  70.     BaseOfCode      : DWORD;
  71.     BaseOfData      : DWORD;
  72.    { NT additional fields. }
  73.     ImageBase       : DWORD;
  74.     SectionAlignment : DWORD;
  75.     FileAlignment   : DWORD;
  76.     MajorOperatingSystemVersion : WORD;
  77.     MinorOperatingSystemVersion : WORD;
  78.     MajorImageVersion : WORD;
  79.     MinorImageVersion : WORD;
  80.     MajorSubsystemVersion : WORD;
  81.     MinorSubsystemVersion : WORD;
  82.     Reserved1       : DWORD;
  83.     SizeOfImage     : DWORD;
  84.     SizeOfHeaders   : DWORD;
  85.     CheckSum        : DWORD;
  86.     Subsystem       : WORD;
  87.     DllCharacteristics : WORD;
  88.     SizeOfStackReserve : DWORD;
  89.     SizeOfStackCommit : DWORD;
  90.     SizeOfHeapReserve : DWORD;
  91.     SizeOfHeapCommit : DWORD;
  92.     LoaderFlags     : DWORD;
  93.     NumberOfRvaAndSizes : DWORD;
  94.     DataDirectory   : packed array [0..IMAGE_NUMBEROF_DIRECTORY_ENTRIES-1] of IMAGE_DATA_DIRECTORY;
  95.   end;
  96.  
  97.   PIMAGE_SECTION_HEADER = ^IMAGE_SECTION_HEADER;
  98.   IMAGE_SECTION_HEADER = packed record
  99.     Name            : packed array [0..IMAGE_SIZEOF_SHORT_NAME-1] of Char;
  100.     PhysicalAddress : DWORD; // or VirtualSize (union);
  101.     VirtualAddress  : DWORD;
  102.     SizeOfRawData   : DWORD;
  103.     PointerToRawData : DWORD;
  104.     PointerToRelocations : DWORD;
  105.     PointerToLinenumbers : DWORD;
  106.     NumberOfRelocations : WORD;
  107.     NumberOfLinenumbers : WORD;
  108.     Characteristics : DWORD;
  109.   end;
  110.  
  111.   PIMAGE_NT_HEADERS = ^IMAGE_NT_HEADERS;
  112.   IMAGE_NT_HEADERS = packed record
  113.     Signature       : DWORD;
  114.     FileHeader      : IMAGE_FILE_HEADER;
  115.     OptionalHeader  : IMAGE_OPTIONAL_HEADER;
  116.   end;
  117.  
  118. { Resources }
  119.  
  120.   PIMAGE_RESOURCE_DIRECTORY = ^IMAGE_RESOURCE_DIRECTORY;
  121.   IMAGE_RESOURCE_DIRECTORY = packed record
  122.     Characteristics : DWORD;
  123.     TimeDateStamp   : DWORD;
  124.     MajorVersion    : WORD;
  125.     MinorVersion    : WORD;
  126.     NumberOfNamedEntries : WORD;
  127.     NumberOfIdEntries : WORD;
  128.   end;
  129.  
  130.   PIMAGE_RESOURCE_DIRECTORY_ENTRY = ^IMAGE_RESOURCE_DIRECTORY_ENTRY;
  131.   IMAGE_RESOURCE_DIRECTORY_ENTRY = packed record
  132.     Name: DWORD;        // Or ID: Word (Union)
  133.     OffsetToData: DWORD;
  134.   end;
  135.  
  136.   PIMAGE_RESOURCE_DATA_ENTRY = ^IMAGE_RESOURCE_DATA_ENTRY;
  137.   IMAGE_RESOURCE_DATA_ENTRY = packed record
  138.     OffsetToData    : DWORD;
  139.     Size            : DWORD;
  140.     CodePage        : DWORD;
  141.     Reserved        : DWORD;
  142.   end;
  143.  
  144.   PIMAGE_RESOURCE_DIR_STRING_U = ^IMAGE_RESOURCE_DIR_STRING_U;
  145.   IMAGE_RESOURCE_DIR_STRING_U = packed record
  146.     Length          : WORD;
  147.     NameString      : array [0..0] of WCHAR;
  148.   end;
  149.  
  150. {
  151.     /* Predefined resource types */
  152.     #define    RT_NEWRESOURCE      0x2000
  153.     #define    RT_ERROR            0x7fff
  154.     #define    RT_CURSOR           1
  155.     #define    RT_BITMAP           2
  156.     #define    RT_ICON             3
  157.     #define    RT_MENU             4
  158.     #define    RT_DIALOG           5
  159.     #define    RT_STRING           6
  160.     #define    RT_FONTDIR          7
  161.     #define    RT_FONT             8
  162.     #define    RT_ACCELERATORS     9
  163.     #define    RT_RCDATA           10
  164.     #define    RT_MESSAGETABLE     11
  165.     #define    RT_GROUP_CURSOR     12
  166.     #define    RT_GROUP_ICON       14
  167.     #define    RT_VERSION          16
  168.     #define    RT_NEWBITMAP        (RT_BITMAP|RT_NEWRESOURCE)
  169.     #define    RT_NEWMENU          (RT_MENU|RT_NEWRESOURCE)
  170.     #define    RT_NEWDIALOG        (RT_DIALOG|RT_NEWRESOURCE)
  171.  
  172. }
  173.  
  174. type
  175.   TResourceType = (
  176.     rtUnknown0,
  177.     rtCursorEntry,
  178.     rtBitmap,
  179.     rtIconEntry,
  180.     rtMenu,
  181.     rtDialog,
  182.     rtString,
  183.     rtFontDir,
  184.     rtFont,
  185.     rtAccelerators,
  186.     rtRCData,
  187.     rtMessageTable,
  188.     rtCursor,
  189.     rtUnknown13,
  190.     rtIcon,
  191.     rtUnknown15,
  192.     rtVersion);
  193.  
  194. { Resource Type Constants }
  195.  
  196. const
  197.   StringsPerBlock = 16;
  198.  
  199. { Resource Related Structures from RESFMT.TXT in WIN32 SDK }
  200.  
  201. type
  202.  
  203.   PIconHeader = ^TIconHeader;
  204.   TIconHeader = packed record
  205.     wReserved: Word;         { Currently zero }
  206.     wType: Word;             { 1 for icons }
  207.     wCount: Word;            { Number of components }
  208.   end;
  209.  
  210.   PIconResInfo = ^TIconResInfo;
  211.   TIconResInfo = packed record
  212.     bWidth: Byte;
  213.     bHeight: Byte;
  214.     bColorCount: Byte;
  215.     bReserved: Byte;
  216.     wPlanes: Word;
  217.     wBitCount: Word;
  218.     lBytesInRes: DWORD;
  219.     wNameOrdinal: Word;      { Points to component }
  220.   end;
  221.  
  222.   PCursorResInfo = ^TCursorResInfo;
  223.   TCursorResInfo = packed record
  224.     wWidth: Word;
  225.     wHeight: Word;
  226.     wPlanes: Word;
  227.     wBitCount: Word;
  228.     lBytesInRes: DWORD;
  229.     wNameOrdinal: Word;      { Points to component }
  230.   end;
  231.  
  232.  
  233. implementation
  234.  
  235. end.
  236.