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.

438 lines
13 KiB

  1. #ifndef _RESTOK_H_
  2. #define _RESTOK_H_
  3. #include "tokenapi.h"
  4. #include "rlmsgtbl.h"
  5. #include "toklist.h"
  6. /*--------------------------------------------------------------------------*/
  7. /* General Purpose Defines */
  8. /*--------------------------------------------------------------------------*/
  9. #define SUCCESS 0
  10. #define FALSE 0
  11. #define TRUE 1
  12. #define BYTELN 8
  13. #define WORDLN 16
  14. #define NOTEXE 0
  15. #define WIN16EXE 1
  16. #define NTEXE 2
  17. #define UNKNOWNEXE 10
  18. #define DHWSIZE 4096 //... # Bytes in szDHW global buffer
  19. #ifdef RLRES16
  20. #define IDFLAG 0xFF
  21. #define HIBITVALUE 0x80
  22. #else
  23. #define IDFLAG 0xFFFF
  24. #define HIBITVALUE 0x8000
  25. #endif
  26. #ifdef D262
  27. #define STRINGSIZE( x ) ((x) * sizeof( TCHAR))
  28. #else
  29. #define STRINGSIZE( x ) ((x) * sizeof(CHAR))
  30. #endif
  31. #define MEMSIZE( x ) ((x) * sizeof( TCHAR))
  32. //... How many chars will fit in a buffer? (
  33. #define WCHARSIN( x) ((x) / sizeof( WCHAR))
  34. #define ACHARSIN( x) (x)
  35. #ifdef UNICODE
  36. #define TCHARSIN( x) WCHARSIN( x)
  37. #else
  38. #define TCHARSIN( x) ACHARSIN( x)
  39. #endif
  40. // String Resource IDs (see rlquiked.h, rledit.h, rladmin.h)
  41. #define IDS_READONLY 11
  42. #define IDS_CLEAN 12
  43. #define IDS_DIRTY 13
  44. #define IDS_RESOURCENAMES 15// IDs 16-31 are reserved for resource names
  45. // Resource types ID
  46. #define ID_RT_CURSOR 1
  47. #define ID_RT_BITMAP 2
  48. #define ID_RT_ICON 3
  49. #define ID_RT_MENU 4
  50. #define ID_RT_DIALOG 5
  51. #define ID_RT_STRING 6
  52. #define ID_RT_FONTDIR 7
  53. #define ID_RT_FONT 8
  54. #define ID_RT_ACCELERATORS 9
  55. #define ID_RT_RCDATA 10
  56. #define ID_RT_ERRTABLE 11
  57. #define ID_RT_GROUP_CURSOR 12
  58. #define ID_RT_GROUP_ICON 14
  59. #define ID_RT_NAMETABLE 15
  60. #define ID_RT_VERSION 16
  61. #define ID_RT_DLGINIT 240
  62. // Important MENU flags
  63. #define POPUP 0x0010
  64. #define ENDMENU 0x0080
  65. #define MFR_POPUP 0x0001
  66. #define MYREAD 1
  67. #define MYWRITE 2
  68. #ifndef NOMINMAX
  69. #ifndef max
  70. #define max(a,b) (((a) > (b)) ? (a) : (b))
  71. #endif
  72. #ifndef min
  73. #define min(a,b) (((a) < (b)) ? (a) : (b))
  74. #endif
  75. #endif /* NOMINMAX */
  76. #define AllocateName( ptr, buf) (ptr) = (TCHAR *)FALLOC( MEMSIZE( lstrlen( (buf)) + 1))
  77. typedef struct _tagMast
  78. {
  79. CHAR szSrc[ MAXFILENAME]; //... Source resource file
  80. CHAR szMtk[ MAXFILENAME]; //... Master token file
  81. CHAR szRdfs[ MAXFILENAME]; //... Cust Res Descr file name
  82. CHAR szSrcDate[ MAXFILENAME]; //... Date stamp of szSrc
  83. CHAR szMpjLastRealUpdate[ MAXFILENAME]; //... Date of last update
  84. WORD wLanguageID; //... Language ID for master project
  85. UINT uCodePage; //... CP used to create tok file
  86. } MSTRDATA, * PMSTRDATA;
  87. typedef struct _tagProj
  88. {
  89. CHAR szPRJ[ MAXFILENAME]; //... This project's Project File name
  90. CHAR szMpj[ MAXFILENAME]; //... Master project file
  91. CHAR szTok[ MAXFILENAME]; //... Project token file
  92. CHAR szBld[ MAXFILENAME]; //... Resource file to be built
  93. CHAR szGlo[ MAXFILENAME]; //... Glosary file for this project
  94. CHAR szTokDate[ MAXFILENAME]; //... Date of last update
  95. UINT uCodePage; //... CP used to create tok file
  96. WORD wLanguageID; //... Language ID for this project
  97. BOOL fSourceEXE;
  98. BOOL fTargetEXE;
  99. } PROJDATA, * PPROJDATA;
  100. #pragma pack(1)
  101. typedef struct ResHeader
  102. {
  103. #ifdef RLRES32
  104. DWORD lHeaderSize;
  105. DWORD lDataVersion;
  106. WORD wLanguageId;
  107. DWORD lVersion;
  108. DWORD lCharacteristics;
  109. #endif
  110. BOOL bTypeFlag; /* Indicat's if ID or string */
  111. BOOL bNameFlag; /* Indicat's if ID or string */
  112. WORD wTypeID;
  113. WORD wNameID;
  114. TCHAR *pszType;
  115. TCHAR *pszName;
  116. WORD wMemoryFlags;
  117. DWORD lSize;
  118. } RESHEADER;
  119. typedef struct ControlData
  120. {
  121. WORD x;
  122. WORD y;
  123. WORD cx;
  124. WORD cy;
  125. DWORD dwID;
  126. DWORD lStyle;
  127. BOOL bClass_Flag; /* Indicat's if ID or string */
  128. WORD bClass;
  129. TCHAR *pszClass;
  130. BOOL bID_Flag; /* Indicat's if ID or string */
  131. WORD wDlgTextID;
  132. TCHAR *pszDlgText;
  133. #ifdef RLRES16
  134. WORD unDefined;
  135. #else
  136. WORD wExtraStuff;
  137. DWORD lExtendedStyle;
  138. #endif
  139. #ifdef PDK2
  140. WORD wUnKnow;
  141. DWORD dwExtra;
  142. #endif
  143. DWORD dwHelpID;
  144. BYTE *pExtraStuff;
  145. } CONTROLDATA;
  146. typedef struct DialogHeader
  147. {
  148. DWORD lStyle;
  149. WORD wNumberOfItems;
  150. WORD x;
  151. WORD y;
  152. WORD cx;
  153. WORD cy;
  154. BOOL bClassFlag; /* Indicat's if ID or string */
  155. WORD wDlgClassID;
  156. TCHAR *pszDlgClass;
  157. BOOL bMenuFlag; /* Indicat's if ID or string */
  158. WORD wDlgMenuID;
  159. TCHAR *pszDlgMenu;
  160. TCHAR *pszCaption;
  161. WORD wPointSize;
  162. TCHAR *pszFontName;
  163. CONTROLDATA *pCntlData;
  164. #ifdef RLRES32
  165. DWORD lExtendedStyle;
  166. BOOL bNameFlag;
  167. WORD wDlgNameID;
  168. TCHAR *pszDlgName;
  169. #endif
  170. WORD wDlgVer;
  171. WORD wSignature;
  172. DWORD dwHelpID;
  173. short wWeight;
  174. short wItalic;
  175. BOOL fDialogEx;
  176. } DIALOGHEADER;
  177. typedef struct MenuItem
  178. {
  179. DWORD dwType;
  180. DWORD dwState;
  181. DWORD dwMenuID;
  182. DWORD dwHelpID;
  183. WORD fItemFlags;
  184. TCHAR *szItemText;
  185. struct MenuItem *pNextItem;
  186. } MENUITEM;
  187. typedef struct MenuHeader
  188. {
  189. WORD wVersion;
  190. WORD cbHeaderSize;
  191. MENUITEM *pMenuItem;
  192. BOOL fMenuEx;
  193. BYTE *pExtraStuff;
  194. } MENUHEADER;
  195. typedef struct StringHeader
  196. {
  197. WORD wChars[16]; // # of characters in each string in this block
  198. TCHAR *pszStrings[16]; // Strings in this block
  199. } STRINGHEADER;
  200. // Version structures taken from ver.h and ver.dll code.
  201. #ifndef RLRES32
  202. #ifndef RLWIN32
  203. typedef struct VS_FIXEDFILEINFO
  204. {
  205. DWORD dwSignature; /* e.g. 0xfeef04bd */
  206. DWORD dwStrucVersion; /* e.g. 0x00000042 = "0.42" */
  207. DWORD dwFileVersionMS; /* e.g. 0x00030075 = "3.75" */
  208. DWORD dwFileVersionLS; /* e.g. 0x00000031 = "0.31" */
  209. DWORD dwProductVersionMS; /* e.g. 0x00030010 = "3.10" */
  210. DWORD dwProductVersionLS; /* e.g. 0x00000031 = "0.31" */
  211. DWORD dwFileFlagsMask; /* = 0x3F for version "0.42" */
  212. DWORD dwFileFlags; /* e.g. VFF_DEBUG | VFF_PRERELEASE */
  213. DWORD dwFileOS; /* e.g. VOS_DOS_WINDOWS16 */
  214. DWORD dwFileType; /* e.g. VFT_DRIVER */
  215. DWORD dwFileSubtype; /* e.g. VFT2_DRV_KEYBOARD */
  216. DWORD dwFileDateMS; /* e.g. 0 */
  217. DWORD dwFileDateLS; /* e.g. 0 */
  218. } VS_FIXEDFILEINFO;
  219. #endif
  220. #endif
  221. typedef struct VERBLOCK
  222. {
  223. #ifdef RLRES32
  224. WORD wLength;
  225. WORD wValueLength;
  226. WORD wType;
  227. WCHAR szKey[1];
  228. #else
  229. int nTotLen;
  230. int nValLen;
  231. TCHAR szKey[1];
  232. #endif
  233. } VERBLOCK ;
  234. typedef VERBLOCK * PVERBLOCK;
  235. #define DWORDUP(x) (((x)+3)&~03)
  236. #define DWORDUPOFFSET(x) ( (DWORDUP(x)) - (x) )
  237. #define WORDUP(x) (((x)+1)&~01)
  238. #define WORDUPOFFSET(x) ( (WORDUP(x)) - (x) )
  239. typedef struct VERHEAD
  240. {
  241. WORD wTotLen;
  242. WORD wValLen;
  243. #ifdef RLRES32
  244. WORD wType;
  245. #endif
  246. TCHAR szKey[( sizeof( TEXT("VS_VERSION_INFO" )) +3 )&~03];
  247. VS_FIXEDFILEINFO vsf;
  248. } VERHEAD ;
  249. typedef struct AccelTableEntry
  250. {
  251. WORD fFlags;
  252. WORD wAscii;
  253. WORD wID;
  254. #ifdef RLRES32
  255. WORD wPadding;
  256. #endif
  257. } ACCELTABLEENTRY;
  258. typedef struct _tagDlgInitData
  259. {
  260. struct _tagDlgInitData *pNext;
  261. WORD wControlID;
  262. WORD wMessageNumber;
  263. DWORD dwStringLen;
  264. PCHAR pszString;
  265. } DLGINITDATA, * PDLGINITDATA;
  266. #pragma pack()
  267. // Menu item types
  268. #define POPUP 0x0010
  269. // function prototypes
  270. DWORD DWORDfpUP( FILE *, DWORD * );
  271. void ClearAccelTable ( ACCELTABLEENTRY * , WORD);
  272. void ClearMenu ( MENUHEADER * );
  273. void ClearDialog ( DIALOGHEADER * );
  274. void ClearResHeader ( RESHEADER );
  275. void ClearString ( STRINGHEADER * );
  276. int IsExe( char * );
  277. int IsRes( char * );
  278. BOOL IsWin32Res( CHAR *);
  279. ACCELTABLEENTRY * GetAccelTable( FILE *, WORD *, DWORD * );
  280. BYTE GetByte ( FILE *, DWORD * );
  281. void GetBytes ( FILE *, DWORD * );
  282. DWORD GetdWord ( FILE *, DWORD * );
  283. DIALOGHEADER * GetDialog( FILE *, DWORD * );
  284. void GetName ( FILE *, TCHAR *, DWORD * );
  285. int MyGetTempFileName(BYTE , LPSTR, WORD, LPSTR);
  286. WORD GetWord ( FILE *, DWORD * );
  287. void GetResMenu ( FILE *, DWORD * , MENUHEADER *);
  288. int GenerateImageFile( char *, char *, char *, char *, WORD );
  289. int GenerateTokFile( char *, char *, BOOL *, WORD);
  290. void GenStatusLine( TOKEN * );
  291. int GetResHeader( FILE *, RESHEADER UNALIGNED *, DWORD *);
  292. STRINGHEADER * GetString( FILE *, DWORD * );
  293. BOOL isdup ( WORD, WORD *, WORD );
  294. FILE * OpenGlossary( CHAR *, CHAR);
  295. int MakeGlossIndex( long *);
  296. int TransString( TCHAR *, TCHAR *, TRANSLIST **, LONG *);
  297. void AddTranslation( TCHAR *szKey,
  298. TCHAR *szTranslation,
  299. LONG *lFilePointer);
  300. void ParseTokCrd( TCHAR *,
  301. WORD UNALIGNED *,
  302. WORD UNALIGNED *,
  303. WORD UNALIGNED *,
  304. WORD UNALIGNED * );
  305. void ParseTok( TCHAR *, TOKEN * );
  306. void PutAccelTable( FILE *,
  307. FILE *,
  308. RESHEADER,
  309. ACCELTABLEENTRY *,
  310. WORD );
  311. void PutByte ( FILE *, TCHAR, DWORD * );
  312. void PutDialog( FILE * , FILE *, RESHEADER , DIALOGHEADER *);
  313. void PutMenu( FILE * , FILE *, RESHEADER , MENUHEADER *);
  314. void PutMenuItem( FILE * , MENUITEM *, DWORD *, BOOL);
  315. void PutMenuRes( FILE * , MENUITEM *, DWORD *);
  316. void PutOrd( FILE *, WORD , TCHAR * , DWORD *);
  317. int PutResHeader( FILE *, RESHEADER , fpos_t * , DWORD * );
  318. void PutWord ( FILE *, WORD, DWORD * );
  319. void PutString ( FILE *, TCHAR *, DWORD * );
  320. void PutStrHdr ( FILE *, FILE *, RESHEADER, STRINGHEADER *);
  321. void PutdWord( FILE *, DWORD , DWORD * );
  322. BOOL MergeTokFiles( FILE *, FILE *, FILE * );
  323. void DoExit( int nErrCode);
  324. void QuitA( int, LPSTR, LPSTR);
  325. #ifdef UNICODE
  326. void QuitW( int, LPWSTR, LPWSTR);
  327. #define QuitT QuitW
  328. #else // UNICODE
  329. #define QuitT QuitA
  330. #endif // UNICODE
  331. void GenerateRESfromRESandTOKandRDFs(CHAR * szTargetRES,
  332. CHAR * szSourceRES,
  333. CHAR * szTOK,
  334. CHAR * szRDFs,
  335. WORD wFilter);
  336. void SkipBytes( FILE *, DWORD * );
  337. WORD ReadHeaderField( FILE * , DWORD * );
  338. void ReadInRes( FILE *, FILE *, DWORD *);
  339. BOOL ResReadBytes( FILE *, char *, size_t, DWORD *);
  340. int ReadWinRes( FILE *, FILE *, FILE *, BOOL, BOOL, WORD );
  341. void ShowEngineErr( int, void *, void *);
  342. void TokAccelTable ( FILE *, RESHEADER, ACCELTABLEENTRY *, WORD);
  343. void TokDialog( FILE *, RESHEADER, DIALOGHEADER *);
  344. void TokMenu( FILE *, RESHEADER, MENUHEADER * );
  345. void TokString( FILE *, RESHEADER, STRINGHEADER * );
  346. WORD UpdateResSize( FILE *, fpos_t *, DWORD );
  347. void UnGetByte( FILE *, BYTE, DWORD * );
  348. void UnGetWord( FILE *, WORD, DWORD * );
  349. void WordUpFilePointer( FILE *, BOOL, LONG, LONG, LONG *);
  350. void DWordUpFilePointer( FILE *, BOOL, LONG, DWORD *);
  351. #ifdef RLRES32
  352. WORD GetResVer( FILE *, DWORD *, VERHEAD *, VERBLOCK **);
  353. int TokResVer( FILE *, RESHEADER, VERBLOCK *, WORD);
  354. DWORD FixCheckSum( LPSTR);
  355. #else
  356. int GetResVer( FILE *, DWORD *, VERHEAD *, VERBLOCK **);
  357. int TokResVer( FILE *, RESHEADER, VERBLOCK *);
  358. #endif
  359. int PutResVer( FILE *, FILE * , RESHEADER, VERHEAD *, VERBLOCK *);
  360. PDLGINITDATA GetDlgInit( FILE *, DWORD *);
  361. void TokDlgInit( FILE *, RESHEADER, PDLGINITDATA);
  362. void PutDlgInit( FILE *, FILE *, RESHEADER, PDLGINITDATA);
  363. void ClearDlgInitData( PDLGINITDATA);
  364. #endif // _RESTOK_H_