[UMPNPMGR] PNP_CreateDevInst: Support the creation of phantom devices

This commit is contained in:
Eric Kohl 2022-04-18 19:53:18 +02:00
parent aa80cfb46e
commit 8897a890c9

View file

@ -2877,8 +2877,11 @@ done:
}
static CONFIGRET
CreateDeviceInstance(LPWSTR pszDeviceID)
static
CONFIGRET
CreateDeviceInstance(
_In_ LPWSTR pszDeviceID,
_In_ BOOL bPhantomDevice)
{
WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
WCHAR szDevice[MAX_DEVICE_ID_LEN];
@ -2962,6 +2965,17 @@ CreateDeviceInstance(LPWSTR pszDeviceID)
return CR_REGISTRY_ERROR;
}
if (bPhantomDevice)
{
DWORD dwPhantomValue = 1;
RegSetValueExW(hKeyInstance,
L"Phantom",
0,
REG_DWORD,
(PBYTE)&dwPhantomValue,
sizeof(dwPhantomValue));
}
/* Create the 'Control' sub key */
lError = RegCreateKeyExW(hKeyInstance,
L"Control",
@ -3061,8 +3075,16 @@ PNP_CreateDevInst(
return ret;
}
/* Create the device instance */
ret = CreateDeviceInstance(pszDeviceID);
if (ulFlags & CM_CREATE_DEVNODE_PHANTOM)
{
/* Create the phantom device instance */
ret = CreateDeviceInstance(pszDeviceID, TRUE);
}
else
{
/* Create the device instance */
ret = CreateDeviceInstance(pszDeviceID, FALSE);
}
DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);