From 3875bcd63162cd40c3cb7132aeb278753fd05c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 27 Dec 2007 21:21:36 +0000 Subject: [PATCH] Use the captured string instead of the original one Fix little bugs introduced in r31467 svn path=/trunk/; revision=31471 --- reactos/ntoskrnl/io/pnpmgr/plugplay.c | 20 ++++++++------------ reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 8 +++++++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/plugplay.c b/reactos/ntoskrnl/io/pnpmgr/plugplay.c index eb34d96720d..43fc9104f1d 100644 --- a/reactos/ntoskrnl/io/pnpmgr/plugplay.c +++ b/reactos/ntoskrnl/io/pnpmgr/plugplay.c @@ -371,7 +371,7 @@ IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData) } /* Get the device object */ - DeviceObject = IopGetDeviceObjectFromDeviceInstance(&PropertyData->DeviceInstance); + DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance); ExFreePool(DeviceInstance.Buffer); if (DeviceObject == NULL) { @@ -552,13 +552,11 @@ IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData) NTSTATUS Status = STATUS_SUCCESS; DPRINT("IopDeviceStatus() called\n"); - DPRINT("Device name: %wZ\n", &StatusData->DeviceInstance); Status = IopCaptureUnicodeString(&DeviceInstance, &StatusData->DeviceInstance); if (!NT_SUCCESS(Status)) - { - return Status; - } + return Status; + DPRINT("Device name: '%wZ'\n", &DeviceInstance); _SEH_TRY { @@ -577,15 +575,13 @@ IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData) if (!NT_SUCCESS(Status)) { - if (DeviceInstance.Buffer) - { - ExFreePool(DeviceInstance.Buffer); - } - return Status; + if (DeviceInstance.Buffer) + ExFreePool(DeviceInstance.Buffer); + return Status; } /* Get the device object */ - DeviceObject = IopGetDeviceObjectFromDeviceInstance(&StatusData->DeviceInstance); + DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance); ExFreePool(DeviceInstance.Buffer); if (DeviceObject == NULL) return STATUS_NO_SUCH_DEVICE; @@ -649,7 +645,7 @@ IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData) } /* Get the device object */ - DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DepthData->DeviceInstance); + DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance); ExFreePool(DeviceInstance.Buffer); if (DeviceObject == NULL) return STATUS_NO_SUCH_DEVICE; diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 89edacde0c5..17372f068a7 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -1653,6 +1653,8 @@ IopGetParentIdPrefix(PDEVICE_NODE DeviceNode, /* OK, value is correct ; prepare to return it */ KeyValue.Length = KeyValue.MaximumLength = (USHORT)ParentIdPrefixInformation->DataLength; KeyValue.Buffer = (PWSTR)ParentIdPrefixInformation->Data; + if (KeyValue.Length && KeyValue.Buffer[KeyValue.Length / sizeof(WCHAR) - 1] == UNICODE_NULL); + KeyValue.Length -= sizeof(WCHAR); } /* We're done */ @@ -2461,7 +2463,11 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode, * Make sure this device node is a direct child of the parent device node * that is given as an argument */ - ASSERT(DeviceNode->Parent == ParentDeviceNode); + if (DeviceNode->Parent != ParentDeviceNode) + { + DPRINT("Not a direct child\n"); + return STATUS_UNSUCCESSFUL; + } if (!IopDeviceNodeHasFlag(DeviceNode, DNF_DISABLED) && !IopDeviceNodeHasFlag(DeviceNode, DNF_ADDED) &&