https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2037bab6c4ae50a6b92ddf2d7294c6dbb420b89a
commit 2037bab6c4ae50a6b92ddf2d7294c6dbb420b89a Author: Eric Kohl <eric.k...@reactos.org> AuthorDate: Sun Dec 2 15:53:22 2018 +0100 Commit: Eric Kohl <eric.k...@reactos.org> CommitDate: Mon Dec 3 22:03:38 2018 +0100 [SETUPAPI] GetDeviceInstanceKeyPath: Trying to open the hardware key opens the software key and vice versa. Fix it by swapping the code paths. --- dll/win32/setupapi/cfgmgr.c | 96 ++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/dll/win32/setupapi/cfgmgr.c b/dll/win32/setupapi/cfgmgr.c index 2c56fd1caa..98b09139b7 100644 --- a/dll/win32/setupapi/cfgmgr.c +++ b/dll/win32/setupapi/cfgmgr.c @@ -236,19 +236,39 @@ GetDeviceInstanceKeyPath( { /* Software Key Path */ - if (ulFlags & CM_REGISTRY_CONFIG) + ulTransferLength = 300 * sizeof(WCHAR); + ulLength = 300 * sizeof(WCHAR); + ret = PNP_GetDeviceRegProp(BindingHandle, + pszDeviceInst, + CM_DRP_DRIVER, + &ulType, + (PVOID)pszBuffer, + &ulTransferLength, + &ulLength, + 0); + if (ret != CR_SUCCESS) { - SplitDeviceInstanceId(pszDeviceInst, - pszBuffer, - pszInstancePath); + ERR("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret); + goto done; + } + + TRACE("szBuffer: %S\n", pszBuffer); + + SplitDeviceInstanceId(pszBuffer, + pszBuffer, + pszInstancePath); + TRACE("szBuffer: %S\n", pszBuffer); + + if (ulFlags & CM_REGISTRY_CONFIG) + { if (ulHardwareProfile == 0) { wsprintfW(pszKeyPath, L"%s\\%s\\%s\\%s", L"System\\CurrentControlSet\\Hardware Profiles", L"Current", - L"System\\CurrentControlSet\\Enum", + L"System\\CurrentControlSet\\Control\\Class", pszBuffer); } else @@ -257,29 +277,15 @@ GetDeviceInstanceKeyPath( L"%s\\%04lu\\%s\\%s", L"System\\CurrentControlSet\\Hardware Profiles", ulHardwareProfile, - L"System\\CurrentControlSet\\Enum", + L"System\\CurrentControlSet\\Control\\Class", pszBuffer); } } - else if (ulFlags & CM_REGISTRY_USER) - { - wsprintfW(pszKeyPath, - L"%s\\%s", - L"System\\CurrentControlSet\\Enum", - pszDeviceInst); - - wcscpy(pszInstancePath, - L"Device Parameters"); - } else { - SplitDeviceInstanceId(pszDeviceInst, - pszBuffer, - pszInstancePath); - wsprintfW(pszKeyPath, L"%s\\%s", - L"System\\CurrentControlSet\\Enum", + L"System\\CurrentControlSet\\Control\\Class", pszBuffer); } } @@ -287,39 +293,19 @@ GetDeviceInstanceKeyPath( { /* Hardware Key Path */ - ulTransferLength = 300 * sizeof(WCHAR); - ulLength = 300 * sizeof(WCHAR); - ret = PNP_GetDeviceRegProp(BindingHandle, - pszDeviceInst, - CM_DRP_DRIVER, - &ulType, - (PVOID)pszBuffer, - &ulTransferLength, - &ulLength, - 0); - if (ret != CR_SUCCESS) - { - ERR("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret); - goto done; - } - - TRACE("szBuffer: %S\n", pszBuffer); - - SplitDeviceInstanceId(pszBuffer, - pszBuffer, - pszInstancePath); - - TRACE("szBuffer: %S\n", pszBuffer); - if (ulFlags & CM_REGISTRY_CONFIG) { + SplitDeviceInstanceId(pszDeviceInst, + pszBuffer, + pszInstancePath); + if (ulHardwareProfile == 0) { wsprintfW(pszKeyPath, L"%s\\%s\\%s\\%s", L"System\\CurrentControlSet\\Hardware Profiles", L"Current", - L"System\\CurrentControlSet\\Control\\Class", + L"System\\CurrentControlSet\\Enum", pszBuffer); } else @@ -328,15 +314,29 @@ GetDeviceInstanceKeyPath( L"%s\\%04lu\\%s\\%s", L"System\\CurrentControlSet\\Hardware Profiles", ulHardwareProfile, - L"System\\CurrentControlSet\\Control\\Class", + L"System\\CurrentControlSet\\Enum", pszBuffer); } } + else if (ulFlags & CM_REGISTRY_USER) + { + wsprintfW(pszKeyPath, + L"%s\\%s", + L"System\\CurrentControlSet\\Enum", + pszDeviceInst); + + wcscpy(pszInstancePath, + L"Device Parameters"); + } else { + SplitDeviceInstanceId(pszDeviceInst, + pszBuffer, + pszInstancePath); + wsprintfW(pszKeyPath, L"%s\\%s", - L"System\\CurrentControlSet\\Control\\Class", + L"System\\CurrentControlSet\\Enum", pszBuffer); } }