From 1bbfd72afbda1e1b953ac6fef7a396ba5b518209 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Wed, 19 Sep 2007 17:49:17 -0700 Subject: [PATCH] setupapi: Add error checking to SetupDiCreateDeviceInfoW stub. --- dlls/setupapi/devinst.c | 41 +++++++++++++++++++++++++++++++++-- dlls/setupapi/tests/devinst.c | 3 --- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index e567670b8f..a1c27dd325 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -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); - FIXME("stub\n"); + 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; } /*********************************************************************** diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index e8fdc33665..05d42d8fa6 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -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: */ -- 2.32.0.93.g670b81a890