rpcrt4: Don't use GetProcAddress for ole32 functions.
It's more elegant to put ole32 in the DELAYIMPORTS.
This commit is contained in:
parent
8e3f316cc9
commit
f0b0c7f464
2 changed files with 14 additions and 50 deletions
|
@ -2,7 +2,7 @@ EXTRADEFS = -D_RPCRT4_ -DMSWMSG
|
|||
MODULE = rpcrt4.dll
|
||||
IMPORTLIB = rpcrt4
|
||||
IMPORTS = uuid advapi32
|
||||
DELAYIMPORTS = iphlpapi wininet secur32 user32 ws2_32 oleaut32
|
||||
DELAYIMPORTS = iphlpapi wininet secur32 user32 ws2_32 ole32 oleaut32
|
||||
|
||||
ndr_types_EXTRAIDLFLAGS = -Oicf
|
||||
|
||||
|
|
|
@ -44,33 +44,6 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
||||
|
||||
static HMODULE hOLE;
|
||||
|
||||
static HRESULT (WINAPI *COM_GetMarshalSizeMax)(ULONG *,REFIID,LPUNKNOWN,DWORD,LPVOID,DWORD);
|
||||
static HRESULT (WINAPI *COM_MarshalInterface)(LPSTREAM,REFIID,LPUNKNOWN,DWORD,LPVOID,DWORD);
|
||||
static HRESULT (WINAPI *COM_UnmarshalInterface)(LPSTREAM,REFIID,LPVOID*);
|
||||
static HRESULT (WINAPI *COM_ReleaseMarshalData)(LPSTREAM);
|
||||
static HRESULT (WINAPI *COM_GetClassObject)(REFCLSID,DWORD,COSERVERINFO *,REFIID,LPVOID *);
|
||||
static HRESULT (WINAPI *COM_GetPSClsid)(REFIID,CLSID *);
|
||||
static LPVOID (WINAPI *COM_MemAlloc)(ULONG);
|
||||
static void (WINAPI *COM_MemFree)(LPVOID);
|
||||
|
||||
static HMODULE LoadCOM(void)
|
||||
{
|
||||
if (hOLE) return hOLE;
|
||||
hOLE = LoadLibraryA("OLE32.DLL");
|
||||
if (!hOLE) return 0;
|
||||
COM_GetMarshalSizeMax = (LPVOID)GetProcAddress(hOLE, "CoGetMarshalSizeMax");
|
||||
COM_MarshalInterface = (LPVOID)GetProcAddress(hOLE, "CoMarshalInterface");
|
||||
COM_UnmarshalInterface = (LPVOID)GetProcAddress(hOLE, "CoUnmarshalInterface");
|
||||
COM_ReleaseMarshalData = (LPVOID)GetProcAddress(hOLE, "CoReleaseMarshalData");
|
||||
COM_GetClassObject = (LPVOID)GetProcAddress(hOLE, "CoGetClassObject");
|
||||
COM_GetPSClsid = (LPVOID)GetProcAddress(hOLE, "CoGetPSClsid");
|
||||
COM_MemAlloc = (LPVOID)GetProcAddress(hOLE, "CoTaskMemAlloc");
|
||||
COM_MemFree = (LPVOID)GetProcAddress(hOLE, "CoTaskMemFree");
|
||||
return hOLE;
|
||||
}
|
||||
|
||||
/* CoMarshalInterface/CoUnmarshalInterface works on streams,
|
||||
* so implement a simple stream on top of the RPC buffer
|
||||
* (which also implements the MInterfacePointer structure) */
|
||||
|
@ -313,14 +286,13 @@ unsigned char * WINAPI NdrInterfacePointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
|||
|
||||
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
||||
pStubMsg->MaxCount = 0;
|
||||
if (!LoadCOM()) return NULL;
|
||||
if (pStubMsg->Buffer + sizeof(DWORD) <= (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) {
|
||||
hr = RpcStream_Create(pStubMsg, TRUE, NULL, &stream);
|
||||
if (hr == S_OK) {
|
||||
if (pMemory)
|
||||
hr = COM_MarshalInterface(stream, riid, (LPUNKNOWN)pMemory,
|
||||
pStubMsg->dwDestContext, pStubMsg->pvDestContext,
|
||||
MSHLFLAGS_NORMAL);
|
||||
hr = CoMarshalInterface(stream, riid, (IUnknown *)pMemory,
|
||||
pStubMsg->dwDestContext, pStubMsg->pvDestContext,
|
||||
MSHLFLAGS_NORMAL);
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
||||
|
@ -343,7 +315,6 @@ unsigned char * WINAPI NdrInterfacePointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
|
|||
HRESULT hr;
|
||||
|
||||
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
||||
if (!LoadCOM()) return NULL;
|
||||
|
||||
/* Avoid reference leaks for [in, out] pointers. */
|
||||
if (pStubMsg->IsClient && *unk)
|
||||
|
@ -356,7 +327,7 @@ unsigned char * WINAPI NdrInterfacePointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
|
|||
hr = RpcStream_Create(pStubMsg, FALSE, &size, &stream);
|
||||
if (hr == S_OK) {
|
||||
if (size != 0)
|
||||
hr = COM_UnmarshalInterface(stream, &IID_NULL, (void **)unk);
|
||||
hr = CoUnmarshalInterface(stream, &IID_NULL, (void **)unk);
|
||||
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
@ -378,10 +349,9 @@ void WINAPI NdrInterfacePointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
|||
ULONG size = 0;
|
||||
|
||||
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
||||
if (!LoadCOM()) return;
|
||||
COM_GetMarshalSizeMax(&size, riid, (LPUNKNOWN)pMemory,
|
||||
pStubMsg->dwDestContext, pStubMsg->pvDestContext,
|
||||
MSHLFLAGS_NORMAL);
|
||||
CoGetMarshalSizeMax(&size, riid, (IUnknown *)pMemory,
|
||||
pStubMsg->dwDestContext, pStubMsg->pvDestContext,
|
||||
MSHLFLAGS_NORMAL);
|
||||
TRACE("size=%ld\n", size);
|
||||
pStubMsg->BufferLength += sizeof(DWORD) + size;
|
||||
}
|
||||
|
@ -422,8 +392,7 @@ void WINAPI NdrInterfacePointerFree(PMIDL_STUB_MESSAGE pStubMsg,
|
|||
*/
|
||||
void * WINAPI NdrOleAllocate(SIZE_T Size)
|
||||
{
|
||||
if (!LoadCOM()) return NULL;
|
||||
return COM_MemAlloc(Size);
|
||||
return CoTaskMemAlloc(Size);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -431,8 +400,7 @@ void * WINAPI NdrOleAllocate(SIZE_T Size)
|
|||
*/
|
||||
void WINAPI NdrOleFree(void *NodeToFree)
|
||||
{
|
||||
if (!LoadCOM()) return;
|
||||
COM_MemFree(NodeToFree);
|
||||
CoTaskMemFree(NodeToFree);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -445,12 +413,10 @@ HRESULT create_proxy(REFIID iid, IUnknown *pUnkOuter, IRpcProxyBuffer **pproxy,
|
|||
IPSFactoryBuffer *psfac;
|
||||
HRESULT r;
|
||||
|
||||
if(!LoadCOM()) return E_FAIL;
|
||||
|
||||
r = COM_GetPSClsid( iid, &clsid );
|
||||
r = CoGetPSClsid(iid, &clsid);
|
||||
if(FAILED(r)) return r;
|
||||
|
||||
r = COM_GetClassObject( &clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void**)&psfac );
|
||||
r = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void **)&psfac);
|
||||
if(FAILED(r)) return r;
|
||||
|
||||
r = IPSFactoryBuffer_CreateProxy(psfac, pUnkOuter, iid, pproxy, ppv);
|
||||
|
@ -469,12 +435,10 @@ HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub)
|
|||
IPSFactoryBuffer *psfac;
|
||||
HRESULT r;
|
||||
|
||||
if(!LoadCOM()) return E_FAIL;
|
||||
|
||||
r = COM_GetPSClsid( iid, &clsid );
|
||||
r = CoGetPSClsid(iid, &clsid);
|
||||
if(FAILED(r)) return r;
|
||||
|
||||
r = COM_GetClassObject( &clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void**)&psfac );
|
||||
r = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void **)&psfac);
|
||||
if(FAILED(r)) return r;
|
||||
|
||||
r = IPSFactoryBuffer_CreateStub(psfac, iid, pUnk, ppstub);
|
||||
|
|
Loading…
Add table
Reference in a new issue