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
|
---|
17 | extern "C" {
|
---|
18 | #endif
|
---|
19 | #include <rpc.h>
|
---|
20 | #include <rpcndr.h>
|
---|
21 | #include <string.h>
|
---|
22 |
|
---|
23 | #define CStdStubBuffer_METHODS CStdStubBuffer_QueryInterface,CStdStubBuffer_AddRef,\
|
---|
24 | CStdStubBuffer_Release,CStdStubBuffer_Connect,CStdStubBuffer_Disconnect,CStdStubBuffer_Invoke,\
|
---|
25 | CStdStubBuffer_IsIIDSupported,CStdStubBuffer_CountRefs,CStdStubBuffer_DebugServerQueryInterface,\
|
---|
26 | CStdStubBuffer_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) \
|
---|
33 | HINSTANCE hProxyDll = 0; \
|
---|
34 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) \
|
---|
35 | { \
|
---|
36 | if(fdwReason == DLL_PROCESS_ATTACH) hProxyDll = hinstDLL; \
|
---|
37 | return TRUE; \
|
---|
38 | } \
|
---|
39 | HRESULT STDAPICALLTYPE DllRegisterServer(void) \
|
---|
40 | {\
|
---|
41 | return NdrDllRegisterProxy(hProxyDll, pProxyFileList, pClsID); \
|
---|
42 | }\
|
---|
43 | HRESULT STDAPICALLTYPE DllUnregisterServer(void)\
|
---|
44 | {\
|
---|
45 | return 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) \
|
---|
67 | void 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) \
|
---|
89 | CLSID_PSFACTORYBUFFER \
|
---|
90 | CStdPSFactoryBuffer gPFactory = {0,0,0,0}; \
|
---|
91 | DLLDATA_GETPROXYDLLINFO(pProxyFileList,pClsID) \
|
---|
92 | DLLGETCLASSOBJECTROUTINE(pProxyFileList,pClsID,&gPFactory) \
|
---|
93 | DLLCANUNLOADNOW(&gPFactory) \
|
---|
94 | CSTDSTUBBUFFERRELEASE(&gPFactory) \
|
---|
95 | CSTDSTUBBUFFER2RELEASE(&gPFactory) \
|
---|
96 | DLLDUMMYPURECALL \
|
---|
97 | DLLREGISTRY_ROUTINES(pProxyFileList, pClsID)
|
---|
98 |
|
---|
99 | #define DLLDATA_STANDARD_ROUTINES DLLDATA_ROUTINES( (const ProxyFileInfo**) pProxyFileList, &CLSID_PSFactoryBuffer)
|
---|
100 |
|
---|
101 | struct tagCInterfaceStubVtbl;
|
---|
102 | struct tagCInterfaceProxyVtbl;
|
---|
103 | typedef struct tagCInterfaceStubVtbl *PCInterfaceStubVtblList;
|
---|
104 | typedef struct tagCInterfaceProxyVtbl *PCInterfaceProxyVtblList;
|
---|
105 | typedef const char *PCInterfaceName;
|
---|
106 | typedef int __stdcall IIDLookupRtn(const IID*,int*);
|
---|
107 | typedef IIDLookupRtn *PIIDLookup;
|
---|
108 | typedef 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;
|
---|
121 | typedef ProxyFileInfo ExtendedProxyFileInfo;
|
---|
122 |
|
---|
123 | typedef struct tagCInterfaceProxyHeader {
|
---|
124 | #ifdef USE_STUBLESS_PROXY
|
---|
125 | const void *pStublessProxyInfo;
|
---|
126 | #endif
|
---|
127 | const IID *piid;
|
---|
128 | } CInterfaceProxyHeader;
|
---|
129 | typedef 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;
|
---|
140 | typedef void (__RPC_STUB *PRPC_STUB_FUNCTION)(IRpcStubBuffer*,IRpcChannelBuffer*,PRPC_MESSAGE,DWORD*);
|
---|
141 | typedef struct tagCInterfaceStubHeader {
|
---|
142 | const IID *piid;
|
---|
143 | const MIDL_SERVER_INFO *pServerInfo;
|
---|
144 | unsigned long DispatchTableCount;
|
---|
145 | const PRPC_STUB_FUNCTION *pDispatchTable;
|
---|
146 | } CInterfaceStubHeader;
|
---|
147 | typedef struct tagCInterfaceStubVtbl {
|
---|
148 | CInterfaceStubHeader header;
|
---|
149 | IRpcStubBufferVtbl Vtbl;
|
---|
150 | } CInterfaceStubVtbl;
|
---|
151 | typedef 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;
|
---|
160 | typedef struct tagCStdPSFactoryBuffer {
|
---|
161 | const IPSFactoryBufferVtbl *lpVtbl;
|
---|
162 | long RefCount;
|
---|
163 | const ProxyFileInfo ** pProxyFileList;
|
---|
164 | long Filler1;
|
---|
165 | } CStdPSFactoryBuffer;
|
---|
166 | void RPC_ENTRY NdrProxyInitialize(void*,PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC,unsigned int);
|
---|
167 | void RPC_ENTRY NdrProxyGetBuffer(void*,PMIDL_STUB_MESSAGE);
|
---|
168 | void RPC_ENTRY NdrProxySendReceive(void*,MIDL_STUB_MESSAGE*);
|
---|
169 | void RPC_ENTRY NdrProxyFreeBuffer(void*,MIDL_STUB_MESSAGE*);
|
---|
170 | HRESULT RPC_ENTRY NdrProxyErrorHandler(DWORD);
|
---|
171 | void RPC_ENTRY NdrStubInitialize(PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC,IRpcChannelBuffer*);
|
---|
172 | void __RPC_STUB NdrStubForwardingFunction(IRpcStubBuffer*,IRpcChannelBuffer*,PRPC_MESSAGE,DWORD*);
|
---|
173 | void RPC_ENTRY NdrStubGetBuffer(IRpcStubBuffer*,IRpcChannelBuffer*,PMIDL_STUB_MESSAGE);
|
---|
174 | HRESULT RPC_ENTRY NdrStubErrorHandler(DWORD);
|
---|
175 | HRESULT STDMETHODCALLTYPE CStdStubBuffer_QueryInterface(IRpcStubBuffer*,REFIID,void**);
|
---|
176 | ULONG STDMETHODCALLTYPE CStdStubBuffer_AddRef(IRpcStubBuffer*);
|
---|
177 | ULONG STDMETHODCALLTYPE CStdStubBuffer_Release(IRpcStubBuffer*);
|
---|
178 | ULONG STDMETHODCALLTYPE NdrCStdStubBuffer_Release(IRpcStubBuffer*,IPSFactoryBuffer*);
|
---|
179 | HRESULT STDMETHODCALLTYPE CStdStubBuffer_Connect(IRpcStubBuffer*,IUnknown*);
|
---|
180 | void STDMETHODCALLTYPE CStdStubBuffer_Disconnect(IRpcStubBuffer*);
|
---|
181 | HRESULT STDMETHODCALLTYPE CStdStubBuffer_Invoke(IRpcStubBuffer*,RPCOLEMESSAGE*,IRpcChannelBuffer*);
|
---|
182 | IRpcStubBuffer* STDMETHODCALLTYPE CStdStubBuffer_IsIIDSupported(IRpcStubBuffer*,REFIID);
|
---|
183 | ULONG STDMETHODCALLTYPE CStdStubBuffer_CountRefs(IRpcStubBuffer*);
|
---|
184 | HRESULT STDMETHODCALLTYPE CStdStubBuffer_DebugServerQueryInterface(IRpcStubBuffer*,void**);
|
---|
185 | void STDMETHODCALLTYPE CStdStubBuffer_DebugServerRelease(IRpcStubBuffer*,void*);
|
---|
186 | HRESULT RPC_ENTRY NdrDllGetClassObject(REFCLSID,REFIID,void**,const ProxyFileInfo**,const CLSID*,CStdPSFactoryBuffer*);
|
---|
187 | HRESULT RPC_ENTRY NdrDllCanUnloadNow(CStdPSFactoryBuffer*);
|
---|
188 | #ifndef NT35_STRICT
|
---|
189 | HRESULT RPC_ENTRY NdrDllRegisterProxy(HMODULE,const ProxyFileInfo**,const CLSID*);
|
---|
190 | HRESULT RPC_ENTRY NdrDllUnregisterProxy(HMODULE,const ProxyFileInfo**,const CLSID*);
|
---|
191 | #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
|
---|
192 | ULONG STDMETHODCALLTYPE
|
---|
193 | CStdStubBuffer2_Release(IRpcStubBuffer*);
|
---|
194 | ULONG STDMETHODCALLTYPE
|
---|
195 | NdrCStdStubBuffer2_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 |
|
---|