Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/combase.c | 50 +++++++++++++++++++++++++++++++ dlls/combase/combase.spec | 2 +- dlls/ole32/compobj.c | 63 --------------------------------------- dlls/ole32/ole32.spec | 2 +- 4 files changed, 52 insertions(+), 65 deletions(-)
diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index 06fc97e17d4..88da5fb888e 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -725,3 +725,53 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetInstanceFromFile(COSERVERINFO *server_info return hr; } } + +/*********************************************************************** + * CoGetInstanceFromIStorage (combase.@) + */ +HRESULT WINAPI CoGetInstanceFromIStorage(COSERVERINFO *server_info, CLSID *rclsid, + IUnknown *outer, DWORD cls_context, IStorage *storage, DWORD count, MULTI_QI *results) +{ + IPersistStorage *ps = NULL; + IUnknown *obj = NULL; + STATSTG stat; + HRESULT hr; + + if (!count || !results || !storage) + return E_INVALIDARG; + + if (server_info) + FIXME("() non-NULL server_info not supported\n"); + + init_multi_qi(count, results, E_NOINTERFACE); + + if (!rclsid) + { + memset(&stat.clsid, 0, sizeof(stat.clsid)); + hr = IStorage_Stat(storage, &stat, STATFLAG_NONAME); + if (FAILED(hr)) + { + ERR("Failed to get CLSID from a storage.\n"); + return hr; + } + + rclsid = &stat.clsid; + } + + hr = CoCreateInstance(rclsid, outer, cls_context, &IID_IUnknown, (void **)&obj); + if (hr != S_OK) + return hr; + + /* Init from IStorage */ + hr = IUnknown_QueryInterface(obj, &IID_IPersistStorage, (void **)&ps); + if (FAILED(hr)) + ERR("failed to get IPersistStorage\n"); + + if (ps) + { + IPersistStorage_Load(ps, storage); + IPersistStorage_Release(ps); + } + + return return_multi_qi(obj, count, results, FALSE); +} diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index e90df05446e..de0ebe7cd31 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -108,7 +108,7 @@ @ stdcall CoGetDefaultContext(long ptr ptr) ole32.CoGetDefaultContext @ stub CoGetErrorInfo @ stdcall CoGetInstanceFromFile(ptr ptr ptr long long wstr long ptr) -@ stdcall CoGetInstanceFromIStorage(ptr ptr ptr long ptr long ptr) ole32.CoGetInstanceFromIStorage +@ stdcall CoGetInstanceFromIStorage(ptr ptr ptr long ptr long ptr) @ stdcall CoGetInterfaceAndReleaseStream(ptr ptr ptr) ole32.CoGetInterfaceAndReleaseStream @ stdcall CoGetMalloc(long ptr) @ stdcall CoGetMarshalSizeMax(ptr ptr ptr long ptr long) ole32.CoGetMarshalSizeMax diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 1ad8a4b1d1d..e63759c0609 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -3434,69 +3434,6 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx( return return_multi_qi(unk, cmq, pResults, TRUE); }
-/*********************************************************************** - * CoGetInstanceFromIStorage [OLE32.@] - */ -HRESULT WINAPI CoGetInstanceFromIStorage( - COSERVERINFO *server_info, - CLSID *rclsid, - IUnknown *outer, - DWORD cls_context, - IStorage *storage, - DWORD count, - MULTI_QI *results -) -{ - IPersistStorage *ps = NULL; - IUnknown* unk = NULL; - STATSTG stat; - HRESULT hr; - - if (count == 0 || !results || !storage) - return E_INVALIDARG; - - if (server_info) - FIXME("() non-NULL server_info not supported\n"); - - init_multi_qi(count, results, E_NOINTERFACE); - - /* optionally get CLSID from a file */ - if (!rclsid) - { - memset(&stat.clsid, 0, sizeof(stat.clsid)); - hr = IStorage_Stat(storage, &stat, STATFLAG_NONAME); - if (FAILED(hr)) - { - ERR("failed to get CLSID from a file\n"); - return hr; - } - - rclsid = &stat.clsid; - } - - hr = CoCreateInstance(rclsid, - outer, - cls_context, - &IID_IUnknown, - (void**)&unk); - - if (hr != S_OK) - return hr; - - /* init from IStorage */ - hr = IUnknown_QueryInterface(unk, &IID_IPersistStorage, (void**)&ps); - if (FAILED(hr)) - ERR("failed to get IPersistStorage\n"); - - if (ps) - { - IPersistStorage_Load(ps, storage); - IPersistStorage_Release(ps); - } - - return return_multi_qi(unk, count, results, FALSE); -} - /*********************************************************************** * CoLoadLibrary (OLE32.@) * diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index b1949eec8ec..6f44e298af8 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -36,7 +36,7 @@ @ stdcall CoGetCurrentProcess() @ stdcall CoGetDefaultContext(long ptr ptr) @ stdcall CoGetInstanceFromFile(ptr ptr ptr long long wstr long ptr) combase.CoGetInstanceFromFile -@ stdcall CoGetInstanceFromIStorage(ptr ptr ptr long ptr long ptr) +@ stdcall CoGetInstanceFromIStorage(ptr ptr ptr long ptr long ptr) combase.CoGetInstanceFromIStorage @ stdcall CoGetInterfaceAndReleaseStream(ptr ptr ptr) @ stdcall CoGetMalloc(long ptr) combase.CoGetMalloc @ stdcall CoGetMarshalSizeMax(ptr ptr ptr long ptr long)