mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 08:15:41 +00:00
[NTOS:PNP]
- Make device instance paths unique if necessary (by adding the parent ID prefix), regardless of the return status from IRP_MN_QUERY_ID/BusQueryInstanceID. Support for this IRP is optional in most cases, and a failure status just indicates no instance id information is needed by the driver stack. Major thanks to Vadim Galyant for debugging this and identifying the root cause. CORE-12732 CORE-12818 CORE-12745 CORE-12733 CORE-12717 CORE-12735 svn path=/trunk/; revision=74053
This commit is contained in:
parent
ab14ba211c
commit
16b4b0a874
1 changed files with 42 additions and 44 deletions
|
@ -1950,59 +1950,57 @@ IopCreateDeviceInstancePath(
|
|||
&IoStatusBlock,
|
||||
IRP_MN_QUERY_ID,
|
||||
&Stack);
|
||||
if (NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
RtlInitUnicodeString(&InstanceId,
|
||||
(PWSTR)IoStatusBlock.Information);
|
||||
DPRINT("IopInitiatePnpIrp(BusQueryInstanceID) failed (Status %lx)\n", Status);
|
||||
ASSERT(IoStatusBlock.Information == 0);
|
||||
}
|
||||
|
||||
InstancePath->Length = 0;
|
||||
InstancePath->MaximumLength = DeviceId.Length + sizeof(WCHAR) +
|
||||
ParentIdPrefix.Length +
|
||||
InstanceId.Length +
|
||||
sizeof(UNICODE_NULL);
|
||||
if (ParentIdPrefix.Length && InstanceId.Length)
|
||||
{
|
||||
InstancePath->MaximumLength += sizeof(WCHAR);
|
||||
}
|
||||
RtlInitUnicodeString(&InstanceId,
|
||||
(PWSTR)IoStatusBlock.Information);
|
||||
|
||||
InstancePath->Buffer = ExAllocatePoolWithTag(PagedPool,
|
||||
InstancePath->MaximumLength,
|
||||
TAG_IO);
|
||||
if (!InstancePath->Buffer)
|
||||
{
|
||||
RtlFreeUnicodeString(&InstanceId);
|
||||
RtlFreeUnicodeString(&ParentIdPrefix);
|
||||
RtlFreeUnicodeString(&DeviceId);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* Start with the device id */
|
||||
RtlCopyUnicodeString(InstancePath, &DeviceId);
|
||||
RtlAppendUnicodeToString(InstancePath, L"\\");
|
||||
|
||||
/* Add information from parent bus device to InstancePath */
|
||||
RtlAppendUnicodeStringToString(InstancePath, &ParentIdPrefix);
|
||||
if (ParentIdPrefix.Length && InstanceId.Length)
|
||||
{
|
||||
RtlAppendUnicodeToString(InstancePath, L"&");
|
||||
}
|
||||
|
||||
/* Finally, add the id returned by the driver stack */
|
||||
RtlAppendUnicodeStringToString(InstancePath, &InstanceId);
|
||||
|
||||
/*
|
||||
* FIXME: Check for valid characters, if there is invalid characters
|
||||
* then bugcheck
|
||||
*/
|
||||
InstancePath->Length = 0;
|
||||
InstancePath->MaximumLength = DeviceId.Length + sizeof(WCHAR) +
|
||||
ParentIdPrefix.Length +
|
||||
InstanceId.Length +
|
||||
sizeof(UNICODE_NULL);
|
||||
if (ParentIdPrefix.Length && InstanceId.Length)
|
||||
{
|
||||
InstancePath->MaximumLength += sizeof(WCHAR);
|
||||
}
|
||||
|
||||
InstancePath->Buffer = ExAllocatePoolWithTag(PagedPool,
|
||||
InstancePath->MaximumLength,
|
||||
TAG_IO);
|
||||
if (!InstancePath->Buffer)
|
||||
{
|
||||
RtlFreeUnicodeString(&InstanceId);
|
||||
RtlFreeUnicodeString(&ParentIdPrefix);
|
||||
RtlFreeUnicodeString(&DeviceId);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
|
||||
/* Start with the device id */
|
||||
RtlCopyUnicodeString(InstancePath, &DeviceId);
|
||||
RtlAppendUnicodeToString(InstancePath, L"\\");
|
||||
|
||||
/* Add information from parent bus device to InstancePath */
|
||||
RtlAppendUnicodeStringToString(InstancePath, &ParentIdPrefix);
|
||||
if (ParentIdPrefix.Length && InstanceId.Length)
|
||||
{
|
||||
DPRINT("IopInitiatePnpIrp(BusQueryInstanceID) failed (Status %x)\n", Status);
|
||||
*InstancePath = DeviceId;
|
||||
RtlAppendUnicodeToString(InstancePath, L"&");
|
||||
}
|
||||
|
||||
/* Finally, add the id returned by the driver stack */
|
||||
RtlAppendUnicodeStringToString(InstancePath, &InstanceId);
|
||||
|
||||
/*
|
||||
* FIXME: Check for valid characters, if there is invalid characters
|
||||
* then bugcheck
|
||||
*/
|
||||
|
||||
RtlFreeUnicodeString(&InstanceId);
|
||||
RtlFreeUnicodeString(&DeviceId);
|
||||
RtlFreeUnicodeString(&ParentIdPrefix);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue