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.

240 lines
7.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: stdrpc.hxx
  7. //
  8. // Contents: Private header file for building interface proxies and stubs.
  9. //
  10. // Classes: CStdPSFactoryBuffer
  11. // CStubBase
  12. // CProxyBase
  13. // CStdProxyBuffer
  14. // CStreamOnMessage
  15. //
  16. // Functions: RpcInitMessage
  17. // RpcGetBuffer
  18. // RpcSendReceive
  19. // RpcFreeBuffer
  20. // RpcGetMarshalSizeMax
  21. // RpcMarshalInterface
  22. // RpcUnmarshalInterface
  23. // RpcClientErrorHandler
  24. // RpcServerErrorHandler
  25. //
  26. // History: 4-Jul-93 ShannonC Created
  27. // 3-Aug-93 ShannonC Changes for NT511 and IDispatch support.
  28. // 20-Oct-93 ShannonC Changed to new IRpcChannelBuffer interface.
  29. //
  30. //--------------------------------------------------------------------------
  31. #ifndef __STDRPC_HXX__
  32. #define __STDRPC_HXX__
  33. #define _OLE2ANAC_H_
  34. #include <stdclass.hxx>
  35. #include "rpcferr.h"
  36. #pragma warning(4:4355)
  37. //+-------------------------------------------------------------------------
  38. //
  39. // Class: CStdPSFactoryBuffer
  40. //
  41. // Synopsis: Standard implementation of a proxy/stub factory. Proxy/stub factory
  42. // implementations should inherit this class and implement the
  43. // method.
  44. //
  45. // Derivation: IPSFactoryBuffer
  46. //
  47. // Notes: By deriving a class from this base class, you automatically
  48. // acquire implementations of DllGetClassObject and DllCanUnloadNow.
  49. //
  50. //--------------------------------------------------------------------------
  51. class CStdPSFactoryBuffer : public IPSFactoryBuffer, public CStdFactory
  52. {
  53. public:
  54. CStdPSFactoryBuffer(REFCLSID rcls);
  55. //
  56. // IUnknown methods
  57. //
  58. STDMETHOD(QueryInterface) ( REFIID riid, void** ppv );
  59. STDMETHOD_(ULONG,AddRef) ( void );
  60. STDMETHOD_(ULONG,Release) ( void );
  61. //
  62. // IPSFactoryBuffer methods must be provided in subclass.
  63. //
  64. };
  65. #pragma warning(default:4355)
  66. //+-------------------------------------------------------------------------
  67. //
  68. // Class: CStubIUnknown
  69. //
  70. // Synopsis: Standard implementation of an RpcStubBuffer
  71. //
  72. // Derivation: IRpcStubBuffer
  73. //
  74. // Notes: The constructor calls DllAddRef, and the destructor calls
  75. // DllRelease. This updates the DLL reference count used by
  76. // DllCanUnloadNow.
  77. //
  78. //--------------------------------------------------------------------------
  79. class CStubIUnknown : public IRpcStubBuffer
  80. {
  81. public:
  82. CStubIUnknown(REFIID riid);
  83. ~CStubIUnknown();
  84. virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);
  85. virtual ULONG STDMETHODCALLTYPE AddRef();
  86. virtual ULONG STDMETHODCALLTYPE Release();
  87. virtual HRESULT STDMETHODCALLTYPE Connect(IUnknown *punkServer);
  88. virtual void STDMETHODCALLTYPE Disconnect(void);
  89. virtual IRpcStubBuffer *STDMETHODCALLTYPE IsIIDSupported(REFIID riid);
  90. virtual ULONG STDMETHODCALLTYPE CountRefs(void);
  91. virtual HRESULT STDMETHODCALLTYPE DebugServerQueryInterface(void **ppv);
  92. virtual void STDMETHODCALLTYPE DebugServerRelease(void *pv);
  93. void *_pInterface;
  94. IID _iid;
  95. private:
  96. ULONG _cRefs;
  97. IUnknown *_punk;
  98. };
  99. //+-------------------------------------------------------------------------
  100. //
  101. // Class: CProxyIUnknown.
  102. //
  103. // Synopsis: Base class for interface proxy.
  104. //
  105. // Notes: The interface proxy is used by a CStdProxyBuffer.
  106. // We store the _iid so we can support dispinterfaces.
  107. //
  108. //--------------------------------------------------------------------------
  109. class CProxyIUnknown
  110. {
  111. public:
  112. CProxyIUnknown(IUnknown *punkOuter, REFIID riid);
  113. ~CProxyIUnknown();
  114. virtual HRESULT STDMETHODCALLTYPE QueryInterface
  115. (
  116. REFIID riid,
  117. void **ppvObject
  118. );
  119. virtual ULONG STDMETHODCALLTYPE AddRef
  120. (
  121. void
  122. );
  123. virtual ULONG STDMETHODCALLTYPE Release
  124. (
  125. void
  126. );
  127. IUnknown *_punkOuter;
  128. IID _iid;
  129. IRpcChannelBuffer *_pRpcChannel;
  130. CProxyIUnknown *_pNext;
  131. };
  132. //+-------------------------------------------------------------------------
  133. //
  134. // Class: CStdProxyBuffer
  135. //
  136. // Synopsis: Standard implementation of an RpcProxyBuffer.
  137. //
  138. // Derivation: IRpcProxyBuffer
  139. //
  140. // Notes: The constructor calls DllAddRef, and the destructor calls
  141. // DllRelease. This updates the DLL reference count used by
  142. // DllCanUnloadNow.
  143. //
  144. // The _pProxy data member points to an interface proxy.
  145. // The interface proxy provides the public interface seen by the
  146. // client application.
  147. //
  148. //--------------------------------------------------------------------------
  149. class CStdProxyBuffer : public IRpcProxyBuffer
  150. {
  151. public:
  152. CStdProxyBuffer(CProxyIUnknown *pProxy);
  153. ~CStdProxyBuffer();
  154. virtual ULONG STDMETHODCALLTYPE AddRef();
  155. virtual ULONG STDMETHODCALLTYPE Release();
  156. virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);
  157. virtual HRESULT STDMETHODCALLTYPE Connect(IRpcChannelBuffer *pChannel);
  158. virtual void STDMETHODCALLTYPE Disconnect();
  159. private:
  160. ULONG _cRefs;
  161. CProxyIUnknown *_pProxy;
  162. };
  163. typedef struct tagMIDLMESSAGE : tagRPCOLEMESSAGE
  164. {
  165. IRpcChannelBuffer *pRpcChannel;
  166. void *packet;
  167. DWORD dwExceptionCode;
  168. } MIDLMESSAGE;
  169. void STDAPICALLTYPE RpcInitMessage(MIDLMESSAGE *pMessage, IRpcChannelBuffer *pRpcChannel);
  170. void STDAPICALLTYPE RpcGetBuffer(MIDLMESSAGE *pMessage, REFIID riid);
  171. void STDAPICALLTYPE RpcSendReceive(MIDLMESSAGE *pMessage);
  172. void STDAPICALLTYPE RpcFreeBuffer(MIDLMESSAGE *pMessage);
  173. void STDAPICALLTYPE RpcGetMarshalSizeMax(RPC_MESSAGE *pMessage, REFIID riid, IUnknown *punk);
  174. void STDAPICALLTYPE RpcMarshalInterface(RPC_MESSAGE *pMessage, REFIID riid, void *pv);
  175. void STDAPICALLTYPE RpcUnmarshalInterface(RPC_MESSAGE *pMessage, REFIID riid, void **ppv);
  176. void STDAPICALLTYPE RpcClientErrorHandler(MIDLMESSAGE *pMessage, DWORD dwException, HRESULT *phResult, error_status_t *pCommStatus, error_status_t *pFaultStatus);
  177. void STDAPICALLTYPE RpcCheckHRESULT(HRESULT hr);
  178. HRESULT STDAPICALLTYPE RpcServerErrorHandler(MIDLMESSAGE *pMessage, DWORD dwException);
  179. class CStreamOnMessage : public IStream
  180. {
  181. public:
  182. STDMETHOD (QueryInterface) ( THIS_ REFIID riid, LPVOID FAR* ppvObj);
  183. STDMETHOD_(ULONG,AddRef) ( THIS );
  184. STDMETHOD_(ULONG,Release) ( THIS );
  185. STDMETHOD (Read) (THIS_ VOID HUGEP *pv,
  186. ULONG cb, ULONG *pcbRead) ;
  187. STDMETHOD (Write) (THIS_ VOID const HUGEP *pv,
  188. ULONG cb,
  189. ULONG *pcbWritten) ;
  190. STDMETHOD (Seek) (THIS_ LARGE_INTEGER dlibMove,
  191. DWORD dwOrigin,
  192. ULARGE_INTEGER *plibNewPosition) ;
  193. STDMETHOD (SetSize) (THIS_ ULARGE_INTEGER libNewSize) ;
  194. STDMETHOD (CopyTo) (THIS_ IStream *pstm,
  195. ULARGE_INTEGER cb,
  196. ULARGE_INTEGER *pcbRead,
  197. ULARGE_INTEGER *pcbWritten) ;
  198. STDMETHOD (Commit) (THIS_ DWORD grfCommitFlags) ;
  199. STDMETHOD (Revert) (THIS) ;
  200. STDMETHOD (LockRegion) (THIS_ ULARGE_INTEGER libOffset,
  201. ULARGE_INTEGER cb,
  202. DWORD dwLockType) ;
  203. STDMETHOD (UnlockRegion) (THIS_ ULARGE_INTEGER libOffset,
  204. ULARGE_INTEGER cb,
  205. DWORD dwLockType) ;
  206. STDMETHOD (Stat) (THIS_ STATSTG *pstatstg, DWORD grfStatFlag) ;
  207. STDMETHOD (Clone) (THIS_ IStream * *ppstm) ;
  208. CStreamOnMessage( MIDLMESSAGE *pMessage);
  209. ~CStreamOnMessage();
  210. unsigned char *actual_buffer;
  211. MIDLMESSAGE *message;
  212. ULONG ref_count;
  213. };
  214. #endif //__STDRPC_HXX__