[ntoskrnl] Better fix for correct display of loaded drivers
authorHervé Poussineau <hpoussin@reactos.org>
Sun, 14 Mar 2010 19:21:38 +0000 (19:21 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Sun, 14 Mar 2010 19:21:38 +0000 (19:21 +0000)
svn path=/trunk/; revision=46200

reactos/ntoskrnl/io/iomgr/driver.c

index a81c25e..ef1b789 100644 (file)
@@ -149,6 +149,39 @@ IopGetDriverObject(
    return STATUS_SUCCESS;
 }
 
+/*
+ * RETURNS
+ *  TRUE if String2 contains String1 as a suffix.
+ */
+BOOLEAN
+NTAPI
+IopSuffixUnicodeString(
+    IN PCUNICODE_STRING String1,
+    IN PCUNICODE_STRING String2)
+{
+    PWCHAR pc1;
+    PWCHAR pc2;
+    ULONG Length;
+
+    if (String2->Length < String1->Length)
+        return FALSE;
+
+    Length = String1->Length / 2;
+    pc1 = String1->Buffer;
+    pc2 = &String2->Buffer[String2->Length / sizeof(WCHAR) - Length];
+
+    if (pc1 && pc2)
+    {
+        while (Length--)
+        {
+            if( *pc1++ != *pc2++ )
+                return FALSE;
+        }
+        return TRUE;
+    }
+    return FALSE;
+}
+
 /*
  * IopDisplayLoadingMessage
  *
@@ -161,19 +194,16 @@ INIT_FUNCTION
 IopDisplayLoadingMessage(PUNICODE_STRING ServiceName)
 {
     CHAR TextBuffer[256];
+    UNICODE_STRING DotSys = RTL_CONSTANT_STRING(L".SYS");
 
     if (ExpInTextModeSetup) return;
     RtlUpcaseUnicodeString(ServiceName, ServiceName, FALSE);
     snprintf(TextBuffer, sizeof(TextBuffer),
-            "%s%s%s\\%wZ",
+            "%s%sSystem32\\Drivers\\%wZ%s\n",
             KeLoaderBlock->ArcBootDeviceName,
             KeLoaderBlock->NtBootPathName,
-            "System32\\Drivers",
-            ServiceName);
-    if (!strstr(TextBuffer, ".sys"))
-        strcat(TextBuffer, ".sys\n");
-    else
-        strcat(TextBuffer, "\n");
+            ServiceName,
+            IopSuffixUnicodeString(&DotSys, ServiceName) ? "" : ".SYS");
     HalDisplayString(TextBuffer);
 }