https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7e8de26164861fc8f6dc0…
commit 7e8de26164861fc8f6dc09c92d2211ed925e981e
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Thu Dec 14 11:43:57 2017 +0100
[NTOS:KD] Pass PreviousMode down to KdpPrintString, since ExGetPreviousMode is not
accurate. CORE-14103
---
ntoskrnl/include/internal/kd.h | 3 ++-
ntoskrnl/kd/kdio.c | 5 +++--
ntoskrnl/kd/kdmain.c | 13 +++++++++----
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/ntoskrnl/include/internal/kd.h b/ntoskrnl/include/internal/kd.h
index 05179ea6d3..daad7538e1 100644
--- a/ntoskrnl/include/internal/kd.h
+++ b/ntoskrnl/include/internal/kd.h
@@ -194,7 +194,8 @@ ULONG
NTAPI
KdpPrintString(
_In_reads_bytes_(Length) PCHAR UnsafeString,
- _In_ ULONG Length);
+ _In_ ULONG Length,
+ _In_ KPROCESSOR_MODE PreviousMode);
ULONG
NTAPI
diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c
index 50e4d8168f..53c99c43d4 100644
--- a/ntoskrnl/kd/kdio.c
+++ b/ntoskrnl/kd/kdio.c
@@ -569,7 +569,8 @@ ULONG
NTAPI
KdpPrintString(
_In_reads_bytes_(Length) PCHAR UnsafeString,
- _In_ ULONG Length)
+ _In_ ULONG Length,
+ _In_ KPROCESSOR_MODE PreviousMode)
{
PLIST_ENTRY CurrentEntry;
PKD_DISPATCH_TABLE CurrentTable;
@@ -580,7 +581,7 @@ KdpPrintString(
Length = min(Length, sizeof(StringBuffer));
- if (ExGetPreviousMode() != KernelMode)
+ if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
diff --git a/ntoskrnl/kd/kdmain.c b/ntoskrnl/kd/kdmain.c
index 52b8babbce..d219f1bb04 100644
--- a/ntoskrnl/kd/kdmain.c
+++ b/ntoskrnl/kd/kdmain.c
@@ -41,14 +41,15 @@ ULONG
NTAPI
KdpServiceDispatcher(ULONG Service,
PVOID Buffer1,
- ULONG Buffer1Length)
+ ULONG Buffer1Length,
+ KPROCESSOR_MODE PreviousMode)
{
ULONG Result = 0;
switch (Service)
{
case BREAKPOINT_PRINT: /* DbgPrint */
- Result = KdpPrintString(Buffer1, Buffer1Length);
+ Result = KdpPrintString(Buffer1, Buffer1Length, PreviousMode);
break;
#if DBG
@@ -145,7 +146,8 @@ KdpEnterDebuggerException(IN PKTRAP_FRAME TrapFrame,
/* Print the string */
KdpServiceDispatcher(BREAKPOINT_PRINT,
(PVOID)ExceptionRecord->ExceptionInformation[1],
- ExceptionRecord->ExceptionInformation[2]);
+ ExceptionRecord->ExceptionInformation[2],
+ PreviousMode);
/* Return success */
KeSetContextReturnRegister(Context, STATUS_SUCCESS);
@@ -493,7 +495,10 @@ KdSystemDebugControl(IN SYSDBG_COMMAND Command,
IN KPROCESSOR_MODE PreviousMode)
{
/* HACK */
- return KdpServiceDispatcher(Command, InputBuffer, InputBufferLength);
+ return KdpServiceDispatcher(Command,
+ InputBuffer,
+ InputBufferLength,
+ PreviousMode);
}
PKDEBUG_ROUTINE KiDebugRoutine = KdpEnterDebuggerException;