Added OLEIVERB_INPLACEACTIVATE implementation in IOleObject::DoVerb.
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 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;
41
42 typedef struct tagProxyFileInfo
43 {
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;
56
57 typedef ProxyFileInfo ExtendedProxyFileInfo;
58
59 typedef struct tagCInterfaceProxyHeader
60 {
61 #ifdef USE_STUBLESS_PROXY
62   const void *pStublessProxyInfo;
63 #endif
64   const IID *piid;
65 } CInterfaceProxyHeader;
66
67 #define CINTERFACE_PROXY_VTABLE(n) \
68   struct \
69   { \
70     CInterfaceProxyHeader header; \
71     void *Vtbl[n]; \
72   }
73
74 typedef struct tagCInterfaceProxyVtbl
75 {
76   CInterfaceProxyHeader header;
77 #if defined(__GNUC__)
78   void *Vtbl[0];
79 #else
80   void *Vtbl[1];
81 #endif
82 } CInterfaceProxyVtbl;
83
84 typedef void (__RPC_STUB *PRPC_STUB_FUNCTION)(
85   IRpcStubBuffer *This,
86   IRpcChannelBuffer *_pRpcChannelBuffer,
87   PRPC_MESSAGE _pRpcMessage,
88   DWORD *pdwStubPhase);
89
90 typedef struct tagCInterfaceStubHeader
91 {
92   const IID *piid;
93   const MIDL_SERVER_INFO *pServerInfo;
94   unsigned long DispatchTableCount;
95   const PRPC_STUB_FUNCTION *pDispatchTable;
96 } CInterfaceStubHeader;
97
98 typedef struct tagCInterfaceStubVtbl
99 {
100   CInterfaceStubHeader header;
101   IRpcStubBufferVtbl Vtbl;
102 } CInterfaceStubVtbl;
103
104 typedef struct tagCStdStubBuffer
105 {
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;
113
114 typedef struct tagCStdPSFactoryBuffer
115 {
116   const IPSFactoryBufferVtbl *lpVtbl;
117   long RefCount;
118   const ProxyFileInfo **pProxyFileList;
119   long Filler1;
120 } CStdPSFactoryBuffer;
121
122 #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
123
124 ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This);
125 ULONG STDMETHODCALLTYPE NdrCStdStubBuffer2_Release(IRpcStubBuffer *This, IPSFactoryBuffer *pPSF);
126
127 #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
128
129
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 );
152
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
164
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 );
176
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                             unsigned long 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 );
190
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 );
196
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 );
201
202 #define CSTDSTUBBUFFERRELEASE(pFactory) \
203 ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \
204   { return NdrCStdStubBuffer_Release(This, (IPSFactoryBuffer *)pFactory); }
205
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
213
214 #define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID, name##_ProxyVtblList[index]->header.piid, sizeof(IID))
215
216 /*
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.
221  */
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;
229
230 /* macros used in dlldata.c files */
231 #define EXTERN_PROXY_FILE(proxy) \
232     EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo
233
234 #define PROXYFILE_LIST_START \
235     const ProxyFileInfo *aProxyFileList[] = \
236     {
237
238 #define REFERENCE_PROXY_FILE(proxy) \
239         & proxy##_ProxyFileInfo
240
241 #define PROXYFILE_LIST_END \
242         NULL \
243     };
244     
245 #if 0
246
247 /* see http://www.microsoft.com/msj/0199/com/com0199.aspx */
248
249 RPCRTAPI HRESULT RPC_ENTRY
250   CreateProxyFromTypeInfo( LPTYPEINFO pTypeInfo, LPUNKNOWN pUnkOuter, REFIID riid,
251                            LPRPCPROXYBUFFER *ppProxy, LPVOID *ppv );
252 RPCRTAPI HRESULT RPC_ENTRY
253   CreateStubFromTypeInfo( LPTYPEINFO pTypeInfo, REFIID riid, LPUNKNOWN pUnkServer,
254                           LPRPCSTUBBUFFER *ppStub );
255
256 #endif
257
258 #endif /*__WINE_RPCDCE_H */