ReactOS 0.4.16-dev-1946-g52006dd
rpcproxy.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2001 Ove Kaaven
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#ifndef __RPCPROXY_H_VERSION__
20#define __RPCPROXY_H_VERSION__ (477)
21#endif
22
23#ifndef __WINE_RPCPROXY_H
24#define __WINE_RPCPROXY_H
25
26#define __midl_proxy
27
28#include <basetsd.h>
29#ifndef GUID_DEFINED
30#include <guiddef.h>
31#endif
32#include <rpc.h>
33#include <rpcndr.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
41typedef const char *PCInterfaceName;
42typedef int __stdcall IIDLookupRtn( const IID *pIID, int *pIndex );
44
45typedef struct tagProxyFileInfo
46{
52 unsigned short TableSize;
53 unsigned short TableVersion;
59
61
63{
64#ifdef USE_STUBLESS_PROXY
65 const void *pStublessProxyInfo;
66#endif
67 const IID *piid;
69
70#define CINTERFACE_PROXY_VTABLE(n) \
71 struct \
72 { \
73 CInterfaceProxyHeader header; \
74 void *Vtbl[n]; \
75 }
76
78{
80 void *Vtbl[];
82
85 IRpcChannelBuffer *_pRpcChannelBuffer,
86 PRPC_MESSAGE _pRpcMessage,
87 DWORD *pdwStubPhase);
88
90{
91 const IID *piid;
96
98{
100 IRpcStubBufferVtbl Vtbl;
102
103typedef struct tagCStdStubBuffer
104{
105 const IRpcStubBufferVtbl *lpVtbl;
108 const struct ICallFactoryVtbl *pCallFactoryVtbl;
112
114{
115 const IPSFactoryBufferVtbl *lpVtbl;
120
121#define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
122
123#define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
124
129RPCRTAPI HRESULT WINAPI CStdStubBuffer_Invoke( IRpcStubBuffer *This, RPCOLEMESSAGE *pRpcMsg, IRpcChannelBuffer *pRpcChannelBuffer );
136
139
140#define CStdStubBuffer_METHODS \
141 CStdStubBuffer_QueryInterface, \
142 CStdStubBuffer_AddRef, \
143 CStdStubBuffer_Release, \
144 CStdStubBuffer_Connect, \
145 CStdStubBuffer_Disconnect, \
146 CStdStubBuffer_Invoke, \
147 CStdStubBuffer_IsIIDSupported, \
148 CStdStubBuffer_CountRefs, \
149 CStdStubBuffer_DebugServerQueryInterface, \
150 CStdStubBuffer_DebugServerRelease
151
153 NdrProxyInitialize( void *This, PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg,
154 PMIDL_STUB_DESC pStubDescriptor, unsigned int ProcNum );
156 NdrProxyGetBuffer( void *This, PMIDL_STUB_MESSAGE pStubMsg );
160 NdrProxyFreeBuffer( void *This, PMIDL_STUB_MESSAGE pStubMsg );
162 NdrProxyErrorHandler( DWORD dwExceptionCode );
163
166 PMIDL_STUB_DESC pStubDescriptor, IRpcChannelBuffer *pRpcChannelBuffer );
169 PMIDL_STUB_DESC pStubDescriptor, IRpcChannelBuffer *pRpcChannelBuffer,
170 ULONG RequestedBufferSize );
172 PRPC_MESSAGE pMsg, DWORD *pdwStubPhase );
176 NdrStubErrorHandler( DWORD dwExceptionCode );
177
179 NdrDllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv, const ProxyFileInfo **pProxyFileList,
180 const CLSID *pclsid, CStdPSFactoryBuffer *pPSFactoryBuffer );
182 NdrDllCanUnloadNow( CStdPSFactoryBuffer *pPSFactoryBuffer );
183
185 NdrDllRegisterProxy( HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid );
187 NdrDllUnregisterProxy( HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid );
188
189#ifdef USE_NEW_WINE_REGISTER_RESOURCES // This needs a global fix. See wine git rev 1331a8e.
190#define __wine_register_resources __wine_register_resources_new
191#define __wine_unregister_resources __wine_unregister_resources_new
194#else
197#endif
198
199#define CSTDSTUBBUFFERRELEASE(pFactory) \
200ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \
201 { return NdrCStdStubBuffer_Release(This, (IPSFactoryBuffer *)pFactory); }
202
203#ifdef PROXY_DELEGATION
204#define CSTDSTUBBUFFER2RELEASE(pFactory) \
205ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \
206 { return NdrCStdStubBuffer2_Release(This, (IPSFactoryBuffer *)pFactory); }
207#else
208#define CSTDSTUBBUFFER2RELEASE(pFactory)
209#endif
210
211#define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID, name##_ProxyVtblList[index]->header.piid, sizeof(IID))
212
213/*
214 * In these macros, BS stands for Binary Search. MIDL uses these to
215 * "unroll" a binary search into the module's IID_Lookup function.
216 * However, I haven't bothered to reimplement that stuff yet;
217 * I've just implemented a linear search for now.
218 */
219#define IID_BS_LOOKUP_SETUP \
220 int c;
221#define IID_BS_LOOKUP_INITIAL_TEST(name, sz, split)
222#define IID_BS_LOOKUP_NEXT_TEST(name, split)
223#define IID_BS_LOOKUP_RETURN_RESULT(name, sz, index) \
224 for (c=0; c<sz; c++) if (!name##_CHECK_IID(c)) { (index)=c; return 1; } \
225 return 0;
226
227/* macros used in dlldata.c files */
228#define EXTERN_PROXY_FILE(proxy) \
229 EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo;
230
231#define PROXYFILE_LIST_START \
232 const ProxyFileInfo * aProxyFileList[] = \
233 {
234
235#define REFERENCE_PROXY_FILE(proxy) \
236 & proxy##_ProxyFileInfo
237
238#define PROXYFILE_LIST_END \
239 NULL \
240 };
241
242
243/* define PROXY_CLSID to use an existing CLSID */
244/* define PROXY_CLSID_IS to specify the CLSID data of the PSFactoryBuffer */
245/* define neither to use the GUID of the first interface */
246#ifdef PROXY_CLSID
247# define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID;
248#else
249# ifdef PROXY_CLSID_IS
250# define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS;
251# define PROXY_CLSID CLSID_PSFactoryBuffer
252# else
253# define CLSID_PSFACTORYBUFFER
254# endif
255#endif
256
257#ifndef PROXY_CLSID
258# define GET_DLL_CLSID (aProxyFileList[0]->pStubVtblList[0] ? \
259 aProxyFileList[0]->pStubVtblList[0]->header.piid : NULL)
260#else
261# define GET_DLL_CLSID &PROXY_CLSID
262#endif
263
264#ifdef ENTRY_PREFIX
265# define __rpc_macro_expand2(a, b) a##b
266# define __rpc_macro_expand(a, b) __rpc_macro_expand2(a, b)
267# define DLLREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllRegisterServer)
268# define DLLUNREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllUnregisterServer)
269# define DLLMAIN_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllMain)
270# define DLLGETCLASSOBJECT_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllGetClassObject)
271# define DLLCANUNLOADNOW_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllCanUnloadNow)
272#else
273# define DLLREGISTERSERVER_ENTRY DllRegisterServer
274# define DLLUNREGISTERSERVER_ENTRY DllUnregisterServer
275# define DLLMAIN_ENTRY DllMain
276# define DLLGETCLASSOBJECT_ENTRY DllGetClassObject
277# define DLLCANUNLOADNOW_ENTRY DllCanUnloadNow
278#endif
279
280#ifdef WINE_REGISTER_DLL
281#ifdef USE_NEW_WINE_REGISTER_RESOURCES
282# define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources()
283# define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources()
284#else
285# define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources( hProxyDll )
286# define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources( hProxyDll )
287#endif
288#else
289# define WINE_DO_REGISTER_DLL(pfl, clsid) return NdrDllRegisterProxy( hProxyDll, (pfl), (clsid) )
290# define WINE_DO_UNREGISTER_DLL(pfl, clsid) return NdrDllUnregisterProxy( hProxyDll, (pfl), (clsid) )
291#endif
292
293
294#define DLLDATA_GETPROXYDLLINFO(pfl, rclsid) \
295 void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
296 const CLSID **ppClsid); \
297 void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
298 const CLSID **ppClsid) \
299 { \
300 *ppProxyFileInfo = (pfl); \
301 *ppClsid = (rclsid); \
302 }
303
304#define DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, factory) \
305 HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, void **ppv); \
306 HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, \
307 void **ppv) \
308 { \
309 return NdrDllGetClassObject(rclsid, riid, ppv, (pfl), \
310 (factory_clsid), factory); \
311 }
312
313#define DLLCANUNLOADNOW(factory) \
314 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void); \
315 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) \
316 { \
317 return NdrDllCanUnloadNow((factory)); \
318 }
319
320#define REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid) \
321 HINSTANCE hProxyDll = NULL; \
322 \
323 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); \
324 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, \
325 LPVOID lpvReserved) \
326 { \
327 if (fdwReason == DLL_PROCESS_ATTACH) \
328 { \
329 DisableThreadLibraryCalls(hinstDLL); \
330 hProxyDll = hinstDLL; \
331 } \
332 return TRUE; \
333 } \
334 \
335 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void); \
336 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) \
337 { \
338 WINE_DO_REGISTER_DLL( (pfl), (factory_clsid) ); \
339 } \
340 \
341 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void); \
342 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) \
343 { \
344 WINE_DO_UNREGISTER_DLL( (pfl), (factory_clsid) ); \
345 }
346
347#if defined(REGISTER_PROXY_DLL) || defined(WINE_REGISTER_DLL)
348# define DLLREGISTRY_ROUTINES(pfl, factory_clsid) \
349 REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid)
350#else
351# define DLLREGISTRY_ROUTINES(pfl, factory_clsid)
352#endif
353
354#define DLLDATA_ROUTINES(pfl, factory_clsid) \
355 CLSID_PSFACTORYBUFFER \
356 CStdPSFactoryBuffer gPFactory = { NULL, 0, NULL, 0 }; \
357 DLLDATA_GETPROXYDLLINFO(pfl, factory_clsid) \
358 DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, &gPFactory) \
359 DLLCANUNLOADNOW(&gPFactory) \
360 CSTDSTUBBUFFERRELEASE(&gPFactory) \
361 CSTDSTUBBUFFER2RELEASE(&gPFactory) \
362 DLLREGISTRY_ROUTINES(pfl, factory_clsid)
363
364#if 0
365
367 CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo, LPUNKNOWN pUnkOuter, REFIID riid,
368 LPRPCPROXYBUFFER *ppProxy, LPVOID *ppv );
370 CreateStubFromTypeInfo( LPTYPEINFO pTypeInfo, REFIID riid, LPUNKNOWN pUnkServer,
371 LPRPCSTUBBUFFER *ppStub );
372
373#endif
374
375#ifdef __cplusplus
376}
377#endif
378
379#endif /*__WINE_RPCPROXY_H */
#define __cdecl
Definition: accygwin.h:79
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
static LPVOID LPUNKNOWN
Definition: dinput.c:53
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4565
HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid, IUnknown *server, IRpcStubBuffer **stub_buffer)
Definition: ndr_typelib.c:1693
HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer, REFIID iid, IRpcProxyBuffer **proxy_buffer, void **out)
Definition: ndr_typelib.c:1556
interface IRpcStubBuffer * LPRPCSTUBBUFFER
Definition: objfwd.h:41
interface IRpcProxyBuffer * LPRPCPROXYBUFFER
Definition: objfwd.h:40
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
void __RPC_STUB NdrStubForwardingFunction(IRpcStubBuffer *This, IRpcChannelBuffer *pChannel, PRPC_MESSAGE pMsg, DWORD *pdwStubPhase)
Definition: cstub.c:421
struct tagCInterfaceProxyVtbl CInterfaceProxyVtbl
RPCRTAPI HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(IRpcStubBuffer *This, void **ppv)
RPCRTAPI void RPC_ENTRY NdrStubInitializePartial(PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDescriptor, IRpcChannelBuffer *pRpcChannelBuffer, ULONG RequestedBufferSize)
IIDLookupRtn * PIIDLookup
Definition: rpcproxy.h:43
int __stdcall IIDLookupRtn(const IID *pIID, int *pIndex)
Definition: rpcproxy.h:42
RPCRTAPI IRpcStubBuffer *WINAPI CStdStubBuffer_IsIIDSupported(IRpcStubBuffer *This, REFIID riid)
RPCRTAPI HRESULT WINAPI CStdStubBuffer_Invoke(IRpcStubBuffer *This, RPCOLEMESSAGE *pRpcMsg, IRpcChannelBuffer *pRpcChannelBuffer)
struct tagCInterfaceStubVtbl CInterfaceStubVtbl
RPCRTAPI HRESULT RPC_ENTRY NdrDllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid, CStdPSFactoryBuffer *pPSFactoryBuffer)
struct tagCInterfaceStubHeader CInterfaceStubHeader
void(__RPC_STUB * PRPC_STUB_FUNCTION)(IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *pdwStubPhase)
Definition: rpcproxy.h:83
RPCRTAPI ULONG WINAPI CStdStubBuffer_AddRef(IRpcStubBuffer *This)
RPCRTAPI HRESULT WINAPI CStdStubBuffer_QueryInterface(IRpcStubBuffer *This, REFIID riid, void **ppvObject)
HRESULT __cdecl __wine_unregister_resources(HMODULE module)
Definition: register.c:124
RPCRTAPI void RPC_ENTRY NdrStubInitialize(PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDescriptor, IRpcChannelBuffer *pRpcChannelBuffer)
ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This)
ProxyFileInfo ExtendedProxyFileInfo
Definition: rpcproxy.h:60
HRESULT __cdecl __wine_register_resources(HMODULE module)
Definition: register.c:112
RPCRTAPI void RPC_ENTRY NdrProxyFreeBuffer(void *This, PMIDL_STUB_MESSAGE pStubMsg)
Definition: cproxy.c:348
RPCRTAPI ULONG WINAPI NdrCStdStubBuffer2_Release(IRpcStubBuffer *This, IPSFactoryBuffer *pPSF)
RPCRTAPI ULONG WINAPI CStdStubBuffer_CountRefs(IRpcStubBuffer *This)
const char * PCInterfaceName
Definition: rpcproxy.h:41
RPCRTAPI HRESULT RPC_ENTRY NdrStubErrorHandler(DWORD dwExceptionCode)
RPCRTAPI void WINAPI CStdStubBuffer_DebugServerRelease(IRpcStubBuffer *This, void *pv)
struct tagCStdStubBuffer CStdStubBuffer
RPCRTAPI void RPC_ENTRY NdrProxySendReceive(void *This, PMIDL_STUB_MESSAGE pStubMsg)
Definition: cproxy.c:314
RPCRTAPI HRESULT RPC_ENTRY NdrDllRegisterProxy(HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid)
Definition: cpsf.c:218
RPCRTAPI HRESULT RPC_ENTRY NdrDllUnregisterProxy(HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid)
Definition: cpsf.c:286
RPCRTAPI void RPC_ENTRY NdrProxyGetBuffer(void *This, PMIDL_STUB_MESSAGE pStubMsg)
Definition: cproxy.c:286
RPCRTAPI void RPC_ENTRY NdrStubGetBuffer(IRpcStubBuffer *This, IRpcChannelBuffer *pRpcChannelBuffer, PMIDL_STUB_MESSAGE pStubMsg)
RPCRTAPI HRESULT RPC_ENTRY NdrDllCanUnloadNow(CStdPSFactoryBuffer *pPSFactoryBuffer)
Definition: cpsf.c:209
struct tagCInterfaceProxyVtbl * PCInterfaceProxyVtblList
Definition: rpcproxy.h:40
struct tagCInterfaceProxyHeader CInterfaceProxyHeader
RPCRTAPI void WINAPI CStdStubBuffer_Disconnect(IRpcStubBuffer *This)
RPCRTAPI void RPC_ENTRY NdrProxyInitialize(void *This, PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDescriptor, unsigned int ProcNum)
Definition: cproxy.c:266
struct tagProxyFileInfo ProxyFileInfo
struct tagCInterfaceStubVtbl * PCInterfaceStubVtblList
Definition: rpcproxy.h:39
RPCRTAPI HRESULT RPC_ENTRY NdrProxyErrorHandler(DWORD dwExceptionCode)
Definition: cproxy.c:366
RPCRTAPI ULONG WINAPI NdrCStdStubBuffer_Release(IRpcStubBuffer *This, IPSFactoryBuffer *pPSF)
RPCRTAPI HRESULT WINAPI CStdStubBuffer_Connect(IRpcStubBuffer *This, IUnknown *pUnkServer)
ULONG STDMETHODCALLTYPE CStdStubBuffer_Release(IRpcStubBuffer *This)
struct tagCStdPSFactoryBuffer CStdPSFactoryBuffer
#define RPC_ENTRY
Definition: rpc.h:63
#define __RPC_STUB
Definition: rpc.h:62
#define RPCRTAPI
Definition: rpc.h:78
CInterfaceProxyHeader header
Definition: rpcproxy.h:79
const PRPC_STUB_FUNCTION * pDispatchTable
Definition: rpcproxy.h:94
const MIDL_SERVER_INFO * pServerInfo
Definition: rpcproxy.h:92
const IID * piid
Definition: rpcproxy.h:91
CInterfaceStubHeader header
Definition: rpcproxy.h:99
IRpcStubBufferVtbl Vtbl
Definition: rpcproxy.h:100
const ProxyFileInfo ** pProxyFileList
Definition: rpcproxy.h:117
const IPSFactoryBufferVtbl * lpVtbl
Definition: rpcproxy.h:115
const struct ICallFactoryVtbl * pCallFactoryVtbl
Definition: rpcproxy.h:108
const IID * pAsyncIID
Definition: rpcproxy.h:109
struct IUnknown * pvServerObject
Definition: rpcproxy.h:107
const IRpcStubBufferVtbl * lpVtbl
Definition: rpcproxy.h:105
struct IPSFactoryBuffer * pPSFactory
Definition: rpcproxy.h:110
unsigned short TableVersion
Definition: rpcproxy.h:53
unsigned short TableSize
Definition: rpcproxy.h:52
const IID ** pDelegatedIIDs
Definition: rpcproxy.h:50
const PCInterfaceStubVtblList * pStubVtblList
Definition: rpcproxy.h:48
const IID ** pAsyncIIDLookup
Definition: rpcproxy.h:54
LONG_PTR Filler3
Definition: rpcproxy.h:56
const PIIDLookup pIIDLookupRtn
Definition: rpcproxy.h:51
LONG_PTR Filler2
Definition: rpcproxy.h:55
const PCInterfaceProxyVtblList * pProxyVtblList
Definition: rpcproxy.h:47
const PCInterfaceName * pNamesArray
Definition: rpcproxy.h:49
LONG_PTR Filler4
Definition: rpcproxy.h:57
#define __stdcall
Definition: typedefs.h:25
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6