source: Daodan/MinGW/include/rpcproxy.h@ 1089

Last change on this file since 1089 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 8.7 KB
RevLine 
[1046]1/*
2 -DREGISTER_PROXY_DLL Generates DllMain, DllRegisterServer, and DllUnregisterServer
3 -DPROXY_CLSID=clsid Specifies a class ID to be used by the proxy DLL.
4 -DPROXY_CLSID_IS={..} Specifies the class ID to be used by the proxy DLL.
5 -DNT35_STRICT No new features
6*/
7#ifndef _RPCPROXY_H
8#define _RPCPROXY_H
9#if __GNUC__ >=3
10#pragma GCC system_header
11#endif
12
13#if defined __cplusplus && !defined CINTERFACE
14#warning "rpcproxy type definitions require CINTERFACE"
15#else
16#ifdef __cplusplus
17extern "C" {
18#endif
19#include <rpc.h>
20#include <rpcndr.h>
21#include <string.h>
22
23#define CStdStubBuffer_METHODS CStdStubBuffer_QueryInterface,CStdStubBuffer_AddRef,\
24CStdStubBuffer_Release,CStdStubBuffer_Connect,CStdStubBuffer_Disconnect,CStdStubBuffer_Invoke,\
25CStdStubBuffer_IsIIDSupported,CStdStubBuffer_CountRefs,CStdStubBuffer_DebugServerQueryInterface,\
26CStdStubBuffer_DebugServerRelease
27#define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID,name##_ProxyVtblList[index]->header.piid,16)
28#define IID_BS_LOOKUP_SETUP int result, low=-1;
29#define IID_BS_LOOKUP_INITIAL_TEST(name,sz,split) if ((result = name##_CHECK_IID(split))>0) { low=sz-split;} else if (!result) { low = split; goto found_label; }
30#define IID_BS_LOOKUP_NEXT_TEST(name,split) if ((result = name##_CHECK_IID(low+split))>=0) { low=low+split; if (!result) goto found_label; }
31#define IID_BS_LOOKUP_RETURN_RESULT(name,sz,index) low+=1; if ((low>=sz )||(result=name##_CHECK_IID(low))) goto not_found_label; found_label: (index)=low; return 1; not_found_label: return 0;
32#define REGISTER_PROXY_DLL_ROUTINES(pProxyFileList, pClsID) \
33HINSTANCE hProxyDll = 0; \
34BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) \
35{ \
36if(fdwReason == DLL_PROCESS_ATTACH) hProxyDll = hinstDLL; \
37return TRUE; \
38} \
39HRESULT STDAPICALLTYPE DllRegisterServer(void) \
40{\
41return NdrDllRegisterProxy(hProxyDll, pProxyFileList, pClsID); \
42}\
43HRESULT STDAPICALLTYPE DllUnregisterServer(void)\
44{\
45return NdrDllUnregisterProxy(hProxyDll, pProxyFileList, pClsID);\
46}
47#ifdef PROXY_CLSID
48#define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID;
49#else
50#ifdef PROXY_CLSID_IS
51#define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS;
52#define PROXY_CLSID CLSID_PSFactoryBuffer
53#else
54#define CLSID_PSFACTORYBUFFER
55#endif
56#endif
57#ifndef PROXY_CLSID
58#define GET_DLL_CLSID (aProxyFileList[0]->pStubVtblList[0] != 0 ? aProxyFileList[0]->pStubVtblList[0]->header.piid : 0)
59#else
60#define GET_DLL_CLSID &PROXY_CLSID
61#endif
62#define EXTERN_PROXY_FILE(name) EXTERN_C const ProxyFileInfo name##_ProxyFileInfo;
63#define PROXYFILE_LIST_START const ProxyFileInfo * aProxyFileList[] = {
64#define REFERENCE_PROXY_FILE(name) & name##_ProxyFileInfo
65#define PROXYFILE_LIST_END 0 };
66#define DLLDATA_GETPROXYDLLINFO(pPFList,pClsid) \
67void RPC_ENTRY GetProxyDllInfo( const ProxyFileInfo*** pInfo, const CLSID ** pId ) \
68{ *pInfo = pPFList; *pId = pClsid; };
69#define DLLGETCLASSOBJECTROUTINE(pPFlist, pClsid,pFactory) HRESULT STDAPICALLTYPE DllGetClassObject(REFCLSID rclsid,REFIID riid,void **ppv) \
70{ return NdrDllGetClassObject(rclsid,riid,ppv,pPFlist,pClsid,pFactory ); }
71#define DLLCANUNLOADNOW(pFactory) HRESULT STDAPICALLTYPE DllCanUnloadNow(void) \
72{ return NdrDllCanUnloadNow( pFactory ); }
73#define DLLDUMMYPURECALL void __cdecl _purecall(void) { }
74#define CSTDSTUBBUFFERRELEASE(pFactory) ULONG STDMETHODCALLTYPE CStdStubBuffer_Release(IRpcStubBuffer *This) \
75{ return NdrCStdStubBuffer_Release(This,(IPSFactoryBuffer *)pFactory); }
76#ifdef PROXY_DELEGATION
77#define CSTDSTUBBUFFER2RELEASE(pFactory) ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This) \
78{ return NdrCStdStubBuffer2_Release(This,(IPSFactoryBuffer *)pFactory); }
79#else
80#define CSTDSTUBBUFFER2RELEASE(pFactory)
81#endif
82
83#ifdef REGISTER_PROXY_DLL
84#define DLLREGISTRY_ROUTINES(pProxyFileList,pClsID ) REGISTER_PROXY_DLL_ROUTINES(pProxyFileList,pClsID)
85#else
86#define DLLREGISTRY_ROUTINES(pProxyFileList,pClsID)
87#endif
88#define DLLDATA_ROUTINES(pProxyFileList,pClsID) \
89CLSID_PSFACTORYBUFFER \
90CStdPSFactoryBuffer gPFactory = {0,0,0,0}; \
91DLLDATA_GETPROXYDLLINFO(pProxyFileList,pClsID) \
92DLLGETCLASSOBJECTROUTINE(pProxyFileList,pClsID,&gPFactory) \
93DLLCANUNLOADNOW(&gPFactory) \
94CSTDSTUBBUFFERRELEASE(&gPFactory) \
95CSTDSTUBBUFFER2RELEASE(&gPFactory) \
96DLLDUMMYPURECALL \
97DLLREGISTRY_ROUTINES(pProxyFileList, pClsID)
98
99#define DLLDATA_STANDARD_ROUTINES DLLDATA_ROUTINES( (const ProxyFileInfo**) pProxyFileList, &CLSID_PSFactoryBuffer)
100
101struct tagCInterfaceStubVtbl;
102struct tagCInterfaceProxyVtbl;
103typedef struct tagCInterfaceStubVtbl *PCInterfaceStubVtblList;
104typedef struct tagCInterfaceProxyVtbl *PCInterfaceProxyVtblList;
105typedef const char *PCInterfaceName;
106typedef int __stdcall IIDLookupRtn(const IID*,int*);
107typedef IIDLookupRtn *PIIDLookup;
108typedef struct tagProxyFileInfo {
109 const PCInterfaceProxyVtblList *pProxyVtblList;
110 const PCInterfaceStubVtblList *pStubVtblList;
111 const PCInterfaceName * pNamesArray;
112 const IID ** pDelegatedIIDs;
113 const PIIDLookup pIIDLookupRtn;
114 unsigned short TableSize;
115 unsigned short TableVersion;
116 unsigned long Filler1;
117 unsigned long Filler2;
118 unsigned long Filler3;
119 unsigned long Filler4;
120}ProxyFileInfo;
121typedef ProxyFileInfo ExtendedProxyFileInfo;
122
123typedef struct tagCInterfaceProxyHeader {
124#ifdef USE_STUBLESS_PROXY
125 const void *pStublessProxyInfo;
126#endif
127 const IID *piid;
128} CInterfaceProxyHeader;
129typedef struct tagCInterfaceProxyVtbl {
130 CInterfaceProxyHeader header;
131#if defined(__WATCOMC__)
132 void *Vtbl[1];
133#else
134#ifdef __GNUC__
135__extension__
136#endif
137 void *Vtbl[0];
138#endif
139} CInterfaceProxyVtbl;
140typedef void (__RPC_STUB *PRPC_STUB_FUNCTION)(IRpcStubBuffer*,IRpcChannelBuffer*,PRPC_MESSAGE,DWORD*);
141typedef struct tagCInterfaceStubHeader {
142 const IID *piid;
143 const MIDL_SERVER_INFO *pServerInfo;
144 unsigned long DispatchTableCount;
145 const PRPC_STUB_FUNCTION *pDispatchTable;
146} CInterfaceStubHeader;
147typedef struct tagCInterfaceStubVtbl {
148 CInterfaceStubHeader header;
149 IRpcStubBufferVtbl Vtbl;
150} CInterfaceStubVtbl;
151typedef struct tagCStdStubBuffer {
152 const struct IRpcStubBufferVtbl * lpVtbl;
153 long RefCount;
154 struct IUnknown *pvServerObject;
155 const struct ICallFactoryVtbl * pCallFactoryVtbl;
156 const IID * pAsyncIID;
157 struct IPSFactoryBuffer * pPSFactory;
158 const struct IReleaseMarshalBuffersVtbl * pRMBVtbl;
159} CStdStubBuffer;
160typedef struct tagCStdPSFactoryBuffer {
161 const IPSFactoryBufferVtbl *lpVtbl;
162 long RefCount;
163 const ProxyFileInfo ** pProxyFileList;
164 long Filler1;
165} CStdPSFactoryBuffer;
166void RPC_ENTRY NdrProxyInitialize(void*,PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC,unsigned int);
167void RPC_ENTRY NdrProxyGetBuffer(void*,PMIDL_STUB_MESSAGE);
168void RPC_ENTRY NdrProxySendReceive(void*,MIDL_STUB_MESSAGE*);
169void RPC_ENTRY NdrProxyFreeBuffer(void*,MIDL_STUB_MESSAGE*);
170HRESULT RPC_ENTRY NdrProxyErrorHandler(DWORD);
171void RPC_ENTRY NdrStubInitialize(PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC,IRpcChannelBuffer*);
172void __RPC_STUB NdrStubForwardingFunction(IRpcStubBuffer*,IRpcChannelBuffer*,PRPC_MESSAGE,DWORD*);
173void RPC_ENTRY NdrStubGetBuffer(IRpcStubBuffer*,IRpcChannelBuffer*,PMIDL_STUB_MESSAGE);
174HRESULT RPC_ENTRY NdrStubErrorHandler(DWORD);
175HRESULT STDMETHODCALLTYPE CStdStubBuffer_QueryInterface(IRpcStubBuffer*,REFIID,void**);
176ULONG STDMETHODCALLTYPE CStdStubBuffer_AddRef(IRpcStubBuffer*);
177ULONG STDMETHODCALLTYPE CStdStubBuffer_Release(IRpcStubBuffer*);
178ULONG STDMETHODCALLTYPE NdrCStdStubBuffer_Release(IRpcStubBuffer*,IPSFactoryBuffer*);
179HRESULT STDMETHODCALLTYPE CStdStubBuffer_Connect(IRpcStubBuffer*,IUnknown*);
180void STDMETHODCALLTYPE CStdStubBuffer_Disconnect(IRpcStubBuffer*);
181HRESULT STDMETHODCALLTYPE CStdStubBuffer_Invoke(IRpcStubBuffer*,RPCOLEMESSAGE*,IRpcChannelBuffer*);
182IRpcStubBuffer* STDMETHODCALLTYPE CStdStubBuffer_IsIIDSupported(IRpcStubBuffer*,REFIID);
183ULONG STDMETHODCALLTYPE CStdStubBuffer_CountRefs(IRpcStubBuffer*);
184HRESULT STDMETHODCALLTYPE CStdStubBuffer_DebugServerQueryInterface(IRpcStubBuffer*,void**);
185void STDMETHODCALLTYPE CStdStubBuffer_DebugServerRelease(IRpcStubBuffer*,void*);
186HRESULT RPC_ENTRY NdrDllGetClassObject(REFCLSID,REFIID,void**,const ProxyFileInfo**,const CLSID*,CStdPSFactoryBuffer*);
187HRESULT RPC_ENTRY NdrDllCanUnloadNow(CStdPSFactoryBuffer*);
188#ifndef NT35_STRICT
189HRESULT RPC_ENTRY NdrDllRegisterProxy(HMODULE,const ProxyFileInfo**,const CLSID*);
190HRESULT RPC_ENTRY NdrDllUnregisterProxy(HMODULE,const ProxyFileInfo**,const CLSID*);
191#define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
192ULONG STDMETHODCALLTYPE
193CStdStubBuffer2_Release(IRpcStubBuffer*);
194ULONG STDMETHODCALLTYPE
195NdrCStdStubBuffer2_Release(IRpcStubBuffer*,IPSFactoryBuffer*);
196#define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0
197#endif
198
199#ifdef __cplusplus
200}
201#endif
202#endif /* defined __cplusplus && !defined CINTERFACE */
203#endif /* ndef _RPCPROXY_H */
204
Note: See TracBrowser for help on using the repository browser.