- RtlInitUnicodeString(&InstanceId,
- (PWSTR)IoStatusBlock.Information);
-
- 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;
- }
-
- /* 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"&");
- }