1 | #ifndef __RPCPROXY_H__
|
---|
2 | #define __RPCPROXY_H__
|
---|
3 | #define __midl_proxy
|
---|
4 |
|
---|
5 | #ifndef INC_OLE2
|
---|
6 | #define INC_OLE2
|
---|
7 | #endif
|
---|
8 |
|
---|
9 | #ifndef GUID_DEFINED
|
---|
10 | #define GUID_DEFINED
|
---|
11 | typedef struct _GUID
|
---|
12 | {
|
---|
13 | unsigned long Data1;
|
---|
14 | unsigned short Data2;
|
---|
15 | unsigned short Data3;
|
---|
16 | unsigned char Data4[8];
|
---|
17 | } GUID;
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #if 0
|
---|
21 | #if !defined( __IID_DEFINED__ )
|
---|
22 | #define __IID_DEFINED__
|
---|
23 |
|
---|
24 | typedef GUID IID;
|
---|
25 | typedef IID *LPIID;
|
---|
26 | #define IID_NULL GUID_NULL
|
---|
27 | #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
|
---|
28 | typedef GUID CLSID;
|
---|
29 | typedef CLSID *LPCLSID;
|
---|
30 | #define CLSID_NULL GUID_NULL
|
---|
31 | #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
|
---|
32 |
|
---|
33 | #ifndef _REFGUID_DEFINED
|
---|
34 | #define _REFGUID_DEFINED
|
---|
35 | typedef const GUID *REFGUID;
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | #ifndef _REFIID_DEFINED
|
---|
39 | #define _REFIID_DEFINED
|
---|
40 | typedef const IID *REFIID;
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #ifndef _REFCLSID_DEFINED
|
---|
44 | #define _REFCLSID_DEFINED
|
---|
45 | typedef const CLSID *REFCLSID;
|
---|
46 | #endif
|
---|
47 | #endif
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | struct tagCInterfaceStubVtbl;
|
---|
51 | struct tagCInterfaceProxyVtbl;
|
---|
52 |
|
---|
53 | typedef struct tagCInterfaceStubVtbl * PCInterfaceStubVtblList;
|
---|
54 | typedef struct tagCInterfaceProxyVtbl * PCInterfaceProxyVtblList;
|
---|
55 | typedef const char * PCInterfaceName;
|
---|
56 | typedef int __stdcall IIDLookupRtn( const IID * pIID, int * pIndex );
|
---|
57 | typedef IIDLookupRtn * PIIDLookup;
|
---|
58 |
|
---|
59 | typedef struct tagProxyFileInfo
|
---|
60 | {
|
---|
61 | const PCInterfaceProxyVtblList *pProxyVtblList;
|
---|
62 | const PCInterfaceStubVtblList *pStubVtblList;
|
---|
63 | const PCInterfaceName * pNamesArray;
|
---|
64 | const IID ** pDelegatedIIDs;
|
---|
65 | const PIIDLookup pIIDLookupRtn;
|
---|
66 | unsigned short TableSize;
|
---|
67 | unsigned short TableVersion;
|
---|
68 | unsigned long Filler1;
|
---|
69 | unsigned long Filler2;
|
---|
70 | unsigned long Filler3;
|
---|
71 | unsigned long Filler4;
|
---|
72 | }ProxyFileInfo;
|
---|
73 |
|
---|
74 | typedef ProxyFileInfo ExtendedProxyFileInfo;
|
---|
75 |
|
---|
76 | #include <rpc.h>
|
---|
77 | //#include <rpcndr.h>
|
---|
78 | #include <string.h>
|
---|
79 | #include <memory.h>
|
---|
80 |
|
---|
81 | typedef struct tagCInterfaceProxyHeader
|
---|
82 | {
|
---|
83 | #ifdef USE_STUBLESS_PROXY
|
---|
84 | const void * pStublessProxyInfo;
|
---|
85 | #endif
|
---|
86 | const IID * piid;
|
---|
87 | } CInterfaceProxyHeader;
|
---|
88 |
|
---|
89 | #define CINTERFACE_PROXY_VTABLE( n ) \
|
---|
90 | struct \
|
---|
91 | { \
|
---|
92 | CInterfaceProxyHeader header; \
|
---|
93 | void *Vtbl[ n ]; \
|
---|
94 | }
|
---|
95 |
|
---|
96 | typedef struct tagCInterfaceProxyVtbl
|
---|
97 | {
|
---|
98 | CInterfaceProxyHeader header;
|
---|
99 | void *Vtbl[1];
|
---|
100 | } CInterfaceProxyVtbl;
|
---|
101 |
|
---|
102 | typedef
|
---|
103 | void
|
---|
104 | (__RPC_STUB * PRPC_STUB_FUNCTION) (
|
---|
105 | IRpcStubBuffer *This,
|
---|
106 | IRpcChannelBuffer * _pRpcChannelBuffer,
|
---|
107 | PRPC_MESSAGE _pRpcMessage,
|
---|
108 | DWORD __RPC_FAR *pdwStubPhase);
|
---|
109 |
|
---|
110 | typedef struct tagCInterfaceStubHeader
|
---|
111 | {
|
---|
112 | const IID *piid;
|
---|
113 | const MIDL_SERVER_INFO *pServerInfo;
|
---|
114 | unsigned long DispatchTableCount;
|
---|
115 | const PRPC_STUB_FUNCTION *pDispatchTable;
|
---|
116 | } CInterfaceStubHeader;
|
---|
117 |
|
---|
118 | typedef struct tagCInterfaceStubVtbl
|
---|
119 | {
|
---|
120 | CInterfaceStubHeader header;
|
---|
121 | IRpcStubBufferVtbl Vtbl;
|
---|
122 | } CInterfaceStubVtbl;
|
---|
123 |
|
---|
124 | typedef struct tagCStdStubBuffer
|
---|
125 | {
|
---|
126 | const struct IRpcStubBufferVtbl * lpVtbl;
|
---|
127 | long RefCount;
|
---|
128 | struct IUnknown * pvServerObject;
|
---|
129 | } CStdStubBuffer;
|
---|
130 |
|
---|
131 | typedef struct tagCStdPSFactoryBuffer
|
---|
132 | {
|
---|
133 | const IPSFactoryBufferVtbl *lpVtbl;
|
---|
134 | long RefCount;
|
---|
135 | const ProxyFileInfo ** pProxyFileList;
|
---|
136 | long Filler1;
|
---|
137 | } CStdPSFactoryBuffer;
|
---|
138 |
|
---|
139 | void RPC_ENTRY NdrProxyInitialize(void * This,
|
---|
140 | PRPC_MESSAGE pRpcMsg,
|
---|
141 | PMIDL_STUB_MESSAGE pStubMsg,
|
---|
142 | PMIDL_STUB_DESC pStubDescriptor,
|
---|
143 | unsigned int ProcNum );
|
---|
144 |
|
---|
145 | void RPC_ENTRY NdrProxyGetBuffer(void * This,
|
---|
146 | PMIDL_STUB_MESSAGE pStubMsg);
|
---|
147 |
|
---|
148 | void RPC_ENTRY NdrProxySendReceive(void *This,
|
---|
149 | MIDL_STUB_MESSAGE *pStubMsg);
|
---|
150 |
|
---|
151 | void RPC_ENTRY NdrProxyFreeBuffer(void *This,
|
---|
152 | MIDL_STUB_MESSAGE *pStubMsg);
|
---|
153 |
|
---|
154 | HRESULT RPC_ENTRY NdrProxyErrorHandler(DWORD dwExceptionCode);
|
---|
155 |
|
---|
156 | void RPC_ENTRY NdrStubInitialize(PRPC_MESSAGE pRpcMsg,
|
---|
157 | PMIDL_STUB_MESSAGE pStubMsg,
|
---|
158 | PMIDL_STUB_DESC pStubDescriptor,
|
---|
159 | IRpcChannelBuffer * pRpcChannelBuffer);
|
---|
160 |
|
---|
161 | void __RPC_STUB NdrStubForwardingFunction(IRpcStubBuffer * This,
|
---|
162 | IRpcChannelBuffer * pChannel,
|
---|
163 | PRPC_MESSAGE pmsg,
|
---|
164 | DWORD *pdwStubPhase);
|
---|
165 |
|
---|
166 | void RPC_ENTRY NdrStubGetBuffer(IRpcStubBuffer * This,
|
---|
167 | IRpcChannelBuffer * pRpcChannelBuffer,
|
---|
168 | PMIDL_STUB_MESSAGE pStubMsg);
|
---|
169 |
|
---|
170 | HRESULT RPC_ENTRY NdrStubErrorHandler(DWORD dwExceptionCode);
|
---|
171 |
|
---|
172 | HRESULT STDMETHODCALLTYPE CStdStubBuffer_QueryInterface(IRpcStubBuffer *This,
|
---|
173 | REFIID riid,
|
---|
174 | void **ppvObject);
|
---|
175 |
|
---|
176 | ULONG STDMETHODCALLTYPE CStdStubBuffer_AddRef(IRpcStubBuffer *This);
|
---|
177 |
|
---|
178 | ULONG STDMETHODCALLTYPE CStdStubBuffer_Release(IRpcStubBuffer *This);
|
---|
179 |
|
---|
180 | ULONG STDMETHODCALLTYPE NdrCStdStubBuffer_Release(IRpcStubBuffer *This, IPSFactoryBuffer * pPSF);
|
---|
181 |
|
---|
182 | HRESULT STDMETHODCALLTYPE CStdStubBuffer_Connect( IRpcStubBuffer *This,
|
---|
183 | IUnknown *pUnkServer);
|
---|
184 |
|
---|
185 | void STDMETHODCALLTYPE CStdStubBuffer_Disconnect(IRpcStubBuffer *This);
|
---|
186 |
|
---|
187 | HRESULT STDMETHODCALLTYPE CStdStubBuffer_Invoke(IRpcStubBuffer *This, RPCOLEMESSAGE *pRpcMsg,
|
---|
188 | IRpcChannelBuffer *pRpcChannelBuffer);
|
---|
189 |
|
---|
190 | IRpcStubBuffer * STDMETHODCALLTYPE CStdStubBuffer_IsIIDSupported(IRpcStubBuffer *This,
|
---|
191 | REFIID riid);
|
---|
192 |
|
---|
193 | ULONG STDMETHODCALLTYPE CStdStubBuffer_CountRefs(IRpcStubBuffer *This);
|
---|
194 |
|
---|
195 | HRESULT STDMETHODCALLTYPE CStdStubBuffer_DebugServerQueryInterface(
|
---|
196 | IRpcStubBuffer *This,
|
---|
197 | void **ppv);
|
---|
198 |
|
---|
199 | void STDMETHODCALLTYPE CStdStubBuffer_DebugServerRelease(IRpcStubBuffer *This,
|
---|
200 | void *pv);
|
---|
201 |
|
---|
202 | #define CStdStubBuffer_METHODS \
|
---|
203 | CStdStubBuffer_QueryInterface,\
|
---|
204 | CStdStubBuffer_AddRef, \
|
---|
205 | CStdStubBuffer_Release, \
|
---|
206 | CStdStubBuffer_Connect, \
|
---|
207 | CStdStubBuffer_Disconnect, \
|
---|
208 | CStdStubBuffer_Invoke, \
|
---|
209 | CStdStubBuffer_IsIIDSupported, \
|
---|
210 | CStdStubBuffer_CountRefs, \
|
---|
211 | CStdStubBuffer_DebugServerQueryInterface, \
|
---|
212 | CStdStubBuffer_DebugServerRelease
|
---|
213 |
|
---|
214 | #define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp( pIID, name##_ProxyVtblList[ index ]->header.piid, 16 )
|
---|
215 |
|
---|
216 | #define IID_BS_LOOKUP_SETUP int result, low=-1;
|
---|
217 |
|
---|
218 | #define IID_BS_LOOKUP_INITIAL_TEST(name, sz, split) \
|
---|
219 | if ( ( result = name##_CHECK_IID( split ) ) > 0 ) \
|
---|
220 | { low = sz - split; } \
|
---|
221 | else if ( !result ) \
|
---|
222 | { low = split; goto found_label; }
|
---|
223 |
|
---|
224 | #define IID_BS_LOOKUP_NEXT_TEST(name, split ) \
|
---|
225 | if ( ( result = name##_CHECK_IID( low + split )) >= 0 ) \
|
---|
226 | { low = low + split; if ( !result ) goto found_label; }
|
---|
227 |
|
---|
228 | #define IID_BS_LOOKUP_RETURN_RESULT(name, sz, index ) \
|
---|
229 | low = low + 1; \
|
---|
230 | if ( ( low >= sz ) || (result = name##_CHECK_IID( low ) )) goto not_found_label; \
|
---|
231 | found_label: (index) = low; return 1; \
|
---|
232 | not_found_label: return 0;
|
---|
233 |
|
---|
234 | HRESULT RPC_ENTRY NdrDllGetClassObject (REFCLSID rclsid,
|
---|
235 | REFIID riid,
|
---|
236 | void ** ppv,
|
---|
237 | const ProxyFileInfo ** pProxyFileList,
|
---|
238 | const CLSID * pclsid,
|
---|
239 | CStdPSFactoryBuffer * pPSFactoryBuffer);
|
---|
240 |
|
---|
241 | HRESULT RPC_ENTRY NdrDllCanUnloadNow(CStdPSFactoryBuffer * pPSFactoryBuffer);
|
---|
242 |
|
---|
243 | HRESULT RPC_ENTRY NdrDllRegisterProxy(
|
---|
244 | IN HMODULE hDll,
|
---|
245 | IN const ProxyFileInfo ** pProxyFileList,
|
---|
246 | IN const CLSID * pclsid);
|
---|
247 |
|
---|
248 | HRESULT RPC_ENTRY NdrDllUnregisterProxy(
|
---|
249 | IN HMODULE hDll,
|
---|
250 | IN const ProxyFileInfo ** pProxyFileList,
|
---|
251 | IN const CLSID * pclsid);
|
---|
252 |
|
---|
253 |
|
---|
254 | #define REGISTER_PROXY_DLL_ROUTINES(pProxyFileList, pClsID) \
|
---|
255 | \
|
---|
256 | HINSTANCE hProxyDll = 0; \
|
---|
257 | \
|
---|
258 | /*DllMain saves the DLL module handle for later use by DllRegisterServer */ \
|
---|
259 | BOOL WINAPI DllMain( \
|
---|
260 | HINSTANCE hinstDLL, \
|
---|
261 | DWORD fdwReason, \
|
---|
262 | LPVOID lpvReserved) \
|
---|
263 | { \
|
---|
264 | if(fdwReason == DLL_PROCESS_ATTACH) \
|
---|
265 | hProxyDll = hinstDLL; \
|
---|
266 | return TRUE; \
|
---|
267 | } \
|
---|
268 | \
|
---|
269 | /* DllRegisterServer registers the interfaces contained in the proxy DLL. */ \
|
---|
270 | HRESULT STDAPICALLTYPE DllRegisterServer() \
|
---|
271 | { \
|
---|
272 | return NdrDllRegisterProxy(hProxyDll, pProxyFileList, pClsID); \
|
---|
273 | } \
|
---|
274 | \
|
---|
275 | /* DllUnregisterServer unregisters the interfaces contained in the proxy DLL. */ \
|
---|
276 | HRESULT STDAPICALLTYPE DllUnregisterServer() \
|
---|
277 | { \
|
---|
278 | return NdrDllUnregisterProxy(hProxyDll, pProxyFileList, pClsID); \
|
---|
279 | }
|
---|
280 |
|
---|
281 | #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
|
---|
282 |
|
---|
283 | ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This);
|
---|
284 |
|
---|
285 | ULONG STDMETHODCALLTYPE NdrCStdStubBuffer2_Release(IRpcStubBuffer *This,IPSFactoryBuffer * pPSF);
|
---|
286 |
|
---|
287 | #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
|
---|
288 |
|
---|
289 | #ifdef PROXY_CLSID
|
---|
290 | #define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID;
|
---|
291 | #else
|
---|
292 | #ifdef PROXY_CLSID_IS
|
---|
293 | #define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS;
|
---|
294 | #define PROXY_CLSID CLSID_PSFactoryBuffer
|
---|
295 | #else
|
---|
296 | #define CLSID_PSFACTORYBUFFER
|
---|
297 | #endif
|
---|
298 | #endif
|
---|
299 |
|
---|
300 | #ifndef PROXY_CLSID
|
---|
301 | #define GET_DLL_CLSID \
|
---|
302 | ( aProxyFileList[0]->pStubVtblList[0] != 0 ? \
|
---|
303 | aProxyFileList[0]->pStubVtblList[0]->header.piid : 0)
|
---|
304 | #else
|
---|
305 | #define GET_DLL_CLSID &PROXY_CLSID
|
---|
306 | #endif
|
---|
307 |
|
---|
308 | #define EXTERN_PROXY_FILE(name) EXTERN_C const ProxyFileInfo name##_ProxyFileInfo;
|
---|
309 |
|
---|
310 | #define PROXYFILE_LIST_START const ProxyFileInfo * aProxyFileList[] = {
|
---|
311 |
|
---|
312 | #define REFERENCE_PROXY_FILE(name) & name##_ProxyFileInfo
|
---|
313 |
|
---|
314 | #define PROXYFILE_LIST_END 0 };
|
---|
315 |
|
---|
316 | #define DLLDATA_GETPROXYDLLINFO(pPFList,pClsid) \
|
---|
317 | void RPC_ENTRY GetProxyDllInfo( const ProxyFileInfo*** pInfo, const CLSID ** pId ) \
|
---|
318 | { \
|
---|
319 | *pInfo = pPFList; \
|
---|
320 | *pId = pClsid; \
|
---|
321 | };
|
---|
322 |
|
---|
323 | #define DLLGETCLASSOBJECTROUTINE(pPFlist, pClsid,pFactory) \
|
---|
324 | HRESULT STDAPICALLTYPE DllGetClassObject ( \
|
---|
325 | REFCLSID rclsid, \
|
---|
326 | REFIID riid, \
|
---|
327 | void ** ppv ) \
|
---|
328 | { \
|
---|
329 | return \
|
---|
330 | NdrDllGetClassObject(rclsid,riid,ppv,pPFlist,pClsid,pFactory ); \
|
---|
331 | }
|
---|
332 |
|
---|
333 | #define DLLCANUNLOADNOW(pFactory) \
|
---|
334 | HRESULT STDAPICALLTYPE DllCanUnloadNow() \
|
---|
335 | { \
|
---|
336 | return NdrDllCanUnloadNow( pFactory ); \
|
---|
337 | }
|
---|
338 |
|
---|
339 |
|
---|
340 | #define DLLDUMMYPURECALL \
|
---|
341 | void __cdecl _purecall(void) \
|
---|
342 | { \
|
---|
343 | }
|
---|
344 |
|
---|
345 | #define CSTDSTUBBUFFERRELEASE(pFactory) \
|
---|
346 | ULONG STDMETHODCALLTYPE CStdStubBuffer_Release(IRpcStubBuffer *This) \
|
---|
347 | { \
|
---|
348 | return NdrCStdStubBuffer_Release(This,(IPSFactoryBuffer *)pFactory); \
|
---|
349 | } \
|
---|
350 |
|
---|
351 | #ifdef PROXY_DELEGATION
|
---|
352 | #define CSTDSTUBBUFFER2RELEASE(pFactory) \
|
---|
353 | ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This) \
|
---|
354 | { \
|
---|
355 | return NdrCStdStubBuffer2_Release(This,(IPSFactoryBuffer *)pFactory); \
|
---|
356 | }
|
---|
357 | #else
|
---|
358 | #define CSTDSTUBBUFFER2RELEASE(pFactory)
|
---|
359 | #endif //PROXY_DELEGATION
|
---|
360 |
|
---|
361 |
|
---|
362 | #ifdef REGISTER_PROXY_DLL
|
---|
363 | #define DLLREGISTRY_ROUTINES(pProxyFileList,pClsID ) REGISTER_PROXY_DLL_ROUTINES(pProxyFileList,pClsID )
|
---|
364 | #else
|
---|
365 | #define DLLREGISTRY_ROUTINES(pProxyFileList,pClsID )
|
---|
366 | #endif //REGISTER_PROXY_DLL
|
---|
367 |
|
---|
368 |
|
---|
369 | #define DLLDATA_ROUTINES(pProxyFileList,pClsID ) \
|
---|
370 | \
|
---|
371 | CLSID_PSFACTORYBUFFER \
|
---|
372 | \
|
---|
373 | CStdPSFactoryBuffer gPFactory = {0,0,0,0}; \
|
---|
374 | \
|
---|
375 | DLLDATA_GETPROXYDLLINFO(pProxyFileList,pClsID) \
|
---|
376 | \
|
---|
377 | DLLGETCLASSOBJECTROUTINE(pProxyFileList,pClsID,&gPFactory) \
|
---|
378 | \
|
---|
379 | DLLCANUNLOADNOW(&gPFactory) \
|
---|
380 | \
|
---|
381 | CSTDSTUBBUFFERRELEASE(&gPFactory) \
|
---|
382 | \
|
---|
383 | CSTDSTUBBUFFER2RELEASE(&gPFactory) \
|
---|
384 | \
|
---|
385 | DLLDUMMYPURECALL \
|
---|
386 | \
|
---|
387 | DLLREGISTRY_ROUTINES(pProxyFileList, pClsID) \
|
---|
388 | \
|
---|
389 |
|
---|
390 |
|
---|
391 | #define DLLDATA_STANDARD_ROUTINES \
|
---|
392 | DLLDATA_ROUTINES( (const ProxyFileInfo**) pProxyFileList, &CLSID_PSFactoryBuffer ) \
|
---|
393 |
|
---|
394 |
|
---|
395 | #endif //__RPCPROXY_H__
|
---|