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 #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
130 RPCRTAPI HRESULT WINAPI
CStdStubBuffer_QueryInterface( IRpcStubBuffer
*This
, REFIID riid
, void **ppvObject
);
131 RPCRTAPI ULONG WINAPI
CStdStubBuffer_AddRef( IRpcStubBuffer
*This
);
132 RPCRTAPI HRESULT WINAPI
CStdStubBuffer_Connect( IRpcStubBuffer
*This
, IUnknown
*pUnkServer
);
133 RPCRTAPI
void WINAPI
CStdStubBuffer_Disconnect( IRpcStubBuffer
*This
);
134 RPCRTAPI HRESULT WINAPI
CStdStubBuffer_Invoke( IRpcStubBuffer
*This
, RPCOLEMESSAGE
*pRpcMsg
, IRpcChannelBuffer
*pRpcChannelBuffer
);
135 RPCRTAPI IRpcStubBuffer
* WINAPI
CStdStubBuffer_IsIIDSupported( IRpcStubBuffer
*This
, REFIID riid
);
136 RPCRTAPI ULONG WINAPI
CStdStubBuffer_CountRefs( IRpcStubBuffer
*This
);
137 RPCRTAPI HRESULT WINAPI
CStdStubBuffer_DebugServerQueryInterface( IRpcStubBuffer
*This
, void **ppv
);
138 RPCRTAPI
void WINAPI
CStdStubBuffer_DebugServerRelease( IRpcStubBuffer
*This
, void *pv
);
139 RPCRTAPI ULONG WINAPI
NdrCStdStubBuffer_Release( IRpcStubBuffer
*This
, IPSFactoryBuffer
*pPSF
);
140 RPCRTAPI ULONG WINAPI
NdrCStdStubBuffer2_Release(IRpcStubBuffer
*This
, IPSFactoryBuffer
*pPSF
);
142 ULONG STDMETHODCALLTYPE
CStdStubBuffer_Release( IRpcStubBuffer
*This
) DECLSPEC_HIDDEN
;
143 ULONG STDMETHODCALLTYPE
CStdStubBuffer2_Release(IRpcStubBuffer
*This
) DECLSPEC_HIDDEN
;
145 #define CStdStubBuffer_METHODS \
146 CStdStubBuffer_QueryInterface, \
147 CStdStubBuffer_AddRef, \
148 CStdStubBuffer_Release, \
149 CStdStubBuffer_Connect, \
150 CStdStubBuffer_Disconnect, \
151 CStdStubBuffer_Invoke, \
152 CStdStubBuffer_IsIIDSupported, \
153 CStdStubBuffer_CountRefs, \
154 CStdStubBuffer_DebugServerQueryInterface, \
155 CStdStubBuffer_DebugServerRelease
157 RPCRTAPI
void RPC_ENTRY
158 NdrProxyInitialize( void *This
, PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
159 PMIDL_STUB_DESC pStubDescriptor
, unsigned int ProcNum
);
160 RPCRTAPI
void RPC_ENTRY
161 NdrProxyGetBuffer( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
162 RPCRTAPI
void RPC_ENTRY
163 NdrProxySendReceive( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
164 RPCRTAPI
void RPC_ENTRY
165 NdrProxyFreeBuffer( void *This
, PMIDL_STUB_MESSAGE pStubMsg
);
166 RPCRTAPI HRESULT RPC_ENTRY
167 NdrProxyErrorHandler( DWORD dwExceptionCode
);
169 RPCRTAPI
void RPC_ENTRY
170 NdrStubInitialize( PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
171 PMIDL_STUB_DESC pStubDescriptor
, IRpcChannelBuffer
*pRpcChannelBuffer
);
172 RPCRTAPI
void RPC_ENTRY
173 NdrStubInitializePartial( PRPC_MESSAGE pRpcMsg
, PMIDL_STUB_MESSAGE pStubMsg
,
174 PMIDL_STUB_DESC pStubDescriptor
, IRpcChannelBuffer
*pRpcChannelBuffer
,
175 ULONG RequestedBufferSize
);
176 void __RPC_STUB
NdrStubForwardingFunction( IRpcStubBuffer
*This
, IRpcChannelBuffer
*pChannel
,
177 PRPC_MESSAGE pMsg
, DWORD
*pdwStubPhase
);
178 RPCRTAPI
void RPC_ENTRY
179 NdrStubGetBuffer( IRpcStubBuffer
*This
, IRpcChannelBuffer
*pRpcChannelBuffer
, PMIDL_STUB_MESSAGE pStubMsg
);
180 RPCRTAPI HRESULT RPC_ENTRY
181 NdrStubErrorHandler( DWORD dwExceptionCode
);
183 RPCRTAPI HRESULT RPC_ENTRY
184 NdrDllGetClassObject( REFCLSID rclsid
, REFIID riid
, void **ppv
, const ProxyFileInfo
**pProxyFileList
,
185 const CLSID
*pclsid
, CStdPSFactoryBuffer
*pPSFactoryBuffer
);
186 RPCRTAPI HRESULT RPC_ENTRY
187 NdrDllCanUnloadNow( CStdPSFactoryBuffer
*pPSFactoryBuffer
);
189 RPCRTAPI HRESULT RPC_ENTRY
190 NdrDllRegisterProxy( HMODULE hDll
, const ProxyFileInfo
**pProxyFileList
, const CLSID
*pclsid
);
191 RPCRTAPI HRESULT RPC_ENTRY
192 NdrDllUnregisterProxy( HMODULE hDll
, const ProxyFileInfo
**pProxyFileList
, const CLSID
*pclsid
);
194 HRESULT __cdecl
__wine_register_resources(void) DECLSPEC_HIDDEN
;
195 HRESULT __cdecl
__wine_unregister_resources(void) DECLSPEC_HIDDEN
;
197 #define CSTDSTUBBUFFERRELEASE(pFactory) \
198 ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \
199 { return NdrCStdStubBuffer_Release(This, (IPSFactoryBuffer *)pFactory); }
201 #ifdef PROXY_DELEGATION
202 #define CSTDSTUBBUFFER2RELEASE(pFactory) \
203 ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \
204 { return NdrCStdStubBuffer2_Release(This, (IPSFactoryBuffer *)pFactory); }
206 #define CSTDSTUBBUFFER2RELEASE(pFactory)
209 #define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID, name##_ProxyVtblList[index]->header.piid, sizeof(IID))
212 * In these macros, BS stands for Binary Search. MIDL uses these to
213 * "unroll" a binary search into the module's IID_Lookup function.
214 * However, I haven't bothered to reimplement that stuff yet;
215 * I've just implemented a linear search for now.
217 #define IID_BS_LOOKUP_SETUP \
219 #define IID_BS_LOOKUP_INITIAL_TEST(name, sz, split)
220 #define IID_BS_LOOKUP_NEXT_TEST(name, split)
221 #define IID_BS_LOOKUP_RETURN_RESULT(name, sz, index) \
222 for (c=0; c<sz; c++) if (!name##_CHECK_IID(c)) { (index)=c; return 1; } \
225 /* macros used in dlldata.c files */
226 #define EXTERN_PROXY_FILE(proxy) \
227 EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo DECLSPEC_HIDDEN;
229 #define PROXYFILE_LIST_START \
230 const ProxyFileInfo * aProxyFileList[] DECLSPEC_HIDDEN = \
233 #define REFERENCE_PROXY_FILE(proxy) \
234 & proxy##_ProxyFileInfo
236 #define PROXYFILE_LIST_END \
241 /* define PROXY_CLSID to use an existing CLSID */
242 /* define PROXY_CLSID_IS to specify the CLSID data of the PSFactoryBuffer */
243 /* define neither to use the GUID of the first interface */
245 # define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID DECLSPEC_HIDDEN;
247 # ifdef PROXY_CLSID_IS
248 # define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer DECLSPEC_HIDDEN; \
249 const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS;
250 # define PROXY_CLSID CLSID_PSFactoryBuffer
252 # define CLSID_PSFACTORYBUFFER
257 # define GET_DLL_CLSID (aProxyFileList[0]->pStubVtblList[0] ? \
258 aProxyFileList[0]->pStubVtblList[0]->header.piid : NULL)
260 # define GET_DLL_CLSID &PROXY_CLSID
264 # define __rpc_macro_expand2(a, b) a##b
265 # define __rpc_macro_expand(a, b) __rpc_macro_expand2(a, b)
266 # define DLLREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllRegisterServer)
267 # define DLLUNREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllUnregisterServer)
268 # define DLLMAIN_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllMain)
269 # define DLLGETCLASSOBJECT_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllGetClassObject)
270 # define DLLCANUNLOADNOW_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllCanUnloadNow)
272 # define DLLREGISTERSERVER_ENTRY DllRegisterServer
273 # define DLLUNREGISTERSERVER_ENTRY DllUnregisterServer
274 # define DLLMAIN_ENTRY DllMain
275 # define DLLGETCLASSOBJECT_ENTRY DllGetClassObject
276 # define DLLCANUNLOADNOW_ENTRY DllCanUnloadNow
279 #ifdef WINE_REGISTER_DLL
280 # define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources()
281 # define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources()
283 # define WINE_DO_REGISTER_DLL(pfl, clsid) return NdrDllRegisterProxy( hProxyDll, (pfl), (clsid) )
284 # define WINE_DO_UNREGISTER_DLL(pfl, clsid) return NdrDllUnregisterProxy( hProxyDll, (pfl), (clsid) )
288 #define DLLDATA_GETPROXYDLLINFO(pfl, rclsid) \
289 void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
290 const CLSID **ppClsid) DECLSPEC_HIDDEN; \
291 void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
292 const CLSID **ppClsid) \
294 *ppProxyFileInfo = (pfl); \
295 *ppClsid = (rclsid); \
298 #define DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, factory) \
299 HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN; \
300 HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, \
303 return NdrDllGetClassObject(rclsid, riid, ppv, (pfl), \
304 (factory_clsid), factory); \
307 #define DLLCANUNLOADNOW(factory) \
308 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) DECLSPEC_HIDDEN; \
309 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) \
311 return NdrDllCanUnloadNow((factory)); \
314 #define REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid) \
315 HINSTANCE hProxyDll DECLSPEC_HIDDEN = NULL; \
317 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DECLSPEC_HIDDEN; \
318 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, \
319 LPVOID lpvReserved) \
321 if (fdwReason == DLL_PROCESS_ATTACH) \
323 DisableThreadLibraryCalls(hinstDLL); \
324 hProxyDll = hinstDLL; \
329 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) DECLSPEC_HIDDEN; \
330 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) \
332 WINE_DO_REGISTER_DLL( (pfl), (factory_clsid) ); \
335 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) DECLSPEC_HIDDEN; \
336 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) \
338 WINE_DO_UNREGISTER_DLL( (pfl), (factory_clsid) ); \
341 #if defined(REGISTER_PROXY_DLL) || defined(WINE_REGISTER_DLL)
342 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid) \
343 REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid)
345 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid)
348 #define DLLDATA_ROUTINES(pfl, factory_clsid) \
349 CLSID_PSFACTORYBUFFER \
350 CStdPSFactoryBuffer DECLSPEC_HIDDEN gPFactory = { NULL, 0, NULL, 0 }; \
351 DLLDATA_GETPROXYDLLINFO(pfl, factory_clsid) \
352 DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, &gPFactory) \
353 DLLCANUNLOADNOW(&gPFactory) \
354 CSTDSTUBBUFFERRELEASE(&gPFactory) \
355 CSTDSTUBBUFFER2RELEASE(&gPFactory) \
356 DLLREGISTRY_ROUTINES(pfl, factory_clsid)
360 RPCRTAPI HRESULT RPC_ENTRY
361 CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo
, LPUNKNOWN pUnkOuter
, REFIID riid
,
362 LPRPCPROXYBUFFER
*ppProxy
, LPVOID
*ppv
);
363 RPCRTAPI HRESULT RPC_ENTRY
364 CreateStubFromTypeInfo( LPTYPEINFO pTypeInfo
, REFIID riid
, LPUNKNOWN pUnkServer
,
365 LPRPCSTUBBUFFER
*ppStub
);
373 #endif /*__WINE_RPCPROXY_H */