reactos/dll/win32/ole32/oleproxy.c

199 lines
5.5 KiB
C
Raw Normal View History

/*
* OLE32 proxy/stub handler
*
* Copyright 2002 Marcus Meissner
* Copyright 2001 Ove Kåven, TransGaming Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "objbase.h"
#include "ole2.h"
#include "rpc.h"
#include "compobj_private.h"
#include "moniker.h"
#include "comcat.h"
#include "wine/debug.h"
[OLE32] Sync with Wine Staging 2.9. CORE-13362 9cc976a ole32: Fix compilation with recent versions of gcc. 2e36326 ole32: Synthesize dibs or bitmaps as appropriate. e27708f ole32: Create CF_DIB and CF_BITMAP entries when either is cached. 20a8f1a ole32: Implement IOleCache_EnumCache(). f9b0f60 ole32: Check the cache entry's stgmedium for the unloaded state. 8fc1a4c ole32: OleUninitialize() does not release the reference to the clipboard's source dataobject. 1d2860e ole32: Fix up the dib's resolution on loading. e7bb4ba ole32: Don't cache the BITMAPFILEHEADER. fc49d98 ole32: Set the advise flags in CreateEntry(). 77d1eba ole32: Use the helper function to copy the clipboard's FORMATETC. 9ee30d7 ole32: Use the helper function to copy the datacache's FORMATETC. 11db491 ole32: Add a helper to copy FORMATETC structures. b399baf ole32: Add CoRegisterSurrogate/Ex stubs. 87dba2b ole32: Zero STGMEDIUM before calling IDataObject::GetData. c7e6fe6 ole32: Added GlobalOptions object stub implementation. fd09c37 ole32: Use generic class factory for StdComponentCategoriesMgr object. 076c782 ole32: Use generic class factory for pointer moniker. 961c3dc ole32: Use generic class factory for class moniker. 947c9ba ole32: Use generic class factory for composite moniker. b05fd46 ole32: Use generic class factory for anti moniker. dee6463 ole32: Use generic class factory for item moniker. cf7883f ole32: Added generic class factory implementation and use it for file moniker. svn path=/trunk/; revision=74829
2017-06-03 22:33:33 +00:00
WINE_DEFAULT_DEBUG_CHANNEL(ole);
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{
TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
{
*ppv = iface;
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
{
return 2;
}
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
{
return 1;
}
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
{
TRACE("(%x)\n", fLock);
return S_OK;
}
static const IClassFactoryVtbl FileMonikerCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
FileMoniker_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory FileMonikerCF = { &FileMonikerCFVtbl };
static const IClassFactoryVtbl ItemMonikerCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
ItemMoniker_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory ItemMonikerCF = { &ItemMonikerCFVtbl };
static const IClassFactoryVtbl AntiMonikerCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
AntiMoniker_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory AntiMonikerCF = { &AntiMonikerCFVtbl };
static const IClassFactoryVtbl CompositeMonikerCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
CompositeMoniker_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory CompositeMonikerCF = { &CompositeMonikerCFVtbl };
static const IClassFactoryVtbl ClassMonikerCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
ClassMoniker_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory ClassMonikerCF = { &ClassMonikerCFVtbl };
static const IClassFactoryVtbl PointerMonikerCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
PointerMoniker_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory PointerMonikerCF = { &PointerMonikerCFVtbl };
static const IClassFactoryVtbl ComCatCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
ComCat_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory ComCatCF = { &ComCatCFVtbl };
static const IClassFactoryVtbl GlobalOptionsCFVtbl =
{
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
GlobalOptions_CreateInstance,
ClassFactory_LockServer
};
IClassFactory GlobalOptionsCF = { &GlobalOptionsCFVtbl };
/***********************************************************************
* DllGetClassObject [OLE32.@]
*/
Sync to Wine-20050830: Francois Gouget <fgouget@free.fr> - Use LPSTORAGE to better match the PSDK. Document the real SEGPTR type using the standard documentation mechanisms. Fixes winapi_check warnings. Robert Shearman <rob@codeweavers.com> - Remove unused thread handle entry from the apartment structure. - Implement IMarshal on proxies so that we don't end up with proxies to proxies, causing potential deadlock issues and performance problems. - Add a test for this situation and remove the todo_wine from another test that now succeeds. - Add stub for CoAllowSetForegroundWindow. Vincent Beron <vberon@mecano.gme.usherb.ca> - Remove local declarations already in included public headers. - Correct mismatches between spec files and comments about export number. Alexandre Julliard <julliard@winehq.org> - Uncomment the typedef in the DECLARE_INTERFACE macro, and get rid of duplicate typedefs. - Use the proper WOW functions everywhere instead of the K32WOW variant. - Don't prefix the functions DllCanUnloadNow, DllGetClassObject and Dll(Un)RegisterServer with the dll name so that the compiler can check the prototypes. - Remove duplicate definition of FILE_BEGIN. - Replace the _ICOM_THIS_From macros by inline functions the way it's already done in shelllink.c. Mike McCormack <mike@codeweavers.com> - Warning fixes for gcc 4.0. - Fix some gcc 4.0 warnings. - return a precomputed result for a NULL string - pass strlen an LPSTR to eliminate a sign warning Marcus Meissner <marcus@jet.franken.de> - Implemented ILockBytes16 (memorystream) support for the 16bit compound storage implementation. - Added ReadClassStg, OleDoAutoConvert, GetConvertStg implementations/stubs. Marcus Meissner <meissner@suse.de> - Added CoCreateInstance16, CoGetClassObject16, OleLoad16 stubs. svn path=/trunk/; revision=17678
2005-09-05 21:56:14 +00:00
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
{
HRESULT hr;
*ppv = NULL;
if (IsEqualIID(rclsid,&CLSID_DfMarshal)&&(
IsEqualIID(iid,&IID_IClassFactory) ||
IsEqualIID(iid,&IID_IUnknown)
)
)
return MARSHAL_GetStandardMarshalCF(ppv);
if (IsEqualIID(rclsid,&CLSID_StdGlobalInterfaceTable) && (IsEqualIID(iid,&IID_IClassFactory) || IsEqualIID(iid,&IID_IUnknown)))
return StdGlobalInterfaceTable_GetFactory(ppv);
if (IsEqualCLSID(rclsid, &CLSID_FileMoniker))
[OLE32] Sync with Wine Staging 2.9. CORE-13362 9cc976a ole32: Fix compilation with recent versions of gcc. 2e36326 ole32: Synthesize dibs or bitmaps as appropriate. e27708f ole32: Create CF_DIB and CF_BITMAP entries when either is cached. 20a8f1a ole32: Implement IOleCache_EnumCache(). f9b0f60 ole32: Check the cache entry's stgmedium for the unloaded state. 8fc1a4c ole32: OleUninitialize() does not release the reference to the clipboard's source dataobject. 1d2860e ole32: Fix up the dib's resolution on loading. e7bb4ba ole32: Don't cache the BITMAPFILEHEADER. fc49d98 ole32: Set the advise flags in CreateEntry(). 77d1eba ole32: Use the helper function to copy the clipboard's FORMATETC. 9ee30d7 ole32: Use the helper function to copy the datacache's FORMATETC. 11db491 ole32: Add a helper to copy FORMATETC structures. b399baf ole32: Add CoRegisterSurrogate/Ex stubs. 87dba2b ole32: Zero STGMEDIUM before calling IDataObject::GetData. c7e6fe6 ole32: Added GlobalOptions object stub implementation. fd09c37 ole32: Use generic class factory for StdComponentCategoriesMgr object. 076c782 ole32: Use generic class factory for pointer moniker. 961c3dc ole32: Use generic class factory for class moniker. 947c9ba ole32: Use generic class factory for composite moniker. b05fd46 ole32: Use generic class factory for anti moniker. dee6463 ole32: Use generic class factory for item moniker. cf7883f ole32: Added generic class factory implementation and use it for file moniker. svn path=/trunk/; revision=74829
2017-06-03 22:33:33 +00:00
return IClassFactory_QueryInterface(&FileMonikerCF, iid, ppv);
if (IsEqualCLSID(rclsid, &CLSID_ItemMoniker))
[OLE32] Sync with Wine Staging 2.9. CORE-13362 9cc976a ole32: Fix compilation with recent versions of gcc. 2e36326 ole32: Synthesize dibs or bitmaps as appropriate. e27708f ole32: Create CF_DIB and CF_BITMAP entries when either is cached. 20a8f1a ole32: Implement IOleCache_EnumCache(). f9b0f60 ole32: Check the cache entry's stgmedium for the unloaded state. 8fc1a4c ole32: OleUninitialize() does not release the reference to the clipboard's source dataobject. 1d2860e ole32: Fix up the dib's resolution on loading. e7bb4ba ole32: Don't cache the BITMAPFILEHEADER. fc49d98 ole32: Set the advise flags in CreateEntry(). 77d1eba ole32: Use the helper function to copy the clipboard's FORMATETC. 9ee30d7 ole32: Use the helper function to copy the datacache's FORMATETC. 11db491 ole32: Add a helper to copy FORMATETC structures. b399baf ole32: Add CoRegisterSurrogate/Ex stubs. 87dba2b ole32: Zero STGMEDIUM before calling IDataObject::GetData. c7e6fe6 ole32: Added GlobalOptions object stub implementation. fd09c37 ole32: Use generic class factory for StdComponentCategoriesMgr object. 076c782 ole32: Use generic class factory for pointer moniker. 961c3dc ole32: Use generic class factory for class moniker. 947c9ba ole32: Use generic class factory for composite moniker. b05fd46 ole32: Use generic class factory for anti moniker. dee6463 ole32: Use generic class factory for item moniker. cf7883f ole32: Added generic class factory implementation and use it for file moniker. svn path=/trunk/; revision=74829
2017-06-03 22:33:33 +00:00
return IClassFactory_QueryInterface(&ItemMonikerCF, iid, ppv);
if (IsEqualCLSID(rclsid, &CLSID_AntiMoniker))
[OLE32] Sync with Wine Staging 2.9. CORE-13362 9cc976a ole32: Fix compilation with recent versions of gcc. 2e36326 ole32: Synthesize dibs or bitmaps as appropriate. e27708f ole32: Create CF_DIB and CF_BITMAP entries when either is cached. 20a8f1a ole32: Implement IOleCache_EnumCache(). f9b0f60 ole32: Check the cache entry's stgmedium for the unloaded state. 8fc1a4c ole32: OleUninitialize() does not release the reference to the clipboard's source dataobject. 1d2860e ole32: Fix up the dib's resolution on loading. e7bb4ba ole32: Don't cache the BITMAPFILEHEADER. fc49d98 ole32: Set the advise flags in CreateEntry(). 77d1eba ole32: Use the helper function to copy the clipboard's FORMATETC. 9ee30d7 ole32: Use the helper function to copy the datacache's FORMATETC. 11db491 ole32: Add a helper to copy FORMATETC structures. b399baf ole32: Add CoRegisterSurrogate/Ex stubs. 87dba2b ole32: Zero STGMEDIUM before calling IDataObject::GetData. c7e6fe6 ole32: Added GlobalOptions object stub implementation. fd09c37 ole32: Use generic class factory for StdComponentCategoriesMgr object. 076c782 ole32: Use generic class factory for pointer moniker. 961c3dc ole32: Use generic class factory for class moniker. 947c9ba ole32: Use generic class factory for composite moniker. b05fd46 ole32: Use generic class factory for anti moniker. dee6463 ole32: Use generic class factory for item moniker. cf7883f ole32: Added generic class factory implementation and use it for file moniker. svn path=/trunk/; revision=74829
2017-06-03 22:33:33 +00:00
return IClassFactory_QueryInterface(&AntiMonikerCF, iid, ppv);
if (IsEqualCLSID(rclsid, &CLSID_CompositeMoniker))
[OLE32] Sync with Wine Staging 2.9. CORE-13362 9cc976a ole32: Fix compilation with recent versions of gcc. 2e36326 ole32: Synthesize dibs or bitmaps as appropriate. e27708f ole32: Create CF_DIB and CF_BITMAP entries when either is cached. 20a8f1a ole32: Implement IOleCache_EnumCache(). f9b0f60 ole32: Check the cache entry's stgmedium for the unloaded state. 8fc1a4c ole32: OleUninitialize() does not release the reference to the clipboard's source dataobject. 1d2860e ole32: Fix up the dib's resolution on loading. e7bb4ba ole32: Don't cache the BITMAPFILEHEADER. fc49d98 ole32: Set the advise flags in CreateEntry(). 77d1eba ole32: Use the helper function to copy the clipboard's FORMATETC. 9ee30d7 ole32: Use the helper function to copy the datacache's FORMATETC. 11db491 ole32: Add a helper to copy FORMATETC structures. b399baf ole32: Add CoRegisterSurrogate/Ex stubs. 87dba2b ole32: Zero STGMEDIUM before calling IDataObject::GetData. c7e6fe6 ole32: Added GlobalOptions object stub implementation. fd09c37 ole32: Use generic class factory for StdComponentCategoriesMgr object. 076c782 ole32: Use generic class factory for pointer moniker. 961c3dc ole32: Use generic class factory for class moniker. 947c9ba ole32: Use generic class factory for composite moniker. b05fd46 ole32: Use generic class factory for anti moniker. dee6463 ole32: Use generic class factory for item moniker. cf7883f ole32: Added generic class factory implementation and use it for file moniker. svn path=/trunk/; revision=74829
2017-06-03 22:33:33 +00:00
return IClassFactory_QueryInterface(&CompositeMonikerCF, iid, ppv);
if (IsEqualCLSID(rclsid, &CLSID_ClassMoniker))
[OLE32] Sync with Wine Staging 2.9. CORE-13362 9cc976a ole32: Fix compilation with recent versions of gcc. 2e36326 ole32: Synthesize dibs or bitmaps as appropriate. e27708f ole32: Create CF_DIB and CF_BITMAP entries when either is cached. 20a8f1a ole32: Implement IOleCache_EnumCache(). f9b0f60 ole32: Check the cache entry's stgmedium for the unloaded state. 8fc1a4c ole32: OleUninitialize() does not release the reference to the clipboard's source dataobject. 1d2860e ole32: Fix up the dib's resolution on loading. e7bb4ba ole32: Don't cache the BITMAPFILEHEADER. fc49d98 ole32: Set the advise flags in CreateEntry(). 77d1eba ole32: Use the helper function to copy the clipboard's FORMATETC. 9ee30d7 ole32: Use the helper function to copy the datacache's FORMATETC. 11db491 ole32: Add a helper to copy FORMATETC structures. b399baf ole32: Add CoRegisterSurrogate/Ex stubs. 87dba2b ole32: Zero STGMEDIUM before calling IDataObject::GetData. c7e6fe6 ole32: Added GlobalOptions object stub implementation. fd09c37 ole32: Use generic class factory for StdComponentCategoriesMgr object. 076c782 ole32: Use generic class factory for pointer moniker. 961c3dc ole32: Use generic class factory for class moniker. 947c9ba ole32: Use generic class factory for composite moniker. b05fd46 ole32: Use generic class factory for anti moniker. dee6463 ole32: Use generic class factory for item moniker. cf7883f ole32: Added generic class factory implementation and use it for file moniker. svn path=/trunk/; revision=74829
2017-06-03 22:33:33 +00:00
return IClassFactory_QueryInterface(&ClassMonikerCF, iid, ppv);
if (IsEqualCLSID(rclsid, &CLSID_PointerMoniker))
[OLE32] Sync with Wine Staging 2.9. CORE-13362 9cc976a ole32: Fix compilation with recent versions of gcc. 2e36326 ole32: Synthesize dibs or bitmaps as appropriate. e27708f ole32: Create CF_DIB and CF_BITMAP entries when either is cached. 20a8f1a ole32: Implement IOleCache_EnumCache(). f9b0f60 ole32: Check the cache entry's stgmedium for the unloaded state. 8fc1a4c ole32: OleUninitialize() does not release the reference to the clipboard's source dataobject. 1d2860e ole32: Fix up the dib's resolution on loading. e7bb4ba ole32: Don't cache the BITMAPFILEHEADER. fc49d98 ole32: Set the advise flags in CreateEntry(). 77d1eba ole32: Use the helper function to copy the clipboard's FORMATETC. 9ee30d7 ole32: Use the helper function to copy the datacache's FORMATETC. 11db491 ole32: Add a helper to copy FORMATETC structures. b399baf ole32: Add CoRegisterSurrogate/Ex stubs. 87dba2b ole32: Zero STGMEDIUM before calling IDataObject::GetData. c7e6fe6 ole32: Added GlobalOptions object stub implementation. fd09c37 ole32: Use generic class factory for StdComponentCategoriesMgr object. 076c782 ole32: Use generic class factory for pointer moniker. 961c3dc ole32: Use generic class factory for class moniker. 947c9ba ole32: Use generic class factory for composite moniker. b05fd46 ole32: Use generic class factory for anti moniker. dee6463 ole32: Use generic class factory for item moniker. cf7883f ole32: Added generic class factory implementation and use it for file moniker. svn path=/trunk/; revision=74829
2017-06-03 22:33:33 +00:00
return IClassFactory_QueryInterface(&PointerMonikerCF, iid, ppv);
if (IsEqualGUID(rclsid, &CLSID_StdComponentCategoriesMgr))
[OLE32] Sync with Wine Staging 2.9. CORE-13362 9cc976a ole32: Fix compilation with recent versions of gcc. 2e36326 ole32: Synthesize dibs or bitmaps as appropriate. e27708f ole32: Create CF_DIB and CF_BITMAP entries when either is cached. 20a8f1a ole32: Implement IOleCache_EnumCache(). f9b0f60 ole32: Check the cache entry's stgmedium for the unloaded state. 8fc1a4c ole32: OleUninitialize() does not release the reference to the clipboard's source dataobject. 1d2860e ole32: Fix up the dib's resolution on loading. e7bb4ba ole32: Don't cache the BITMAPFILEHEADER. fc49d98 ole32: Set the advise flags in CreateEntry(). 77d1eba ole32: Use the helper function to copy the clipboard's FORMATETC. 9ee30d7 ole32: Use the helper function to copy the datacache's FORMATETC. 11db491 ole32: Add a helper to copy FORMATETC structures. b399baf ole32: Add CoRegisterSurrogate/Ex stubs. 87dba2b ole32: Zero STGMEDIUM before calling IDataObject::GetData. c7e6fe6 ole32: Added GlobalOptions object stub implementation. fd09c37 ole32: Use generic class factory for StdComponentCategoriesMgr object. 076c782 ole32: Use generic class factory for pointer moniker. 961c3dc ole32: Use generic class factory for class moniker. 947c9ba ole32: Use generic class factory for composite moniker. b05fd46 ole32: Use generic class factory for anti moniker. dee6463 ole32: Use generic class factory for item moniker. cf7883f ole32: Added generic class factory implementation and use it for file moniker. svn path=/trunk/; revision=74829
2017-06-03 22:33:33 +00:00
return IClassFactory_QueryInterface(&ComCatCF, iid, ppv);
hr = OLE32_DllGetClassObject(rclsid, iid, ppv);
if (SUCCEEDED(hr))
return hr;
return Handler_DllGetClassObject(rclsid, iid, ppv);
}