Subversion Repositories Kolibri OS

Rev

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

  1. //
  2.  
  3. // Section characteristics.
  4.  
  5. //
  6.  
  7. //      IMAGE_SCN_TYPE_REG                   0x00000000  // Reserved.
  8.  
  9. //      IMAGE_SCN_TYPE_DSECT                 0x00000001  // Reserved.
  10.  
  11. //      IMAGE_SCN_TYPE_NOLOAD                0x00000002  // Reserved.
  12.  
  13. //      IMAGE_SCN_TYPE_GROUP                 0x00000004  // Reserved.
  14.  
  15. #define IMAGE_SCN_TYPE_NO_PAD                0x00000008  // Reserved.
  16.  
  17. //      IMAGE_SCN_TYPE_COPY                  0x00000010  // Reserved.
  18.  
  19.  
  20.  
  21. #define IMAGE_SCN_CNT_CODE                   0x00000020  // Section contains code.
  22.  
  23. #define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  // Section contains initialized data.
  24.  
  25. #define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  // Section contains uninitialized data.
  26.  
  27.  
  28.  
  29. #define IMAGE_SCN_LNK_OTHER                  0x00000100  // Reserved.
  30.  
  31. #define IMAGE_SCN_LNK_INFO                   0x00000200  // Section contains comments or some other type of information.
  32.  
  33. //      IMAGE_SCN_TYPE_OVER                  0x00000400  // Reserved.
  34.  
  35. #define IMAGE_SCN_LNK_REMOVE                 0x00000800  // Section contents will not become part of image.
  36.  
  37. #define IMAGE_SCN_LNK_COMDAT                 0x00001000  // Section contents comdat.
  38.  
  39. //                                           0x00002000  // Reserved.
  40.  
  41. //      IMAGE_SCN_MEM_PROTECTED - Obsolete   0x00004000
  42.  
  43. #define IMAGE_SCN_NO_DEFER_SPEC_EXC          0x00004000  // Reset speculative exceptions handling bits in the TLB entries for this section.
  44.  
  45. #define IMAGE_SCN_GPREL                      0x00008000  // Section content can be accessed relative to GP
  46.  
  47. #define IMAGE_SCN_MEM_FARDATA                0x00008000
  48.  
  49. //      IMAGE_SCN_MEM_SYSHEAP  - Obsolete    0x00010000
  50.  
  51. #define IMAGE_SCN_MEM_PURGEABLE              0x00020000
  52.  
  53. #define IMAGE_SCN_MEM_16BIT                  0x00020000
  54.  
  55. #define IMAGE_SCN_MEM_LOCKED                 0x00040000
  56.  
  57. #define IMAGE_SCN_MEM_PRELOAD                0x00080000
  58.  
  59.  
  60.  
  61. #define IMAGE_SCN_ALIGN_1BYTES               0x00100000  //
  62.  
  63. #define IMAGE_SCN_ALIGN_2BYTES               0x00200000  //
  64.  
  65. #define IMAGE_SCN_ALIGN_4BYTES               0x00300000  //
  66.  
  67. #define IMAGE_SCN_ALIGN_8BYTES               0x00400000  //
  68.  
  69. #define IMAGE_SCN_ALIGN_16BYTES              0x00500000  // Default alignment if no others are specified.
  70.  
  71. #define IMAGE_SCN_ALIGN_32BYTES              0x00600000  //
  72.  
  73. #define IMAGE_SCN_ALIGN_64BYTES              0x00700000  //
  74.  
  75. #define IMAGE_SCN_ALIGN_128BYTES             0x00800000  //
  76.  
  77. #define IMAGE_SCN_ALIGN_256BYTES             0x00900000  //
  78.  
  79. #define IMAGE_SCN_ALIGN_512BYTES             0x00A00000  //
  80.  
  81. #define IMAGE_SCN_ALIGN_1024BYTES            0x00B00000  //
  82.  
  83. #define IMAGE_SCN_ALIGN_2048BYTES            0x00C00000  //
  84.  
  85. #define IMAGE_SCN_ALIGN_4096BYTES            0x00D00000  //
  86.  
  87. #define IMAGE_SCN_ALIGN_8192BYTES            0x00E00000  //
  88.  
  89. // Unused                                    0x00F00000
  90.  
  91. #define IMAGE_SCN_ALIGN_MASK                 0x00F00000
  92.  
  93.  
  94.  
  95. #define IMAGE_SCN_LNK_NRELOC_OVFL            0x01000000  // Section contains extended relocations.
  96.  
  97. #define IMAGE_SCN_MEM_DISCARDABLE            0x02000000  // Section can be discarded.
  98.  
  99. #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  // Section is not cachable.
  100.  
  101. #define IMAGE_SCN_MEM_NOT_PAGED              0x08000000  // Section is not pageable.
  102.  
  103. #define IMAGE_SCN_MEM_SHARED                 0x10000000  // Section is shareable.
  104.  
  105. #define IMAGE_SCN_MEM_EXECUTE                0x20000000  // Section is executable.
  106.  
  107. #define IMAGE_SCN_MEM_READ                   0x40000000  // Section is readable.
  108.  
  109. #define IMAGE_SCN_MEM_WRITE                  0x80000000  // Section is writeable.
  110.  
  111.  
  112.  
  113. //
  114.  
  115. // I386 relocation types.
  116.  
  117. //
  118.  
  119. #define IMAGE_REL_I386_ABSOLUTE 0x0000  //Reference is absolute, no relocation is necessary
  120.  
  121. #define IMAGE_REL_I386_DIR16    0x0001  //Direct 16-bit reference to the symbols virtual address
  122.  
  123. #define IMAGE_REL_I386_REL16    0x0002  //PC-relative 16-bit reference to the symbols virtual address
  124.  
  125. #define IMAGE_REL_I386_DIR32    0x0006  //Direct 32-bit reference to the symbols virtual address
  126.  
  127. #define IMAGE_REL_I386_DIR32NB  0x0007  //Direct 32-bit reference to the symbols virtual address, base not included
  128.  
  129. #define IMAGE_REL_I386_SEG12    0x0009  //Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
  130.  
  131. #define IMAGE_REL_I386_SECTION  0x000A
  132.  
  133. #define IMAGE_REL_I386_SECREL   0x000B
  134.  
  135. #define IMAGE_REL_I386_REL32    0x0014  //PC-relative 32-bit reference to the symbols virtual address
  136.  
  137.  
  138.  
  139. typedef struct _COFF_HEADER_
  140.  
  141. {
  142.  
  143.         short cpu;    //¬¨­ ⨯ CPU - ¢á¥£¤  0x14C
  144.  
  145.         short numobj;   //ç¨á«® ¢å®¤®¢ ¢ â ¡«¨æã ®¡ê¥ªâ®¢
  146.  
  147.         long date_time; //¤ â  ¬®¤¨ä¨ª æ¨¨ «¨­ª¥à®¬
  148.  
  149.         long pCOFF;
  150.  
  151.         long COFFsize;
  152.  
  153.   short SizeOfOptionalHeader;
  154.  
  155.   short Characteristics;
  156.  
  157. }COFF_HEADER;
  158.  
  159.  
  160.  
  161. typedef struct _IMAGE_SYMBOL
  162.  
  163. {
  164.  
  165.         union{
  166.  
  167.                 char sname[8];
  168.  
  169.                 struct{
  170.  
  171.                         unsigned long Short;
  172.  
  173.                         unsigned long Long;
  174.  
  175.                 }Name;
  176.  
  177.                 char *LongName[2];
  178.  
  179.         }N;
  180.  
  181.         unsigned long Value;
  182.  
  183.         short SectionNumber;
  184.  
  185.         unsigned short Type;
  186.  
  187.         unsigned char StorageClass;
  188.  
  189.         unsigned char NumberOfAuxSymbols;
  190.  
  191. }IMAGE_SYMBOL;
  192.  
  193.  
  194.  
  195. typedef struct _IMAGE_RELOCATION {
  196.  
  197.         union {
  198.  
  199.                 unsigned long VirtualAddress;
  200.  
  201.                 unsigned long RelocCount; // Set to the real count when IMAGE_SCN_LNK_NRELOC_OVFL is set
  202.  
  203.         };
  204.  
  205.         unsigned long SymbolTableIndex;
  206.  
  207.         unsigned short Type;
  208.  
  209. }IMAGE_RELOCATION;
  210.  
  211.  
  212.  
  213.