--- branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c 2005-03-06 02:34:18 UTC (rev 13846)
+++ branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c 2005-03-06 05:32:54 UTC (rev 13847)
@@ -97,7 +97,7 @@
STATIC LONG KdbNumberOfRowsTerminal = -1;
STATIC LONG KdbNumberOfColsTerminal = -1;
-PCHAR KdbInitFileBuffer = NULL; /* Buffer where KDB.init file is loaded into during initialization */
+PCHAR KdbInitFileBuffer = NULL; /* Buffer where KDBinit file is loaded into during initialization */
STATIC CONST struct
{
@@ -1682,6 +1682,7 @@
INT Length;
INT i;
INT RowsPrintedByTerminal;
+ ULONG ScanCode;
va_list ap;
/* Check if the user has aborted output of the current command */
@@ -1703,20 +1704,17 @@
{
/* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */
TerminalReportsSize = FALSE;
- DbgPrint("\x1b[18t");
- i = 10;
- while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
+ //DbgPrint("\x1b[18t");
+ c = KdbpTryGetCharSerial(10);
if (c == KEY_ESC)
{
- i = 5;
- while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
+ c = KdbpTryGetCharSerial(5);
if (c == '[')
{
Length = 0;
for (;;)
{
- i = 5;
- while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
+ c = KdbpTryGetCharSerial(5);
if (c == -1)
break;
Buffer[Length++] = c;
@@ -1781,13 +1779,19 @@
if (KdbNumberOfColsPrinted > 0)
DbgPrint("\n");
DbgPrint("--- Press q to abort, any other key to continue ---");
- while ((c = KdbpTryGetCharSerial()) == -1);
+ if (KdDebugState & KD_DEBUG_KDSERIAL)
+ c = KdbpGetCharSerial();
+ else
+ c = KdbpGetCharKeyboard(&ScanCode);
if (c == '\r')
{
- /* Ignore \r and wait for \n or another \r - if \n is not received here
+ /* Try to read '\n' which might follow '\r' - if \n is not received here
* it will be interpreted as "return" when the next command should be read.
*/
- while ((c = KdbpTryGetCharSerial()) == -1);
+ if (KdDebugState & KD_DEBUG_KDSERIAL)
+ c = KdbpTryGetCharSerial(5);
+ else
+ c = KdbpTryGetCharKeyboard(&ScanCode, 5);
}
DbgPrint("\n");
if (c == 'q')
@@ -1914,7 +1918,7 @@
OUT PCHAR Buffer,
IN ULONG Size)
{
- CHAR Key;
+ CHAR Key, NextKey;
PCHAR Orig = Buffer;
ULONG ScanCode = 0;
BOOLEAN EchoOn;
@@ -1929,14 +1933,14 @@
{
if (KdDebugState & KD_DEBUG_KDSERIAL)
{
- while ((Key = KdbpTryGetCharSerial()) == -1);
+ Key = KdbpGetCharSerial();
ScanCode = 0;
if (Key == KEY_ESC) /* ESC */
{
- while ((Key = KdbpTryGetCharSerial()) == -1);
+ Key = KdbpGetCharSerial();
if (Key == '[')
{
- while ((Key = KdbpTryGetCharSerial()) == -1);
+ Key = KdbpGetCharSerial();
switch (Key)
{
case 'A':
@@ -1954,7 +1958,9 @@
}
}
else
- while ((Key = KdbpTryGetCharKeyboard(&ScanCode)) == -1);
+ {
+ Key = KdbpGetCharKeyboard(&ScanCode);
+ }
if ((Buffer - Orig) >= (Size - 1))
{
@@ -1965,10 +1971,13 @@
if (Key == '\r')
{
- /* Ignore this key... */
- }
- else if (Key == '\n')
- {
+ /* Read the next char - this is to throw away a \n which most clients should
+ * send after \r.
+ */
+ if (KdDebugState & KD_DEBUG_KDSERIAL)
+ NextKey = KdbpTryGetCharSerial(5);
+ else
+ NextKey = KdbpTryGetCharKeyboard(&ScanCode, 5);
DbgPrint("\n");
/*
* Repeat the last command if the user presses enter. Reduces the
@@ -2197,7 +2206,7 @@
CHAR c;
/* Execute the commands in the init file */
- DbgPrint("KDB: Executing KDB.init file...\n");
+ DbgPrint("KDB: Executing KDBinit file...\n");
p1 = KdbInitFileBuffer;
while (p1[0] != '\0')
{
@@ -2228,12 +2237,12 @@
while (p1[0] == '\r' || p1[0] == '\n')
p1++;
}
- DbgPrint("KDB: KDB.init executed\n");
+ DbgPrint("KDB: KDBinit executed\n");
}
/*!\brief Called when KDB is initialized
*
- * Reads the KDB.init file from the SystemRoot\system32\drivers\etc directory and executes it.
+ * Reads the KDBinit file from the SystemRoot\system32\drivers\etc directory and executes it.
*/
VOID
KdbpCliInit()
@@ -2249,7 +2258,7 @@
ULONG OldEflags;
/* Initialize the object attributes */
- RtlInitUnicodeString(&FileName, L"\\SystemRoot\\system32\\drivers\\etc\\KDB.init");
+ RtlInitUnicodeString(&FileName, L"\\SystemRoot\\system32\\drivers\\etc\\KDBinit");
InitializeObjectAttributes(&ObjectAttributes, &FileName, 0, NULL, NULL);
/* Open the file */
@@ -2258,7 +2267,7 @@
FILE_NO_INTERMEDIATE_BUFFERING);
if (!NT_SUCCESS(Status))
{
- DPRINT("Could not open \\SystemRoot\\system32\\drivers\\etc\\KDB.init (Status 0x%x)", Status);
+ DPRINT("Could not open \\SystemRoot\\system32\\drivers\\etc\\KDBinit (Status 0x%x)", Status);
return;
}
@@ -2268,7 +2277,7 @@
if (!NT_SUCCESS(Status))
{
ZwClose(hFile);
- DPRINT("Could not query size of \\SystemRoot\\system32\\drivers\\etc\\KDB.init (Status 0x%x)", Status);
+ DPRINT("Could not query size of \\SystemRoot\\system32\\drivers\\etc\\KDBinit (Status 0x%x)", Status);
return;
}
FileSize = FileStdInfo.EndOfFile.u.LowPart;
@@ -2278,7 +2287,7 @@
if (FileBuffer == NULL)
{
ZwClose(hFile);
- DPRINT("Could not allocate %d bytes for KDB.init file\n", FileSize);
+ DPRINT("Could not allocate %d bytes for KDBinit file\n", FileSize);
return;
}
@@ -2288,7 +2297,7 @@
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{
ExFreePool(FileBuffer);
- DPRINT("Could not read KDB.init file into memory (Status 0x%lx)\n", Status);
+ DPRINT("Could not read KDBinit file into memory (Status 0x%lx)\n", Status);
return;
}
FileSize = min(FileSize, Iosb.Information);