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.

231 lines
6.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: GO1632Pr.cxx (16 bit target)
  7. //
  8. // Contents: Functions to thunk interface pointer from 16 to 32 bit.
  9. //
  10. // Functions:
  11. //
  12. // History: 13-Dec-93 JohannP Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <headers.cxx>
  16. #pragma hdrstop
  17. #include <call32.hxx>
  18. #include <obj16.hxx>
  19. #include <go1632pr.hxx>
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Macro: DEFINE_METHOD
  23. //
  24. // Synopsis: Defines a generic 16->32 proxy method
  25. //
  26. // History: 23-Feb-94 DrewB Created
  27. //
  28. //
  29. // Notes: A proxy method's primary reason for existence is to
  30. // get into the 32-bit world with a pointer to the 16-bit
  31. // stack. This is accomplished by taking the address of
  32. // the this pointer. Since methods are cdecl, this works
  33. // for methods with any number of parameters because the
  34. // first parameter is always the one closest to the return
  35. // address.
  36. // The method also passed on the object ID and the method
  37. // index so that the method's arguments can be properly
  38. // thunked on the 32-bit side
  39. //
  40. //----------------------------------------------------------------------------
  41. #define DEFINE_METHOD(n) \
  42. STDMETHODIMP_(DWORD) Proxy1632Method##n(THUNK1632OBJ FAR *ptoThis16) \
  43. { \
  44. thkDebugOut((DEB_THUNKMGR, "Proxy1632Method: %p(%d)\n", ptoThis16, n)); \
  45. return CallObjectInWOW( n, CDECL_STACK_PTR(ptoThis16)); \
  46. }
  47. #if DBG == 1
  48. #pragma pack(1)
  49. struct SplitGuid
  50. {
  51. DWORD dw1;
  52. WORD w1;
  53. WORD w2;
  54. BYTE b[8];
  55. };
  56. #pragma pack()
  57. char *GuidString(GUID const *pguid)
  58. {
  59. static char ach[39];
  60. SplitGuid *psg = (SplitGuid *)pguid;
  61. wsprintf(ach, "{%08lX-%04hX-%04hX-%02X%02X-%02X%02X%02X%02X%02X%02X}",
  62. psg->dw1, psg->w1, psg->w2, psg->b[0], psg->b[1], psg->b[2],
  63. psg->b[3], psg->b[4], psg->b[5], psg->b[6], psg->b[7]);
  64. return ach;
  65. }
  66. #endif
  67. //+---------------------------------------------------------------------------
  68. //
  69. // Function: Proxy1632QueryInterface, public
  70. //
  71. // Synopsis: QueryInterface for the proxy object.
  72. //
  73. // History: 01-Apr-94 JohannP Created
  74. //
  75. //----------------------------------------------------------------------------
  76. STDMETHODIMP_(DWORD) Proxy1632QueryInterface(THUNK1632OBJ FAR *ptoThis16,
  77. REFIID refiid,
  78. LPVOID *ppv)
  79. {
  80. DWORD dwRet;
  81. LPVOID lpvoid = (LPVOID)&refiid;
  82. IID iid = refiid;
  83. thkDebugOut((DEB_THUNKMGR, " Proxy1632QueryInterface: %p %s\n",
  84. ptoThis16, GuidString((IID const *)&iid) ));
  85. // Why do we make a copy of the iid only so that we can over-write
  86. // it so that we can return the pointer to it in it? This should be
  87. // re-written.
  88. //
  89. dwRet = CallProcIn32((DWORD)ptoThis16, SMI_QUERYINTERFACE, (DWORD)&iid,
  90. lpIUnknownObj32, 0, CP32_NARGS);
  91. *ppv = (LPVOID) iid.Data1;
  92. thkDebugOut(( DEB_THUNKMGR,
  93. "Out Proxy1632QueryInterface: (%p)->%p scRet:0x%08lx\n",
  94. ptoThis16, *ppv, dwRet));
  95. return dwRet;
  96. }
  97. //+---------------------------------------------------------------------------
  98. //
  99. // Function: Proxy1632AddRef, public
  100. //
  101. // Synopsis: AddRef for the generic proxy object
  102. //
  103. // History: 01-Apr-94 JohannP Created
  104. //
  105. //----------------------------------------------------------------------------
  106. STDMETHODIMP_(DWORD) Proxy1632AddRef(THUNK1632OBJ FAR *ptoThis16)
  107. {
  108. DWORD dwRet;
  109. thkDebugOut(( DEB_THUNKMGR, "In Proxy1632AddRef: %p \n",ptoThis16));
  110. dwRet = CallProcIn32((DWORD)ptoThis16, SMI_ADDREF, 0,
  111. lpIUnknownObj32, 0, CP32_NARGS);
  112. thkDebugOut(( DEB_THUNKMGR, "Out Proxy1632AddRef: %p dwRet:%ld\n",
  113. ptoThis16, dwRet));
  114. return dwRet;
  115. }
  116. //+---------------------------------------------------------------------------
  117. //
  118. // Function: Proxy1632Release, public
  119. //
  120. // Synopsis: Release for the proxy object.
  121. //
  122. // History: 01-Apr-94 JohannP Created
  123. //
  124. //----------------------------------------------------------------------------
  125. STDMETHODIMP_(DWORD) Proxy1632Release(THUNK1632OBJ FAR *ptoThis16)
  126. {
  127. DWORD dwRet;
  128. thkDebugOut(( DEB_THUNKMGR, "In Proxy1632Release: %p\n", ptoThis16));
  129. dwRet = CallProcIn32((DWORD)ptoThis16, SMI_RELEASE, 0,
  130. lpIUnknownObj32, 0, CP32_NARGS);
  131. thkDebugOut(( DEB_THUNKMGR, "Out Proxy1632Release: %p dwRet:%ld\n",
  132. ptoThis16,dwRet));
  133. return dwRet;
  134. }
  135. // Additional methods so that any possible interface can be represented
  136. // using the vtable made up out of all the methods
  137. DEFINE_METHOD(3)
  138. DEFINE_METHOD(4)
  139. DEFINE_METHOD(5)
  140. DEFINE_METHOD(6)
  141. DEFINE_METHOD(7)
  142. DEFINE_METHOD(8)
  143. DEFINE_METHOD(9)
  144. DEFINE_METHOD(10)
  145. DEFINE_METHOD(11)
  146. DEFINE_METHOD(12)
  147. DEFINE_METHOD(13)
  148. DEFINE_METHOD(14)
  149. DEFINE_METHOD(15)
  150. DEFINE_METHOD(16)
  151. DEFINE_METHOD(17)
  152. DEFINE_METHOD(18)
  153. DEFINE_METHOD(19)
  154. DEFINE_METHOD(20)
  155. DEFINE_METHOD(21)
  156. DEFINE_METHOD(22)
  157. DEFINE_METHOD(23)
  158. DEFINE_METHOD(24)
  159. DEFINE_METHOD(25)
  160. DEFINE_METHOD(26)
  161. DEFINE_METHOD(27)
  162. DEFINE_METHOD(28)
  163. DEFINE_METHOD(29)
  164. DEFINE_METHOD(30)
  165. DEFINE_METHOD(31)
  166. // A vtable which will end up calling back to our proxy methods
  167. DWORD atfnProxy1632Vtbl[] =
  168. {
  169. (DWORD)Proxy1632QueryInterface,
  170. (DWORD)Proxy1632AddRef,
  171. (DWORD)Proxy1632Release,
  172. (DWORD)Proxy1632Method3,
  173. (DWORD)Proxy1632Method4,
  174. (DWORD)Proxy1632Method5,
  175. (DWORD)Proxy1632Method6,
  176. (DWORD)Proxy1632Method7,
  177. (DWORD)Proxy1632Method8,
  178. (DWORD)Proxy1632Method9,
  179. (DWORD)Proxy1632Method10,
  180. (DWORD)Proxy1632Method11,
  181. (DWORD)Proxy1632Method12,
  182. (DWORD)Proxy1632Method13,
  183. (DWORD)Proxy1632Method14,
  184. (DWORD)Proxy1632Method15,
  185. (DWORD)Proxy1632Method16,
  186. (DWORD)Proxy1632Method17,
  187. (DWORD)Proxy1632Method18,
  188. (DWORD)Proxy1632Method19,
  189. (DWORD)Proxy1632Method20,
  190. (DWORD)Proxy1632Method21,
  191. (DWORD)Proxy1632Method22,
  192. (DWORD)Proxy1632Method23,
  193. (DWORD)Proxy1632Method24,
  194. (DWORD)Proxy1632Method25,
  195. (DWORD)Proxy1632Method26,
  196. (DWORD)Proxy1632Method27,
  197. (DWORD)Proxy1632Method28,
  198. (DWORD)Proxy1632Method29,
  199. (DWORD)Proxy1632Method30,
  200. (DWORD)Proxy1632Method31
  201. };
  202.