Andrew Wesie : setupapi: Fix SetupDiGetDeviceRegistryProperty if property does not exist.

Alexandre Julliard julliard at winehq.org
Tue May 2 15:58:47 CDT 2017


Module: wine
Branch: master
Commit: e4645d60d72a9fbfbd745e275d4f90110bdceb4d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e4645d60d72a9fbfbd745e275d4f90110bdceb4d

Author: Andrew Wesie <awesie at gmail.com>
Date:   Mon May  1 22:14:57 2017 -0500

setupapi: Fix SetupDiGetDeviceRegistryProperty if property does not exist.

Signed-off-by: Andrew Wesie <awesie at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/setupapi/devinst.c       | 8 ++++++--
 dlls/setupapi/tests/devinst.c | 8 ++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index ffb5fad..4a852da 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -3125,7 +3125,9 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
         LONG l = RegQueryValueExA(devInfo->key, PropertyMap[Property].nameA,
                 NULL, PropertyRegDataType, PropertyBuffer, &size);
 
-        if (l == ERROR_MORE_DATA || !PropertyBufferSize)
+        if (l == ERROR_FILE_NOT_FOUND)
+            SetLastError(ERROR_INVALID_DATA);
+        else if (l == ERROR_MORE_DATA || !PropertyBufferSize)
             SetLastError(ERROR_INSUFFICIENT_BUFFER);
         else if (!l)
             ret = TRUE;
@@ -3186,7 +3188,9 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(
         LONG l = RegQueryValueExW(devInfo->key, PropertyMap[Property].nameW,
                 NULL, PropertyRegDataType, PropertyBuffer, &size);
 
-        if (l == ERROR_MORE_DATA || !PropertyBufferSize)
+        if (l == ERROR_FILE_NOT_FOUND)
+            SetLastError(ERROR_INVALID_DATA);
+        else if (l == ERROR_MORE_DATA || !PropertyBufferSize)
             SetLastError(ERROR_INSUFFICIENT_BUFFER);
         else if (!l)
             ret = TRUE;
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
index 6ca0e92..4df00b1 100644
--- a/dlls/setupapi/tests/devinst.c
+++ b/dlls/setupapi/tests/devinst.c
@@ -1053,6 +1053,10 @@ static void testDeviceRegistryPropertyA(void)
     todo_wine
     ok(!ret && GetLastError() == ERROR_INVALID_DATA,
      "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
+    ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_HARDWAREID,
+     NULL, NULL, 0, &size);
+    ok(!ret && GetLastError() == ERROR_INVALID_DATA,
+     "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
     pSetupDiDestroyDeviceInfoList(set);
 
     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, bogus, &key);
@@ -1158,6 +1162,10 @@ static void testDeviceRegistryPropertyW(void)
     todo_wine
     ok(!ret && GetLastError() == ERROR_INVALID_DATA,
      "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
+    ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_HARDWAREID,
+     NULL, NULL, 0, &size);
+    ok(!ret && GetLastError() == ERROR_INVALID_DATA,
+     "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
     pSetupDiDestroyDeviceInfoList(set);
 
     res = RegOpenKeyW(HKEY_LOCAL_MACHINE, bogus, &key);




More information about the wine-cvs mailing list