Skip to content

Commit 55cfedb

Browse files
committed
[NTOS:KD] Merge KdpPrintString()/KdpPromptString() with kd64 version
1 parent 5407e17 commit 55cfedb

File tree

2 files changed

+65
-65
lines changed

2 files changed

+65
-65
lines changed

ntoskrnl/kd/kdio.c

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -508,56 +508,81 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
508508
BOOLEAN
509509
NTAPI
510510
KdpPrintString(
511-
_In_ PSTRING Output)
512-
{
513-
PLIST_ENTRY CurrentEntry;
514-
PKD_DISPATCH_TABLE CurrentTable;
511+
_In_ PSTRING Output);
515512

516-
if (!KdpDebugMode.Value) return FALSE;
513+
extern STRING KdbPromptString;
517514

518-
/* Call the registered handlers */
519-
CurrentEntry = KdProviders.Flink;
520-
while (CurrentEntry != &KdProviders)
515+
VOID
516+
NTAPI
517+
KdSendPacket(
518+
IN ULONG PacketType,
519+
IN PSTRING MessageHeader,
520+
IN PSTRING MessageData,
521+
IN OUT PKD_CONTEXT Context)
522+
{
523+
if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
521524
{
522-
/* Get the current table */
523-
CurrentTable = CONTAINING_RECORD(CurrentEntry,
524-
KD_DISPATCH_TABLE,
525-
KdProvidersList);
525+
PSTRING Output = MessageData;
526+
PLIST_ENTRY CurrentEntry;
527+
PKD_DISPATCH_TABLE CurrentTable;
526528

527-
/* Call it */
528-
CurrentTable->KdpPrintRoutine(Output->Buffer, Output->Length);
529+
if (!KdpDebugMode.Value) return;
529530

530-
/* Next Table */
531-
CurrentEntry = CurrentEntry->Flink;
532-
}
531+
/* Call the registered handlers */
532+
CurrentEntry = KdProviders.Flink;
533+
while (CurrentEntry != &KdProviders)
534+
{
535+
/* Get the current table */
536+
CurrentTable = CONTAINING_RECORD(CurrentEntry,
537+
KD_DISPATCH_TABLE,
538+
KdProvidersList);
533539

534-
/* Call the Wrapper Routine */
535-
if (WrapperTable.KdpPrintRoutine)
536-
WrapperTable.KdpPrintRoutine(Output->Buffer, Output->Length);
540+
/* Call it */
541+
CurrentTable->KdpPrintRoutine(Output->Buffer, Output->Length);
537542

538-
return FALSE;
539-
}
543+
/* Next Table */
544+
CurrentEntry = CurrentEntry->Flink;
545+
}
540546

541-
extern STRING KdbPromptString;
547+
/* Call the Wrapper Routine */
548+
if (WrapperTable.KdpPrintRoutine)
549+
WrapperTable.KdpPrintRoutine(Output->Buffer, Output->Length);
542550

543-
BOOLEAN
551+
return;
552+
}
553+
UNIMPLEMENTED;
554+
}
555+
556+
KDSTATUS
544557
NTAPI
545-
KdpPromptString(
546-
_In_ PSTRING PromptString,
547-
_In_ PSTRING ResponseString)
558+
KdReceivePacket(
559+
IN ULONG PacketType,
560+
OUT PSTRING MessageHeader,
561+
OUT PSTRING MessageData,
562+
OUT PULONG DataLength,
563+
IN OUT PKD_CONTEXT Context)
548564
{
549565
#ifdef KDBG
550566
KIRQL OldIrql;
551567
STRING StringChar;
552568
CHAR Response;
553569
USHORT i;
554570
ULONG DummyScanCode;
571+
CHAR MessageBuffer[100];
572+
STRING ResponseString;
573+
#endif
555574

575+
if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
576+
return KdPacketTimedOut;
577+
578+
#ifdef KDBG
579+
ResponseString.Buffer = MessageBuffer;
580+
ResponseString.Length = 0;
581+
ResponseString.MaximumLength = min(sizeof(MessageBuffer), MessageData->MaximumLength);
556582
StringChar.Buffer = &Response;
557583
StringChar.Length = StringChar.MaximumLength = sizeof(Response);
558584

559585
/* Display the string and print a new line for log neatness */
560-
KdpPrintString(PromptString);
561586
*StringChar.Buffer = '\n';
562587
KdpPrintString(&StringChar);
563588

@@ -573,7 +598,7 @@ KdpPromptString(
573598
KbdDisableMouse();
574599

575600
/* Loop the whole string */
576-
for (i = 0; i < ResponseString->MaximumLength; i++)
601+
for (i = 0; i < ResponseString.MaximumLength; i++)
577602
{
578603
/* Check if this is serial debugging mode */
579604
if (KdbDebugState & KD_DEBUG_KDSERIAL)
@@ -618,58 +643,33 @@ KdpPromptString(
618643
* Null terminate the output string -- documentation states that
619644
* DbgPrompt does not null terminate, but it does
620645
*/
621-
*(PCHAR)(ResponseString->Buffer + i) = 0;
646+
*(PCHAR)(ResponseString.Buffer + i) = 0;
622647
break;
623648
}
624649

625650
/* Write it back and print it to the log */
626-
*(PCHAR)(ResponseString->Buffer + i) = Response;
651+
*(PCHAR)(ResponseString.Buffer + i) = Response;
627652
KdpReleaseLock(&KdpSerialSpinLock, OldIrql);
628653
KdpPrintString(&StringChar);
629654
OldIrql = KdpAcquireLock(&KdpSerialSpinLock);
630655
}
631656

657+
/* Print a new line */
658+
*StringChar.Buffer = '\n';
659+
KdpPrintString(&StringChar);
660+
632661
/* Return the length */
633-
ResponseString->Length = i;
662+
RtlCopyMemory(MessageData->Buffer, ResponseString.Buffer, i);
663+
*DataLength = i;
634664

635665
if (!(KdbDebugState & KD_DEBUG_KDSERIAL))
636666
KbdEnableMouse();
637667

638668
/* Release the spinlock */
639669
KdpReleaseLock(&KdpSerialSpinLock, OldIrql);
640670

641-
/* Print a new line */
642-
*StringChar.Buffer = '\n';
643-
KdpPrintString(&StringChar);
644671
#endif
645-
646-
/* Success; we don't need to resend */
647-
return FALSE;
648-
}
649-
650-
VOID
651-
NTAPI
652-
KdSendPacket(
653-
IN ULONG PacketType,
654-
IN PSTRING MessageHeader,
655-
IN PSTRING MessageData,
656-
IN OUT PKD_CONTEXT Context)
657-
{
658-
UNIMPLEMENTED;
659-
return;
660-
}
661-
662-
KDSTATUS
663-
NTAPI
664-
KdReceivePacket(
665-
IN ULONG PacketType,
666-
OUT PSTRING MessageHeader,
667-
OUT PSTRING MessageData,
668-
OUT PULONG DataLength,
669-
IN OUT PKD_CONTEXT Context)
670-
{
671-
UNIMPLEMENTED;
672-
return 0;
672+
return KdPacketReceived;
673673
}
674674

675675
/* EOF */

ntoskrnl/kd64/kdprint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
/* FUNCTIONS *****************************************************************/
1717

18-
#ifdef _WINKD_
19-
2018
BOOLEAN
2119
NTAPI
2220
KdpPrintString(
@@ -132,6 +130,8 @@ KdpPromptString(
132130
return FALSE;
133131
}
134132

133+
#ifdef _WINKD_
134+
135135
VOID
136136
NTAPI
137137
KdpCommandString(IN PSTRING NameString,

0 commit comments

Comments
 (0)