[NTOS:KDBG] Use KdbpSendCommandSerial() to send specific ANSI escape sequences.

Use this function instead of KdpDprintf(), otherwise, we send them to
**ALL** the display providers, including for example dmesg. Replaying
the listing with dmesg would then cause the terminal to misbehave later.
For example, it would send the answer of a "Query Device Attributes"
command, as the response to a query for terminal size...
This commit is contained in:
Hermès Bélusca-Maïto 2023-03-28 14:13:48 +02:00
parent 29e147beca
commit 430d7ebb93
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 22 additions and 12 deletions

View file

@ -13,8 +13,17 @@
/* FUNCTIONS *****************************************************************/
VOID
KdbpSendCommandSerial(
_In_ PCSTR Command)
{
while (*Command)
KdPortPutByteEx(&SerialPortInfo, *Command++);
}
CHAR
KdbpTryGetCharSerial(ULONG Retry)
KdbpTryGetCharSerial(
_In_ ULONG Retry)
{
CHAR Result = -1;

View file

@ -294,13 +294,18 @@ KdbpSafeWriteMemory(OUT PVOID Dest,
IN PVOID Src,
IN ULONG Bytes);
#define KdbpGetCharKeyboard(ScanCode) KdbpTryGetCharKeyboard(ScanCode, 0)
#define KdbpGetCharKeyboard(ScanCode) KdbpTryGetCharKeyboard((ScanCode), 0)
CHAR
KdbpTryGetCharKeyboard(PULONG ScanCode, ULONG Retry);
#define KdbpGetCharSerial() KdbpTryGetCharSerial(0)
CHAR
KdbpTryGetCharSerial(ULONG Retry);
KdbpTryGetCharSerial(
_In_ ULONG Retry);
VOID
KdbpSendCommandSerial(
_In_ PCSTR Command);
VOID
KbdDisableMouse(VOID);

View file

@ -2919,7 +2919,7 @@ KdbpPagerInternal(
TerminalInitialized = TRUE;
/* Enable line-wrap */
KdpDprintf("\x1b[?7h");
KdbpSendCommandSerial("\x1b[?7h");
/*
* Query terminal type.
@ -2928,7 +2928,7 @@ KdbpPagerInternal(
* string. Instead, use the VT52-compatible 'ESC Z' sequence or the
* VT100-compatible 'ESC[c' one.
*/
KdpDprintf("\x1b[c");
KdbpSendCommandSerial("\x1b[c");
KeStallExecutionProcessor(100000);
Length = 0;
@ -2967,7 +2967,7 @@ KdbpPagerInternal(
{
/* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */
TerminalReportsSize = FALSE;
KdpDprintf("\x1b[18t");
KdbpSendCommandSerial("\x1b[18t");
KeStallExecutionProcessor(100000);
c = KdbpTryGetCharSerial(5000);
@ -3122,7 +3122,8 @@ KdbpPagerInternal(
p = CountOnePageUp(Buffer, BufLength, pBufEnd);
i = strcspn(p, "\n");
}
else if (ScanCode == KEYSC_PAGEUP || c == 'u')
else if (ScanCode == KEYSC_PAGEUP ||
ScanCode == KEYSC_ARROWUP || c == 'u')
{
p = CountOnePageUp(Buffer, BufLength, p);
i = strcspn(p, "\n");
@ -3132,11 +3133,6 @@ KdbpPagerInternal(
p = Buffer;
i = strcspn(p, "\n");
}
else if (ScanCode == KEYSC_ARROWUP)
{
p = CountOnePageUp(Buffer, BufLength, p);
i = strcspn(p, "\n");
}
}
KdbNumberOfRowsPrinted = 0;