[NTOS:KDBG] Fix the display type of GDT TRAPGATE32.
[reactos.git] / ntoskrnl / kdbg / kdb_cli.c
index ed40fe3..b4d750d 100644 (file)
@@ -97,6 +97,7 @@ BOOLEAN ExpKdbgExtPoolFind(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtDefWrites(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtIrpFind(ULONG Argc, PCHAR Argv[]);
+BOOLEAN ExpKdbgExtHandle(ULONG Argc, PCHAR Argv[]);
 
 #ifdef __ROS_DWARF__
 static BOOLEAN KdbpCmdPrintStruct(ULONG Argc, PCHAR Argv[]);
@@ -194,6 +195,7 @@ static const struct
     { "!filecache", "!filecache", "Display cache usage.", ExpKdbgExtFileCache },
     { "!defwrites", "!defwrites", "Display cache write values.", ExpKdbgExtDefWrites },
     { "!irpfind", "!irpfind [Pool [startaddress [criteria data]]]", "Lists IRPs potentially matching criteria", ExpKdbgExtIrpFind },
+    { "!handle", "!handle [Handle]", "Displays info about handles", ExpKdbgExtHandle },
 };
 
 /* FUNCTIONS *****************************************************************/
@@ -2022,19 +2024,19 @@ KdbpCmdGdtLdtIdt(
             {
                 switch (Type)
                 {
-                    case 1: SegType = "TSS16(Avl)"; break;
-                    case 2: SegType = "LDT"; break;
-                    case 3: SegType = "TSS16(Busy)"; break;
-                    case 4: SegType = "CALLGATE16"; break;
-                    case 5: SegType = "TASKGATE"; break;
-                    case 6: SegType = "INTGATE16"; break;
-                    case 7: SegType = "TRAPGATE16"; break;
-                    case 9: SegType = "TSS32(Avl)"; break;
-                    case 11: SegType = "TSS32(Busy)"; break;
-                    case 12: SegType = "CALLGATE32"; break;
-                    case 14: SegType = "INTGATE32"; break;
-                    case 15: SegType = "INTGATE32"; break;
-                    default: SegType = "UNKNOWN"; break;
+                    case  1: SegType = "TSS16(Avl)";    break;
+                    case  2: SegType = "LDT";           break;
+                    case  3: SegType = "TSS16(Busy)";   break;
+                    case  4: SegType = "CALLGATE16";    break;
+                    case  5: SegType = "TASKGATE";      break;
+                    case  6: SegType = "INTGATE16";     break;
+                    case  7: SegType = "TRAPGATE16";    break;
+                    case  9: SegType = "TSS32(Avl)";    break;
+                    case 11: SegType = "TSS32(Busy)";   break;
+                    case 12: SegType = "CALLGATE32";    break;
+                    case 14: SegType = "INTGATE32";     break;
+                    case 15: SegType = "TRAPGATE32";    break;
+                    default: SegType = "UNKNOWN";       break;
                 }
 
                 if (!(Type >= 1 && Type <= 3) &&
@@ -2059,7 +2061,7 @@ KdbpCmdGdtLdtIdt(
                     SegType = "CODE16";
             }
 
-            if ((SegDesc[1] & (1 << 15)) == 0) /* not present */
+            if ((SegDesc[1] & (1 << 15)) == 0) /* Not present */
             {
                 KdbpPrint("  %03d  0x%04x  %-11s  [NP]        [NP]        %02d   NP\n",
                           i / 8, i | Dpl | ul, SegType, Dpl);
@@ -2660,15 +2662,16 @@ KdbpPrint(
         {
             while ((p2 = strrchr(p, '\x1b'))) /* Look for escape character */
             {
+                size_t len = strlen(p2);
                 if (p2[1] == '[')
                 {
                     j = 2;
                     while (!isalpha(p2[j++]));
-                    strcpy(p2, p2 + j);
+                    memmove(p2, p2 + j, len + 1 - j);
                 }
                 else
                 {
-                    strcpy(p2, p2 + 1);
+                    memmove(p2, p2 + 1, len);
                 }
             }
         }
@@ -3005,15 +3008,16 @@ KdbpPager(
         {
             while ((p2 = strrchr(p, '\x1b'))) /* Look for escape character */
             {
+                size_t len = strlen(p2);
                 if (p2[1] == '[')
                 {
                     j = 2;
                     while (!isalpha(p2[j++]));
-                    strcpy(p2, p2 + j);
+                    memmove(p2, p2 + j, len + 1 - j);
                 }
                 else
                 {
-                    strcpy(p2, p2 + 1);
+                    memmove(p2, p2 + 1, len);
                 }
             }
         }
@@ -3670,14 +3674,16 @@ KdpSerialDebugPrint(
 STRING KdpPromptString = RTL_CONSTANT_STRING("kdb:> ");
 extern KSPIN_LOCK KdpSerialSpinLock;
 
-ULONG
+USHORT
 NTAPI
 KdpPrompt(
     _In_reads_bytes_(InStringLength) PCHAR UnsafeInString,
     _In_ USHORT InStringLength,
     _Out_writes_bytes_(OutStringLength) PCHAR UnsafeOutString,
     _In_ USHORT OutStringLength,
-    _In_ KPROCESSOR_MODE PreviousMode)
+    _In_ KPROCESSOR_MODE PreviousMode,
+    _In_ PKTRAP_FRAME TrapFrame,
+    _In_ PKEXCEPTION_FRAME ExceptionFrame)
 {
     USHORT i;
     CHAR Response;