https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c60d25fb264d0b12957921bf29d43b40eee7e5b1

commit c60d25fb264d0b12957921bf29d43b40eee7e5b1
Author:     Thomas Faber <thomas.fa...@reactos.org>
AuthorDate: Sat May 2 17:57:46 2020 +0200
Commit:     Thomas Faber <thomas.fa...@reactos.org>
CommitDate: Sun May 17 20:56:16 2020 +0200

    [NTOS:PNP] Directly accept a UNICODE_STRING in LocateChildDevice. CORE-15882
---
 ntoskrnl/io/pnpmgr/pnproot.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/ntoskrnl/io/pnpmgr/pnproot.c b/ntoskrnl/io/pnpmgr/pnproot.c
index e89426acb00..02e580e9e71 100644
--- a/ntoskrnl/io/pnpmgr/pnproot.c
+++ b/ntoskrnl/io/pnpmgr/pnproot.c
@@ -92,16 +92,15 @@ static PDEVICE_OBJECT PnpRootDeviceObject = NULL;
 static NTSTATUS
 LocateChildDevice(
     IN PPNPROOT_FDO_DEVICE_EXTENSION DeviceExtension,
-    IN PCWSTR DeviceId,
+    IN PCUNICODE_STRING DeviceId,
     IN PCWSTR InstanceId,
     OUT PPNPROOT_DEVICE* ChildDevice)
 {
     PPNPROOT_DEVICE Device;
-    UNICODE_STRING DeviceIdU, InstanceIdU;
+    UNICODE_STRING InstanceIdU;
     PLIST_ENTRY NextEntry;
 
-    /* Initialize the strings to compare  */
-    RtlInitUnicodeString(&DeviceIdU, DeviceId);
+    /* Initialize the string to compare */
     RtlInitUnicodeString(&InstanceIdU, InstanceId);
 
     /* Start looping */
@@ -113,7 +112,7 @@ LocateChildDevice(
         Device = CONTAINING_RECORD(NextEntry, PNPROOT_DEVICE, ListEntry);
 
         /* See if the strings match */
-        if (RtlEqualUnicodeString(&DeviceIdU, &Device->DeviceID, TRUE) &&
+        if (RtlEqualUnicodeString(DeviceId, &Device->DeviceID, TRUE) &&
             RtlEqualUnicodeString(&InstanceIdU, &Device->InstanceID, TRUE))
         {
             /* They do, so set the pointer and return success */
@@ -267,7 +266,7 @@ tryagain:
         for (NextInstance = 0; NextInstance <= 9999; NextInstance++)
         {
              _snwprintf(InstancePath, sizeof(InstancePath) / sizeof(WCHAR), 
L"%04lu", NextInstance);
-             Status = LocateChildDevice(DeviceExtension, 
Device->DeviceID.Buffer, InstancePath, &Device);
+             Status = LocateChildDevice(DeviceExtension, &Device->DeviceID, 
InstancePath, &Device);
              if (Status == STATUS_NO_SUCH_DEVICE)
                  break;
         }
@@ -281,7 +280,7 @@ tryagain:
     }
 
     _snwprintf(InstancePath, sizeof(InstancePath) / sizeof(WCHAR), L"%04lu", 
NextInstance);
-    Status = LocateChildDevice(DeviceExtension, Device->DeviceID.Buffer, 
InstancePath, &Device);
+    Status = LocateChildDevice(DeviceExtension, &Device->DeviceID, 
InstancePath, &Device);
     if (Status != STATUS_NO_SUCH_DEVICE || NextInstance > 9999)
     {
         DPRINT1("NextInstance value is corrupt! (%lu)\n", NextInstance);
@@ -460,8 +459,7 @@ CreateDeviceFromRegistry(
     BUFFER Buffer1, Buffer2;
 
     /* If the device already exists, there's nothing to do */
-    NT_ASSERT(DevicePath->Buffer[DevicePath->Length / sizeof(WCHAR)] == 
UNICODE_NULL);
-    Status = LocateChildDevice(DeviceExtension, DevicePath->Buffer, 
InstanceId, &Device);
+    Status = LocateChildDevice(DeviceExtension, DevicePath, InstanceId, 
&Device);
     if (Status != STATUS_NO_SUCH_DEVICE)
     {
         return STATUS_SUCCESS;

Reply via email to