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.

360 lines
9.0 KiB

  1. #include <stdio.h>
  2. #include <windef.h>
  3. #define wcsdigit(w) (w >= 0x0030 && w <= 0x0039)
  4. #define TRUE 1
  5. #define FALSE 0
  6. /* The ResType field of NewHeader identifies the resource type */
  7. #define ICONTYPE 1
  8. #define CURSORTYPE 2
  9. /* Identifies the menu item template version number */
  10. #define MENUITEMTEMPLATEVERISONNUMBER 0
  11. #define MENUITEMTEMPLATEBYTESINHEADER 0
  12. #define DIFFERENCE 11
  13. /* Predefined resource types */
  14. #define RT_NAMETABLE MAKEINTRESOURCE((DWORD)15)
  15. #define RT_NEWRESOURCE 0x2000
  16. #define RT_ERROR 0x7fff
  17. #define RT_NEWBITMAP MAKEINTRESOURCE((DWORD)RT_BITMAP+DIFFERENCE)
  18. #define BUTTONCODE 0x80
  19. #define EDITCODE 0x81
  20. #define STATICCODE 0x82
  21. #define LISTBOXCODE 0x83
  22. #define SCROLLBARCODE 0x84
  23. #define COMBOBOXCODE 0x85
  24. /* Translater flag bits */
  25. #define fVIRTKEY 1
  26. #define fNOINVERT 2
  27. #define fSHIFT 4
  28. #define fCONTROL 8
  29. #define fALT 16
  30. /* menu flag bits */
  31. #define OPGRAYED 0x0001
  32. #define OPINACTIVE 0x0002
  33. #define OPBITMAP 0x0004
  34. #define OPOWNERDRAW 0x0100
  35. #define OPUSECHECKBITMAPS 0x0200
  36. #define OPCHECKED 0x0008
  37. #define OPPOPUP 0x0010
  38. #define OPBREAKWBAR 0x0020
  39. #define OPBREAK 0x0040
  40. #define OPENDMENU 0x0080
  41. #define OPHELP 0x4000
  42. #define OPSEPARATOR 0x0800
  43. /*#define OPPOPHELP 0x0004*/
  44. /*
  45. ** dialog & menu template tokens (these start at 40)
  46. */
  47. /* buttons */
  48. #define TKRADIOBUTTON 40
  49. #define TKCHECKBOX 41
  50. #define TKPUSHBUTTON 42
  51. #define TKDEFPUSHBUTTON 43
  52. #define TKAUTOCHECKBOX 44
  53. #define TK3STATE 45
  54. #define TKAUTO3STATE 46
  55. #define TKUSERBUTTON 47
  56. #define TKAUTORADIOBUTTON 48
  57. #define TKOWNERDRAW 50
  58. #define TKGROUPBOX 51
  59. /* static/edit */
  60. #define TKEDITTEXT 60
  61. #define TKLTEXT 61
  62. #define TKRTEXT 62
  63. #define TKCTEXT 63
  64. #define TKEDIT 64
  65. #define TKSTATIC 65
  66. #define TKICON 66
  67. #define TKBITMAP 67
  68. /* menu stuff */
  69. #define TKMENU 70
  70. #define TKMENUITEM 71
  71. #define TKSEPARATOR 72
  72. #define TKCHECKED 73
  73. #define TKGRAYED 74
  74. #define TKINACTIVE 75
  75. #define TKBREAKWBAR 76
  76. #define TKBREAK 77
  77. #define TKPOPUP 78
  78. #define TKHELP 79
  79. /* other controls */
  80. #define TKLISTBOX 90
  81. #define TKCOMBOBOX 91
  82. #define TKRCDATA 92
  83. #define TKSCROLLBAR 93
  84. #define TKFONT 94
  85. #define TKBUTTON 95
  86. #define TKMESSAGETABLE 96
  87. /* math expression tokens */
  88. #define TKCLASS 100
  89. #define TKPLUS 101
  90. #define TKMINUS 102
  91. #define TKNOINVERT 103
  92. #define TKNOT 104
  93. #define TKKANJI 105
  94. #define TKSHIFT 106
  95. /* Accel table */
  96. #define TKALT 110
  97. #define TKASCII 111
  98. #define TKVIRTKEY 112
  99. #define TKVALUE 113
  100. #define TKBLOCK 114
  101. /* verison */
  102. #define TKFILEVERSION 120
  103. #define TKPRODUCTVERSION 121
  104. #define TKFILEFLAGSMASK 122
  105. #define TKFILEFLAGS 123
  106. #define TKFILEOS 124
  107. #define TKFILETYPE 125
  108. #define TKFILESUBTYPE 126
  109. /* misc */
  110. #define TKCHARACTERISTICS 130
  111. #define TKLANGUAGE 131
  112. #define TKVERSION 132
  113. #define TKSTYLE 133
  114. #define TKCONTROL 134
  115. #define TKCAPTION 135
  116. #define TKDLGINCLUDE 136
  117. #define TKLSTR 137
  118. #define TKEXSTYLE 0xfff7 /* so as not to conflict with x-coordinate */
  119. /* memory and load flags */
  120. #define TKFIXED 0xfff0
  121. #define TKMOVEABLE 0xfff1
  122. #define TKDISCARD 0xfff2
  123. #define TKLOADONCALL 0xfff3
  124. #define TKPRELOAD 0xfff4
  125. #define TKPURE 0xfff5
  126. #define TKIMPURE 0xfff6
  127. /* special tokens */
  128. #define CHCARRIAGE '\r'
  129. #define CHSPACE ' '
  130. #define CHNEWLINE '\n'
  131. #define CHTAB 9
  132. #define CHDIRECTIVE '#'
  133. #define CHQUOTE '"'
  134. #define CHEXTENSION '.'
  135. #define CHCSOURCE 'c'
  136. #define CHCHEADER 'h'
  137. #define DEBUGLEX 1
  138. #define DEBUGPAR 2
  139. #define DEBUGGEN 4
  140. /* The following switches, when defined enable various options
  141. ** #define DEBUG enables debugging output. Use one or more of the
  142. ** values defined above to enable debugging output for different modules */
  143. /* Version number. VERSION and REVISION are used to set the API number
  144. ** in an RCed file. SIGNON_* are used just to print the signon banner.
  145. ** Changing VERSION and REVISION means that applications RCed with this
  146. ** version will not run with earlier versions of Windows. */
  147. #define VERSION 2
  148. #define REVISION 03
  149. #define SIGNON_VER 3
  150. #define SIGNON_REV 20
  151. /* GetToken() flags */
  152. #define TOKEN_NOEXPRESSION 0x8000
  153. /* Current token structure */
  154. #define MAXSTR (4096+1)
  155. #define MAXTOKSTR (256+1)
  156. #pragma pack(2)
  157. typedef struct tok {
  158. LONG longval;
  159. int row; /* line number of current token */
  160. int col; /* column number of current token */
  161. BOOL flongval; /* is parsed number a long? */
  162. USHORT val;
  163. UCHAR type;
  164. } TOKEN;
  165. typedef struct _fontdir {
  166. USHORT ordinal;
  167. USHORT nbyFont;
  168. struct _fontdir *next;
  169. } FONTDIR;
  170. typedef struct _OBJLST {
  171. struct _OBJLST *next;
  172. DWORD nObj; /* objecty number */
  173. DWORD cb; /* number of bytes used */
  174. DWORD cpg; /* number of pages used */
  175. DWORD flags; /* object memory flags */
  176. } OBJLST, *POBJLST;
  177. typedef struct Control {
  178. /* don't re-order the first items! */
  179. LONG style;
  180. LONG exstyle;
  181. SHORT x,y,cx,cy;
  182. SHORT id;
  183. /* end of don't re-order */
  184. WCHAR fOrdinalText;
  185. WCHAR class[ MAXTOKSTR ];
  186. WCHAR text[ MAXTOKSTR ];
  187. } CNTRL;
  188. struct DialogHeader {
  189. /* don't re-order the first items! */
  190. LONG style;
  191. LONG exstyle;
  192. WORD bNumberOfItems;
  193. SHORT x,y,cx,cy;
  194. /* end of don't re-order */
  195. WCHAR MenuName [ MAXTOKSTR ];
  196. WCHAR Class[ MAXTOKSTR ];
  197. WCHAR Title[ MAXTOKSTR ];
  198. USHORT pointsize;
  199. WCHAR Font[ MAXTOKSTR ];
  200. UCHAR fOrdinalMenu, fClassOrdinal;
  201. };
  202. typedef struct mnHeader {
  203. USHORT menuTemplateVersionNumber;
  204. USHORT menuTemplateBytesInHeader;
  205. } MNHEADER;
  206. typedef struct mnStruc {
  207. SHORT id;
  208. WCHAR szText[ MAXTOKSTR ];
  209. UCHAR OptFlags;
  210. UCHAR PopFlag;
  211. } MNSTRUC;
  212. /* End of file character/token */
  213. #define EOFMARK 127
  214. /* single character keywords that we ignore */
  215. #define LPAREN 1 /* ( */
  216. #define RPAREN 2 /* ) */
  217. /* multiple character keywords */
  218. #define FIRSTKWD 11 /* for adding to table indices */
  219. #define OR FIRSTKWD+1
  220. #define BEGIN FIRSTKWD+2
  221. #define END FIRSTKWD+3
  222. #define COMMA FIRSTKWD+4
  223. #define TILDE FIRSTKWD+5
  224. #define AND FIRSTKWD+6
  225. #define EQUAL FIRSTKWD+7
  226. #define LASTKWD FIRSTKWD+8 /* 19 */
  227. /* Token types */
  228. #define NUMLIT LASTKWD+1 /* 20 */
  229. #define STRLIT LASTKWD+2
  230. #define CHARLIT LASTKWD+3
  231. #define LSTRLIT LASTKWD+4
  232. #define BLOCKSIZE 16
  233. struct StringEntry {
  234. struct StringEntry *next;
  235. DWORD version;
  236. DWORD characteristics;
  237. USHORT hibits;
  238. SHORT flags;
  239. WORD language;
  240. WCHAR *rgsz[ BLOCKSIZE ];
  241. };
  242. struct AccEntry {
  243. WORD flags;
  244. WCHAR ascii;
  245. USHORT id;
  246. USHORT unused;
  247. };
  248. typedef struct resinfo {
  249. DWORD version;
  250. DWORD characteristics;
  251. LONG exstyleT;
  252. LONG BinOffset;
  253. LONG size;
  254. struct resinfo *next;
  255. DWORD poffset;
  256. WCHAR *name;
  257. POBJLST pObjLst;
  258. WORD language;
  259. SHORT flags;
  260. USHORT nameord;
  261. USHORT cLang;
  262. } RESINFO;
  263. typedef struct typinfo {
  264. struct typinfo *next;
  265. struct resinfo *pres;
  266. WCHAR *type;
  267. USHORT typeord;
  268. USHORT cTypeStr;
  269. USHORT cNameStr;
  270. SHORT nres;
  271. } TYPINFO;
  272. int ResCount; /* number of resources */
  273. TYPINFO *pTypInfo;
  274. typedef struct tagResAdditional {
  275. DWORD DataSize; // size of data without header
  276. DWORD HeaderSize; // Length of the header
  277. // [Ordinal or Name TYPE]
  278. // [Ordinal or Name NAME]
  279. DWORD DataVersion; // version of data struct
  280. WORD MemoryFlags; // state of the resource
  281. WORD LanguageId; // Unicode support for NLS
  282. DWORD Version; // Version of the resource data
  283. DWORD Characteristics; // Characteristics of the data
  284. } RESADDITIONAL;
  285. #pragma pack()
  286. /* Global variables */
  287. extern SHORT nFontsRead;
  288. extern FONTDIR *pFontList;
  289. extern FONTDIR *pFontLast;
  290. extern FILE *errfh;
  291. extern FILE *outfh;
  292. extern TOKEN token;
  293. extern int errorCount;
  294. extern CHAR tokenbuf[ MAXSTR ];
  295. extern WCHAR unicodebuf[ MAXSTR ];
  296. extern UCHAR separators[EOFMARK+1];
  297. extern UCHAR exename[_MAX_PATH], fullname[_MAX_PATH];
  298. extern UCHAR curFile[_MAX_PATH];
  299. extern WORD language;
  300. extern LONG version;
  301. extern LONG characteristics;
  302. extern struct DialogHeader *pLocDlg;
  303. extern int mnEndFlagLoc; /* patch location for end of a menu. */
  304. /* we set the high order bit there */
  305. extern BOOL fFoundBinFile; /* is there a .res file to read? */
  306. extern BOOL fVerbose; /* verbose mode (-v) */
  307. extern BOOL fKanjiMode;
  308. extern SHORT k1,k2,k3,k4;
  309. extern RESINFO*pResString;