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.

226 lines
4.3 KiB

  1. /*++=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. dispatch.cxx
  5. Abstract:
  6. Implements the IDispatch interface for the W3Spoof object.
  7. Author:
  8. Paul M Midgen (pmidge) 18-January-2001
  9. Revision History:
  10. 18-January-2001 pmidge
  11. Created
  12. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--*/
  13. #include "common.h"
  14. //
  15. // WARNING: do not modify these values. use disphash.exe to generate
  16. // new values.
  17. //
  18. DISPIDTABLEENTRY g_W3SpoofDisptable[] =
  19. {
  20. 0x021fca0d, DISPID_W3SPOOF_REGISTERCLIENT, L"registerclient",
  21. 0x008a2dce, DISPID_W3SPOOF_REVOKECLIENT, L"revokeclient"
  22. };
  23. DWORD g_cW3SpoofDisptable = (sizeof(g_W3SpoofDisptable) / sizeof(DISPIDTABLEENTRY));
  24. LPWSTR g_wszW3SpoofObjectName = L"w3spoof";
  25. //-----------------------------------------------------------------------------
  26. // IDispatch
  27. //-----------------------------------------------------------------------------
  28. HRESULT
  29. __stdcall
  30. CW3Spoof::GetTypeInfoCount(UINT* pctinfo)
  31. {
  32. DEBUG_ENTER((
  33. DBG_DISPATCH,
  34. rt_hresult,
  35. "CW3Spoof::GetTypeInfoCount",
  36. "this=%#x; pctinfo=%#x",
  37. this,
  38. pctinfo
  39. ));
  40. HRESULT hr = S_OK;
  41. if( !pctinfo )
  42. {
  43. hr = E_POINTER;
  44. }
  45. else
  46. {
  47. *pctinfo = 1;
  48. }
  49. DEBUG_LEAVE(hr);
  50. return hr;
  51. }
  52. HRESULT
  53. __stdcall
  54. CW3Spoof::GetTypeInfo(UINT index, LCID lcid, ITypeInfo** ppti)
  55. {
  56. DEBUG_ENTER((
  57. DBG_DISPATCH,
  58. rt_hresult,
  59. "CW3Spoof::GetTypeInfo",
  60. "this=%#x; index=%#x; lcid=%#x; ppti=%#x",
  61. this,
  62. index,
  63. lcid,
  64. ppti
  65. ));
  66. HRESULT hr = S_OK;
  67. if( !ppti )
  68. {
  69. hr = E_POINTER;
  70. }
  71. else
  72. {
  73. if( index != 0 )
  74. {
  75. hr = DISP_E_BADINDEX;
  76. *ppti = NULL;
  77. }
  78. else
  79. {
  80. hr = GetTypeInfoFromName(g_wszW3SpoofObjectName, m_ptl, ppti);
  81. }
  82. }
  83. DEBUG_LEAVE(hr);
  84. return hr;
  85. }
  86. HRESULT
  87. __stdcall
  88. CW3Spoof::GetIDsOfNames(REFIID riid, LPOLESTR* arNames, UINT cNames, LCID lcid, DISPID* arDispId)
  89. {
  90. DEBUG_ENTER((
  91. DBG_DISPATCH,
  92. rt_hresult,
  93. "CW3Spoof::GetIDsOfNames",
  94. "this=%#x; riid=%s; arNames=%#x; cNames=%d; lcid=%#x; arDispId=%#x",
  95. this,
  96. MapIIDToString(riid),
  97. arNames,
  98. cNames,
  99. lcid,
  100. arDispId
  101. ));
  102. HRESULT hr = S_OK;
  103. UINT n = 0L;
  104. if( !IsEqualIID(riid, IID_NULL) )
  105. {
  106. hr = E_INVALIDARG;
  107. goto quit;
  108. }
  109. while( n < cNames )
  110. {
  111. arDispId[n] = GetDispidFromName(g_W3SpoofDisptable, g_cW3SpoofDisptable, arNames[n]);
  112. ++n;
  113. }
  114. quit:
  115. DEBUG_LEAVE(hr);
  116. return hr;
  117. }
  118. HRESULT
  119. __stdcall
  120. CW3Spoof::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD flags, DISPPARAMS* pdp, VARIANT* pvr, EXCEPINFO* pei, UINT* pae)
  121. {
  122. DEBUG_ENTER((
  123. DBG_DISPATCH,
  124. rt_hresult,
  125. "CW3Spoof::Invoke",
  126. "this=%#x; dispid=%s; riid=%s; lcid=%#x; flags=%#x; pdp=%#x; pvr=%#x; pei=%#x; pae=%#x",
  127. this,
  128. MapDispidToString(dispid),
  129. MapIIDToString(riid),
  130. lcid,
  131. flags,
  132. pdp, pvr,
  133. pei, pae
  134. ));
  135. HRESULT hr = S_OK;
  136. hr = ValidateDispatchArgs(riid, pdp, pvr, pae);
  137. if( FAILED(hr) )
  138. goto quit;
  139. switch( dispid )
  140. {
  141. case DISPID_W3SPOOF_REGISTERCLIENT :
  142. {
  143. hr = ValidateInvokeFlags(flags, DISPATCH_METHOD, FALSE);
  144. if( SUCCEEDED(hr) )
  145. {
  146. hr = ValidateArgCount(pdp, 2, FALSE, 0);
  147. if( SUCCEEDED(hr) )
  148. {
  149. hr = RegisterClient(
  150. V_BSTR(&pdp->rgvarg[1]),
  151. V_BSTR(&pdp->rgvarg[0])
  152. );
  153. }
  154. }
  155. }
  156. break;
  157. case DISPID_W3SPOOF_REVOKECLIENT :
  158. {
  159. hr = ValidateInvokeFlags(flags, DISPATCH_METHOD, FALSE);
  160. if( SUCCEEDED(hr) )
  161. {
  162. hr = ValidateArgCount(pdp, 1, FALSE, 0);
  163. if( SUCCEEDED(hr) )
  164. {
  165. hr = RevokeClient(
  166. V_BSTR(&pdp->rgvarg[0])
  167. );
  168. }
  169. }
  170. }
  171. break;
  172. default : hr = DISP_E_MEMBERNOTFOUND;
  173. }
  174. quit:
  175. if( FAILED(hr) )
  176. {
  177. hr = HandleDispatchError(L"w3spoof object", pei, hr);
  178. }
  179. DEBUG_LEAVE(hr);
  180. return hr;
  181. }