https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a7a222b52db416283eeca2aa0e3d0a923d2881e9

commit a7a222b52db416283eeca2aa0e3d0a923d2881e9
Author:     Eric Kohl <[email protected]>
AuthorDate: Sat Apr 23 16:59:47 2022 +0200
Commit:     Eric Kohl <[email protected]>
CommitDate: Sat Apr 23 16:59:47 2022 +0200

    [UMPNPMGR] PNP_CreateDevInst: Convert a phantom device to a normal device
---
 base/services/umpnpmgr/rpcserver.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/base/services/umpnpmgr/rpcserver.c 
b/base/services/umpnpmgr/rpcserver.c
index 26b9ab88ab3..50cf19b261c 100644
--- a/base/services/umpnpmgr/rpcserver.c
+++ b/base/services/umpnpmgr/rpcserver.c
@@ -3057,6 +3057,7 @@ PNP_CreateDevInst(
     DWORD ulFlags)
 {
     HKEY hKey = NULL;
+    DWORD dwSize, dwPhantom;
     CONFIGRET ret = CR_SUCCESS;
 
     DPRINT("PNP_CreateDevInst(%p %S %S %lu 0x%08lx)\n",
@@ -3104,8 +3105,26 @@ PNP_CreateDevInst(
             goto done;
         }
 
-        /* Create the device instance */
-        ret = CreateDeviceInstance(pszDeviceID, FALSE);
+        /* If it does not already exist ... */
+        if (hKey == NULL)
+        {
+            /* Create the device instance */
+            ret = CreateDeviceInstance(pszDeviceID, FALSE);
+
+            /* Open the device instance key */
+            RegOpenKeyEx(hEnumKey, pszDeviceID, 0, KEY_READ | KEY_WRITE, 
&hKey);
+        }
+
+        /* If the device instance is a phantom, turn it into an non-phantom */
+        if (hKey != NULL)
+        {
+            dwPhantom = 0;
+            dwSize = sizeof(DWORD);
+            RegQueryValueEx(hKey, L"Phantom", NULL, NULL, (PBYTE)&dwPhantom, 
&dwSize);
+
+            if (dwPhantom != 0)
+                RegDeleteValue(hKey, L"Phantom");
+        }
     }
 
 done:

Reply via email to