PVOID Context)
{
IO_STATUS_BLOCK IoStatusBlock;
+ PWSTR InformationString;
PDEVICE_NODE ParentDeviceNode;
WCHAR InstancePath[MAX_PATH];
IO_STACK_LOCATION Stack;
&IoStatusBlock,
IRP_MN_QUERY_ID,
&Stack);
- if (NT_SUCCESS(Status))
- {
- /* Copy the device id string */
- wcscpy(InstancePath, (PWSTR)IoStatusBlock.Information);
-
- /*
- * FIXME: Check for valid characters, if there is invalid characters
- * then bugcheck.
- */
- }
- else
+ if (!NT_SUCCESS(Status))
{
DPRINT1("IopInitiatePnpIrp() failed (Status %x)\n", Status);
return STATUS_SUCCESS;
}
+ /* Copy the device id string */
+ InformationString = (PWSTR)IoStatusBlock.Information;
+ wcscpy(InstancePath, InformationString);
+
+ /*
+ * FIXME: Check for valid characters, if there is invalid characters
+ * then bugcheck.
+ */
+
+ ExFreePoolWithTag(InformationString, 0);
+
DPRINT("Sending IRP_MN_QUERY_CAPABILITIES to device stack (after enumeration)\n");
Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCapabilities);
&Stack);
if (NT_SUCCESS(Status))
{
+ InformationString = (PWSTR)IoStatusBlock.Information;
+
/* Append the instance id string */
wcscat(InstancePath, L"\\");
if (ParentIdPrefix.Length > 0)
{
/* Add information from parent bus device to InstancePath */
wcscat(InstancePath, ParentIdPrefix.Buffer);
- if (IoStatusBlock.Information && *(PWSTR)IoStatusBlock.Information)
+ if (InformationString && *InformationString)
{
wcscat(InstancePath, L"&");
}
}
- if (IoStatusBlock.Information)
+ if (InformationString)
{
- wcscat(InstancePath, (PWSTR)IoStatusBlock.Information);
+ wcscat(InstancePath, InformationString);
}
/*
* FIXME: Check for valid characters, if there is invalid characters
* then bugcheck
*/
+
+ if (InformationString)
+ {
+ ExFreePoolWithTag(InformationString, 0);
+ }
}
else
{
&IoStatusBlock,
IRP_MN_QUERY_DEVICE_TEXT,
&Stack);
+ InformationString = NT_SUCCESS(Status) ? (PWSTR)IoStatusBlock.Information
+ : NULL;
/* This key is mandatory, so even if the Irp fails, we still write it */
RtlInitUnicodeString(&ValueName, L"DeviceDesc");
if (ZwQueryValueKey(InstanceKey, &ValueName, KeyValueBasicInformation, NULL, 0, &RequiredLength) == STATUS_OBJECT_NAME_NOT_FOUND)
{
- if (NT_SUCCESS(Status) &&
- IoStatusBlock.Information &&
- (*(PWSTR)IoStatusBlock.Information != 0))
+ if (InformationString &&
+ *InformationString != UNICODE_NULL)
{
/* This key is overriden when a driver is installed. Don't write the
* new description if another one already exists */
&ValueName,
0,
REG_SZ,
- (PVOID)IoStatusBlock.Information,
- ((ULONG)wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
+ InformationString,
+ ((ULONG)wcslen(InformationString) + 1) * sizeof(WCHAR));
}
else
{
}
}
+ if (InformationString)
+ {
+ ExFreePoolWithTag(InformationString, 0);
+ }
+
DPRINT("Sending IRP_MN_QUERY_DEVICE_TEXT.DeviceTextLocation to device stack\n");
Stack.Parameters.QueryDeviceText.DeviceTextType = DeviceTextLocationInformation;
&Stack);
if (NT_SUCCESS(Status) && IoStatusBlock.Information)
{
- DPRINT("LocationInformation: %S\n", (PWSTR)IoStatusBlock.Information);
+ InformationString = (PWSTR)IoStatusBlock.Information;
+ DPRINT("LocationInformation: %S\n", InformationString);
RtlInitUnicodeString(&ValueName, L"LocationInformation");
Status = ZwSetValueKey(InstanceKey,
&ValueName,
0,
REG_SZ,
- (PVOID)IoStatusBlock.Information,
- ((ULONG)wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
+ InformationString,
+ ((ULONG)wcslen(InformationString) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status);
}
+
+ ExFreePoolWithTag(InformationString, 0);
}
else
{
DeviceNode->ChildBusNumber = BusInformation->BusNumber;
DeviceNode->ChildInterfaceType = BusInformation->LegacyBusType;
DeviceNode->ChildBusTypeIndex = IopGetBusTypeGuidIndex(&BusInformation->BusTypeGuid);
- ExFreePool(BusInformation);
+ ExFreePoolWithTag(BusInformation, 0);
}
else
{