Leaked source code of windows server 2003
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.

195 lines
6.4 KiB

  1. #ifndef _EXE2RES_H_
  2. #define _EXE2RES_H_
  3. #define BUFSIZE 2048
  4. /* error codes for file handling functions */
  5. #define IDERR_SUCCESS 0
  6. #define IDERR_BASE 255
  7. #define IDERR_ALLOCFAIL (IDERR_BASE+1)
  8. #define IDERR_LOCKFAIL (IDERR_BASE+2)
  9. #define IDERR_OPENFAIL (IDERR_BASE+3)
  10. #define IDERR_READFAIL (IDERR_BASE+4)
  11. #define IDERR_WINFUNCFAIL (IDERR_BASE+5)
  12. #define IDERR_INVALIDPARAM (IDERR_BASE+6)
  13. #define IDERR_FILETYPEBAD (IDERR_BASE+7)
  14. #define IDERR_EXETYPEBAD (IDERR_BASE+8)
  15. #define IDERR_WINVERSIONBAD (IDERR_BASE+9)
  16. #define IDERR_RESTABLEBAD (IDERR_BASE+10)
  17. #define IDERR_ICONBAD (IDERR_BASE+11)
  18. #define IDERR_NOICONS (IDERR_BASE+12)
  19. #define IDERR_ARRAYFULL (IDERR_BASE+13)
  20. #ifdef RLDOS
  21. /* Predefined resource types */
  22. #define RT_NEWRESOURCE 0x2000
  23. #define RT_ERROR 0x7fff
  24. #define RT_CURSOR 1
  25. #define RT_BITMAP 2
  26. #define RT_ICON 3
  27. #define RT_MENU 4
  28. #define RT_DIALOG 5
  29. #define RT_STRING 6
  30. #define RT_FONTDIR 7
  31. #define RT_FONT 8
  32. #define RT_ACCELERATORS 9
  33. #define RT_RCDATA 10
  34. /* Error tables were never implemented and can be removed from RC */
  35. /* #define RT_ERRTABLE 11 (done for 3.1) */
  36. #define RT_GROUP_CURSOR 12
  37. /* The value 13 is unused */
  38. #define RT_GROUP_ICON 14
  39. /* Name Tables no longer exist (this change made for 3.1) */
  40. #define RT_NAMETABLE 15
  41. #define RT_VERSION 16
  42. #endif //RLDOS
  43. #ifndef RLWIN32
  44. typedef unsigned short USHORT;
  45. typedef short SHORT;
  46. #endif
  47. typedef struct resinfo
  48. {
  49. struct resinfo *next;
  50. SHORT flags;
  51. WORD nameord;
  52. PSTR name;
  53. LONG BinOffset;
  54. LONG size;
  55. WORD *poffset;
  56. } RESINFO;
  57. typedef struct typinfo
  58. {
  59. struct typinfo *next;
  60. WORD typeord;
  61. PSTR type;
  62. SHORT nres;
  63. struct resinfo *pres;
  64. } TYPINFO;
  65. /* ----- Function prototypes ----- */
  66. int ExtractResFromExe16A( CHAR *szInputExe,
  67. CHAR *szOutputRes,
  68. WORD wFilter);
  69. int BuildExeFromRes16A( CHAR *szTargetExe,
  70. CHAR *szSourceRes,
  71. CHAR *szSourceExe);
  72. /* ----- Symbols ----- */
  73. #define PRELOAD_ALIGN 5
  74. #define PRELOAD_MINPADDING 16
  75. #define DO_PRELOAD 1
  76. #define DO_LOADONCALL 2
  77. #define NUMZEROS 512
  78. #define RESTABLEHEADER 4
  79. #define MAXCODE 8192
  80. #define MAXFARCODE 65500
  81. #define WINDOWSEXE 2
  82. #define OLDEXESIGNATURE 0x5A4D
  83. #define NEWEXESIGNATURE 0x454E
  84. #define ORDINALFLAG 0x8000
  85. #define CV_OLD_SIG 0x42524e44L /* Old Signature is 'DNRB' */
  86. #define CV_SIGNATURE 0x424e /* New signature is 'NBxx' (x = digit) */
  87. /* local typedefs */
  88. typedef struct { /* DOS 1, 2, 3, 4 .EXE header */
  89. WORD ehSignature; /* signature bytes */
  90. WORD ehcbLP; /* bytes on last page of file */
  91. WORD ehcp; /* pages in file */
  92. WORD ehcRelocation; /* count of relocation table entries*/
  93. WORD ehcParagraphHdr; /* size of header in paragraphs */
  94. WORD ehMinAlloc; /* minimum extra paragraphs needed */
  95. WORD ehMaxAlloc; /* maximum extra paragraphs needed */
  96. WORD ehSS; /* initial \(relative\) SS value */
  97. WORD ehSP; /* initial SP value */
  98. WORD ehChecksum; /* checksum */
  99. WORD ehIP; /* initial IP value */
  100. WORD ehCS; /* initial \(relative\) CS value */
  101. WORD ehlpRelocation; /* file address of relocation table */
  102. WORD ehOverlayNo; /* overlay number */
  103. WORD ehReserved[16]; /* reserved words */
  104. LONG ehPosNewHdr; /* file address of new exe header */
  105. } EXEHDR; /* eh */
  106. typedef struct { /* new .EXE header */
  107. WORD nhSignature; /* signature bytes */
  108. char nhVer; /* LINK version number */
  109. char nhRev; /* LINK revision number */
  110. WORD nhoffEntryTable; /* offset of Entry Table */
  111. WORD nhcbEntryTable; /* number of bytes in Entry Table */
  112. LONG nhCRC; /* checksum of whole file */
  113. WORD nhFlags; /* flag word */
  114. WORD nhAutoData; /* automatic data segment number */
  115. WORD nhHeap; /* initial heap allocation */
  116. WORD nhStack; /* initial stack allocation */
  117. LONG nhCSIP; /* initial CS:IP setting */
  118. LONG nhSSSP; /* initial SS:SP setting */
  119. WORD nhcSeg; /* count of file segments */
  120. WORD nhcMod; /* entries in Module Reference Table*/
  121. WORD nhcbNonResNameTable; /* size of non-resident name table */
  122. WORD nhoffSegTable; /* offset of Segment Table */
  123. WORD nhoffResourceTable; /* offset of Resource Table */
  124. WORD nhoffResNameTable; /* offset of Resident Name Table */
  125. WORD nhoffModRefTable; /* offset of Module Reference Table */
  126. WORD nhoffImpNameTable; /* offset of Imported Names Table */
  127. LONG nhoffNonResNameTable; /* offset of Non-resident Names Tab */
  128. WORD nhcMovableEntries; /* count of movable entries */
  129. WORD nhcAlign; /* segment alignment shift count */
  130. WORD nhCRes; /* count of resource segments */
  131. BYTE nhExeType; /* target OS \(OS/2=1, Windows=2\) */
  132. BYTE nhFlagsOther; /* additional exe flags */
  133. WORD nhGangStart; /* offset to gangload area */
  134. WORD nhGangLength; /* length of gangload area */
  135. WORD nhSwapArea; /* minimum code swap area size*/
  136. WORD nhExpVer; /* expected Windows version number */
  137. } NEWHDR; /* nh */
  138. typedef struct {
  139. WORD rtType;
  140. WORD rtCount;
  141. LONG rtProc;
  142. } RESTYPEINFO;
  143. typedef struct { /* Resource name information block */
  144. WORD rnOffset; /* file offset to resource data */
  145. WORD rnLength; /* length of resource data */
  146. WORD rnFlags; /* resource flags */
  147. WORD rnID; /* resource name id */
  148. WORD rnHandle; /* reserved for runtime use */
  149. WORD rnUsage; /* reserved for runtime use */
  150. } RESNAMEINFO; /* rn */
  151. /* ----- CodeView types and symbols ----- */
  152. typedef struct
  153. {
  154. char signature[4];
  155. long secTblOffset;
  156. } CVINFO;
  157. typedef struct
  158. {
  159. long secOffset[5];
  160. unsigned version;
  161. } CVSECTBL;
  162. #endif // _EXE2RES_H_