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 /* FIXME: Find an appropriate version number. I guess something is better than nothing */
21 #define __RPCPROXY_H_VERSION__ ( 399 )
24 #ifndef __WINE_RPCPROXY_H
25 #define __WINE_RPCPROXY_H
40 typedef struct tagCInterfaceStubVtbl
*PCInterfaceStubVtblList
;
41 typedef struct tagCInterfaceProxyVtbl
*PCInterfaceProxyVtblList
;
42 typedef const char *PCInterfaceName
;
43 typedef int __stdcall
IIDLookupRtn( const IID
*pIID
, int *pIndex
);
44 typedef IIDLookupRtn
*PIIDLookup
;
46 typedef struct tagProxyFileInfo
48 const PCInterfaceProxyVtblList
*pProxyVtblList
;
49 const PCInterfaceStubVtblList
*pStubVtblList
;
50 const PCInterfaceName
*pNamesArray
;
51 const IID
**pDelegatedIIDs
;
52 const PIIDLookup pIIDLookupRtn
;
53 unsigned short TableSize
;
54 unsigned short TableVersion
;
55 const IID
**pAsyncIIDLookup
;
61 typedef ProxyFileInfo ExtendedProxyFileInfo
;
63 typedef struct tagCInterfaceProxyHeader
65 #ifdef USE_STUBLESS_PROXY
66 const void *pStublessProxyInfo
;
69 } CInterfaceProxyHeader
;
71 #define CINTERFACE_PROXY_VTABLE(n) \
74 CInterfaceProxyHeader header; \
78 typedef struct tagCInterfaceProxyVtbl
80 CInterfaceProxyHeader header
;
86 } CInterfaceProxyVtbl
;
88 typedef void (__RPC_STUB
*PRPC_STUB_FUNCTION
)(
90 IRpcChannelBuffer
*_pRpcChannelBuffer
,
91 PRPC_MESSAGE _pRpcMessage
,
94 typedef struct tagCInterfaceStubHeader
97 const MIDL_SERVER_INFO
*pServerInfo
;
98 ULONG DispatchTableCount
;
99 const PRPC_STUB_FUNCTION
*pDispatchTable
;
100 } CInterfaceStubHeader
;
102 typedef struct tagCInterfaceStubVtbl
104 CInterfaceStubHeader header
;
105 IRpcStubBufferVtbl Vtbl
;
106 } CInterfaceStubVtbl
;
108 typedef struct tagCStdStubBuffer
110 const IRpcStubBufferVtbl
*lpVtbl
;
112 struct IUnknown
*pvServerObject
;
113 const struct ICallFactoryVtbl
*pCallFactoryVtbl
;
114 const IID
*pAsyncIID
;
115 struct IPSFactoryBuffer
*pPSFactory
;
118 typedef struct tagCStdPSFactoryBuffer
120 const IPSFactoryBufferVtbl
*lpVtbl
;
122 const ProxyFileInfo
**pProxyFileList
;
124 } CStdPSFactoryBuffer
;
126 #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
128 ULONG STDMETHODCALLTYPE
CStdStubBuffer2_Release(IRpcStubBuffer
*This
) DECLSPEC_HIDDEN
;
129 ULONG STDMETHODCALLTYPE
NdrCStdStubBuffer2_Release(IRpcStubBuffer
*This
, IPSFactoryBuffer
*pPSF
);
131 #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
135 CStdStubBuffer_QueryInterface( IRpcStubBuffer
*This
, REFIID riid
, void **ppvObject
);
137 CStdStubBuffer_AddRef( IRpcStubBuffer
*This
);
139 CStdStubBuffer_Release( IRpcStubBuffer
*This
) DECLSPEC_HIDDEN
;
141 NdrCStdStubBuffer_Release( IRpcStubBuffer
*This
, IPSFactoryBuffer
*pPSF
);
143 CStdStubBuffer_Connect( IRpcStubBuffer
*This
, IUnknown
*pUnkServer
);
145 CStdStubBuffer_Disconnect( IRpcStubBuffer
*This
);
147 CStdStubBuffer_Invoke( IRpcStubBuffer
*This
, RPCOLEMESSAGE
*pRpcMsg
, IRpcChannelBuffer
*pRpcChannelBuffer
);
148 IRpcStubBuffer
* WINAPI
149 CStdStubBuffer_IsIIDSupported( IRpcStubBuffer
*This
, REFIID riid
);
151 CStdStubBuffer_CountRefs( IRpcStubBuffer
*This
);
153 CStdStubBuffer_DebugServerQueryInterface( IRpcStubBuffer
*This
, void **ppv
);
155 CStdStubBuffer_DebugServerRelease( IRpcStubBuffer
*This
, void *pv
);
157 #define CStdStubBuffer_METHODS \
158 CStdStubBuffer_QueryInterface, \
159 CStdStubBuffer_AddRef, \
160 CStdStubBuffer_Release, \
161 CStdStubBuffer_Connect, \
162 CStdStubBuffer_Disconnect, \
163 CStdStubBuffer_Invoke, \
164 CStdStubBuffer_IsIIDSupported, \
165 CStdStubBuffer_CountRefs, \
166 CStdStubBuffer_DebugServerQueryInterface, \
167 CStdStubBuffer_DebugServerRelease
169 RPCRTAPI
void RPC_ENTRY
170 NdrProxyInitialize( void *This
, PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
171 PMIDL_STUB_DESC pStubDescriptor
, unsigned int ProcNum
);
172 RPCRTAPI
void RPC_ENTRY
173 NdrProxyGetBuffer( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
174 RPCRTAPI
void RPC_ENTRY
175 NdrProxySendReceive( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
176 RPCRTAPI
void RPC_ENTRY
177 NdrProxyFreeBuffer( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
178 RPCRTAPI HRESULT RPC_ENTRY
179 NdrProxyErrorHandler( DWORD dwExceptionCode
);
181 RPCRTAPI
void RPC_ENTRY
182 NdrStubInitialize( PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
183 PMIDL_STUB_DESC pStubDescriptor
, IRpcChannelBuffer
*pRpcChannelBuffer
);
184 RPCRTAPI
void RPC_ENTRY
185 NdrStubInitializePartial( PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
186 PMIDL_STUB_DESC pStubDescriptor
, IRpcChannelBuffer
*pRpcChannelBuffer
,
187 ULONG RequestedBufferSize
);
188 void __RPC_STUB
NdrStubForwardingFunction( IRpcStubBuffer
*This
, IRpcChannelBuffer
*pChannel
,
189 PRPC_MESSAGE pMsg
, DWORD
*pdwStubPhase
);
190 RPCRTAPI
void RPC_ENTRY
191 NdrStubGetBuffer( IRpcStubBuffer
*This
, IRpcChannelBuffer
*pRpcChannelBuffer
, PMIDL_STUB_MESSAGE pStubMsg
);
192 RPCRTAPI HRESULT RPC_ENTRY
193 NdrStubErrorHandler( DWORD dwExceptionCode
);
195 RPCRTAPI HRESULT RPC_ENTRY
196 NdrDllGetClassObject( REFCLSID rclsid
, REFIID riid
, void **ppv
, const ProxyFileInfo
**pProxyFileList
,
197 const CLSID
*pclsid
, CStdPSFactoryBuffer
*pPSFactoryBuffer
);
198 RPCRTAPI HRESULT RPC_ENTRY
199 NdrDllCanUnloadNow( CStdPSFactoryBuffer
*pPSFactoryBuffer
);
201 RPCRTAPI HRESULT RPC_ENTRY
202 NdrDllRegisterProxy( HMODULE hDll
, const ProxyFileInfo
**pProxyFileList
, const CLSID
*pclsid
);
203 RPCRTAPI HRESULT RPC_ENTRY
204 NdrDllUnregisterProxy( HMODULE hDll
, const ProxyFileInfo
**pProxyFileList
, const CLSID
*pclsid
);
206 HRESULT __cdecl
__wine_register_resources( HMODULE module
) DECLSPEC_HIDDEN
;
207 HRESULT __cdecl
__wine_unregister_resources( HMODULE module
) DECLSPEC_HIDDEN
;
209 #define CSTDSTUBBUFFERRELEASE(pFactory) \
210 ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \
211 { return NdrCStdStubBuffer_Release(This, (IPSFactoryBuffer *)pFactory); }
213 #ifdef PROXY_DELEGATION
214 #define CSTDSTUBBUFFER2RELEASE(pFactory) \
215 ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \
216 { return NdrCStdStubBuffer2_Release(This, (IPSFactoryBuffer *)pFactory); }
218 #define CSTDSTUBBUFFER2RELEASE(pFactory)
221 #define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID, name##_ProxyVtblList[index]->header.piid, sizeof(IID))
224 * In these macros, BS stands for Binary Search. MIDL uses these to
225 * "unroll" a binary search into the module's IID_Lookup function.
226 * However, I haven't bothered to reimplement that stuff yet;
227 * I've just implemented a linear search for now.
229 #define IID_BS_LOOKUP_SETUP \
231 #define IID_BS_LOOKUP_INITIAL_TEST(name, sz, split)
232 #define IID_BS_LOOKUP_NEXT_TEST(name, split)
233 #define IID_BS_LOOKUP_RETURN_RESULT(name, sz, index) \
234 for (c=0; c<sz; c++) if (!name##_CHECK_IID(c)) { (index)=c; return 1; } \
237 /* macros used in dlldata.c files */
238 #define EXTERN_PROXY_FILE(proxy) \
239 EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo DECLSPEC_HIDDEN;
241 #define PROXYFILE_LIST_START \
242 const ProxyFileInfo * aProxyFileList[] DECLSPEC_HIDDEN = \
245 #define REFERENCE_PROXY_FILE(proxy) \
246 & proxy##_ProxyFileInfo
248 #define PROXYFILE_LIST_END \
253 /* define PROXY_CLSID to use an existing CLSID */
254 /* define PROXY_CLSID_IS to specify the CLSID data of the PSFactoryBuffer */
255 /* define neither to use the GUID of the first interface */
257 # define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID DECLSPEC_HIDDEN;
259 # ifdef PROXY_CLSID_IS
260 # define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer DECLSPEC_HIDDEN; \
261 const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS;
262 # define PROXY_CLSID CLSID_PSFactoryBuffer
264 # define CLSID_PSFACTORYBUFFER
269 # define GET_DLL_CLSID (aProxyFileList[0]->pStubVtblList[0] ? \
270 aProxyFileList[0]->pStubVtblList[0]->header.piid : NULL)
272 # define GET_DLL_CLSID &PROXY_CLSID
276 # define __rpc_macro_expand2(a, b) a##b
277 # define __rpc_macro_expand(a, b) __rpc_macro_expand2(a, b)
278 # define DLLREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllRegisterServer)
279 # define DLLUNREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllUnregisterServer)
280 # define DLLMAIN_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllMain)
281 # define DLLGETCLASSOBJECT_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllGetClassObject)
282 # define DLLCANUNLOADNOW_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllCanUnloadNow)
284 # define DLLREGISTERSERVER_ENTRY DllRegisterServer
285 # define DLLUNREGISTERSERVER_ENTRY DllUnregisterServer
286 # define DLLMAIN_ENTRY DllMain
287 # define DLLGETCLASSOBJECT_ENTRY DllGetClassObject
288 # define DLLCANUNLOADNOW_ENTRY DllCanUnloadNow
291 #ifdef WINE_REGISTER_DLL
292 # define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources( hProxyDll )
293 # define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources( hProxyDll )
295 # define WINE_DO_REGISTER_DLL(pfl, clsid) return NdrDllRegisterProxy( hProxyDll, (pfl), (clsid) )
296 # define WINE_DO_UNREGISTER_DLL(pfl, clsid) return NdrDllUnregisterProxy( hProxyDll, (pfl), (clsid) )
300 #define DLLDATA_GETPROXYDLLINFO(pfl, rclsid) \
301 void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
302 const CLSID **ppClsid) DECLSPEC_HIDDEN; \
303 void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
304 const CLSID **ppClsid) \
306 *ppProxyFileInfo = (pfl); \
307 *ppClsid = (rclsid); \
310 #define DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, factory) \
311 HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN; \
312 HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, \
315 return NdrDllGetClassObject(rclsid, riid, ppv, (pfl), \
316 (factory_clsid), factory); \
319 #define DLLCANUNLOADNOW(factory) \
320 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) DECLSPEC_HIDDEN; \
321 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) \
323 return NdrDllCanUnloadNow((factory)); \
326 #define REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid) \
327 HINSTANCE hProxyDll DECLSPEC_HIDDEN = NULL; \
329 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DECLSPEC_HIDDEN; \
330 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, \
331 LPVOID lpvReserved) \
333 if (fdwReason == DLL_PROCESS_ATTACH) \
335 DisableThreadLibraryCalls(hinstDLL); \
336 hProxyDll = hinstDLL; \
341 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) DECLSPEC_HIDDEN; \
342 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) \
344 WINE_DO_REGISTER_DLL( (pfl), (factory_clsid) ); \
347 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) DECLSPEC_HIDDEN; \
348 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) \
350 WINE_DO_UNREGISTER_DLL( (pfl), (factory_clsid) ); \
353 #if defined(REGISTER_PROXY_DLL) || defined(WINE_REGISTER_DLL)
354 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid) \
355 REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid)
357 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid)
360 #define DLLDATA_ROUTINES(pfl, factory_clsid) \
361 CLSID_PSFACTORYBUFFER \
362 CStdPSFactoryBuffer DECLSPEC_HIDDEN gPFactory = { NULL, 0, NULL, 0 }; \
363 DLLDATA_GETPROXYDLLINFO(pfl, factory_clsid) \
364 DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, &gPFactory) \
365 DLLCANUNLOADNOW(&gPFactory) \
366 CSTDSTUBBUFFERRELEASE(&gPFactory) \
367 CSTDSTUBBUFFER2RELEASE(&gPFactory) \
368 DLLREGISTRY_ROUTINES(pfl, factory_clsid)
372 RPCRTAPI HRESULT RPC_ENTRY
373 CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo
, LPUNKNOWN pUnkOuter
, REFIID riid
,
374 LPRPCPROXYBUFFER
*ppProxy
, LPVOID
*ppv
);
375 RPCRTAPI HRESULT RPC_ENTRY
376 CreateStubFromTypeInfo( LPTYPEINFO pTypeInfo
, REFIID riid
, LPUNKNOWN pUnkServer
,
377 LPRPCSTUBBUFFER
*ppStub
);
385 #endif /*__WINE_RPCPROXY_H */