https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f3ac86713d7b519910e28…
commit f3ac86713d7b519910e28430b5909c164b8fbe44
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Tue Apr 19 00:09:27 2022 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Tue Apr 19 00:09:54 2022 +0200
[UMPNPMGR] PNP_CreateDevInst: A phantom device can only be created if the device did
not exist before
---
base/services/umpnpmgr/rpcserver.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/base/services/umpnpmgr/rpcserver.c b/base/services/umpnpmgr/rpcserver.c
index 140f1efa91a..25461975ee0 100644
--- a/base/services/umpnpmgr/rpcserver.c
+++ b/base/services/umpnpmgr/rpcserver.c
@@ -3052,6 +3052,7 @@ PNP_CreateDevInst(
PNP_RPC_STRING_LEN ulLength,
DWORD ulFlags)
{
+ HKEY hKey = NULL;
CONFIGRET ret = CR_SUCCESS;
DPRINT("PNP_CreateDevInst(%p %S %S %lu 0x%08lx)\n",
@@ -3075,8 +3076,18 @@ PNP_CreateDevInst(
return ret;
}
+ /* Try to open the device instance key */
+ RegOpenKeyEx(hEnumKey, pszDeviceID, 0, KEY_READ | KEY_WRITE, &hKey);
+
if (ulFlags & CM_CREATE_DEVNODE_PHANTOM)
{
+ /* Fail, if the device already exists */
+ if (hKey != NULL)
+ {
+ ret = CR_ALREADY_SUCH_DEVINST;
+ goto done;
+ }
+
/* Create the phantom device instance */
ret = CreateDeviceInstance(pszDeviceID, TRUE);
}
@@ -3086,6 +3097,10 @@ PNP_CreateDevInst(
ret = CreateDeviceInstance(pszDeviceID, FALSE);
}
+done:
+ if (hKey)
+ RegCloseKey(hKey);
+
DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
return ret;