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.

133 lines
5.8 KiB

  1. readme for interpreted thunks
  2. Interpreted Thunks are an attempt to replace the simplest thunk functions
  3. in WOW with a bit of data. Each thunk consists of a pointer to the Win32
  4. API routine (actually to a callable loader thunk in one of the pages set
  5. aside for fixups if needed) and a pointer to a variable-length byte stream
  6. which dictates how to convert arguments and return values. The first byte
  7. is an opcode indicating how to thunk the leftmost argument, the last byte
  8. is distinguished by having its high bit set (0x8?) and indicates how to
  9. thunk the return value.
  10. A tool called genwowit reads a source file called wow.it which contains
  11. psuedo-prototypes (really thunk descriptions) and generates wowit.h
  12. and wowit.c with the actualy thunk table and assiociated instruction
  13. "swamp" containing all the bytecode instruction streams. See
  14. \nt\private\sdktools\genwowit\readme.txt for details.
  15. Note that the major restriction of interpreted thunks as implemented is
  16. that pointers to structures which need thunking are not supported.
  17. Here's a tiny wow.it and the wowit.h and wowit.c that result.
  18. ----- wow.it begin
  19. INT UpdateColors(HGDI);
  20. INT StartPage(HGDI);
  21. INT EndPage(HGDI);
  22. DWORD GetFontData(HGDI, DWORD, DWORD, PTR, DWORD);
  23. WORD GetRasterizerCaps(PTR, INT);
  24. WORD IsGDIObject=GetObjectType(HGDI);
  25. WORD GetTextAlign(HGDI);
  26. INT GetTextCharacterExtra(HGDI);
  27. INT SetTextCharacterExtra(HGDI, INT);
  28. DWORD GetTextColor(HGDI);
  29. INT GetTextFace(HGDI, INT, PTR);
  30. INT SetTextJustification(HGDI, INT, INT);
  31. WORD TextOut(HGDI, INT, INT, PTR, INT);
  32. ----- wow.it end
  33. here's the output genwowit produces on the console:
  34. Generated wowit.h and wowit.c from wow.it
  35. 13 thunks, 8 unique instruction streams, 29 instruction bytes, 5 max args.
  36. And the files:
  37. ----- wowit.h begin
  38. //
  39. // wowit.h generated by genwowit.exe from wow.it, DO NOT EDIT.
  40. //
  41. #include "intthunk.h"
  42. #define MAX_IT_ARGS 5
  43. #define IT_WORD ( (UCHAR) 0x0 )
  44. #define IT_INT ( (UCHAR) 0x1 )
  45. #define IT_DWORD ( (UCHAR) 0x2 )
  46. #define IT_LPDWORD ( (UCHAR) 0x3 )
  47. #define IT_PTR ( (UCHAR) 0x4 )
  48. #define IT_PTRORATOM ( (UCHAR) 0x5 )
  49. #define IT_HGDI ( (UCHAR) 0x6 )
  50. #define IT_HUSER ( (UCHAR) 0x7 )
  51. #define IT_COLOR ( (UCHAR) 0x8 )
  52. #define IT_HINST ( (UCHAR) 0x9 )
  53. #define IT_HICON ( (UCHAR) 0xa )
  54. #define IT_16ONLY ( (UCHAR) 0xb )
  55. #define IT_32ONLY ( (UCHAR) 0xc )
  56. #define IT_RETMASK ( (UCHAR) 0x80 )
  57. #define IT_DWORDRET ( IT_RETMASK | (UCHAR) 0x0 )
  58. #define IT_WORDRET ( IT_RETMASK | (UCHAR) 0x1 )
  59. #define IT_INTRET ( IT_RETMASK | (UCHAR) 0x2 )
  60. #define IT_HGDIRET ( IT_RETMASK | (UCHAR) 0x3 )
  61. #define IT_HUSERRET ( IT_RETMASK | (UCHAR) 0x4 )
  62. #define IT_ZERORET ( IT_RETMASK | (UCHAR) 0x5 )
  63. #define IT_HICONRET ( IT_RETMASK | (UCHAR) 0x6 )
  64. #define IT_ONERET ( IT_RETMASK | (UCHAR) 0x7 )
  65. #define IT_HPRNDWPRET ( IT_RETMASK | (UCHAR) 0x8 )
  66. #define ITID_UpdateColors 0
  67. #define ITID_StartPage 1
  68. #define ITID_EndPage 2
  69. #define ITID_GetFontData 3
  70. #define ITID_GetRasterizerCaps 4
  71. #define ITID_IsGDIObject 5
  72. #define ITID_GetTextAlign 6
  73. #define ITID_GetTextCharacterExtra 7
  74. #define ITID_SetTextCharacterExtra 8
  75. #define ITID_GetTextColor 9
  76. #define ITID_GetTextFace 10
  77. #define ITID_SetTextJustification 11
  78. #define ITID_TextOut 12
  79. #define ITID_MAX 12
  80. ----- wowit.h end
  81. ----- wowit.c begin
  82. //
  83. // wowit.c generated by genwowit.exe from wow.it, DO NOT EDIT.
  84. //
  85. #include "precomp.h"
  86. #pragma hdrstop
  87. #define WOWIT_C
  88. #include "wowit.h"
  89. CONST BYTE InstrSwamp[] = {
  90. /* 0 0x0 */ IT_HGDI, IT_INTRET,
  91. /* 1 0x2 */ IT_HGDI, IT_DWORD, IT_DWORD, IT_PTR, IT_DWORD, IT_DWORDRET,
  92. /* 2 0x8 */ IT_HGDI, IT_INT, IT_INT, IT_PTR, IT_INT, IT_WORDRET,
  93. /* 3 0xe */ IT_HGDI, IT_WORDRET,
  94. /* 4 0x10 */ IT_HGDI, IT_INT, IT_INTRET,
  95. /* 5 0x13 */ IT_HGDI, IT_DWORDRET,
  96. /* 6 0x15 */ IT_HGDI, IT_INT, IT_PTR, IT_INTRET,
  97. /* 7 0x19 */ IT_HGDI, IT_INT, IT_INT, IT_INTRET,
  98. };
  99. INT_THUNK_TABLEENTRY IntThunkTable[] = {
  100. /* 0 */ { (FARPROC) UpdateColors, InstrSwamp + 0x0 }, /* 0 */
  101. /* 1 */ { (FARPROC) StartPage, InstrSwamp + 0x0 }, /* 0 */
  102. /* 2 */ { (FARPROC) EndPage, InstrSwamp + 0x0 }, /* 0 */
  103. /* 3 */ { (FARPROC) GetFontData, InstrSwamp + 0x2 }, /* 1 */
  104. /* 4 */ { (FARPROC) GetRasterizerCaps, InstrSwamp + 0xb }, /* 2 + 3 */
  105. /* 5 */ { (FARPROC) GetObjectType, InstrSwamp + 0xe }, /* 3 */
  106. /* 6 */ { (FARPROC) GetTextAlign, InstrSwamp + 0xe }, /* 3 */
  107. /* 7 */ { (FARPROC) GetTextCharacterExtra, InstrSwamp + 0x0 }, /* 0 */
  108. /* 8 */ { (FARPROC) SetTextCharacterExtra, InstrSwamp + 0x10 }, /* 4 */
  109. /* 9 */ { (FARPROC) GetTextColor, InstrSwamp + 0x13 }, /* 5 */
  110. /* 10 */ { (FARPROC) GetTextFace, InstrSwamp + 0x15 }, /* 6 */
  111. /* 11 */ { (FARPROC) SetTextJustification, InstrSwamp + 0x19 }, /* 7 */
  112. /* 12 */ { (FARPROC) TextOut, InstrSwamp + 0x8 }, /* 2 */
  113. };
  114. ----- wowit.c end