notepad: Fully revise Korean translation.
[wine/wine64.git] / include / rpcproxy.h
blob1ebc5d82dc03788cde28cdd49dc42efcc606506c
1 /*
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 )
22 #endif
24 #ifndef __WINE_RPCPROXY_H
25 #define __WINE_RPCPROXY_H
27 #define __midl_proxy
29 #include <basetsd.h>
30 #ifndef GUID_DEFINED
31 #include <guiddef.h>
32 #endif
33 #include <rpc.h>
34 #include <rpcndr.h>
36 typedef struct tagCInterfaceStubVtbl *PCInterfaceStubVtblList;
37 typedef struct tagCInterfaceProxyVtbl *PCInterfaceProxyVtblList;
38 typedef const char *PCInterfaceName;
39 typedef int __stdcall IIDLookupRtn( const IID *pIID, int *pIndex );
40 typedef IIDLookupRtn *PIIDLookup;
42 typedef struct tagProxyFileInfo
44 const PCInterfaceProxyVtblList *pProxyVtblList;
45 const PCInterfaceStubVtblList *pStubVtblList;
46 const PCInterfaceName *pNamesArray;
47 const IID **pDelegatedIIDs;
48 const PIIDLookup pIIDLookupRtn;
49 unsigned short TableSize;
50 unsigned short TableVersion;
51 const IID **pAsyncIIDLookup;
52 LONG_PTR Filler2;
53 LONG_PTR Filler3;
54 LONG_PTR Filler4;
55 } ProxyFileInfo;
57 typedef ProxyFileInfo ExtendedProxyFileInfo;
59 typedef struct tagCInterfaceProxyHeader
61 #ifdef USE_STUBLESS_PROXY
62 const void *pStublessProxyInfo;
63 #endif
64 const IID *piid;
65 } CInterfaceProxyHeader;
67 #define CINTERFACE_PROXY_VTABLE(n) \
68 struct \
69 { \
70 CInterfaceProxyHeader header; \
71 void *Vtbl[n]; \
74 typedef struct tagCInterfaceProxyVtbl
76 CInterfaceProxyHeader header;
77 #if defined(__GNUC__)
78 void *Vtbl[0];
79 #else
80 void *Vtbl[1];
81 #endif
82 } CInterfaceProxyVtbl;
84 typedef void (__RPC_STUB *PRPC_STUB_FUNCTION)(
85 IRpcStubBuffer *This,
86 IRpcChannelBuffer *_pRpcChannelBuffer,
87 PRPC_MESSAGE _pRpcMessage,
88 DWORD *pdwStubPhase);
90 typedef struct tagCInterfaceStubHeader
92 const IID *piid;
93 const MIDL_SERVER_INFO *pServerInfo;
94 ULONG DispatchTableCount;
95 const PRPC_STUB_FUNCTION *pDispatchTable;
96 } CInterfaceStubHeader;
98 typedef struct tagCInterfaceStubVtbl
100 CInterfaceStubHeader header;
101 IRpcStubBufferVtbl Vtbl;
102 } CInterfaceStubVtbl;
104 typedef struct tagCStdStubBuffer
106 const IRpcStubBufferVtbl *lpVtbl;
107 LONG RefCount;
108 struct IUnknown *pvServerObject;
109 const struct ICallFactoryVtbl *pCallFactoryVtbl;
110 const IID *pAsyncIID;
111 struct IPSFactoryBuffer *pPSFactory;
112 } CStdStubBuffer;
114 typedef struct tagCStdPSFactoryBuffer
116 const IPSFactoryBufferVtbl *lpVtbl;
117 LONG RefCount;
118 const ProxyFileInfo **pProxyFileList;
119 LONG Filler1;
120 } CStdPSFactoryBuffer;
122 #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
124 ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This);
125 ULONG STDMETHODCALLTYPE NdrCStdStubBuffer2_Release(IRpcStubBuffer *This, IPSFactoryBuffer *pPSF);
127 #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
130 HRESULT WINAPI
131 CStdStubBuffer_QueryInterface( IRpcStubBuffer *This, REFIID riid, void **ppvObject );
132 ULONG WINAPI
133 CStdStubBuffer_AddRef( IRpcStubBuffer *This );
134 ULONG WINAPI
135 CStdStubBuffer_Release( IRpcStubBuffer *This );
136 ULONG WINAPI
137 NdrCStdStubBuffer_Release( IRpcStubBuffer *This, IPSFactoryBuffer *pPSF );
138 HRESULT WINAPI
139 CStdStubBuffer_Connect( IRpcStubBuffer *This, IUnknown *pUnkServer );
140 void WINAPI
141 CStdStubBuffer_Disconnect( IRpcStubBuffer *This );
142 HRESULT WINAPI
143 CStdStubBuffer_Invoke( IRpcStubBuffer *This, RPCOLEMESSAGE *pRpcMsg, IRpcChannelBuffer *pRpcChannelBuffer );
144 IRpcStubBuffer * WINAPI
145 CStdStubBuffer_IsIIDSupported( IRpcStubBuffer *This, REFIID riid );
146 ULONG WINAPI
147 CStdStubBuffer_CountRefs( IRpcStubBuffer *This );
148 HRESULT WINAPI
149 CStdStubBuffer_DebugServerQueryInterface( IRpcStubBuffer *This, void **ppv );
150 void WINAPI
151 CStdStubBuffer_DebugServerRelease( IRpcStubBuffer *This, void *pv );
153 #define CStdStubBuffer_METHODS \
154 CStdStubBuffer_QueryInterface, \
155 CStdStubBuffer_AddRef, \
156 CStdStubBuffer_Release, \
157 CStdStubBuffer_Connect, \
158 CStdStubBuffer_Disconnect, \
159 CStdStubBuffer_Invoke, \
160 CStdStubBuffer_IsIIDSupported, \
161 CStdStubBuffer_CountRefs, \
162 CStdStubBuffer_DebugServerQueryInterface, \
163 CStdStubBuffer_DebugServerRelease
165 RPCRTAPI void RPC_ENTRY
166 NdrProxyInitialize( void *This, PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg,
167 PMIDL_STUB_DESC pStubDescriptor, unsigned int ProcNum );
168 RPCRTAPI void RPC_ENTRY
169 NdrProxyGetBuffer( void *This, PMIDL_STUB_MESSAGE pStubMsg );
170 RPCRTAPI void RPC_ENTRY
171 NdrProxySendReceive( void *This, PMIDL_STUB_MESSAGE pStubMsg );
172 RPCRTAPI void RPC_ENTRY
173 NdrProxyFreeBuffer( void *This, PMIDL_STUB_MESSAGE pStubMsg );
174 RPCRTAPI HRESULT RPC_ENTRY
175 NdrProxyErrorHandler( DWORD dwExceptionCode );
177 RPCRTAPI void RPC_ENTRY
178 NdrStubInitialize( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg,
179 PMIDL_STUB_DESC pStubDescriptor, IRpcChannelBuffer *pRpcChannelBuffer );
180 RPCRTAPI void RPC_ENTRY
181 NdrStubInitializePartial( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg,
182 PMIDL_STUB_DESC pStubDescriptor, IRpcChannelBuffer *pRpcChannelBuffer,
183 ULONG RequestedBufferSize );
184 void __RPC_STUB NdrStubForwardingFunction( IRpcStubBuffer *This, IRpcChannelBuffer *pChannel,
185 PRPC_MESSAGE pMsg, DWORD *pdwStubPhase );
186 RPCRTAPI void RPC_ENTRY
187 NdrStubGetBuffer( IRpcStubBuffer *This, IRpcChannelBuffer *pRpcChannelBuffer, PMIDL_STUB_MESSAGE pStubMsg );
188 RPCRTAPI HRESULT RPC_ENTRY
189 NdrStubErrorHandler( DWORD dwExceptionCode );
191 RPCRTAPI HRESULT RPC_ENTRY
192 NdrDllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv, const ProxyFileInfo **pProxyFileList,
193 const CLSID *pclsid, CStdPSFactoryBuffer *pPSFactoryBuffer );
194 RPCRTAPI HRESULT RPC_ENTRY
195 NdrDllCanUnloadNow( CStdPSFactoryBuffer *pPSFactoryBuffer );
197 RPCRTAPI HRESULT RPC_ENTRY
198 NdrDllRegisterProxy( HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid );
199 RPCRTAPI HRESULT RPC_ENTRY
200 NdrDllUnregisterProxy( HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid );
202 #define CSTDSTUBBUFFERRELEASE(pFactory) \
203 ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \
204 { return NdrCStdStubBuffer_Release(This, (IPSFactoryBuffer *)pFactory); }
206 #ifdef PROXY_DELEGATION
207 #define CSTDSTUBBUFFER2RELEASE(pFactory) \
208 ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \
209 { return NdrCStdStubBuffer2_Release(This, (IPSFactoryBuffer *)pFactory); }
210 #else
211 #define CSTDSTUBBUFFER2RELEASE(pFactory)
212 #endif
214 #define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID, name##_ProxyVtblList[index]->header.piid, sizeof(IID))
217 * In these macros, BS stands for Binary Search. MIDL uses these to
218 * "unroll" a binary search into the module's IID_Lookup function.
219 * However, I haven't bothered to reimplement that stuff yet;
220 * I've just implemented a linear search for now.
222 #define IID_BS_LOOKUP_SETUP \
223 int c;
224 #define IID_BS_LOOKUP_INITIAL_TEST(name, sz, split)
225 #define IID_BS_LOOKUP_NEXT_TEST(name, split)
226 #define IID_BS_LOOKUP_RETURN_RESULT(name, sz, index) \
227 for (c=0; c<sz; c++) if (!name##_CHECK_IID(c)) { (index)=c; return 1; } \
228 return 0;
230 /* macros used in dlldata.c files */
231 #define EXTERN_PROXY_FILE(proxy) \
232 EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo;
234 #define PROXYFILE_LIST_START \
235 const ProxyFileInfo *aProxyFileList[] = \
238 #define REFERENCE_PROXY_FILE(proxy) \
239 & proxy##_ProxyFileInfo
241 #define PROXYFILE_LIST_END \
242 NULL \
246 /* define PROXY_CLSID to use an existing CLSID */
247 /* define PROXY_CLSID_IS to specify the CLSID data of the PSFactoryBuffer */
248 /* define neither to use the GUID of the first interface */
249 #ifdef PROXY_CLSID
250 # define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID;
251 #else
252 # ifdef PROXY_CLSID_IS
253 # define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = \
254 PROXY_CLSID_IS;
255 # define PROXY_CLSID CLSID_PSFactoryBuffer
256 # else
257 # define CLSID_PSFACTORYBUFFER
258 # endif
259 #endif
261 #ifndef PROXY_CLSID
262 # define GET_DLL_CLSID (aProxyFileList[0]->pStubVtblList[0] ? \
263 aProxyFileList[0]->pStubVtblList[0]->header.piid : NULL)
264 #else
265 # define GET_DLL_CLSID &PROXY_CLSID
266 #endif
268 #ifdef ENTRY_PREFIX
269 # define __rpc_macro_expand2(a, b) a##b
270 # define __rpc_macro_expand(a, b) __rpc_macro_expand2(a, b)
271 # define DLLREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllRegisterServer)
272 # define DLLUNREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllUnregisterServer)
273 # define DLLMAIN_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllMain)
274 # define DLLGETCLASSOBJECT_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllGetClassObject)
275 # define DLLCANUNLOADNOW_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllCanUnloadNow)
276 #else
277 # define DLLREGISTERSERVER_ENTRY DllRegisterServer
278 # define DLLUNREGISTERSERVER_ENTRY DllUnregisterServer
279 # define DLLMAIN_ENTRY DllMain
280 # define DLLGETCLASSOBJECT_ENTRY DllGetClassObject
281 # define DLLCANUNLOADNOW_ENTRY DllCanUnloadNow
282 #endif
284 #define DLLDATA_GETPROXYDLLINFO(pfl, rclsid) \
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, \
294 void **ppv) \
296 return NdrDllGetClassObject(rclsid, riid, ppv, (pfl), \
297 (factory_clsid), factory); \
300 #define DLLCANUNLOADNOW(factory) \
301 HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) \
303 return NdrDllCanUnloadNow((factory)); \
306 #define REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid) \
307 HINSTANCE hProxyDll = NULL; \
309 BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, \
310 LPVOID lpvReserved) \
312 if (fdwReason == DLL_PROCESS_ATTACH) \
314 DisableThreadLibraryCalls(hinstDLL); \
315 hProxyDll = hinstDLL; \
317 return TRUE; \
320 HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) \
322 return NdrDllRegisterProxy(hProxyDll, (pfl), (factory_clsid)); \
325 HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) \
327 return NdrDllUnregisterProxy(hProxyDll, (pfl), (factory_clsid)); \
330 #ifdef REGISTER_PROXY_DLL
331 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid) \
332 REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid)
333 #else
334 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid)
335 #endif
337 #define DLLDATA_ROUTINES(pfl, factory_clsid) \
338 CLSID_PSFACTORYBUFFER \
339 CStdPSFactoryBuffer gPFactory = { NULL, 0, NULL, 0 }; \
340 DLLDATA_GETPROXYDLLINFO(pfl, factory_clsid) \
341 DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, &gPFactory) \
342 DLLCANUNLOADNOW(&gPFactory) \
343 CSTDSTUBBUFFERRELEASE(&gPFactory) \
344 CSTDSTUBBUFFER2RELEASE(&gPFactory) \
345 DLLREGISTRY_ROUTINES(pfl, factory_clsid)
347 #if 0
349 /* see http://www.microsoft.com/msj/0199/com/com0199.aspx */
351 RPCRTAPI HRESULT RPC_ENTRY
352 CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo, LPUNKNOWN pUnkOuter, REFIID riid,
353 LPRPCPROXYBUFFER *ppProxy, LPVOID *ppv );
354 RPCRTAPI HRESULT RPC_ENTRY
355 CreateStubFromTypeInfo( LPTYPEINFO pTypeInfo, REFIID riid, LPUNKNOWN pUnkServer,
356 LPRPCSTUBBUFFER *ppStub );
358 #endif
360 #endif /*__WINE_RPCDCE_H */