From 3cd4b118a5c7cf627eab677238f11fd257be01b8 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Wed, 19 Sep 2007 17:57:40 -0700 Subject: [PATCH] Implement SetupDiRegisterDeviceInfo --- dlls/setupapi/devinst.c | 28 ++++++++++++++++++++++++++-- dlls/setupapi/tests/devinst.c | 5 ----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 9c6b37b..0bdabd4 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1060,11 +1060,35 @@ BOOL WINAPI SetupDiRegisterDeviceInfo( PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData) { + struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet; + struct DeviceInfo *devInfo; + TRACE("%p %p %08x %p %p %p\n", DeviceInfoSet, DeviceInfoData, Flags, CompareProc, CompareContext, DupDeviceInfoData); - FIXME("\n"); - return FALSE; + if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA) + || !DeviceInfoData->Reserved) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; + if (devInfo->phantom) + { + devInfo->phantom = FALSE; + RegDeleteValueW(devInfo->key, Phantom); + } + return TRUE; } /*********************************************************************** diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index a18f91a..0ef9047 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -289,7 +289,6 @@ static void testRegisterDeviceInfo(void) } SetLastError(0xdeadbeef); ret = pSetupDiRegisterDeviceInfo(NULL, NULL, 0, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); ret = pSetupDiRegisterDeviceInfo(NULL, NULL, 0, NULL, NULL, NULL); @@ -301,18 +300,15 @@ static void testRegisterDeviceInfo(void) SetLastError(0xdeadbeef); ret = pSetupDiRegisterDeviceInfo(set, NULL, 0, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); SetLastError(0xdeadbeef); ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); devInfo.cbSize = sizeof(devInfo); SetLastError(0xdeadbeef); ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); ret = pSetupDiCreateDeviceInfoA(set, "USB\\BOGUS\\0000", &guid, @@ -324,7 +320,6 @@ static void testRegisterDeviceInfo(void) /* If it already existed, registering it again will fail */ ret = pSetupDiRegisterDeviceInfo(set, &devInfo, 0, NULL, NULL, NULL); - todo_wine ok(ret, "SetupDiCreateDeviceInfoA failed: %d\n", GetLastError()); } /* FIXME: On Win2K+ systems, this is now persisted to registry in -- 1.4.1