mirror of
https://github.com/reactos/reactos.git
synced 2025-05-22 02:25:18 +00:00
[SHELL32] IQueryAssociations: Fix path and length (#6656)
Implementing correct FindExecutable... JIRA issue: CORE-19493 - If there were filename extension, then skip to the extension by using PathFindExtensionW. - Use "open" verb if there is no default action if possible. - Set outlen at CQueryAssociations::ReturnString.
This commit is contained in:
parent
a83e40f6d1
commit
6ac153632f
1 changed files with 16 additions and 12 deletions
|
@ -96,6 +96,11 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::Init(
|
||||||
{
|
{
|
||||||
WCHAR *progId;
|
WCHAR *progId;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
LPCWSTR pchDotExt;
|
||||||
|
|
||||||
|
pchDotExt = PathFindExtensionW(pszAssoc);
|
||||||
|
if (pchDotExt && *pchDotExt)
|
||||||
|
pszAssoc = pchDotExt;
|
||||||
|
|
||||||
LONG ret = RegOpenKeyExW(HKEY_CLASSES_ROOT,
|
LONG ret = RegOpenKeyExW(HKEY_CLASSES_ROOT,
|
||||||
pszAssoc,
|
pszAssoc,
|
||||||
|
@ -216,7 +221,7 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString(
|
||||||
case ASSOCSTR_EXECUTABLE:
|
case ASSOCSTR_EXECUTABLE:
|
||||||
{
|
{
|
||||||
hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
|
hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
|
||||||
if (FAILED(hr))
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
{
|
{
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -535,28 +540,25 @@ HRESULT CQueryAssociations::GetValue(HKEY hkey, const WCHAR *name, void **data,
|
||||||
|
|
||||||
ret = RegQueryValueExW(hkey, name, 0, NULL, NULL, &size);
|
ret = RegQueryValueExW(hkey, name, 0, NULL, NULL, &size);
|
||||||
if (ret != ERROR_SUCCESS)
|
if (ret != ERROR_SUCCESS)
|
||||||
{
|
|
||||||
return HRESULT_FROM_WIN32(ret);
|
return HRESULT_FROM_WIN32(ret);
|
||||||
}
|
|
||||||
if (!size)
|
if (!size)
|
||||||
{
|
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
|
||||||
*data = HeapAlloc(GetProcessHeap(), 0, size);
|
*data = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
if (!*data)
|
if (!*data)
|
||||||
{
|
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
|
||||||
ret = RegQueryValueExW(hkey, name, 0, NULL, (LPBYTE)*data, &size);
|
ret = RegQueryValueExW(hkey, name, 0, NULL, (LPBYTE)*data, &size);
|
||||||
if (ret != ERROR_SUCCESS)
|
if (ret != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, *data);
|
HeapFree(GetProcessHeap(), 0, *data);
|
||||||
return HRESULT_FROM_WIN32(ret);
|
return HRESULT_FROM_WIN32(ret);
|
||||||
}
|
}
|
||||||
if(data_size)
|
|
||||||
{
|
if (data_size)
|
||||||
*data_size = size;
|
*data_size = size;
|
||||||
}
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,6 +606,8 @@ HRESULT CQueryAssociations::GetCommand(const WCHAR *extra, WCHAR **command)
|
||||||
{
|
{
|
||||||
/* check for default verb */
|
/* check for default verb */
|
||||||
hr = this->GetValue(hkeyShell, NULL, (void**)&extra_from_reg, NULL);
|
hr = this->GetValue(hkeyShell, NULL, (void**)&extra_from_reg, NULL);
|
||||||
|
if (FAILED(hr))
|
||||||
|
hr = this->GetValue(hkeyShell, L"open", (void**)&extra_from_reg, NULL);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
/* no default verb, try first subkey */
|
/* no default verb, try first subkey */
|
||||||
|
@ -662,7 +666,7 @@ HRESULT CQueryAssociations::GetExecutable(LPCWSTR pszExtra, LPWSTR path, DWORD p
|
||||||
WCHAR *pszEnd;
|
WCHAR *pszEnd;
|
||||||
|
|
||||||
HRESULT hr = this->GetCommand(pszExtra, &pszCommand);
|
HRESULT hr = this->GetCommand(pszExtra, &pszCommand);
|
||||||
if (FAILED(hr))
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
{
|
{
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -765,7 +769,7 @@ HRESULT CQueryAssociations::ReturnString(ASSOCF flags, LPWSTR out, DWORD *outlen
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = datalen;
|
*outlen = len = datalen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len)
|
if (len)
|
||||||
|
|
Loading…
Reference in a new issue