include: Add IAutoCompleteDropDown declaration.
[wine] / include / rpcproxy.h
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 /* FIXME: Find an appropriate version number.  I guess something is better than nothing */
21 #define __RPCPROXY_H_VERSION__ ( 399 )
22 #endif
23
24 #ifndef __WINE_RPCPROXY_H
25 #define __WINE_RPCPROXY_H
26
27 #define __midl_proxy
28
29 #include <basetsd.h>
30 #ifndef GUID_DEFINED
31 #include <guiddef.h>
32 #endif
33 #include <rpc.h>
34 #include <rpcndr.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
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;
45
46 typedef struct tagProxyFileInfo
47 {
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;
56   LONG_PTR Filler2;
57   LONG_PTR Filler3;
58   LONG_PTR Filler4;
59 } ProxyFileInfo;
60
61 typedef ProxyFileInfo ExtendedProxyFileInfo;
62
63 typedef struct tagCInterfaceProxyHeader
64 {
65 #ifdef USE_STUBLESS_PROXY
66   const void *pStublessProxyInfo;
67 #endif
68   const IID *piid;
69 } CInterfaceProxyHeader;
70
71 #define CINTERFACE_PROXY_VTABLE(n) \
72   struct \
73   { \
74     CInterfaceProxyHeader header; \
75     void *Vtbl[n]; \
76   }
77
78 typedef struct tagCInterfaceProxyVtbl
79 {
80   CInterfaceProxyHeader header;
81 #if defined(__GNUC__)
82   void *Vtbl[0];
83 #else
84   void *Vtbl[1];
85 #endif
86 } CInterfaceProxyVtbl;
87
88 typedef void (__RPC_STUB *PRPC_STUB_FUNCTION)(
89   IRpcStubBuffer *This,
90   IRpcChannelBuffer *_pRpcChannelBuffer,
91   PRPC_MESSAGE _pRpcMessage,
92   DWORD *pdwStubPhase);
93
94 typedef struct tagCInterfaceStubHeader
95 {
96   const IID *piid;
97   const MIDL_SERVER_INFO *pServerInfo;
98   ULONG DispatchTableCount;
99   const PRPC_STUB_FUNCTION *pDispatchTable;
100 } CInterfaceStubHeader;
101
102 typedef struct tagCInterfaceStubVtbl
103 {
104   CInterfaceStubHeader header;
105   IRpcStubBufferVtbl Vtbl;
106 } CInterfaceStubVtbl;
107
108 typedef struct tagCStdStubBuffer
109 {
110   const IRpcStubBufferVtbl *lpVtbl;
111   LONG RefCount;
112   struct IUnknown *pvServerObject;
113   const struct ICallFactoryVtbl *pCallFactoryVtbl;
114   const IID *pAsyncIID;
115   struct IPSFactoryBuffer *pPSFactory;
116 } CStdStubBuffer;
117
118 typedef struct tagCStdPSFactoryBuffer
119 {
120   const IPSFactoryBufferVtbl *lpVtbl;
121   LONG RefCount;
122   const ProxyFileInfo **pProxyFileList;
123   LONG Filler1;
124 } CStdPSFactoryBuffer;
125
126 #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
127
128 ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This);
129 ULONG STDMETHODCALLTYPE NdrCStdStubBuffer2_Release(IRpcStubBuffer *This, IPSFactoryBuffer *pPSF);
130
131 #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
132
133
134 HRESULT WINAPI
135   CStdStubBuffer_QueryInterface( IRpcStubBuffer *This, REFIID riid, void **ppvObject );
136 ULONG WINAPI
137   CStdStubBuffer_AddRef( IRpcStubBuffer *This );
138 ULONG WINAPI
139   CStdStubBuffer_Release( IRpcStubBuffer *This );
140 ULONG WINAPI
141   NdrCStdStubBuffer_Release( IRpcStubBuffer *This, IPSFactoryBuffer *pPSF );
142 HRESULT WINAPI
143   CStdStubBuffer_Connect( IRpcStubBuffer *This, IUnknown *pUnkServer );
144 void WINAPI
145   CStdStubBuffer_Disconnect( IRpcStubBuffer *This );
146 HRESULT WINAPI
147   CStdStubBuffer_Invoke( IRpcStubBuffer *This, RPCOLEMESSAGE *pRpcMsg, IRpcChannelBuffer *pRpcChannelBuffer );
148 IRpcStubBuffer * WINAPI
149   CStdStubBuffer_IsIIDSupported( IRpcStubBuffer *This, REFIID riid );
150 ULONG WINAPI
151   CStdStubBuffer_CountRefs( IRpcStubBuffer *This );
152 HRESULT WINAPI
153   CStdStubBuffer_DebugServerQueryInterface( IRpcStubBuffer *This, void **ppv );
154 void WINAPI
155   CStdStubBuffer_DebugServerRelease( IRpcStubBuffer *This, void *pv );
156
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
168
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 );
180
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 );
194
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 );
200
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 );
205
206 #define CSTDSTUBBUFFERRELEASE(pFactory) \
207 ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \
208   { return NdrCStdStubBuffer_Release(This, (IPSFactoryBuffer *)pFactory); }
209
210 #ifdef PROXY_DELEGATION
211 #define CSTDSTUBBUFFER2RELEASE(pFactory) \
212 ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \
213   { return NdrCStdStubBuffer2_Release(This, (IPSFactoryBuffer *)pFactory); }
214 #else
215 #define CSTDSTUBBUFFER2RELEASE(pFactory)
216 #endif
217
218 #define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID, name##_ProxyVtblList[index]->header.piid, sizeof(IID))
219
220 /*
221  * In these macros, BS stands for Binary Search. MIDL uses these to
222  * "unroll" a binary search into the module's IID_Lookup function.
223  * However, I haven't bothered to reimplement that stuff yet;
224  * I've just implemented a linear search for now.
225  */
226 #define IID_BS_LOOKUP_SETUP \
227   int c;
228 #define IID_BS_LOOKUP_INITIAL_TEST(name, sz, split)
229 #define IID_BS_LOOKUP_NEXT_TEST(name, split)
230 #define IID_BS_LOOKUP_RETURN_RESULT(name, sz, index) \
231   for (c=0; c<sz; c++) if (!name##_CHECK_IID(c)) { (index)=c; return 1; } \
232   return 0;
233
234 /* macros used in dlldata.c files */
235 #define EXTERN_PROXY_FILE(proxy) \
236     EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo;
237
238 #define PROXYFILE_LIST_START \
239     const ProxyFileInfo *aProxyFileList[] = \
240     {
241
242 #define REFERENCE_PROXY_FILE(proxy) \
243         & proxy##_ProxyFileInfo
244
245 #define PROXYFILE_LIST_END \
246         NULL \
247     };
248
249
250 /* define PROXY_CLSID to use an existing CLSID */
251 /* define PROXY_CLSID_IS to specify the CLSID data of the PSFactoryBuffer */
252 /* define neither to use the GUID of the first interface */
253 #ifdef PROXY_CLSID
254 # define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID;
255 #else
256 # ifdef PROXY_CLSID_IS
257 #  define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = \
258     PROXY_CLSID_IS;
259 #  define PROXY_CLSID CLSID_PSFactoryBuffer
260 # else
261 #  define CLSID_PSFACTORYBUFFER
262 # endif
263 #endif
264
265 #ifndef PROXY_CLSID
266 # define GET_DLL_CLSID (aProxyFileList[0]->pStubVtblList[0] ? \
267     aProxyFileList[0]->pStubVtblList[0]->header.piid : NULL)
268 #else
269 # define GET_DLL_CLSID &PROXY_CLSID
270 #endif
271
272 #ifdef ENTRY_PREFIX
273 # define __rpc_macro_expand2(a, b) a##b
274 # define __rpc_macro_expand(a, b) __rpc_macro_expand2(a, b)
275 # define DLLREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllRegisterServer)
276 # define DLLUNREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllUnregisterServer)
277 # define DLLMAIN_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllMain)
278 # define DLLGETCLASSOBJECT_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllGetClassObject)
279 # define DLLCANUNLOADNOW_ENTRY __rpc_macro_expand(ENTRY_PREFIX, DllCanUnloadNow)
280 #else
281 # define DLLREGISTERSERVER_ENTRY DllRegisterServer
282 # define DLLUNREGISTERSERVER_ENTRY DllUnregisterServer
283 # define DLLMAIN_ENTRY DllMain
284 # define DLLGETCLASSOBJECT_ENTRY DllGetClassObject
285 # define DLLCANUNLOADNOW_ENTRY DllCanUnloadNow
286 #endif
287
288 #define DLLDATA_GETPROXYDLLINFO(pfl, rclsid) \
289     void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \
290                                    const CLSID **ppClsid) \
291     { \
292         *ppProxyFileInfo = (pfl); \
293         *ppClsid = (rclsid); \
294     }
295
296 #define DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, factory) \
297     HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, \
298                                            void **ppv) \
299     { \
300         return NdrDllGetClassObject(rclsid, riid, ppv, (pfl), \
301                                     (factory_clsid), factory); \
302     }
303
304 #define DLLCANUNLOADNOW(factory) \
305     HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) \
306     { \
307         return NdrDllCanUnloadNow((factory)); \
308     }
309
310 #define REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid) \
311     HINSTANCE hProxyDll = NULL; \
312     \
313     BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, \
314                               LPVOID lpvReserved) \
315     { \
316         if (fdwReason == DLL_PROCESS_ATTACH) \
317         { \
318             DisableThreadLibraryCalls(hinstDLL); \
319             hProxyDll = hinstDLL; \
320         } \
321         return TRUE; \
322     } \
323     \
324     HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) \
325     { \
326         return NdrDllRegisterProxy(hProxyDll, (pfl), (factory_clsid)); \
327     } \
328     \
329     HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) \
330     { \
331         return NdrDllUnregisterProxy(hProxyDll, (pfl), (factory_clsid)); \
332     }
333
334 #ifdef REGISTER_PROXY_DLL
335 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid) \
336     REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid)
337 #else
338 # define DLLREGISTRY_ROUTINES(pfl, factory_clsid)
339 #endif
340
341 #define DLLDATA_ROUTINES(pfl, factory_clsid) \
342     CLSID_PSFACTORYBUFFER \
343     CStdPSFactoryBuffer gPFactory = { NULL, 0, NULL, 0 }; \
344     DLLDATA_GETPROXYDLLINFO(pfl, factory_clsid) \
345     DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, &gPFactory) \
346     DLLCANUNLOADNOW(&gPFactory) \
347     CSTDSTUBBUFFERRELEASE(&gPFactory) \
348     CSTDSTUBBUFFER2RELEASE(&gPFactory) \
349     DLLREGISTRY_ROUTINES(pfl, factory_clsid)
350
351 #if 0
352
353 RPCRTAPI HRESULT RPC_ENTRY
354   CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo, LPUNKNOWN pUnkOuter, REFIID riid,
355                            LPRPCPROXYBUFFER *ppProxy, LPVOID *ppv );
356 RPCRTAPI HRESULT RPC_ENTRY
357   CreateStubFromTypeInfo( LPTYPEINFO pTypeInfo, REFIID riid, LPUNKNOWN pUnkServer,
358                           LPRPCSTUBBUFFER *ppStub );
359
360 #endif
361
362 #ifdef __cplusplus
363 }
364 #endif
365
366 #endif /*__WINE_RPCPROXY_H */