mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 12:43:05 +00:00
[UMPNPMGR] PNP_CreateDevInst: Do not create a new device while generating a device id
This commit is contained in:
parent
11886ebec2
commit
426687becf
1 changed files with 20 additions and 21 deletions
|
@ -3012,23 +3012,25 @@ PNP_CreateDevInst(
|
||||||
{
|
{
|
||||||
WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
|
WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
|
||||||
DWORD dwInstanceNumber;
|
DWORD dwInstanceNumber;
|
||||||
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
|
HKEY hKey;
|
||||||
|
|
||||||
/* Generated ID is: Root\<Device ID>\<Instance number> */
|
/* Generated ID is: Root\<Device ID>\<Instance number> */
|
||||||
dwInstanceNumber = 0;
|
dwInstanceNumber = 0;
|
||||||
do
|
while (dwError == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
swprintf(szGeneratedInstance, L"Root\\%ls\\%04lu",
|
swprintf(szGeneratedInstance, L"Root\\%ls\\%04lu",
|
||||||
pszDeviceID, dwInstanceNumber);
|
pszDeviceID, dwInstanceNumber);
|
||||||
|
|
||||||
/* Try to create a device instance with this ID */
|
/* Try to open the enum key of the device instance */
|
||||||
ret = CreateDeviceInstance(szGeneratedInstance);
|
dwError = RegOpenKeyEx(hEnumKey, szGeneratedInstance, 0, KEY_QUERY_VALUE, &hKey);
|
||||||
|
if (dwError == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
RegCloseKey(hKey);
|
||||||
dwInstanceNumber++;
|
dwInstanceNumber++;
|
||||||
}
|
}
|
||||||
while (ret == CR_ALREADY_SUCH_DEVINST);
|
}
|
||||||
|
|
||||||
if (ret == CR_SUCCESS)
|
|
||||||
{
|
|
||||||
/* pszDeviceID is an out parameter too for generated IDs */
|
/* pszDeviceID is an out parameter too for generated IDs */
|
||||||
if (wcslen(szGeneratedInstance) > ulLength)
|
if (wcslen(szGeneratedInstance) > ulLength)
|
||||||
{
|
{
|
||||||
|
@ -3039,12 +3041,9 @@ PNP_CreateDevInst(
|
||||||
wcscpy(pszDeviceID, szGeneratedInstance);
|
wcscpy(pszDeviceID, szGeneratedInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Create the device instance */
|
/* Create the device instance */
|
||||||
ret = CreateDeviceInstance(pszDeviceID);
|
ret = CreateDeviceInstance(pszDeviceID);
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
|
DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue