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