mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:02:56 +00:00
Fix SetupDiGetDeviceRegistryPropertyA, which should return the required size and the registry data type if the buffer is too small
(typical case when you call it 2 times: 1st time to get the required size, 2nd time to get real data) svn path=/trunk/; revision=18408
This commit is contained in:
parent
cf9a86c858
commit
543acff480
1 changed files with 17 additions and 14 deletions
|
@ -2157,7 +2157,7 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
|
||||||
DWORD PropertyBufferSizeW;
|
DWORD PropertyBufferSizeW;
|
||||||
PBYTE PropertyBufferW;
|
PBYTE PropertyBufferW;
|
||||||
|
|
||||||
TRACE("%04lx %p %ld %p %p %ld %p\n", (DWORD)devinfo, DeviceInfoData,
|
TRACE("%p %p %ld %p %p %ld %p\n", devinfo, DeviceInfoData,
|
||||||
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
|
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
|
||||||
RequiredSize);
|
RequiredSize);
|
||||||
|
|
||||||
|
@ -2173,18 +2173,25 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
|
||||||
PropertyBufferSizeW,
|
PropertyBufferSizeW,
|
||||||
&RequiredSizeW);
|
&RequiredSizeW);
|
||||||
|
|
||||||
if (!bResult)
|
if (bResult || GetLastError() == ERROR_MORE_DATA)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, PropertyBufferW);
|
|
||||||
return bResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
bIsStringProperty = (RegType == REG_SZ || RegType == REG_MULTI_SZ || RegType == REG_EXPAND_SZ);
|
bIsStringProperty = (RegType == REG_SZ || RegType == REG_MULTI_SZ || RegType == REG_EXPAND_SZ);
|
||||||
|
|
||||||
if (bIsStringProperty)
|
if (bIsStringProperty)
|
||||||
RequiredSizeA = RequiredSizeW / sizeof(WCHAR);
|
RequiredSizeA = RequiredSizeW / sizeof(WCHAR);
|
||||||
else
|
else
|
||||||
RequiredSizeA = RequiredSizeW;
|
RequiredSizeA = RequiredSizeW;
|
||||||
|
if (RequiredSize)
|
||||||
|
*RequiredSize = RequiredSizeA;
|
||||||
|
if (PropertyRegDataType)
|
||||||
|
*PropertyRegDataType = RegType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bResult)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, PropertyBufferW);
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
if (RequiredSizeA <= PropertyBufferSize)
|
if (RequiredSizeA <= PropertyBufferSize)
|
||||||
{
|
{
|
||||||
|
@ -2206,10 +2213,6 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, PropertyBufferW);
|
HeapFree(GetProcessHeap(), 0, PropertyBufferW);
|
||||||
if (PropertyRegDataType)
|
|
||||||
*PropertyRegDataType = RegType;
|
|
||||||
if (RequiredSize)
|
|
||||||
*RequiredSize = RequiredSizeA;
|
|
||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2877,13 +2880,13 @@ BOOL WINAPI SetupDiCallClassInstaller(
|
||||||
LPWSTR lpGuidString;
|
LPWSTR lpGuidString;
|
||||||
if (UuidToStringW((UUID*)&DeviceInfoData->ClassGuid, &lpGuidString) == RPC_S_OK)
|
if (UuidToStringW((UUID*)&DeviceInfoData->ClassGuid, &lpGuidString) == RPC_S_OK)
|
||||||
{
|
{
|
||||||
rc = RegQueryValueExW(hKey, L"Installer32", NULL, &dwRegType, NULL, &dwLength);
|
rc = RegQueryValueExW(hKey, lpGuidString, NULL, &dwRegType, NULL, &dwLength);
|
||||||
if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
|
if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
|
||||||
{
|
{
|
||||||
LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
|
LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
|
||||||
if (KeyBuffer != NULL)
|
if (KeyBuffer != NULL)
|
||||||
{
|
{
|
||||||
rc = RegQueryValueExW(hKey, L"Installer32", NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
|
rc = RegQueryValueExW(hKey, lpGuidString, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
|
||||||
if (rc == ERROR_SUCCESS)
|
if (rc == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
LPCWSTR ptr;
|
LPCWSTR ptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue