2 * Copyright (C) 2001 Ove Kaaven
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.
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.
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
19 #ifndef __RPCPROXY_H_VERSION__
20 #define __RPCPROXY_H_VERSION__ (477)
23 #ifndef __WINE_RPCPROXY_H
24 #define __WINE_RPCPROXY_H
39 typedef struct tagCInterfaceStubVtbl
*PCInterfaceStubVtblList
;
40 typedef struct tagCInterfaceProxyVtbl
*PCInterfaceProxyVtblList
;
41 typedef const char *PCInterfaceName
;
42 typedef int __stdcall
IIDLookupRtn( const IID
*pIID
, int *pIndex
);
43 typedef IIDLookupRtn
*PIIDLookup
;
45 typedef struct tagProxyFileInfo
47 const PCInterfaceProxyVtblList
*pProxyVtblList
;
48 const PCInterfaceStubVtblList
*pStubVtblList
;
49 const PCInterfaceName
*pNamesArray
;
50 const IID
**pDelegatedIIDs
;
51 const PIIDLookup pIIDLookupRtn
;
52 unsigned short TableSize
;
53 unsigned short TableVersion
;
54 const IID
**pAsyncIIDLookup
;
60 typedef ProxyFileInfo ExtendedProxyFileInfo
;
62 typedef struct tagCInterfaceProxyHeader
64 #ifdef USE_STUBLESS_PROXY
65 const void *pStublessProxyInfo
;
68 } CInterfaceProxyHeader
;
70 #define CINTERFACE_PROXY_VTABLE(n) \
73 CInterfaceProxyHeader header; \
77 typedef struct tagCInterfaceProxyVtbl
79 CInterfaceProxyHeader header
;
81 } CInterfaceProxyVtbl
;
83 typedef void (__RPC_STUB
*PRPC_STUB_FUNCTION
)(
85 IRpcChannelBuffer
*_pRpcChannelBuffer
,
86 PRPC_MESSAGE _pRpcMessage
,
89 typedef struct tagCInterfaceStubHeader
92 const MIDL_SERVER_INFO
*pServerInfo
;
93 ULONG DispatchTableCount
;
94 const PRPC_STUB_FUNCTION
*pDispatchTable
;
95 } CInterfaceStubHeader
;
97 typedef struct tagCInterfaceStubVtbl
99 CInterfaceStubHeader header
;
100 IRpcStubBufferVtbl Vtbl
;
101 } CInterfaceStubVtbl
;
103 typedef struct tagCStdStubBuffer
105 const IRpcStubBufferVtbl
*lpVtbl
;
107 struct IUnknown
*pvServerObject
;
108 const struct ICallFactoryVtbl
*pCallFactoryVtbl
;
109 const IID
*pAsyncIID
;
110 struct IPSFactoryBuffer
*pPSFactory
;
113 typedef struct tagCStdPSFactoryBuffer
115 const IPSFactoryBufferVtbl
*lpVtbl
;
117 const ProxyFileInfo
**pProxyFileList
;
119 } CStdPSFactoryBuffer
;
121 #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
123 #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
125 RPCRTAPI HRESULT WINAPI
CStdStubBuffer_QueryInterface( IRpcStubBuffer
*This
, REFIID riid
, void **ppvObject
);
126 RPCRTAPI ULONG WINAPI
CStdStubBuffer_AddRef( IRpcStubBuffer
*This
);
127 RPCRTAPI HRESULT WINAPI
CStdStubBuffer_Connect( IRpcStubBuffer
*This
, IUnknown
*pUnkServer
);
128 RPCRTAPI
void WINAPI
CStdStubBuffer_Disconnect( IRpcStubBuffer
*This
);
129 RPCRTAPI HRESULT WINAPI
CStdStubBuffer_Invoke( IRpcStubBuffer
*This
, RPCOLEMESSAGE
*pRpcMsg
, IRpcChannelBuffer
*pRpcChannelBuffer
);
130 RPCRTAPI IRpcStubBuffer
* WINAPI
CStdStubBuffer_IsIIDSupported( IRpcStubBuffer
*This
, REFIID riid
);
131 RPCRTAPI ULONG WINAPI
CStdStubBuffer_CountRefs( IRpcStubBuffer
*This
);
132 RPCRTAPI HRESULT WINAPI
CStdStubBuffer_DebugServerQueryInterface( IRpcStubBuffer
*This
, void **ppv
);
133 RPCRTAPI
void WINAPI
CStdStubBuffer_DebugServerRelease( IRpcStubBuffer
*This
, void *pv
);
134 RPCRTAPI ULONG WINAPI
NdrCStdStubBuffer_Release( IRpcStubBuffer
*This
, IPSFactoryBuffer
*pPSF
);
135 RPCRTAPI ULONG WINAPI
NdrCStdStubBuffer2_Release(IRpcStubBuffer
*This
, IPSFactoryBuffer
*pPSF
);
137 ULONG STDMETHODCALLTYPE
CStdStubBuffer_Release( IRpcStubBuffer
*This
);
138 ULONG STDMETHODCALLTYPE
CStdStubBuffer2_Release(IRpcStubBuffer
*This
);
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
152 RPCRTAPI
void RPC_ENTRY
153 NdrProxyInitialize( void *This
, PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
154 PMIDL_STUB_DESC pStubDescriptor
, unsigned int ProcNum
);
155 RPCRTAPI
void RPC_ENTRY
156 NdrProxyGetBuffer( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
157 RPCRTAPI
void RPC_ENTRY
158 NdrProxySendReceive( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
159 RPCRTAPI
void RPC_ENTRY
160 NdrProxyFreeBuffer( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
161 RPCRTAPI HRESULT RPC_ENTRY
162 NdrProxyErrorHandler( DWORD dwExceptionCode
);
164 RPCRTAPI
void RPC_ENTRY
165 NdrStubInitialize( PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
166 PMIDL_STUB_DESC pStubDescriptor
, IRpcChannelBuffer
*pRpcChannelBuffer
);
167 RPCRTAPI
void RPC_ENTRY
168 NdrStubInitializePartial( PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
169 PMIDL_STUB_DESC pStubDescriptor
, IRpcChannelBuffer
*pRpcChannelBuffer
,
170 ULONG RequestedBufferSize
);
171 void __RPC_STUB
NdrStubForwardingFunction( IRpcStubBuffer
*This
, IRpcChannelBuffer
*pChannel
,
172 PRPC_MESSAGE pMsg
, DWORD
*pdwStubPhase
);
173 RPCRTAPI
void RPC_ENTRY
174 NdrStubGetBuffer( IRpcStubBuffer
*This
, IRpcChannelBuffer
*pRpcChannelBuffer
, PMIDL_STUB_MESSAGE pStubMsg
);
175 RPCRTAPI HRESULT RPC_ENTRY
176 NdrStubErrorHandler( DWORD dwExceptionCode
);
178 RPCRTAPI HRESULT RPC_ENTRY
179 NdrDllGetClassObject( REFCLSID rclsid
, REFIID riid
, void **ppv
, const ProxyFileInfo
**pProxyFileList
,
180 const CLSID
*pclsid
, CStdPSFactoryBuffer
*pPSFactoryBuffer
);
181 RPCRTAPI HRESULT RPC_ENTRY
182 NdrDllCanUnloadNow( CStdPSFactoryBuffer
*pPSFactoryBuffer
);
184 RPCRTAPI HRESULT RPC_ENTRY
185 NdrDllRegisterProxy( HMODULE hDll
, const ProxyFileInfo
**pProxyFileList
, const CLSID
*pclsid
);
186 RPCRTAPI HRESULT RPC_ENTRY
187 NdrDllUnregisterProxy( HMODULE hDll
, const ProxyFileInfo
**pProxyFileList
, const CLSID
*pclsid
);
189 HRESULT __cdecl
__wine_register_resources(void);
190 HRESULT __cdecl
__wine_unregister_resources(void);
192 #define CSTDSTUBBUFFERRELEASE(pFactory) \
193 ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \
194 { return NdrCStdStubBuffer_Release(This, (IPSFactoryBuffer *)pFactory); }
196 #ifdef PROXY_DELEGATION
197 #define CSTDSTUBBUFFER2RELEASE(pFactory) \
198 ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \
199 { return NdrCStdStubBuffer2_Release(This, (IPSFactoryBuffer *)pFactory); }
201 #define CSTDSTUBBUFFER2RELEASE(pFactory)
204 #define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID, name##_ProxyVtblList[index]->header.piid, sizeof(IID))
207 * In these macros, BS stands for Binary Search. MIDL uses these to
208 * "unroll" a binary search into the module's IID_Lookup function.
209 * However, I haven't bothered to reimplement that stuff yet;
210 * I've just implemented a linear search for now.
212 #define IID_BS_LOOKUP_SETUP \
214 #define IID_BS_LOOKUP_INITIAL_TEST(name, sz, split)
215 #define IID_BS_LOOKUP_NEXT_TEST(name, split)
216 #define IID_BS_LOOKUP_RETURN_RESULT(name, sz, index) \
217 for (c=0; c<sz; c++) if (!name##_CHECK_IID(c)) { (index)=c; return 1; } \
220 /* macros used in dlldata.c files */
221 #define EXTERN_PROXY_FILE(proxy) \
222 EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo;
224 #define PROXYFILE_LIST_START \
225 const ProxyFileInfo * aProxyFileList[] = \
228 #define REFERENCE_PROXY_FILE(proxy) \
229 & proxy##_ProxyFileInfo
231 #define PROXYFILE_LIST_END \
236 /* define PROXY_CLSID to use an existing CLSID */
237 /* define PROXY_CLSID_IS to specify the CLSID data of the PSFactoryBuffer */
238 /* define neither to use the GUID of the first interface */
240 # define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID;
242 # ifdef PROXY_CLSID_IS
243 # define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS;
244 # define PROXY_CLSID CLSID_PSFactoryBuffer
246 # define CLSID_PSFACTORYBUFFER
251 # define GET_DLL_CLSID (aProxyFileList[0]->pStubVtblList[0] ? \
252 aProxyFileList[0]->pStubVtblList[0]->header.piid : NULL)
254 # define GET_DLL_CLSID &PROXY_CLSID
258 # define __rpc_macro_expand2(a, b) a##b
259 # define __rpc_macro_expand(a, b) __rpc_macro_expand2(a, b)
260 # define DLLREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllRegisterServer)
261 # define DLLUNREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllUnregisterServer)
262 # define DLLMAIN_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllMain)
263 # define DLLGETCLASSOBJECT_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllGetClassObject)
264 # define DLLCANUNLOADNOW_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllCanUnloadNow)
266 # define DLLREGISTERSERVER_ENTRY DllRegisterServer
267 # define DLLUNREGISTERSERVER_ENTRY DllUnregisterServer
268 # define DLLMAIN_ENTRY DllMain
269 # define DLLGETCLASSOBJECT_ENTRY DllGetClassObject
270 # define DLLCANUNLOADNOW_ENTRY DllCanUnloadNow
273 #ifdef WINE_REGISTER_DLL
274 # define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources()
275 # define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources()
277 # define WINE_DO_REGISTER_DLL(pfl, clsid) return NdrDllRegisterProxy( hProxyDll, (pfl), (clsid) )
278 # define WINE_DO_UNREGISTER_DLL(pfl, clsid) return NdrDllUnregisterProxy( hProxyDll, (pfl), (clsid) )
282 #define DLLDATA_GETPROXYDLLINFO(pfl, rclsid) \
283 void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
284 const CLSID **ppClsid); \
285 void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
286 const CLSID **ppClsid) \
288 *ppProxyFileInfo = (pfl); \
289 *ppClsid = (rclsid); \
292 #define DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, factory) \
293 HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, void **ppv); \
294 HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, \
297 return NdrDllGetClassObject(rclsid, riid, ppv, (pfl), \
298 (factory_clsid), factory); \
301 #define DLLCANUNLOADNOW(factory) \
302 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void); \
303 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) \
305 return NdrDllCanUnloadNow((factory)); \
308 #define REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid) \
309 HINSTANCE hProxyDll = NULL; \
311 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); \
312 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, \
313 LPVOID lpvReserved) \
315 if (fdwReason == DLL_PROCESS_ATTACH) \
317 DisableThreadLibraryCalls(hinstDLL); \
318 hProxyDll = hinstDLL; \
323 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void); \
324 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) \
326 WINE_DO_REGISTER_DLL( (pfl), (factory_clsid) ); \
329 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void); \
330 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) \
332 WINE_DO_UNREGISTER_DLL( (pfl), (factory_clsid) ); \
335 #if defined(REGISTER_PROXY_DLL) || defined(WINE_REGISTER_DLL)
336 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid) \
337 REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid)
339 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid)
342 #define DLLDATA_ROUTINES(pfl, factory_clsid) \
343 CLSID_PSFACTORYBUFFER \
344 CStdPSFactoryBuffer gPFactory = { NULL, 0, NULL, 0 }; \
345 DLLDATA_GETPROXYDLLINFO(pfl, factory_clsid) \
346 DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, &gPFactory) \
347 DLLCANUNLOADNOW(&gPFactory) \
348 CSTDSTUBBUFFERRELEASE(&gPFactory) \
349 CSTDSTUBBUFFER2RELEASE(&gPFactory) \
350 DLLREGISTRY_ROUTINES(pfl, factory_clsid)
354 RPCRTAPI HRESULT RPC_ENTRY
355 CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo
, LPUNKNOWN pUnkOuter
, REFIID riid
,
356 LPRPCPROXYBUFFER
*ppProxy
, LPVOID
*ppv
);
357 RPCRTAPI HRESULT RPC_ENTRY
358 CreateStubFromTypeInfo( LPTYPEINFO pTypeInfo
, REFIID riid
, LPUNKNOWN pUnkServer
,
359 LPRPCSTUBBUFFER
*ppStub
);
367 #endif /*__WINE_RPCPROXY_H */