mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[UMPNPMGR] PNP_GetDeviceListSize: Implement the buffer size calculation for given enumerators and take care of the terminating double Unicode null character.
This commit is contained in:
parent
e3c8002dfc
commit
7c66247343
1 changed files with 68 additions and 2 deletions
|
@ -746,12 +746,73 @@ GetDeviceInstanceListSize(
|
||||||
RegCloseKey(hDeviceKey);
|
RegCloseKey(hDeviceKey);
|
||||||
|
|
||||||
/* Return the largest possible buffer size */
|
/* Return the largest possible buffer size */
|
||||||
*pulLength = (dwSubKeys * (wcslen(pszDevice) + 1 + dwMaxSubKeyLength + 1)) + 1;
|
*pulLength = dwSubKeys * (wcslen(pszDevice) + 1 + dwMaxSubKeyLength + 1);
|
||||||
|
|
||||||
return CR_SUCCESS;
|
return CR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
CONFIGRET
|
||||||
|
GetEnumeratorInstanceListSize(
|
||||||
|
_In_ LPCWSTR pszEnumerator,
|
||||||
|
_Out_ PULONG pulLength)
|
||||||
|
{
|
||||||
|
WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
|
||||||
|
WCHAR szPathBuffer[512];
|
||||||
|
HKEY hEnumeratorKey;
|
||||||
|
DWORD dwIndex, dwDeviceLength, dwBufferLength;
|
||||||
|
DWORD dwError;
|
||||||
|
CONFIGRET ret = CR_SUCCESS;
|
||||||
|
|
||||||
|
*pulLength = 0;
|
||||||
|
|
||||||
|
/* Open the enumerator key */
|
||||||
|
dwError = RegOpenKeyExW(hEnumKey,
|
||||||
|
pszEnumerator,
|
||||||
|
0,
|
||||||
|
KEY_ENUMERATE_SUB_KEYS,
|
||||||
|
&hEnumeratorKey);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
|
||||||
|
return CR_REGISTRY_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (dwIndex = 0; ; dwIndex++)
|
||||||
|
{
|
||||||
|
dwDeviceLength = MAX_DEVICE_ID_LEN;
|
||||||
|
dwError = RegEnumKeyExW(hEnumeratorKey,
|
||||||
|
dwIndex,
|
||||||
|
szDeviceBuffer,
|
||||||
|
&dwDeviceLength,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
break;
|
||||||
|
|
||||||
|
wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
|
||||||
|
DPRINT("Path: %S\n", szPathBuffer);
|
||||||
|
|
||||||
|
ret = GetDeviceInstanceListSize(szPathBuffer, &dwBufferLength);
|
||||||
|
if (ret != CR_SUCCESS)
|
||||||
|
{
|
||||||
|
*pulLength = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pulLength += dwBufferLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the enumerator key */
|
||||||
|
RegCloseKey(hEnumeratorKey);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Function 11 */
|
/* Function 11 */
|
||||||
DWORD
|
DWORD
|
||||||
WINAPI
|
WINAPI
|
||||||
|
@ -840,7 +901,8 @@ PNP_GetDeviceListSize(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = CR_CALL_NOT_IMPLEMENTED;
|
ret = GetEnumeratorInstanceListSize(pszFilter,
|
||||||
|
pulLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* CM_GETIDLIST_FILTER_NONE */
|
else /* CM_GETIDLIST_FILTER_NONE */
|
||||||
|
@ -848,6 +910,10 @@ PNP_GetDeviceListSize(
|
||||||
ret = CR_CALL_NOT_IMPLEMENTED;
|
ret = CR_CALL_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add one character for the terminating double UNICODE_NULL */
|
||||||
|
if (ret == CR_SUCCESS)
|
||||||
|
(*pulLength) += 1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue