From 07f8340c1597d111dbb81cc35badde10d0ffe01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sat, 9 Sep 2006 17:10:51 +0000 Subject: [PATCH] Use Guid specified in device info set (if available) in SetupDiGetClassDevsExW. Update some documentation (taken from Wine) svn path=/trunk/; revision=23999 --- reactos/dll/win32/setupapi/devclass.c | 74 ++++++++++++++++----------- reactos/dll/win32/setupapi/devinst.c | 27 +++++++--- 2 files changed, 65 insertions(+), 36 deletions(-) diff --git a/reactos/dll/win32/setupapi/devclass.c b/reactos/dll/win32/setupapi/devclass.c index 9bd5f9a764f..f289e394323 100644 --- a/reactos/dll/win32/setupapi/devclass.c +++ b/reactos/dll/win32/setupapi/devclass.c @@ -129,6 +129,9 @@ SetupDiBuildClassInfoList( /*********************************************************************** * SetupDiBuildClassInfoListExA (SETUPAPI.@) * + * Returns a list of setup class GUIDs that identify the classes + * that are installed on a local or remote macine. + * * PARAMS * Flags [I] control exclusion of classes from the list. * ClassGuidList [O] pointer to a GUID-typed array that receives a list of setup class GUIDs. @@ -906,10 +909,10 @@ cleanup: * SETUP_CreateDevicesListFromEnumerator * * PARAMS - * list [I] Device info set to fill with discovered devices. + * list [IO] Device info set to fill with discovered devices. * pClassGuid [I] If specified, only devices which belong to this class will be added. * Enumerator [I] Location to search devices to add. - * hEnumeratorKey [O] Registry key corresponding to Enumerator key. Must have KEY_ENUMERATE_SUB_KEYS right. + * hEnumeratorKey [I] Registry key corresponding to Enumerator key. Must have KEY_ENUMERATE_SUB_KEYS right. * * RETURNS * Success: ERROR_SUCCESS. @@ -1169,45 +1172,58 @@ SetupDiGetClassDevsExW( if (Flags & DIGCF_PROFILE) FIXME(": flag DIGCF_PROFILE ignored\n"); - /* FIXME: list->ClassGuid is never used! */ - if (Flags & DIGCF_ALLCLASSES) - pClassGuid = NULL; - else if (ClassGuid) - pClassGuid = ClassGuid; - else - { - SetLastError(ERROR_INVALID_PARAMETER); - goto cleanup; - } - if (Flags & DIGCF_DEVICEINTERFACE) - { rc = SETUP_CreateInterfaceList(list, MachineName, ClassGuid, Enumerator, Flags & DIGCF_PRESENT); - if (rc != ERROR_SUCCESS) - { - SetLastError(rc); - goto cleanup; - } - ret = hDeviceInfo; - } else { + /* Determine which class(es) should be included in the deviceset */ if (Flags & DIGCF_ALLCLASSES) - rc = SETUP_CreateDevicesList(list, MachineName, NULL, Enumerator); + { + /* The caller wants all classes. Check if + * the deviceset limits us to one class */ + if (IsEqualIID(&list->ClassGuid, &GUID_NULL)) + pClassGuid = NULL; + else + pClassGuid = &list->ClassGuid; + } else if (ClassGuid) - rc = SETUP_CreateDevicesList(list, MachineName, pClassGuid, Enumerator); + { + /* The caller wants one class. Check if it matches deviceset class */ + if (IsEqualIID(&list->ClassGuid, ClassGuid) + || IsEqualIID(&list->ClassGuid, &GUID_NULL)) + { + pClassGuid = ClassGuid; + } + else + { + SetLastError(ERROR_INVALID_PARAMETER); + goto cleanup; + } + } + else if (!IsEqualIID(&list->ClassGuid, &GUID_NULL)) + { + /* No class specified. Try to use the one of the deviceset */ + if (IsEqualIID(&list->ClassGuid, &GUID_NULL)) + pClassGuid = &list->ClassGuid; + else + { + SetLastError(ERROR_INVALID_PARAMETER); + goto cleanup; + } + } else { SetLastError(ERROR_INVALID_PARAMETER); goto cleanup; } - if (rc != ERROR_SUCCESS) - { - SetLastError(rc); - goto cleanup; - } - ret = hDeviceInfo; + rc = SETUP_CreateDevicesList(list, MachineName, pClassGuid, Enumerator); } + if (rc != ERROR_SUCCESS) + { + SetLastError(rc); + goto cleanup; + } + ret = hDeviceInfo; cleanup: if (!DeviceInfoSet && hDeviceInfo != INVALID_HANDLE_VALUE && hDeviceInfo != ret) diff --git a/reactos/dll/win32/setupapi/devinst.c b/reactos/dll/win32/setupapi/devinst.c index 7cdd36391ab..909196359d7 100644 --- a/reactos/dll/win32/setupapi/devinst.c +++ b/reactos/dll/win32/setupapi/devinst.c @@ -83,7 +83,7 @@ SetupDiCreateDeviceInfoList( IN CONST GUID *ClassGuid OPTIONAL, IN HWND hwndParent OPTIONAL) { - return SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent, NULL, NULL); + return SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent, NULL, NULL); } /*********************************************************************** @@ -112,8 +112,7 @@ SetupDiCreateDeviceInfoListExA( hDevInfo = SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent, MachineNameW, Reserved); - if (MachineNameW) - MyFree(MachineNameW); + MyFree(MachineNameW); return hDevInfo; } @@ -148,6 +147,20 @@ GetErrorCodeFromCrCode(const IN CONFIGRET cr) /*********************************************************************** * SetupDiCreateDeviceInfoListExW (SETUPAPI.@) + * + * Create an empty DeviceInfoSet list. + * + * PARAMS + * ClassGuid [I] if not NULL only devices with GUID ClcassGuid are associated + * with this list. + * hwndParent [I] hwnd needed for interface related actions. + * MachineName [I] name of machine to create emtpy DeviceInfoSet list, if NULL + * local regestry will be used. + * Reserved [I] must be NULL + * + * RETURNS + * Success: empty list. + * Failure: INVALID_HANDLE_VALUE. */ HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW( @@ -175,7 +188,7 @@ SetupDiCreateDeviceInfoListExW( SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto cleanup; } - memset(list, 0, sizeof(struct DeviceInfoSet)); + ZeroMemory(list, sizeof(struct DeviceInfoSet)); list->magic = SETUP_DEV_INFO_SET_MAGIC; memcpy( @@ -805,7 +818,7 @@ CreateDeviceInfoElement( SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - memset(deviceInfo, 0, size); + ZeroMemory(deviceInfo, size); cr = CM_Locate_DevNode_ExW(&deviceInfo->dnDevInst, (DEVINSTID_W)InstancePath, CM_LOCATE_DEVNODE_PHANTOM, list->hMachine); if (cr != CR_SUCCESS) @@ -1510,7 +1523,7 @@ SetupDiCallClassInstaller( coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement)); if (!coinstaller) continue; - memset(coinstaller, 0, sizeof(struct CoInstallerElement)); + ZeroMemory(coinstaller, sizeof(struct CoInstallerElement)); if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS) InsertTailList(&DeviceCoInstallersListHead, &coinstaller->ListEntry); else @@ -1554,7 +1567,7 @@ SetupDiCallClassInstaller( coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement)); if (!coinstaller) continue; - memset(coinstaller, 0, sizeof(struct CoInstallerElement)); + ZeroMemory(coinstaller, sizeof(struct CoInstallerElement)); if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS) InsertTailList(&ClassCoInstallersListHead, &coinstaller->ListEntry); else