Source code of Windows XP (NT5)
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.

400 lines
11 KiB

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