Commit 1bbfd72a authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

setupapi: Add error checking to SetupDiCreateDeviceInfoW stub.

parent c1ccd657
......@@ -752,13 +752,50 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(
DWORD CreationFlags,
PSP_DEVINFO_DATA DeviceInfoData)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
BOOL ret = FALSE;
TRACE("%p %s %s %s %p %x %p\n", DeviceInfoSet, debugstr_w(DeviceName),
debugstr_guid(ClassGuid), debugstr_w(DeviceDescription),
hwndParent, CreationFlags, DeviceInfoData);
if (!DeviceName)
{
SetLastError(ERROR_INVALID_DEVINST_NAME);
return FALSE;
}
if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!ClassGuid)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (set->magic == SETUP_DEVICE_INFO_SET_MAGIC)
{
if (IsEqualGUID(&set->ClassGuid, &GUID_NULL) ||
IsEqualGUID(ClassGuid, &set->ClassGuid))
ret = TRUE;
else
SetLastError(ERROR_CLASS_MISMATCH);
if ((CreationFlags & DICD_GENERATE_ID) && strchrW(DeviceName, '\\'))
{
SetLastError(ERROR_INVALID_DEVINST_NAME);
ret = FALSE;
}
if (ret)
{
FIXME("stub\n");
ret = FALSE;
}
}
else
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
return ret;
}
/***********************************************************************
......
......@@ -146,13 +146,11 @@ static void testCreateDeviceInfo(void)
}
SetLastError(0xdeadbeef);
ret = pSetupDiCreateDeviceInfoA(NULL, NULL, NULL, NULL, NULL, 0, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_DEVINST_NAME,
"Expected ERROR_INVALID_DEVINST_NAME, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pSetupDiCreateDeviceInfoA(NULL, "Root\\LEGACY_BOGUS\\0000", NULL,
NULL, NULL, 0, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
"Expected ERROR_INVALID_HANDLEHANDLE, got %08x\n", GetLastError());
set = pSetupDiCreateDeviceInfoList(&guid, NULL);
......@@ -166,7 +164,6 @@ static void testCreateDeviceInfo(void)
SetLastError(0xdeadbeef);
ret = pSetupDiCreateDeviceInfoA(set, "Root\\LEGACY_BOGUS\\0000", NULL,
NULL, NULL, 0, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
/* Finally, with all three required parameters, this succeeds: */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment