mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
[UMPNPMGR] PNP_GetRelatedDeviceInstance must return the root device as the parent of non-existing devices
This commit is contained in:
parent
94d144f8a5
commit
11886ebec2
1 changed files with 33 additions and 3 deletions
|
@ -413,6 +413,17 @@ IsRootDeviceInstanceID(
|
|||
}
|
||||
|
||||
|
||||
static
|
||||
BOOL
|
||||
IsPresentDeviceInstanceID(
|
||||
_In_ LPWSTR pszDeviceInstanceID)
|
||||
{
|
||||
DWORD ulStatus, ulProblem;
|
||||
|
||||
return (GetDeviceStatus(pszDeviceInstanceID, &ulStatus, &ulProblem) == CR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
CONFIGRET
|
||||
OpenConfigurationKey(
|
||||
|
@ -781,10 +792,29 @@ PNP_GetRelatedDeviceInstance(
|
|||
if (!IsValidDeviceInstanceID(pDeviceID))
|
||||
return CR_INVALID_DEVINST;
|
||||
|
||||
/* The root device does not have a parent device or sibling devices */
|
||||
if ((ulRelationship == PNP_GET_PARENT_DEVICE_INSTANCE) ||
|
||||
(ulRelationship == PNP_GET_SIBLING_DEVICE_INSTANCE))
|
||||
if (ulRelationship == PNP_GET_PARENT_DEVICE_INSTANCE)
|
||||
{
|
||||
/* The root device does not have a parent */
|
||||
if (IsRootDeviceInstanceID(pDeviceID))
|
||||
return CR_NO_SUCH_DEVINST;
|
||||
|
||||
/* Return the root device for non existing devices */
|
||||
if (!IsPresentDeviceInstanceID(pDeviceID))
|
||||
{
|
||||
if ((wcslen(szRootDeviceInstanceID) + 1) > *pulLength)
|
||||
{
|
||||
*pulLength = wcslen(szRootDeviceInstanceID) + 1;
|
||||
return CR_BUFFER_SMALL;
|
||||
}
|
||||
|
||||
wcscpy(pRelatedDeviceId, szRootDeviceInstanceID);
|
||||
*pulLength = wcslen(szRootDeviceInstanceID) + 1;
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
}
|
||||
else if (ulRelationship == PNP_GET_SIBLING_DEVICE_INSTANCE)
|
||||
{
|
||||
/* The root device does not have siblings */
|
||||
if (IsRootDeviceInstanceID(pDeviceID))
|
||||
return CR_NO_SUCH_DEVINST;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue