Wrapping DCE RPC Calls to Interoperate with ORPC
This is an example of a server side wrapper for the Bar method. It assumes the existence of small helper functions to import and export object references and lookup previously exported object references.
RPC_STATUS Bar(handle_t h, short i, OBJREF * prIB, OBJREF ** pprIW) {
UUID ipid;
RPC_STATUS status;
IFoo * pIF;
IBar * pIB;
IWaz * PIW;
HRESULT hR;
status = RpcBindingInqObject(h, &ipid);
if (status) return(SOMETHING);
status = ORpcLookupIPID(ipid, &pIF);
if (status) return(SOMETHING);
status = ORpcImportObjRef(prIB, &pIB);
if (status) return(SOMETHING);
hR = pIF->Bar(i, pIB, &pIW); // actual call to the method!
pIB->Release();
status = ORpcExportObjRef(pIW, pprIW);
return(hR ? hR : SOMETHING);
};
This is an example of the client side wrapper for Bar:
// assume some class CFoo that implements Bar method
class CFoo : IUnknown, IFoo {
UUID ipid; // one for each interface?
handle_t h;
virtual HRESULT QueryInterface(UUID iid, void **ppvoid);
virtual HRESULT AddRef();
virtual HRESULT Release();
virtual HRESULT Bar(short i, IFoo * pIF, IWaz ** ppIW);
};
HRESULT CFoo::Bar(short i, IFoo * pIF, IWaz ** ppIW) {
OBJREF * prIF;
OBJREF * prIW;
HRESULT hR;
RPC_STATUS status;
status = RpcBindingSetObject(this->h, this->ipid);
if (status) return(SOMETHING);
status = ORpcExportObjRef(pIF, &prIF);
if (status) return(SOMETHING);
hR = Bar(this->h, i, prIF, &prIW);
status = ORpcImportObjRef(prIW, ppIW);
ORpcFreeObjRef(prIF);
ORpcFreeObjRef(prIW);
return(hR ? hR : SOMETHING);
};