combase: Move ProgIDFromCLSID().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-08-10 11:12:50 +03:00 committed by Alexandre Julliard
parent ea8d11a8e5
commit 0213ebefbe
4 changed files with 86 additions and 75 deletions

View File

@ -33,6 +33,28 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
#define CHARS_IN_GUID 39
struct comclassredirect_data
{
ULONG size;
ULONG flags;
DWORD model;
GUID clsid;
GUID alias;
GUID clsid2;
GUID tlbid;
ULONG name_len;
ULONG name_offset;
ULONG progid_len;
ULONG progid_offset;
ULONG clrdata_len;
ULONG clrdata_offset;
DWORD miscstatus;
DWORD miscstatuscontent;
DWORD miscstatusthumbnail;
DWORD miscstatusicon;
DWORD miscstatusdocprint;
};
static NTSTATUS create_key(HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr)
{
NTSTATUS status = NtCreateKey((HANDLE *)retkey, access, attr, 0, NULL, 0, NULL);
@ -831,6 +853,68 @@ done:
return hr;
}
/******************************************************************************
* ProgIDFromCLSID (combase.@)
*/
HRESULT WINAPI DECLSPEC_HOTPATCH ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *progid)
{
ACTCTX_SECTION_KEYED_DATA data;
LONG progidlen = 0;
HKEY hkey;
HRESULT hr;
if (!progid)
return E_INVALIDARG;
*progid = NULL;
data.cbSize = sizeof(data);
if (FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
clsid, &data))
{
struct comclassredirect_data *comclass = (struct comclassredirect_data *)data.lpData;
if (comclass->progid_len)
{
WCHAR *ptrW;
*progid = CoTaskMemAlloc(comclass->progid_len + sizeof(WCHAR));
if (!*progid) return E_OUTOFMEMORY;
ptrW = (WCHAR *)((BYTE *)comclass + comclass->progid_offset);
memcpy(*progid, ptrW, comclass->progid_len + sizeof(WCHAR));
return S_OK;
}
else
return REGDB_E_CLASSNOTREG;
}
hr = open_key_for_clsid(clsid, L"ProgID", KEY_READ, &hkey);
if (FAILED(hr))
return hr;
if (RegQueryValueW(hkey, NULL, NULL, &progidlen))
hr = REGDB_E_CLASSNOTREG;
if (hr == S_OK)
{
*progid = CoTaskMemAlloc(progidlen * sizeof(WCHAR));
if (*progid)
{
if (RegQueryValueW(hkey, NULL, *progid, &progidlen))
{
hr = REGDB_E_CLASSNOTREG;
CoTaskMemFree(*progid);
*progid = NULL;
}
}
else
hr = E_OUTOFMEMORY;
}
RegCloseKey(hkey);
return hr;
}
static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr)
{
ULONG i;

View File

@ -279,7 +279,7 @@
@ stub NdrExtStubInitialize
@ stub NdrOleDllGetClassObject
@ stub NdrpFindInterface
@ stdcall ProgIDFromCLSID(ptr ptr) ole32.ProgIDFromCLSID
@ stdcall ProgIDFromCLSID(ptr ptr)
@ stdcall PropVariantClear(ptr)
@ stdcall PropVariantCopy(ptr ptr)
@ stub ReleaseFuncDescs

View File

@ -2485,79 +2485,6 @@ HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey
return S_OK;
}
/******************************************************************************
* ProgIDFromCLSID [OLE32.@]
*
* Converts a class id into the respective program ID.
*
* PARAMS
* clsid [I] Class ID, as found in registry.
* ppszProgID [O] Associated ProgID.
*
* RETURNS
* S_OK
* E_OUTOFMEMORY
* REGDB_E_CLASSNOTREG if the given clsid has no associated ProgID
*/
HRESULT WINAPI DECLSPEC_HOTPATCH ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *ppszProgID)
{
static const WCHAR wszProgID[] = {'P','r','o','g','I','D',0};
ACTCTX_SECTION_KEYED_DATA data;
HKEY hkey;
HRESULT ret;
LONG progidlen = 0;
if (!ppszProgID)
return E_INVALIDARG;
*ppszProgID = NULL;
data.cbSize = sizeof(data);
if (FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
clsid, &data))
{
struct comclassredirect_data *comclass = (struct comclassredirect_data*)data.lpData;
if (comclass->progid_len)
{
WCHAR *ptrW;
*ppszProgID = CoTaskMemAlloc(comclass->progid_len + sizeof(WCHAR));
if (!*ppszProgID) return E_OUTOFMEMORY;
ptrW = (WCHAR*)((BYTE*)comclass + comclass->progid_offset);
memcpy(*ppszProgID, ptrW, comclass->progid_len + sizeof(WCHAR));
return S_OK;
}
else
return REGDB_E_CLASSNOTREG;
}
ret = COM_OpenKeyForCLSID(clsid, wszProgID, KEY_READ, &hkey);
if (FAILED(ret))
return ret;
if (RegQueryValueW(hkey, NULL, NULL, &progidlen))
ret = REGDB_E_CLASSNOTREG;
if (ret == S_OK)
{
*ppszProgID = CoTaskMemAlloc(progidlen * sizeof(WCHAR));
if (*ppszProgID)
{
if (RegQueryValueW(hkey, NULL, *ppszProgID, &progidlen)) {
ret = REGDB_E_CLASSNOTREG;
CoTaskMemFree(*ppszProgID);
*ppszProgID = NULL;
}
}
else
ret = E_OUTOFMEMORY;
}
RegCloseKey(hkey);
return ret;
}
/******************************************************************************
* CLSIDFromProgID [OLE32.@]
*

View File

@ -237,7 +237,7 @@
@ stdcall OleTranslateAccelerator(ptr ptr ptr)
@ stdcall OleUninitialize()
@ stub OpenOrCreateStream
@ stdcall ProgIDFromCLSID(ptr ptr)
@ stdcall ProgIDFromCLSID(ptr ptr) combase.ProgIDFromCLSID
@ stdcall PropStgNameToFmtId(wstr ptr)
@ stdcall PropSysAllocString(wstr)
@ stdcall PropSysFreeString(wstr)