https://git.reactos.org/?p=reactos.git;a=commitdiff;h=31a5fa61bbf47c897059d…
commit 31a5fa61bbf47c897059d9af350f4646c1d01488
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sun Jul 17 19:17:18 2022 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Wed Jul 20 23:57:42 2022 +0200
[NTOS:KDBG] Add KdbpPrintUnicodeString
Calling normal unicode functions is not allowed at IRQL > APC_LEVEL, so calling
_vsnprintf with unicode parameters from KDBG is invalid.
---
ntoskrnl/kdbg/kdb.h | 4 ++++
ntoskrnl/kdbg/kdb_cli.c | 34 ++++++++++++++++++++++++++++++----
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/kdbg/kdb.h b/ntoskrnl/kdbg/kdb.h
index 68f4ce03b05..808c13c5550 100644
--- a/ntoskrnl/kdbg/kdb.h
+++ b/ntoskrnl/kdbg/kdb.h
@@ -107,6 +107,10 @@ KdbpPrint(
IN PCHAR Format,
IN ... OPTIONAL);
+VOID
+KdbpPrintUnicodeString(
+ _In_ PCUNICODE_STRING String);
+
BOOLEAN
NTAPI
KdbpGetHexNumber(
diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index 4958dd9be71..7da99daef32 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -564,10 +564,14 @@ KdbpPrintStructInternal
KdbpPrint("%s%p+%x: %s", Indent, ((PCHAR)BaseAddress) +
Member->BaseOffset, Member->Size, Member->Name ? Member->Name :
"<anoymous>");
if (DoRead) {
if (!strcmp(Member->Type, "_UNICODE_STRING")) {
- KdbpPrint("\"%wZ\"\n", ((PCHAR)BaseAddress) +
Member->BaseOffset);
+ KdbpPrint("\"");
+ KdbpPrintUnicodeString(((PCHAR)BaseAddress) + Member->BaseOffset);
+ KdbpPrint("\"\n");
continue;
} else if (!strcmp(Member->Type, "PUNICODE_STRING")) {
- KdbpPrint("\"%wZ\"\n",
*(((PUNICODE_STRING*)((PCHAR)BaseAddress) + Member->BaseOffset)));
+ KdbpPrint("\"");
+ KdbpPrintUnicodeString(*(((PUNICODE_STRING*)((PCHAR)BaseAddress) +
Member->BaseOffset)));
+ KdbpPrint("\"\n");
continue;
}
switch (Member->Size) {
@@ -2109,7 +2113,9 @@ KdbpCmdMod(
KdbpPrint(" Base Size Name\n");
for (;;)
{
- KdbpPrint(" %08x %08x %wZ\n", LdrEntry->DllBase,
LdrEntry->SizeOfImage, &LdrEntry->BaseDllName);
+ KdbpPrint(" %p %08x ", LdrEntry->DllBase,
LdrEntry->SizeOfImage);
+ KdbpPrintUnicodeString(&LdrEntry->BaseDllName);
+ KdbpPrint("\n");
if(DisplayOnlyOneModule || !KdbpSymFindModule(NULL, i++, &LdrEntry))
break;
@@ -3035,6 +3041,24 @@ KdbpPrint(
}
}
+VOID
+KdbpPrintUnicodeString(
+ _In_ PCUNICODE_STRING String)
+{
+ ULONG i;
+
+ if ((String == NULL) || (String->Buffer == NULL))
+ {
+ KdbpPrint("<NULL>");
+ return;
+ }
+
+ for (i = 0; i < String->Length / sizeof(WCHAR); i++)
+ {
+ KdbpPrint("%c", (CHAR)String->Buffer[i]);
+ }
+}
+
/** memrchr(), explicitly defined, since was absent in MinGW of RosBE. */
/*
* Reverse memchr()
@@ -3863,7 +3887,9 @@ KdbpCliModuleLoaded(
if (!KdbBreakOnModuleLoad)
return;
- KdbpPrint("Module %wZ loaded.\n", Name);
+ KdbpPrint("Module ");
+ KdbpPrintUnicodeString(Name);
+ KdbpPrint(" loaded.\n");
DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
}