From b10d99a3713c7c1a579132446b26abeeed63b683 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 10 Aug 2020 11:12:52 +0300 Subject: [PATCH] combase: Move CLSIDFromString(). Signed-off-by: Nikolay Sivov Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/combase/combase.c | 22 +++++++++++++ dlls/combase/combase.spec | 2 +- dlls/ole32/compobj.c | 69 --------------------------------------- dlls/ole32/ole32.spec | 2 +- 4 files changed, 24 insertions(+), 71 deletions(-) diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index 2d202c796d5..2bfd1d79a7d 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -1053,6 +1053,28 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid) return clsid_from_string_reg(progid, clsid); } +/****************************************************************************** + * CLSIDFromString (combase.@) + */ +HRESULT WINAPI CLSIDFromString(LPCOLESTR str, LPCLSID clsid) +{ + CLSID tmp_id; + HRESULT hr; + + if (!clsid) + return E_INVALIDARG; + + if (guid_from_string(str, clsid)) + return S_OK; + + /* It appears a ProgID is also valid */ + hr = clsid_from_string_reg(str, &tmp_id); + if (SUCCEEDED(hr)) + *clsid = tmp_id; + + return hr; +} + static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr) { ULONG i; diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 4e5c5a9dc9e..97e8f254dcb 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -68,7 +68,7 @@ @ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr) @ stub CLSIDFromOle1Class @ stdcall CLSIDFromProgID(wstr ptr) -@ stdcall CLSIDFromString(wstr ptr) ole32.CLSIDFromString +@ stdcall CLSIDFromString(wstr ptr) @ stub CleanupOleStateInAllTls @ stdcall CleanupTlsOleState(ptr) @ stub ClearCleanupFlag diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 91ff8124282..ff0c352c645 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -2257,75 +2257,6 @@ static BOOL guid_from_string(LPCWSTR s, GUID *id) return FALSE; } -/*****************************************************************************/ - -static HRESULT clsid_from_string_reg(LPCOLESTR progid, CLSID *clsid) -{ - static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 }; - WCHAR buf2[CHARS_IN_GUID]; - LONG buf2len = sizeof(buf2); - HKEY xhkey; - WCHAR *buf; - - memset(clsid, 0, sizeof(*clsid)); - buf = HeapAlloc( GetProcessHeap(),0,(lstrlenW(progid)+8) * sizeof(WCHAR) ); - if (!buf) return E_OUTOFMEMORY; - lstrcpyW( buf, progid ); - lstrcatW( buf, clsidW ); - if (open_classes_key(HKEY_CLASSES_ROOT, buf, MAXIMUM_ALLOWED, &xhkey)) - { - HeapFree(GetProcessHeap(),0,buf); - WARN("couldn't open key for ProgID %s\n", debugstr_w(progid)); - return CO_E_CLASSSTRING; - } - HeapFree(GetProcessHeap(),0,buf); - - if (RegQueryValueW(xhkey,NULL,buf2,&buf2len)) - { - RegCloseKey(xhkey); - WARN("couldn't query clsid value for ProgID %s\n", debugstr_w(progid)); - return CO_E_CLASSSTRING; - } - RegCloseKey(xhkey); - return guid_from_string(buf2, clsid) ? S_OK : CO_E_CLASSSTRING; -} - -/****************************************************************************** - * CLSIDFromString [OLE32.@] - * - * Converts a unique identifier from its string representation into - * the GUID struct. - * - * PARAMS - * idstr [I] The string representation of the GUID. - * id [O] GUID converted from the string. - * - * RETURNS - * S_OK on success - * CO_E_CLASSSTRING if idstr is not a valid CLSID - * - * SEE ALSO - * StringFromCLSID - */ -HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id ) -{ - HRESULT ret = CO_E_CLASSSTRING; - CLSID tmp_id; - - if (!id) - return E_INVALIDARG; - - if (guid_from_string(idstr, id)) - return S_OK; - - /* It appears a ProgID is also valid */ - ret = clsid_from_string_reg(idstr, &tmp_id); - if(SUCCEEDED(ret)) - *id = tmp_id; - - return ret; -} - /****************************************************************************** * IIDFromString [OLE32.@] * diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index ce5d7987d94..f71fd52032b 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -5,7 +5,7 @@ @ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr) combase.CLIPFORMAT_UserUnmarshal @ stdcall CLSIDFromProgID(wstr ptr) combase.CLSIDFromProgID @ stdcall CLSIDFromProgIDEx(wstr ptr) -@ stdcall CLSIDFromString(wstr ptr) +@ stdcall CLSIDFromString(wstr ptr) combase.CLSIDFromString @ stdcall CoAddRefServerProcess() @ stdcall CoAllowSetForegroundWindow(ptr ptr) @ stdcall CoBuildVersion()