Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef __RPCPROXY_H_VERSION__
      7 #define __RPCPROXY_H_VERSION__ (475)
      8 #endif
      9 
     10 #ifndef __RPCPROXY_H__
     11 #define __RPCPROXY_H__
     12 #define __midl_proxy
     13 
     14 #ifdef __REQUIRED_RPCPROXY_H_VERSION__
     15 #if (475 < __REQUIRED_RPCPROXY_H_VERSION__)
     16 #error Incorrect <rpcproxy.h> version. Use the header that matches with the MIDL compiler.
     17 #endif
     18 #endif
     19 
     20 #if defined(__ia64__) || defined(__x86_64)
     21 #include <pshpack8.h>
     22 #endif
     23 
     24 #include <basetsd.h>
     25 
     26 #ifndef INC_OLE2
     27 #define INC_OLE2
     28 #endif
     29 
     30 #ifndef GUID_DEFINED
     31 #include <guiddef.h>
     32 #endif
     33 #if defined(__cplusplus)
     34 extern "C" {
     35 #endif
     36   struct tagCInterfaceStubVtbl;
     37   struct tagCInterfaceProxyVtbl;
     38 
     39   typedef struct tagCInterfaceStubVtbl *PCInterfaceStubVtblList;
     40   typedef struct tagCInterfaceProxyVtbl *PCInterfaceProxyVtblList;
     41   typedef const char *PCInterfaceName;
     42   typedef int __stdcall IIDLookupRtn(const IID *pIID,int *pIndex);
     43   typedef IIDLookupRtn *PIIDLookup;
     44 
     45   typedef struct tagProxyFileInfo {
     46     const PCInterfaceProxyVtblList *pProxyVtblList;
     47     const PCInterfaceStubVtblList *pStubVtblList;
     48     const PCInterfaceName *pNamesArray;
     49     const IID **pDelegatedIIDs;
     50     const PIIDLookup pIIDLookupRtn;
     51     unsigned short TableSize;
     52     unsigned short TableVersion;
     53     const IID **pAsyncIIDLookup;
     54     LONG_PTR Filler2;
     55     LONG_PTR Filler3;
     56     LONG_PTR Filler4;
     57   } ProxyFileInfo;
     58 
     59   typedef ProxyFileInfo ExtendedProxyFileInfo;
     60 
     61 #include <rpc.h>
     62 #include <rpcndr.h>
     63 #include <string.h>
     64 #include <memory.h>
     65 
     66   typedef struct tagCInterfaceProxyHeader {
     67 #ifdef USE_STUBLESS_PROXY
     68     const void *pStublessProxyInfo;
     69 #endif
     70     const IID *piid;
     71   } CInterfaceProxyHeader;
     72 
     73 #define CINTERFACE_PROXY_VTABLE(n) struct { CInterfaceProxyHeader header; void *Vtbl[n ]; }
     74 
     75   typedef struct tagCInterfaceProxyVtbl {
     76     CInterfaceProxyHeader header;
     77     void *Vtbl[];
     78   } CInterfaceProxyVtbl;
     79 
     80   typedef void (__RPC_STUB *PRPC_STUB_FUNCTION)(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *pdwStubPhase);
     81 
     82   typedef struct tagCInterfaceStubHeader {
     83     const IID *piid;
     84     const MIDL_SERVER_INFO *pServerInfo;
     85     unsigned __LONG32 DispatchTableCount;
     86     const PRPC_STUB_FUNCTION *pDispatchTable;
     87   } CInterfaceStubHeader;
     88 
     89   typedef struct tagCInterfaceStubVtbl {
     90     CInterfaceStubHeader header;
     91     IRpcStubBufferVtbl Vtbl;
     92   } CInterfaceStubVtbl;
     93 
     94   typedef struct tagCStdStubBuffer {
     95     const struct IRpcStubBufferVtbl *lpVtbl;
     96     __LONG32 RefCount;
     97     struct IUnknown *pvServerObject;
     98     const struct ICallFactoryVtbl *pCallFactoryVtbl;
     99     const IID *pAsyncIID;
    100     struct IPSFactoryBuffer *pPSFactory;
    101     const struct IReleaseMarshalBuffersVtbl *pRMBVtbl;
    102   } CStdStubBuffer;
    103 
    104   typedef struct tagCStdPSFactoryBuffer {
    105     const IPSFactoryBufferVtbl *lpVtbl;
    106     __LONG32 RefCount;
    107     const ProxyFileInfo **pProxyFileList;
    108     __LONG32 Filler1;
    109   } CStdPSFactoryBuffer;
    110 
    111   RPCRTAPI void RPC_ENTRY NdrProxyInitialize(void *This,PRPC_MESSAGE pRpcMsg,PMIDL_STUB_MESSAGE pStubMsg,PMIDL_STUB_DESC pStubDescriptor,unsigned int ProcNum);
    112   RPCRTAPI void RPC_ENTRY NdrProxyGetBuffer(void *This,PMIDL_STUB_MESSAGE pStubMsg);
    113   RPCRTAPI void RPC_ENTRY NdrProxySendReceive(void *This,MIDL_STUB_MESSAGE *pStubMsg);
    114   RPCRTAPI void RPC_ENTRY NdrProxyFreeBuffer(void *This,MIDL_STUB_MESSAGE *pStubMsg);
    115   RPCRTAPI HRESULT RPC_ENTRY NdrProxyErrorHandler(DWORD dwExceptionCode);
    116   RPCRTAPI void RPC_ENTRY NdrStubInitialize(PRPC_MESSAGE pRpcMsg,PMIDL_STUB_MESSAGE pStubMsg,PMIDL_STUB_DESC pStubDescriptor,IRpcChannelBuffer *pRpcChannelBuffer);
    117   RPCRTAPI void RPC_ENTRY NdrStubInitializePartial(PRPC_MESSAGE pRpcMsg,PMIDL_STUB_MESSAGE pStubMsg,PMIDL_STUB_DESC pStubDescriptor,IRpcChannelBuffer *pRpcChannelBuffer,unsigned __LONG32 RequestedBufferSize);
    118   void __RPC_STUB NdrStubForwardingFunction(IRpcStubBuffer *This,IRpcChannelBuffer *pChannel,PRPC_MESSAGE pmsg,DWORD *pdwStubPhase);
    119   RPCRTAPI void RPC_ENTRY NdrStubGetBuffer(IRpcStubBuffer *This,IRpcChannelBuffer *pRpcChannelBuffer,PMIDL_STUB_MESSAGE pStubMsg);
    120   RPCRTAPI HRESULT RPC_ENTRY NdrStubErrorHandler(DWORD dwExceptionCode);
    121   HRESULT WINAPI CStdStubBuffer_QueryInterface(IRpcStubBuffer *This,REFIID riid,void **ppvObject);
    122   ULONG WINAPI CStdStubBuffer_AddRef(IRpcStubBuffer *This);
    123   ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This);
    124   ULONG WINAPI NdrCStdStubBuffer_Release(IRpcStubBuffer *This,IPSFactoryBuffer *pPSF);
    125   HRESULT WINAPI CStdStubBuffer_Connect(IRpcStubBuffer *This,IUnknown *pUnkServer);
    126   void WINAPI CStdStubBuffer_Disconnect(IRpcStubBuffer *This);
    127   HRESULT WINAPI CStdStubBuffer_Invoke(IRpcStubBuffer *This,RPCOLEMESSAGE *pRpcMsg,IRpcChannelBuffer *pRpcChannelBuffer);
    128   IRpcStubBuffer *WINAPI CStdStubBuffer_IsIIDSupported(IRpcStubBuffer *This,REFIID riid);
    129   ULONG WINAPI CStdStubBuffer_CountRefs(IRpcStubBuffer *This);
    130   HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(IRpcStubBuffer *This,void **ppv);
    131   void WINAPI CStdStubBuffer_DebugServerRelease(IRpcStubBuffer *This,void *pv);
    132 
    133 #define CStdStubBuffer_METHODS CStdStubBuffer_QueryInterface,CStdStubBuffer_AddRef,CStdStubBuffer_Release,CStdStubBuffer_Connect,CStdStubBuffer_Disconnect,CStdStubBuffer_Invoke,CStdStubBuffer_IsIIDSupported,CStdStubBuffer_CountRefs,CStdStubBuffer_DebugServerQueryInterface,CStdStubBuffer_DebugServerRelease
    134 #define CStdAsyncStubBuffer_METHODS 0,0,0,0,0,0,0,0,0,0
    135 #define CStdAsyncStubBuffer_DELEGATING_METHODS 0,0,0,0,0,0,0,0,0,0
    136 
    137 #define IID_GENERIC_CHECK_IID(name,pIID,index) memcmp(pIID,name##_ProxyVtblList[index ]->header.piid,16)
    138 #define IID_BS_LOOKUP_SETUP int result,low=-1;
    139 #define IID_BS_LOOKUP_INITIAL_TEST(name,sz,split) result = name##_CHECK_IID(split); if (result > 0) { low = sz - split; } else if (!result) { low = split; goto found_label; }
    140 #define IID_BS_LOOKUP_NEXT_TEST(name,split) result = name##_CHECK_IID(low + split); if (result >= 0) { low = low + split; if (!result) goto found_label; }
    141 #define IID_BS_LOOKUP_RETURN_RESULT(name,sz,index) low = low + 1; if (low >= sz) goto not_found_label; result = name##_CHECK_IID(low); if (result) goto not_found_label; found_label: (index) = low; return 1; not_found_label: return 0;
    142 
    143   RPCRTAPI HRESULT RPC_ENTRY NdrDllGetClassObject(REFCLSID rclsid,REFIID riid,void **ppv,const ProxyFileInfo **pProxyFileList,const CLSID *pclsid,CStdPSFactoryBuffer *pPSFactoryBuffer);
    144   RPCRTAPI HRESULT RPC_ENTRY NdrDllCanUnloadNow(CStdPSFactoryBuffer *pPSFactoryBuffer);
    145 
    146 #ifndef ENTRY_PREFIX
    147 #ifndef DllMain
    148 #define DISABLE_THREAD_LIBRARY_CALLS(x) DisableThreadLibraryCalls(x)
    149 #endif
    150 
    151 #define ENTRY_PREFIX
    152 #define DLLREGISTERSERVER_ENTRY DllRegisterServer
    153 #define DLLUNREGISTERSERVER_ENTRY DllUnregisterServer
    154 #define DLLMAIN_ENTRY DllMain
    155 
    156 #define DLLGETCLASSOBJECT_ENTRY DllGetClassObject
    157 #define DLLCANUNLOADNOW_ENTRY DllCanUnloadNow
    158 #else
    159 #define __rpc_macro_expand2(a,b) a##b
    160 #define __rpc_macro_expand(a,b) __rpc_macro_expand2(a,b)
    161 #define DLLREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX,DllRegisterServer)
    162 #define DLLUNREGISTERSERVER_ENTRY __rpc_macro_expand(ENTRY_PREFIX,DllUnregisterServer)
    163 #define DLLMAIN_ENTRY __rpc_macro_expand(ENTRY_PREFIX,DllMain)
    164 
    165 #define DLLGETCLASSOBJECT_ENTRY __rpc_macro_expand(ENTRY_PREFIX,DllGetClassObject)
    166 #define DLLCANUNLOADNOW_ENTRY __rpc_macro_expand(ENTRY_PREFIX,DllCanUnloadNow)
    167 #endif
    168 
    169 #ifndef DISABLE_THREAD_LIBRARY_CALLS
    170 #define DISABLE_THREAD_LIBRARY_CALLS(x)
    171 #endif
    172 
    173   RPCRTAPI HRESULT RPC_ENTRY NdrDllRegisterProxy(HMODULE hDll,const ProxyFileInfo **pProxyFileList,const CLSID *pclsid);
    174   RPCRTAPI HRESULT RPC_ENTRY NdrDllUnregisterProxy(HMODULE hDll,const ProxyFileInfo **pProxyFileList,const CLSID *pclsid);
    175 
    176 #define REGISTER_PROXY_DLL_ROUTINES(pProxyFileList,pClsID) HINSTANCE hProxyDll = 0; WINBOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) { if(fdwReason==DLL_PROCESS_ATTACH) { hProxyDll = hinstDLL; DISABLE_THREAD_LIBRARY_CALLS(hinstDLL); } return TRUE; } HRESULT WINAPI DLLREGISTERSERVER_ENTRY() { return NdrDllRegisterProxy(hProxyDll,pProxyFileList,pClsID); } HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY() { return NdrDllUnregisterProxy(hProxyDll,pProxyFileList,pClsID); }
    177 #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction
    178 
    179   ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This);
    180   ULONG WINAPI NdrCStdStubBuffer2_Release(IRpcStubBuffer *This,IPSFactoryBuffer *pPSF);
    181 
    182 #define CStdStubBuffer_DELEGATING_METHODS 0,0,CStdStubBuffer2_Release,0,0,0,0,0,0,0
    183 
    184 #ifdef PROXY_CLSID
    185 #define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID;
    186 #else
    187 #ifdef PROXY_CLSID_IS
    188 #define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS;
    189 #define PROXY_CLSID CLSID_PSFactoryBuffer
    190 #else
    191 #define CLSID_PSFACTORYBUFFER
    192 #endif
    193 #endif
    194 
    195 #ifndef PROXY_CLSID
    196 #define GET_DLL_CLSID (aProxyFileList[0]->pStubVtblList[0]!=0 ? aProxyFileList[0]->pStubVtblList[0]->header.piid : 0)
    197 #else
    198 #define GET_DLL_CLSID &PROXY_CLSID
    199 #endif
    200 
    201 #define EXTERN_PROXY_FILE(name) EXTERN_C const ProxyFileInfo name##_ProxyFileInfo;
    202 #define PROXYFILE_LIST_START const ProxyFileInfo *aProxyFileList[] = {
    203 #define REFERENCE_PROXY_FILE(name) & name##_ProxyFileInfo
    204 #define PROXYFILE_LIST_END 0 };
    205 #define DLLDATA_GETPROXYDLLINFO(pPFList,pClsid) void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo***pInfo,const CLSID **pId) { *pInfo = pPFList; *pId = pClsid; }
    206 #define DLLGETCLASSOBJECTROUTINE(pPFlist,pClsid,pFactory) HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY (REFCLSID rclsid,REFIID riid,void **ppv) { return NdrDllGetClassObject(rclsid,riid,ppv,pPFlist,pClsid,pFactory); }
    207 #define DLLCANUNLOADNOW(pFactory) HRESULT WINAPI DLLCANUNLOADNOW_ENTRY() { return NdrDllCanUnloadNow(pFactory); }
    208 #define DLLDUMMYPURECALL void __cdecl _purecall(void) { }
    209 #define CSTDSTUBBUFFERRELEASE(pFactory) ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) { return NdrCStdStubBuffer_Release(This,(IPSFactoryBuffer *)pFactory); }
    210 #ifdef PROXY_DELEGATION
    211 #define CSTDSTUBBUFFER2RELEASE(pFactory) ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) { return NdrCStdStubBuffer2_Release(This,(IPSFactoryBuffer *)pFactory); }
    212 #else
    213 #define CSTDSTUBBUFFER2RELEASE(pFactory)
    214 #endif
    215 
    216 #ifdef REGISTER_PROXY_DLL
    217 #define DLLREGISTRY_ROUTINES(pProxyFileList,pClsID) REGISTER_PROXY_DLL_ROUTINES(pProxyFileList,pClsID)
    218 #else
    219 #define DLLREGISTRY_ROUTINES(pProxyFileList,pClsID)
    220 #endif
    221 
    222 #define DLLDATA_ROUTINES(pProxyFileList,pClsID) CLSID_PSFACTORYBUFFER CStdPSFactoryBuffer gPFactory = {0,0,0,0}; DLLDATA_GETPROXYDLLINFO(pProxyFileList,pClsID) DLLGETCLASSOBJECTROUTINE(pProxyFileList,pClsID,&gPFactory) DLLCANUNLOADNOW(&gPFactory) CSTDSTUBBUFFERRELEASE(&gPFactory) CSTDSTUBBUFFER2RELEASE(&gPFactory) DLLDUMMYPURECALL DLLREGISTRY_ROUTINES(pProxyFileList,pClsID)
    223 #define DLLDATA_STANDARD_ROUTINES DLLDATA_ROUTINES((const ProxyFileInfo**) pProxyFileList,&CLSID_PSFactoryBuffer)
    224 
    225 #if defined(__cplusplus)
    226 }
    227 #endif
    228 
    229 #if defined(__ia64__) || defined(__x86_64)
    230 #include <poppack.h>
    231 #endif
    232 #endif
    233