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.

223 lines
4.4 KiB

  1. /*++
  2. (C) Copyright Microsoft Corporation 1988-1992
  3. Module Name:
  4. updres.h
  5. Author:
  6. Floyd A Rogers 2/7/92
  7. Revision History:
  8. Floyd Rogers
  9. Created
  10. --*/
  11. #define DEFAULT_CODEPAGE 1252
  12. #define MAJOR_RESOURCE_VERSION 4
  13. #define MINOR_RESOURCE_VERSION 0
  14. #define BUTTONCODE 0x80
  15. #define EDITCODE 0x81
  16. #define STATICCODE 0x82
  17. #define LISTBOXCODE 0x83
  18. #define SCROLLBARCODE 0x84
  19. #define COMBOBOXCODE 0x85
  20. #define SEEK_SET 0
  21. #define SEEK_CUR 1
  22. #define SEEK_END 2
  23. #define MAXSTR (256+1)
  24. //
  25. // An ID_WORD indicates the following WORD is an ordinal rather
  26. // than a string
  27. //
  28. #define ID_WORD 0xffff
  29. //typedef WCHAR *PWCHAR;
  30. typedef struct MY_STRING {
  31. ULONG discriminant; // long to make the rest of the struct aligned
  32. union u {
  33. struct {
  34. struct MY_STRING *pnext;
  35. ULONG ulOffsetToString;
  36. USHORT cbD;
  37. USHORT cb;
  38. WCHAR *sz;
  39. } ss;
  40. WORD Ordinal;
  41. } uu;
  42. } SDATA, *PSDATA, **PPSDATA;
  43. #define IS_STRING 1
  44. #define IS_ID 2
  45. // defines to make deferencing easier
  46. #define OffsetToString uu.ss.ulOffsetToString
  47. #define cbData uu.ss.cbD
  48. #define cbsz uu.ss.cb
  49. #define szStr uu.ss.sz
  50. typedef struct _RESNAME {
  51. struct _RESNAME *pnext; // The first three fields should be the
  52. PSDATA Name; // same in both res structures
  53. ULONG OffsetToData;
  54. PSDATA Type;
  55. ULONG SectionNumber;
  56. ULONG DataSize;
  57. ULONG_PTR OffsetToDataEntry;
  58. USHORT ResourceNumber;
  59. USHORT NumberOfLanguages;
  60. WORD LanguageId;
  61. } RESNAME, *PRESNAME, **PPRESNAME;
  62. typedef struct _RESTYPE {
  63. struct _RESTYPE *pnext; // The first three fields should be the
  64. PSDATA Type; // same in both res structures
  65. ULONG OffsetToData;
  66. struct _RESNAME *NameHeadID;
  67. struct _RESNAME *NameHeadName;
  68. ULONG NumberOfNamesID;
  69. ULONG NumberOfNamesName;
  70. } RESTYPE, *PRESTYPE, **PPRESTYPE;
  71. typedef struct _UPDATEDATA {
  72. ULONG cbStringTable;
  73. PSDATA StringHead;
  74. PRESNAME ResHead;
  75. PRESTYPE ResTypeHeadID;
  76. PRESTYPE ResTypeHeadName;
  77. LONG Status;
  78. HANDLE hFileName;
  79. } UPDATEDATA, *PUPDATEDATA;
  80. //
  81. // Round up a byte count to a power of 2:
  82. //
  83. #define ROUNDUP(cbin, align) (((cbin) + (align) - 1) & ~((align) - 1))
  84. //
  85. // Return the remainder, given a byte count and a power of 2:
  86. //
  87. #define REMAINDER(cbin,align) (((align)-((cbin)&((align)-1)))&((align)-1))
  88. #define CBLONG (sizeof(LONG))
  89. #define BUFSIZE (4L * 1024L)
  90. /* functions for adding/deleting resources to update list */
  91. LONG
  92. AddResource(
  93. IN PSDATA Type,
  94. IN PSDATA Name,
  95. IN WORD Language,
  96. IN PUPDATEDATA pupd,
  97. IN PVOID lpData,
  98. IN ULONG cb
  99. );
  100. PSDATA
  101. AddStringOrID(
  102. LPCWSTR lp,
  103. PUPDATEDATA pupd
  104. );
  105. BOOL
  106. InsertResourceIntoLangList(
  107. PUPDATEDATA pUpd,
  108. PSDATA Type,
  109. PSDATA Name,
  110. PRESTYPE pType,
  111. PRESNAME pName,
  112. INT idLang,
  113. INT fName,
  114. INT cb,
  115. PVOID lpData
  116. );
  117. BOOL
  118. DeleteResourceFromList(
  119. PUPDATEDATA pUpd,
  120. PRESTYPE pType,
  121. PRESNAME pName,
  122. INT idLang,
  123. INT fType,
  124. INT fName
  125. );
  126. /* Prototypes for Enumeration done in BeginUpdateResource */
  127. BOOL
  128. EnumTypesFunc(
  129. HANDLE hModule,
  130. LPWSTR lpType,
  131. LPARAM lParam
  132. );
  133. BOOL
  134. EnumNamesFunc(
  135. HANDLE hModule,
  136. LPWSTR lpName,
  137. LPWSTR lpType,
  138. LPARAM lParam
  139. );
  140. BOOL
  141. EnumLangsFunc(
  142. HANDLE hModule,
  143. LPWSTR lpType,
  144. LPWSTR lpName,
  145. WORD languages,
  146. LPARAM lParam
  147. );
  148. /* Prototypes for genral worker functions in updres.c */
  149. LONG
  150. WriteResFile(
  151. IN HANDLE hUpdate,
  152. IN WCHAR *pDstname
  153. );
  154. VOID
  155. FreeData(
  156. PUPDATEDATA pUpd
  157. );
  158. PRESNAME
  159. WriteResSection(
  160. PUPDATEDATA pUpdate,
  161. INT outfh,
  162. ULONG align,
  163. ULONG cbLeft,
  164. PRESNAME pResSave
  165. );
  166. LONG
  167. PatchRVAs(
  168. int inpfh,
  169. int outfh,
  170. PIMAGE_SECTION_HEADER po32,
  171. ULONG pagedelta,
  172. PIMAGE_NT_HEADERS pNew,
  173. ULONG OldSize);
  174. LONG
  175. PatchDebug(
  176. int inpfh,
  177. int outfh,
  178. PIMAGE_SECTION_HEADER po32DebugOld,
  179. PIMAGE_SECTION_HEADER po32DebugNew,
  180. PIMAGE_SECTION_HEADER po32DebugDirOld,
  181. PIMAGE_SECTION_HEADER po32DebugDirNew,
  182. PIMAGE_NT_HEADERS pOld,
  183. PIMAGE_NT_HEADERS pNew,
  184. ULONG ibMaxDbgOffsetOld,
  185. PULONG pPointerToRawData);