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.

143 lines
6.2 KiB

  1. readme for genwowit.exe
  2. This tool generates two source files for wow32, wowit.c and wowit.h,
  3. from the input file wow.it. wow.it contains one pseudo-prototype
  4. for each API we want to have an interpreted thunk for. The program
  5. converts these psuedo-prototypes into interpreted thunk byte streams
  6. in wowit.c's InstrSwamp byte array, and entries in wowit.c's
  7. IntThunkTable which point to the API and the thunk instruction stream.
  8. The psuedo-prototypes can have two names separated by an equals sign,
  9. indicating the 16-bit API name on the left is thunked to the 32-bit
  10. API name on the right.
  11. The bytecode instruction streams consist of 0 or more argument conversion
  12. opcodes, which don't have the high bit (0x80) set, followed by a return
  13. code conversion opcode, which does have the high bit set.
  14. genwowit tries to keep InstrSwamp as small as possible by pointing
  15. multiple interpreted thunks at the same instruction stream when they
  16. share prototypes (args & retval types). See for example below how
  17. UpdateColors, StartPage, EndPage, and GetTextCharacterExtra all
  18. use the first instruction stream because they all take a GDI handle
  19. and return an int.
  20. Further, genwowit will point into the middle of an existing instruction
  21. stream if it contains the instruction stream it needs. For example see
  22. below how the wowit.c IntThunkTable GetRasterizerCaps entry points to
  23. InstrSwamp + 0xb, which is 3 bytes into the instruction stream for
  24. TextOut, because ignoring the first three TextOut args they have the
  25. same prototype.
  26. An example, here's a tiny wow.it and the wowit.h and wowit.c that result.
  27. ----- wow.it begin
  28. INT UpdateColors(HGDI);
  29. INT StartPage(HGDI);
  30. INT EndPage(HGDI);
  31. DWORD GetFontData(HGDI, DWORD, DWORD, PTR, DWORD);
  32. WORD GetRasterizerCaps(PTR, INT);
  33. WORD IsGDIObject=GetObjectType(HGDI);
  34. WORD GetTextAlign(HGDI);
  35. INT GetTextCharacterExtra(HGDI);
  36. INT SetTextCharacterExtra(HGDI, INT);
  37. DWORD GetTextColor(HGDI);
  38. INT GetTextFace(HGDI, INT, PTR);
  39. INT SetTextJustification(HGDI, INT, INT);
  40. WORD TextOut(HGDI, INT, INT, PTR, INT);
  41. ----- wow.it end
  42. here's the output genwowit produces on the console:
  43. Generated wowit.h and wowit.c from wow.it
  44. 13 thunks, 8 unique instruction streams, 29 instruction bytes, 5 max args.
  45. And the files:
  46. ----- wowit.h begin
  47. //
  48. // wowit.h generated by genwowit.exe from wow.it, DO NOT EDIT.
  49. //
  50. #include "intthunk.h"
  51. #define MAX_IT_ARGS 5
  52. #define IT_WORD ( (UCHAR) 0x0 )
  53. #define IT_INT ( (UCHAR) 0x1 )
  54. #define IT_DWORD ( (UCHAR) 0x2 )
  55. #define IT_LPDWORD ( (UCHAR) 0x3 )
  56. #define IT_PTR ( (UCHAR) 0x4 )
  57. #define IT_PTRORATOM ( (UCHAR) 0x5 )
  58. #define IT_HGDI ( (UCHAR) 0x6 )
  59. #define IT_HUSER ( (UCHAR) 0x7 )
  60. #define IT_COLOR ( (UCHAR) 0x8 )
  61. #define IT_HINST ( (UCHAR) 0x9 )
  62. #define IT_HICON ( (UCHAR) 0xa )
  63. #define IT_16ONLY ( (UCHAR) 0xb )
  64. #define IT_32ONLY ( (UCHAR) 0xc )
  65. #define IT_RETMASK ( (UCHAR) 0x80 )
  66. #define IT_DWORDRET ( IT_RETMASK | (UCHAR) 0x0 )
  67. #define IT_WORDRET ( IT_RETMASK | (UCHAR) 0x1 )
  68. #define IT_INTRET ( IT_RETMASK | (UCHAR) 0x2 )
  69. #define IT_HGDIRET ( IT_RETMASK | (UCHAR) 0x3 )
  70. #define IT_HUSERRET ( IT_RETMASK | (UCHAR) 0x4 )
  71. #define IT_ZERORET ( IT_RETMASK | (UCHAR) 0x5 )
  72. #define IT_HICONRET ( IT_RETMASK | (UCHAR) 0x6 )
  73. #define IT_ONERET ( IT_RETMASK | (UCHAR) 0x7 )
  74. #define IT_HPRNDWPRET ( IT_RETMASK | (UCHAR) 0x8 )
  75. #define ITID_UpdateColors 0
  76. #define ITID_StartPage 1
  77. #define ITID_EndPage 2
  78. #define ITID_GetFontData 3
  79. #define ITID_GetRasterizerCaps 4
  80. #define ITID_IsGDIObject 5
  81. #define ITID_GetTextAlign 6
  82. #define ITID_GetTextCharacterExtra 7
  83. #define ITID_SetTextCharacterExtra 8
  84. #define ITID_GetTextColor 9
  85. #define ITID_GetTextFace 10
  86. #define ITID_SetTextJustification 11
  87. #define ITID_TextOut 12
  88. #define ITID_MAX 12
  89. ----- wowit.h end
  90. ----- wowit.c begin
  91. //
  92. // wowit.c generated by genwowit.exe from wow.it, DO NOT EDIT.
  93. //
  94. #include "precomp.h"
  95. #pragma hdrstop
  96. #define WOWIT_C
  97. #include "wowit.h"
  98. CONST BYTE InstrSwamp[] = {
  99. /* 0 0x0 */ IT_HGDI, IT_INTRET,
  100. /* 1 0x2 */ IT_HGDI, IT_DWORD, IT_DWORD, IT_PTR, IT_DWORD, IT_DWORDRET,
  101. /* 2 0x8 */ IT_HGDI, IT_INT, IT_INT, IT_PTR, IT_INT, IT_WORDRET,
  102. /* 3 0xe */ IT_HGDI, IT_WORDRET,
  103. /* 4 0x10 */ IT_HGDI, IT_INT, IT_INTRET,
  104. /* 5 0x13 */ IT_HGDI, IT_DWORDRET,
  105. /* 6 0x15 */ IT_HGDI, IT_INT, IT_PTR, IT_INTRET,
  106. /* 7 0x19 */ IT_HGDI, IT_INT, IT_INT, IT_INTRET,
  107. };
  108. INT_THUNK_TABLEENTRY IntThunkTable[] = {
  109. /* 0 */ { (FARPROC) UpdateColors, InstrSwamp + 0x0 }, /* 0 */
  110. /* 1 */ { (FARPROC) StartPage, InstrSwamp + 0x0 }, /* 0 */
  111. /* 2 */ { (FARPROC) EndPage, InstrSwamp + 0x0 }, /* 0 */
  112. /* 3 */ { (FARPROC) GetFontData, InstrSwamp + 0x2 }, /* 1 */
  113. /* 4 */ { (FARPROC) GetRasterizerCaps, InstrSwamp + 0xb }, /* 2 + 3 */
  114. /* 5 */ { (FARPROC) GetObjectType, InstrSwamp + 0xe }, /* 3 */
  115. /* 6 */ { (FARPROC) GetTextAlign, InstrSwamp + 0xe }, /* 3 */
  116. /* 7 */ { (FARPROC) GetTextCharacterExtra, InstrSwamp + 0x0 }, /* 0 */
  117. /* 8 */ { (FARPROC) SetTextCharacterExtra, InstrSwamp + 0x10 }, /* 4 */
  118. /* 9 */ { (FARPROC) GetTextColor, InstrSwamp + 0x13 }, /* 5 */
  119. /* 10 */ { (FARPROC) GetTextFace, InstrSwamp + 0x15 }, /* 6 */
  120. /* 11 */ { (FARPROC) SetTextJustification, InstrSwamp + 0x19 }, /* 7 */
  121. /* 12 */ { (FARPROC) TextOut, InstrSwamp + 0x8 }, /* 2 */
  122. };
  123. ----- wowit.c end