[UMPNPMGR]

- Handle the CM_CREATE_DEVNODE_GENERATE_ID flag
[SETUPAPI]
- Use the correct ID (the newly generated instance ID) when creating the device info if the DICD_GENERATE_ID flag was passed in

svn path=/trunk/; revision=59699
This commit is contained in:
Cameron Gutman 2013-08-11 19:57:47 +00:00
parent fb58b492f6
commit c673f80b25
3 changed files with 56 additions and 9 deletions

View file

@ -1613,16 +1613,42 @@ DWORD PNP_CreateDevInst(
if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
{
/* FIXME */
DPRINT1("CM_CREATE_DEVNODE_GENERATE_ID support not implemented yet!\n", ret);
ret = CR_CALL_NOT_IMPLEMENTED;
goto done;
WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
DWORD dwInstanceNumber;
/* Generated ID is: Root\<Device ID>\<Instance number> */
dwInstanceNumber = 0;
do
{
swprintf(szGeneratedInstance, L"Root\\%ls\\%04d",
pszDeviceID, dwInstanceNumber);
/* Try to create a device instance with this ID */
ret = CreateDeviceInstance(szGeneratedInstance);
dwInstanceNumber++;
}
while (ret == CR_ALREADY_SUCH_DEVINST);
if (ret == CR_SUCCESS)
{
/* pszDeviceID is an out parameter too for generated IDs */
if (wcslen(szGeneratedInstance) > ulLength)
{
ret = CR_BUFFER_SMALL;
}
else
{
wcscpy(pszDeviceID, szGeneratedInstance);
}
}
}
else
{
/* Create the device instance */
ret = CreateDeviceInstance(pszDeviceID);
}
/* Create the device instance */
ret = CreateDeviceInstance(pszDeviceID);
done:;
DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
return ret;

View file

@ -681,7 +681,9 @@ CONFIGRET WINAPI CM_Create_DevNode_ExW(
if (ret == CR_SUCCESS)
{
*pdnDevInst = pSetupStringTableAddString(StringTable, pDeviceID, 1);
/* If CM_CREATE_DEVINST_GENERATE_ID was passed in, PNP_CreateDevInst
* will return the generated device ID in szLocalDeviceID */
*pdnDevInst = pSetupStringTableAddString(StringTable, szLocalDeviceID, 1);
if (*pdnDevInst == 0)
ret = CR_NO_SUCH_DEVNODE;
}

View file

@ -1727,6 +1727,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(
CONFIGRET cr;
DEVINST RootDevInst;
DEVINST DevInst;
WCHAR GenInstanceId[MAX_DEVICE_ID_LEN];
TRACE("%p %s %s %s %p %x %p\n", DeviceInfoSet, debugstr_w(DeviceName),
debugstr_guid(ClassGuid), debugstr_w(DeviceDescription),
@ -1789,6 +1790,24 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(
return FALSE;
}
if (CreationFlags & DICD_GENERATE_ID)
{
/* Grab the actual instance ID that was created */
cr = CM_Get_Device_ID_Ex(DevInst,
GenInstanceId,
MAX_DEVICE_ID_LEN,
0,
set->hMachine);
if (cr != CR_SUCCESS)
{
SetLastError(GetErrorCodeFromCrCode(cr));
return FALSE;
}
DeviceName = GenInstanceId;
TRACE("Using generated instance ID: %s\n", debugstr_w(DeviceName));
}
if (CreateDeviceInfo(set, DeviceName, ClassGuid, &deviceInfo))
{
InsertTailList(&set->ListHead, &deviceInfo->ListEntry);