setupapi: Brace the guid in SetupDiOpenClassRegKeyExW.
This commit is contained in:
parent
9ae4e8d98e
commit
e6e96d3ea1
|
@ -1413,6 +1413,7 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW(
|
|||
PVOID Reserved)
|
||||
{
|
||||
LPWSTR lpGuidString;
|
||||
WCHAR bracedGuidString[39];
|
||||
HKEY hClassesKey;
|
||||
HKEY hClassKey;
|
||||
LPCWSTR lpKeyName;
|
||||
|
@ -1455,19 +1456,22 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW(
|
|||
RegCloseKey(hClassesKey);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
bracedGuidString[0] = '{';
|
||||
memcpy(&bracedGuidString[1], lpGuidString, 36*sizeof(WCHAR));
|
||||
bracedGuidString[37] = '}';
|
||||
bracedGuidString[38] = 0;
|
||||
RpcStringFreeW(&lpGuidString);
|
||||
|
||||
if (RegOpenKeyExW(hClassesKey,
|
||||
lpGuidString,
|
||||
bracedGuidString,
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hClassKey))
|
||||
{
|
||||
RpcStringFreeW(&lpGuidString);
|
||||
RegCloseKey(hClassesKey);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
RpcStringFreeW(&lpGuidString);
|
||||
RegCloseKey(hClassesKey);
|
||||
|
||||
return hClassKey;
|
||||
|
|
|
@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
|
|||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
TESTDLL = setupapi.dll
|
||||
IMPORTS = setupapi kernel32
|
||||
IMPORTS = setupapi advapi32 kernel32
|
||||
|
||||
CTESTS = \
|
||||
devinst.c \
|
||||
|
|
|
@ -87,6 +87,7 @@ static void test_SetupDiOpenClassRegKeyExA(void)
|
|||
/* This is a unique guid for testing purposes */
|
||||
GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04,
|
||||
0x00,0x11,0x95,0x5c,0x2b,0xdb}};
|
||||
static const CHAR guidString[] = "{6a55b5a4-3f65-11db-b704-0011955c2bdb}";
|
||||
HKEY hkey;
|
||||
|
||||
/* Check return value for non-existent key */
|
||||
|
@ -94,6 +95,30 @@ static void test_SetupDiOpenClassRegKeyExA(void)
|
|||
DIOCR_INSTALLER, NULL, NULL);
|
||||
ok(hkey == INVALID_HANDLE_VALUE,
|
||||
"returned %p (expected INVALID_HANDLE_VALUE)\n", hkey);
|
||||
|
||||
/* Test it for a key that exists */
|
||||
hkey = SetupDiOpenClassRegKey(NULL, KEY_ALL_ACCESS);
|
||||
if (hkey != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
HKEY classKey;
|
||||
if (RegCreateKeyA(hkey, guidString, &classKey) == ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(classKey);
|
||||
SetLastError(0xdeadbeef);
|
||||
classKey = pSetupDiOpenClassRegKeyExA(&guid, KEY_ALL_ACCESS,
|
||||
DIOCR_INSTALLER, NULL, NULL);
|
||||
ok(classKey != INVALID_HANDLE_VALUE,
|
||||
"opening class registry key failed with error %ld\n",
|
||||
GetLastError());
|
||||
if (classKey != INVALID_HANDLE_VALUE)
|
||||
RegCloseKey(classKey);
|
||||
RegDeleteKeyA(hkey, guidString);
|
||||
}
|
||||
else
|
||||
trace("failed to create registry key for test\n");
|
||||
}
|
||||
else
|
||||
trace("failed to open classes key\n");
|
||||
}
|
||||
|
||||
START_TEST(devinst)
|
||||
|
|
Loading…
Reference in New Issue