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.

261 lines
5.3 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. /*
  31. * All TYPE and NAME's that are STRING's instead of ORDINAL values
  32. * are represented by one of these structures which links into the
  33. * table from the StringHead link of the UPDATEDATA structure
  34. */
  35. typedef struct MY_STRING {
  36. ULONG discriminant; // long to make the rest of the struct aligned
  37. union u {
  38. struct {
  39. struct MY_STRING *pnext;
  40. ULONG ulOffsetToString;
  41. USHORT cbD;
  42. USHORT cb;
  43. WCHAR *sz;
  44. } ss;
  45. WORD Ordinal;
  46. } uu;
  47. } SDATA, *PSDATA, **PPSDATA;
  48. #define IS_STRING 1
  49. #define IS_ID 2
  50. // defines to make deferencing easier
  51. #define OffsetToString uu.ss.ulOffsetToString
  52. #define cbData uu.ss.cbD
  53. #define cbsz uu.ss.cb
  54. #define szStr uu.ss.sz
  55. // Resource Name Information
  56. typedef struct _RESNAME {
  57. struct _RESNAME *pnext; // The first three fields should be the
  58. PSDATA Name; // same in both res structures
  59. ULONG OffsetToData;
  60. PSDATA Type;
  61. ULONG SectionNumber;
  62. ULONG DataSize;
  63. ULONG_PTR OffsetToDataEntry;
  64. USHORT ResourceNumber;
  65. USHORT NumberOfLanguages;
  66. WORD LanguageId;
  67. } RESNAME, *PRESNAME, **PPRESNAME;
  68. // Resource Type Information
  69. typedef struct _RESTYPE {
  70. struct _RESTYPE *pnext; // The first three fields should be the
  71. PSDATA Type; // same in both res structures
  72. ULONG OffsetToData;
  73. struct _RESNAME *NameHeadID;
  74. struct _RESNAME *NameHeadName;
  75. ULONG NumberOfNamesID;
  76. ULONG NumberOfNamesName;
  77. } RESTYPE, *PRESTYPE, **PPRESTYPE;
  78. // Main Header for the linked lists of resources??
  79. typedef struct _UPDATEDATA {
  80. ULONG cbStringTable;
  81. PSDATA StringHead;
  82. PRESNAME ResHead;
  83. PRESTYPE ResTypeHeadID;
  84. PRESTYPE ResTypeHeadName;
  85. LONG Status;
  86. HANDLE hFileName;
  87. } UPDATEDATA, *PUPDATEDATA;
  88. //
  89. // Round up a byte count to a power of 2:
  90. //
  91. #define ROUNDUP(cbin, align) (((cbin) + (align) - 1) & ~((align) - 1))
  92. //
  93. // Return the remainder, given a byte count and a power of 2:
  94. //
  95. #define REMAINDER(cbin,align) (((align)-((cbin)&((align)-1)))&((align)-1))
  96. #define CBLONG (sizeof(LONG))
  97. #define BUFSIZE (4L * 1024L)
  98. /* functions for adding/deleting resources to update list */
  99. LONG
  100. AddResource(
  101. IN PSDATA Type,
  102. IN PSDATA Name,
  103. IN WORD Language,
  104. IN PUPDATEDATA pupd,
  105. IN PVOID lpData,
  106. IN ULONG cb
  107. );
  108. PSDATA
  109. AddStringOrID(
  110. LPCWSTR lp,
  111. PUPDATEDATA pupd
  112. );
  113. BOOL
  114. InsertResourceIntoLangList(
  115. PUPDATEDATA pUpd,
  116. PSDATA Type,
  117. PSDATA Name,
  118. PRESTYPE pType,
  119. PRESNAME pName,
  120. INT idLang,
  121. INT fName,
  122. INT cb,
  123. PVOID lpData
  124. );
  125. BOOL
  126. DeleteResourceFromList(
  127. PUPDATEDATA pUpd,
  128. PRESTYPE pType,
  129. PRESNAME pName,
  130. INT idLang,
  131. INT fType,
  132. INT fName
  133. );
  134. /* Prototypes for Enumeration done in BeginUpdateResource */
  135. BOOL
  136. EnumTypesFunc(
  137. HANDLE hModule,
  138. LPSTR lpType,
  139. LONG_PTR lParam
  140. );
  141. BOOL
  142. EnumNamesFunc(
  143. HANDLE hModule,
  144. LPSTR lpName,
  145. LPSTR lpType,
  146. LONG_PTR lParam
  147. );
  148. BOOL
  149. EnumLangsFunc(
  150. HANDLE hModule,
  151. LPSTR lpType,
  152. LPSTR lpName,
  153. WORD languages,
  154. LONG_PTR lParam
  155. );
  156. /* Prototypes for genral worker functions in updres.c */
  157. LONG
  158. WriteResFile(
  159. IN HANDLE hUpdate,
  160. IN TCHAR *pDstname
  161. );
  162. VOID
  163. FreeData(
  164. PUPDATEDATA pUpd
  165. );
  166. PRESNAME
  167. WriteResSection(
  168. PUPDATEDATA pUpdate,
  169. INT outfh,
  170. ULONG align,
  171. ULONG cbLeft,
  172. PRESNAME pResSave
  173. );
  174. LONG
  175. PatchRVAs(
  176. int inpfh,
  177. int outfh,
  178. PIMAGE_SECTION_HEADER po32,
  179. ULONG pagedelta,
  180. PIMAGE_NT_HEADERS pNew,
  181. ULONG OldSize);
  182. LONG
  183. PatchDebug(
  184. int inpfh,
  185. int outfh,
  186. PIMAGE_SECTION_HEADER po32DebugOld,
  187. PIMAGE_SECTION_HEADER po32DebugNew,
  188. PIMAGE_SECTION_HEADER po32DebugDirOld,
  189. PIMAGE_SECTION_HEADER po32DebugDirNew,
  190. PIMAGE_NT_HEADERS pOld,
  191. PIMAGE_NT_HEADERS pNew,
  192. ULONG ibMaxDbgOffsetOld,
  193. PULONG pPointerToRawData);
  194. HANDLE
  195. LocalBeginUpdateResource(
  196. LPCSTR pwch,
  197. BOOL bDeleteExistingResources
  198. );
  199. BOOL
  200. LocalUpdateResource(
  201. HANDLE hUpdate,
  202. LPCTSTR lpType,
  203. LPCTSTR lpName,
  204. WORD language,
  205. LPVOID lpData,
  206. ULONG cb
  207. );
  208. BOOL
  209. LocalEndUpdateResource(
  210. HANDLE hUpdate,
  211. BOOL fDiscard
  212. );