ReactOS 0.4.16-dev-1020-gf135cab
kdio.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/kd/kdio.c
5 * PURPOSE: NT Kernel Debugger Input/Output Functions
6 *
7 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
8 */
9
10/* INCLUDES ******************************************************************/
11
12#include <ntoskrnl.h>
13#include <reactos/buildno.h>
14#include "kd.h"
15#include "kdterminal.h"
16#ifdef KDBG
17#include "../kdbg/kdb.h"
18#endif
19
20#define NDEBUG
21#include <debug.h>
22
23#undef KdSendPacket
24#undef KdReceivePacket
25
26/* GLOBALS *******************************************************************/
27
28#define KdpBufferSize (1024 * 512)
31static volatile ULONG KdpCurrentPosition = 0;
32static volatile ULONG KdpFreeBytes = 0;
36ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log");
37
41
42#define KdpScreenLineLengthDefault 80
45
49
51{
55#ifdef KDBG // See kdb_cli.c
56 KdpKdbgInit
57#endif
58};
59
60/* LOCKING FUNCTIONS *********************************************************/
61
66{
68
69 /* Acquire the spinlock without waiting at raised IRQL */
70 while (TRUE)
71 {
72 /* Loop until the spinlock becomes available */
73 while (!KeTestSpinLock(SpinLock));
74
75 /* Spinlock is free, raise IRQL to high level */
77
78 /* Try to get the spinlock */
80 break;
81
82 /* Someone else got the spinlock, lower IRQL back */
84 }
85
86 return OldIrql;
87}
88
89VOID
94{
95 /* Release the spinlock */
97 // KeReleaseSpinLockFromDpcLevel(SpinLock);
98
99 /* Restore the old IRQL */
101}
102
103/* FILE DEBUG LOG FUNCTIONS **************************************************/
104
105static VOID
106NTAPI
108{
109 ULONG beg, end, num;
111
113
115
116 while (TRUE)
117 {
119
120 /* Bug */
121 /* Keep KdpCurrentPosition and KdpFreeBytes values in local
122 * variables to avoid their possible change from Producer part,
123 * KdpPrintToLogFile function
124 */
127
128 /* Now securely calculate values, based on local variables */
129 beg = (end + num) % KdpBufferSize;
131
132 /* Nothing to do? */
133 if (num == 0)
134 continue;
135
136 if (end > beg)
137 {
139 KdpDebugBuffer + beg, num, NULL, NULL);
140 }
141 else
142 {
144 KdpDebugBuffer + beg, KdpBufferSize - beg, NULL, NULL);
145
148 }
149
151 }
152}
153
154static VOID
155NTAPI
159{
161 ULONG beg, end, num;
162
163 if (KdpDebugBuffer == NULL) return;
164
165 /* Acquire the printing spinlock without waiting at raised IRQL */
167
168 beg = KdpCurrentPosition;
170 if (num != 0)
171 {
172 end = (beg + num) % KdpBufferSize;
174 KdpFreeBytes -= num;
175
176 if (end > beg)
177 {
179 }
180 else
181 {
184 }
185 }
186
187 /* Release the spinlock */
189
190 /* Signal the logger thread */
193}
194
196NTAPI
199 _In_ ULONG BootPhase)
200{
202
203 if (!KdpDebugMode.File)
205
206 if (BootPhase == 0)
207 {
208 /* Write out the functions that we support for now */
209 DispatchTable->KdpPrintRoutine = KdpPrintToLogFile;
210
211 /* Register for BootPhase 1 initialization and as a Provider */
212 DispatchTable->KdpInitRoutine = KdpDebugLogInit;
213 InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
214 }
215 else if (BootPhase == 1)
216 {
217 /* Allocate a buffer for debug log */
220 TAG_KDBG);
221 if (!KdpDebugBuffer)
222 {
224 RemoveEntryList(&DispatchTable->KdProvidersList);
225 return STATUS_NO_MEMORY;
226 }
228
229 /* Initialize spinlock */
231
232 /* Register for later BootPhase 2 reinitialization */
233 DispatchTable->KdpInitRoutine = KdpDebugLogInit;
234
235 /* Announce ourselves */
236 HalDisplayString(" File log debugging enabled\r\n");
237 }
238 else if (BootPhase >= 2)
239 {
243 HANDLE ThreadHandle;
245
246 /* If we have already successfully opened the log file, bail out */
247 if (KdpLogFileHandle != NULL)
248 return STATUS_SUCCESS;
249
250 /* Setup the log name */
252 if (!NT_SUCCESS(Status))
253 goto Failure;
254
256 &FileName,
258 NULL,
259 NULL);
260
261 /* Create the log file */
262 Status = ZwCreateFile(&KdpLogFileHandle,
265 &Iosb,
266 NULL,
272 NULL,
273 0);
274
276
277 if (!NT_SUCCESS(Status))
278 {
279 DPRINT1("Failed to open log file: 0x%08lx\n", Status);
280
281 /* Schedule an I/O reinitialization if needed */
284 {
285 DispatchTable->KdpInitRoutine = KdpDebugLogInit;
286 return Status;
287 }
288 goto Failure;
289 }
290
294 {
296 FILE_POSITION_INFORMATION FilePosInfo;
297
298 Status = ZwQueryInformationFile(KdpLogFileHandle,
299 &Iosb,
300 &FileInfo,
301 sizeof(FileInfo),
303 DPRINT("Status: 0x%08lx - EOF offset: %I64d\n",
304 Status, FileInfo.EndOfFile.QuadPart);
305
306 Status = ZwQueryInformationFile(KdpLogFileHandle,
307 &Iosb,
308 &FilePosInfo,
309 sizeof(FilePosInfo),
311 DPRINT("Status: 0x%08lx - Position: %I64d\n",
312 Status, FilePosInfo.CurrentByteOffset.QuadPart);
313
314 FilePosInfo.CurrentByteOffset.QuadPart = FileInfo.EndOfFile.QuadPart;
315 Status = ZwSetInformationFile(KdpLogFileHandle,
316 &Iosb,
317 &FilePosInfo,
318 sizeof(FilePosInfo),
320 DPRINT("ZwSetInformationFile(FilePositionInfo) returned: 0x%08lx\n", Status);
321 }
325
326 /* Create the logger thread */
327 Status = PsCreateSystemThread(&ThreadHandle,
329 NULL,
330 NULL,
331 NULL,
333 NULL);
334 if (!NT_SUCCESS(Status))
335 {
336 DPRINT1("Failed to create log file thread: 0x%08lx\n", Status);
338 goto Failure;
339 }
340
342 ZwSetInformationThread(ThreadHandle,
344 &Priority,
345 sizeof(Priority));
346
347 ZwClose(ThreadHandle);
348 return Status;
349
350Failure:
351 KdpFreeBytes = 0;
355 RemoveEntryList(&DispatchTable->KdProvidersList);
356 }
357
358 return Status;
359}
360
361/* SERIAL FUNCTIONS **********************************************************/
362
363static VOID
364NTAPI
368{
369 PCCH pch = String;
371
372 /* Acquire the printing spinlock without waiting at raised IRQL */
374
375 /* Output the string */
376 while (pch < String + Length && *pch)
377 {
378 if (*pch == '\n')
379 {
381 }
383 ++pch;
384 }
385
386 /* Release the spinlock */
388}
389
391NTAPI
394 _In_ ULONG BootPhase)
395{
396 if (!KdpDebugMode.Serial)
398
399 if (BootPhase == 0)
400 {
401 /* Write out the functions that we support for now */
402 DispatchTable->KdpPrintRoutine = KdpSerialPrint;
403
404 /* Initialize the Port */
406 {
409 }
411
412 /* Initialize spinlock */
414
415 /* Register for BootPhase 1 initialization and as a Provider */
416 DispatchTable->KdpInitRoutine = KdpSerialInit;
417 InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
418 }
419 else if (BootPhase == 1)
420 {
421 /* Announce ourselves */
422 HalDisplayString(" Serial debugging enabled\r\n");
423 }
424
425 return STATUS_SUCCESS;
426}
427
428/* SCREEN FUNCTIONS **********************************************************/
429
430VOID
432{
433 if (InbvIsBootDriverInstalled() /* &&
434 !InbvCheckDisplayOwnership() */)
435 {
436 /* Acquire ownership and reset the display */
444 }
445}
446
447// extern VOID NTAPI InbvSetDisplayOwnership(IN BOOLEAN DisplayOwned);
448
449VOID
451{
454 {
455 /* Release the display */
456 // InbvSetDisplayOwnership(FALSE);
458 }
459}
460
461static VOID
462NTAPI
466{
467 PCCH pch = String;
468
469 while (pch < String + Length && *pch)
470 {
471 if (*pch == '\b')
472 {
473 /* HalDisplayString does not support '\b'. Workaround it and use '\r' */
474 if (KdpScreenLineLength > 0)
475 {
476 /* Remove last character from buffer */
479
480 /* Clear row and print line again */
481 HalDisplayString("\r");
483 }
484 }
485 else
486 {
489 }
490
492 {
493 /* Print buffered characters */
496
497 /* Clear line buffer */
498 KdpScreenLineBuffer[0] = '\0';
500 }
501
502 ++pch;
503 }
504
505 /* Print buffered characters */
507 {
510 }
511}
512
514NTAPI
517 _In_ ULONG BootPhase)
518{
519 if (!KdpDebugMode.Screen)
521
522 if (BootPhase == 0)
523 {
524 /* Write out the functions that we support for now */
525 DispatchTable->KdpPrintRoutine = KdpScreenPrint;
526
527 /* Register for BootPhase 1 initialization and as a Provider */
528 DispatchTable->KdpInitRoutine = KdpScreenInit;
529 InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
530 }
531 else if (BootPhase == 1)
532 {
533 /* Take control of the display */
535
536 /* Announce ourselves */
537 HalDisplayString(" Screen debugging enabled\r\n");
538 }
539
540 return STATUS_SUCCESS;
541}
542
543
544/* GENERAL FUNCTIONS *********************************************************/
545
546static VOID
550{
551 PLIST_ENTRY CurrentEntry;
552 PKD_DISPATCH_TABLE CurrentTable;
553
554 /* Call the registered providers */
555 for (CurrentEntry = KdProviders.Flink;
556 CurrentEntry != &KdProviders;
557 CurrentEntry = CurrentEntry->Flink)
558 {
559 CurrentTable = CONTAINING_RECORD(CurrentEntry,
561 KdProvidersList);
562
563 CurrentTable->KdpPrintRoutine(String, Length);
564 }
565}
566
567VOID
570{
572}
573
574VOID
578 ...)
579{
580 va_list ap;
582 CHAR Buffer[512];
583
584 /* Format the string */
587 sizeof(Buffer),
588 Format,
589 ap);
590 va_end(ap);
591
592 /* Send it to the display providers */
594}
595
596#ifdef KDBG
597extern const CSTRING KdbPromptStr;
598#endif
599
600VOID
601NTAPI
603 _In_ ULONG PacketType,
604 _In_ PSTRING MessageHeader,
605 _In_opt_ PSTRING MessageData,
607{
608 PDBGKD_DEBUG_IO DebugIo;
609
610 if (PacketType == PACKET_TYPE_KD_STATE_CHANGE32 ||
611 PacketType == PACKET_TYPE_KD_STATE_CHANGE64)
612 {
613 PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange = (PDBGKD_ANY_WAIT_STATE_CHANGE)MessageHeader->Buffer;
614
615 if (WaitStateChange->NewState == DbgKdLoadSymbolsStateChange)
616 return; // Ignore: invoked anytime a new module is loaded.
617
618 /* We should not get there, unless an exception has been raised */
619 if (WaitStateChange->NewState == DbgKdExceptionStateChange)
620 {
621 PEXCEPTION_RECORD64 ExceptionRecord = &WaitStateChange->u.Exception.ExceptionRecord;
622
623 /*
624 * Claim the debugger to be present, so that KdpSendWaitContinue()
625 * can call back KdReceivePacket(PACKET_TYPE_KD_STATE_MANIPULATE),
626 * which, in turn, informs KD that the exception cannot be handled.
627 */
629 SharedUserData->KdDebuggerEnabled |= 0x00000002;
630
631 KdIoPrintf("%s: Got exception 0x%08lx @ 0x%p, Flags 0x%08x, %s - Info[0]: 0x%p\n",
633 ExceptionRecord->ExceptionCode,
634 (PVOID)(ULONG_PTR)ExceptionRecord->ExceptionAddress,
635 ExceptionRecord->ExceptionFlags,
636 WaitStateChange->u.Exception.FirstChance ? "FirstChance" : "LastChance",
637 ExceptionRecord->ExceptionInformation[0]);
638#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_ARM64)
640 if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
642 {
643 PCONTEXT ContextRecord = &KeGetCurrentPrcb()->ProcessorState.ContextFrame;
644 ULONG Status =
645#if defined(_M_IX86)
646 ContextRecord->Eax;
647#elif defined(_M_AMD64)
648 (ULONG)ContextRecord->Rcx;
649#elif defined(_M_ARM)
650 ContextRecord->R0;
651#else // defined(_M_ARM64)
652 (ULONG)ContextRecord->X0;
653#endif
654 KdIoPrintf("STATUS_BREAKPOINT Status 0x%08lx\n", Status);
655 }
656// #else
657// #error Unknown architecture
658#endif
659 return;
660 }
661
662 KdIoPrintf("%s: PACKET_TYPE_KD_STATE_CHANGE32/64 NewState %d is UNIMPLEMENTED\n",
663 __FUNCTION__, WaitStateChange->NewState);
664 return;
665 }
666 else
667 if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
668 {
669 PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
670 KdIoPrintf("%s: PACKET_TYPE_KD_STATE_MANIPULATE for ApiNumber %lu\n",
671 __FUNCTION__, ManipulateState->ApiNumber);
672 return;
673 }
674
675 if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
676 {
677 KdIoPrintf("%s: PacketType %d is UNIMPLEMENTED\n", __FUNCTION__, PacketType);
678 return;
679 }
680
681 DebugIo = (PDBGKD_DEBUG_IO)MessageHeader->Buffer;
682
683 /* Validate API call */
684 if (MessageHeader->Length != sizeof(DBGKD_DEBUG_IO))
685 return;
686 if ((DebugIo->ApiNumber != DbgKdPrintStringApi) &&
687 (DebugIo->ApiNumber != DbgKdGetStringApi))
688 {
689 return;
690 }
691 if (!MessageData)
692 return;
693
694 /* NOTE: MessageData->Length should be equal to
695 * DebugIo.u.PrintString.LengthOfString, or to
696 * DebugIo.u.GetString.LengthOfPromptString */
697
698 if (!KdpDebugMode.Value)
699 return;
700
701 /* Print the string proper */
702 KdIoPrintString(MessageData->Buffer, MessageData->Length);
703}
704
706NTAPI
708 _In_ ULONG PacketType,
709 _Out_ PSTRING MessageHeader,
710 _Out_ PSTRING MessageData,
713{
714#ifdef KDBG
715 PDBGKD_DEBUG_IO DebugIo;
716 STRING ResponseString;
717 CHAR MessageBuffer[512];
718#endif
719
720 if (PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
721 {
722 /* We don't support breaks-in */
723 return KdPacketTimedOut;
724 }
725
726 if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
727 {
728 PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
729 RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength);
730
731 /* The exception (notified via DbgKdExceptionStateChange in
732 * KdSendPacket()) cannot be handled: return a failure code */
733 ManipulateState->ApiNumber = DbgKdContinueApi;
735 return KdPacketReceived;
736 }
737
738 if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
739 {
740 KdIoPrintf("%s: PacketType %d is UNIMPLEMENTED\n", __FUNCTION__, PacketType);
741 return KdPacketTimedOut;
742 }
743
744#ifdef KDBG
745 DebugIo = (PDBGKD_DEBUG_IO)MessageHeader->Buffer;
746
747 /* Validate API call */
748 if (MessageHeader->MaximumLength != sizeof(DBGKD_DEBUG_IO))
749 return KdPacketNeedsResend;
750 if (DebugIo->ApiNumber != DbgKdGetStringApi)
751 return KdPacketNeedsResend;
752
753 /* NOTE: We cannot use directly MessageData->Buffer here as it points
754 * to the temporary KdpMessageBuffer scratch buffer that is being
755 * shared with all the possible I/O KD operations that may happen. */
756 ResponseString.Buffer = MessageBuffer;
757 ResponseString.Length = 0;
758 ResponseString.MaximumLength = min(sizeof(MessageBuffer),
759 MessageData->MaximumLength);
760 ResponseString.MaximumLength = min(ResponseString.MaximumLength,
762
763 /* The prompt string has been printed by KdSendPacket; go to
764 * new line and print the kdb prompt -- for SYSREG2 support. */
765 KdIoPrintString("\n", 1);
766 KdIoPuts(KdbPromptStr.Buffer); // Alternatively, use "Input> "
767
770
771 /*
772 * Read a NULL-terminated line of user input and retrieve its length.
773 * Official documentation states that DbgPrompt() includes a terminating
774 * newline character but does not NULL-terminate. However, experiments
775 * show that this behaviour is left at the discretion of WinDbg itself.
776 * WinDbg NULL-terminates the string unless its buffer is too short,
777 * in which case the string is simply truncated without NULL-termination.
778 */
779 ResponseString.Length =
780 (USHORT)KdIoReadLine(ResponseString.Buffer,
781 ResponseString.MaximumLength);
782
785
786 /* Adjust and return the string length */
787 *DataLength = min(ResponseString.Length + sizeof(ANSI_NULL),
789 MessageData->Length = DebugIo->u.GetString.LengthOfStringRead = *DataLength;
790
791 /* Only now we can copy back the data into MessageData->Buffer */
792 RtlCopyMemory(MessageData->Buffer, ResponseString.Buffer, *DataLength);
793#endif
794
795 return KdPacketReceived;
796}
797
798/* EOF */
unsigned char BOOLEAN
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define __cdecl
Definition: accygwin.h:79
#define VOID
Definition: acefi.h:82
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define DPRINT1
Definition: precomp.h:8
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
@ ThreadPriority
Definition: compat.h:937
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
LONG KPRIORITY
Definition: compat.h:803
#define FILE_SHARE_READ
Definition: compat.h:136
#define __FUNCTION__
Definition: types.h:116
return Iosb
Definition: create.c:4403
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define NonPagedPool
Definition: env_spec_w32.h:307
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define ExGetPreviousMode
Definition: ex.h:143
#define InterlockedExchangeAddUL(Addend, Value)
Definition: ex.h:1550
struct _FileName FileName
Definition: fatprocs.h:897
std::wstring STRING
Definition: fontsub.cpp:33
@ FilePositionInformation
Definition: from_kernel.h:75
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_WRITE_THROUGH
Definition: from_kernel.h:26
#define FILE_OPEN_IF
Definition: from_kernel.h:56
#define FILE_SEQUENTIAL_ONLY
Definition: from_kernel.h:27
Status
Definition: gdiplustypes.h:25
GLuint GLuint end
Definition: gl.h:1545
GLuint GLuint num
Definition: glext.h:9618
PUCHAR KdComPortInUse
Definition: usage.c:17
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:293
VOID NTAPI InbvInstallDisplayStringFilter(_In_ INBV_DISPLAY_STRING_FILTER DisplayFilter)
Definition: inbv.c:390
VOID NTAPI InbvNotifyDisplayOwnershipLost(_In_ INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:407
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:319
VOID NTAPI InbvSetTextColor(_In_ ULONG Color)
Definition: inbv.c:463
BOOLEAN NTAPI InbvEnableDisplayString(_In_ BOOLEAN Enable)
Definition: inbv.c:373
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:434
VOID NTAPI InbvSetScrollRegion(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom)
Definition: inbv.c:451
VOID NTAPI InbvSolidColorFill(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ ULONG Color)
Definition: inbv.c:488
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:399
BOOLEAN NTAPI KdPortInitializeEx(PCPPORT PortInformation, ULONG ComPortNumber)
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define HIGH_PRIORITY
SIZE_T KdIoReadLine(_Out_ PCHAR Buffer, _In_ SIZE_T Size)
Reads a line of user input from the terminal.
Definition: kdprompt.c:51
#define KdMax
Definition: kd.h:93
NTSTATUS(NTAPI * PKDP_INIT_ROUTINE)(_In_ struct _KD_DISPATCH_TABLE *DispatchTable, _In_ ULONG BootPhase)
Definition: kd.h:9
const CSTRING KdbPromptStr
Definition: kdb_cli.c:149
#define DEFAULT_DEBUG_PORT
Definition: kdcom.c:25
#define DEFAULT_DEBUG_BAUD_RATE
Definition: kdcom.c:28
VOID NTAPI RtlpBreakWithStatusInstruction(VOID)
static VOID NTAPI KdpLoggerThread(PVOID Context)
Definition: kdio.c:107
static volatile ULONG KdpFreeBytes
Definition: kdio.c:32
ULONG SerialPortNumber
Definition: kdio.c:39
VOID __cdecl KdIoPrintf(_In_ PCSTR Format,...)
Definition: kdio.c:576
NTSTATUS NTAPI KdpSerialInit(_In_ PKD_DISPATCH_TABLE DispatchTable, _In_ ULONG BootPhase)
Definition: kdio.c:392
static HANDLE KdpLogFileHandle
Definition: kdio.c:35
VOID NTAPI KdbpReleaseLock(_In_ PKSPIN_LOCK SpinLock, _In_ KIRQL OldIrql)
Definition: kdio.c:91
LIST_ENTRY KdProviders
Definition: kdio.c:47
static ULONG KdpScreenLineBufferPos
Definition: kdio.c:44
VOID NTAPI KdSendPacket(_In_ ULONG PacketType, _In_ PSTRING MessageHeader, _In_opt_ PSTRING MessageData, _Inout_ PKD_CONTEXT Context)
Definition: kdio.c:602
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:46
#define KdpBufferSize
Definition: kdio.c:28
KDSTATUS NTAPI KdReceivePacket(_In_ ULONG PacketType, _Out_ PSTRING MessageHeader, _Out_ PSTRING MessageData, _Out_ PULONG DataLength, _Inout_ PKD_CONTEXT Context)
Definition: kdio.c:707
VOID KdpScreenRelease(VOID)
Definition: kdio.c:450
KIRQL NTAPI KdbpAcquireLock(_In_ PKSPIN_LOCK SpinLock)
Definition: kdio.c:64
static PCHAR KdpDebugBuffer
Definition: kdio.c:30
static CHAR KdpScreenLineBuffer[KdpScreenLineLengthDefault+1]
Definition: kdio.c:43
static VOID KdIoPrintString(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:547
PKDP_INIT_ROUTINE InitRoutines[KdMax]
Definition: kdio.c:50
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:38
NTSTATUS NTAPI KdpScreenInit(_In_ PKD_DISPATCH_TABLE DispatchTable, _In_ ULONG BootPhase)
Definition: kdio.c:515
NTSTATUS NTAPI KdpDebugLogInit(_In_ PKD_DISPATCH_TABLE DispatchTable, _In_ ULONG BootPhase)
Definition: kdio.c:197
static KSPIN_LOCK KdpDebugLogSpinLock
Definition: kdio.c:33
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:34
static ULONG KdpScreenLineLength
Definition: kdio.c:44
VOID KdpScreenAcquire(VOID)
Definition: kdio.c:431
ANSI_STRING KdpLogFileName
Definition: kdio.c:36
static BOOLEAN KdpLoggingEnabled
Definition: kdio.c:29
CPPORT SerialPortInfo
Definition: kdio.c:40
static VOID NTAPI KdpScreenPrint(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:463
VOID KdIoPuts(_In_ PCSTR String)
Definition: kdio.c:568
static VOID NTAPI KdpPrintToLogFile(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:156
static volatile ULONG KdpCurrentPosition
Definition: kdio.c:31
static VOID NTAPI KdpSerialPrint(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:365
#define KdpScreenLineLengthDefault
Definition: kdio.c:42
VOID KbdDisableMouse(VOID)
Definition: kdps2kbd.c:98
VOID KbdEnableMouse(VOID)
Definition: kdps2kbd.c:93
ULONG KdbDebugState
Definition: kdterminal.c:32
@ KD_DEBUG_KDSERIAL
Definition: kdterminal.h:36
if(dx< 0)
Definition: linetemp.h:194
#define pch(ap)
Definition: match.c:418
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define min(a, b)
Definition: monoChain.cc:55
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1182
#define KernelMode
Definition: asm.h:38
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define _Inout_
Definition: no_sal2.h:162
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define FILE_APPEND_DATA
Definition: nt_native.h:634
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:662
#define ANSI_NULL
CONST CHAR * PCCH
Definition: ntbasedef.h:400
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ SynchronizationEvent
BOOLEAN FASTCALL KeTestSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:475
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:309
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:298
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
#define STATUS_BREAKPOINT
Definition: ntstatus.h:184
#define STATUS_PORT_DISCONNECTED
Definition: ntstatus.h:291
#define DBG_EXCEPTION_NOT_HANDLED
Definition: ntstatus.h:57
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define SCREEN_WIDTH
Definition: pc98video.c:27
#define SCREEN_HEIGHT
Definition: pc98video.c:28
unsigned short USHORT
Definition: pedump.c:61
#define BV_COLOR_WHITE
Definition: display.h:30
#define BV_COLOR_BLACK
Definition: display.h:15
#define KdPacketReceived
Definition: kddll.h:5
#define KdPacketNeedsResend
Definition: kddll.h:7
ULONG KDSTATUS
Definition: kddll.h:4
#define KdPacketTimedOut
Definition: kddll.h:6
#define SharedUserData
#define FileStandardInformation
Definition: propsheet.cpp:61
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
PUCHAR Address
Definition: cportlib.h:29
CONST CHAR * Buffer
Definition: umtypes.h:159
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3640 u
DBGKM_EXCEPTION64 Exception
Definition: windbgkd.h:508
NTSTATUS ContinueStatus
Definition: windbgkd.h:579
DBGKD_GET_STRING GetString
Definition: windbgkd.h:427
ULONG ApiNumber
Definition: windbgkd.h:421
union _DBGKD_DEBUG_IO::@3637 u
ULONG LengthOfStringRead
Definition: windbgkd.h:413
union _DBGKD_MANIPULATE_STATE64::@3648 u
DBGKD_CONTINUE Continue
Definition: windbgkd.h:799
EXCEPTION_RECORD64 ExceptionRecord
Definition: windbgkd.h:312
NTSTATUS ExceptionCode
Definition: rtltypes.h:190
ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]
Definition: rtltypes.h:196
ULONG64 ExceptionAddress
Definition: rtltypes.h:193
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
UCHAR File
Definition: kd.h:106
UCHAR Screen
Definition: kd.h:104
UCHAR Serial
Definition: kd.h:105
ULONG Value
Definition: kd.h:110
PKDP_PRINT_ROUTINE KdpPrintRoutine
Definition: kd.h:119
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TAG_KDBG
Definition: tag.h:38
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
const char * PCSTR
Definition: typedefs.h:52
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:655
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:248
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:228
#define DbgKdLoadSymbolsStateChange
Definition: windbgkd.h:60
#define DbgKdPrintStringApi
Definition: windbgkd.h:122
#define PACKET_TYPE_KD_STATE_CHANGE32
Definition: windbgkd.h:42
#define PACKET_TYPE_KD_STATE_MANIPULATE
Definition: windbgkd.h:43
#define DbgKdGetStringApi
Definition: windbgkd.h:123
struct _DBGKD_ANY_WAIT_STATE_CHANGE * PDBGKD_ANY_WAIT_STATE_CHANGE
struct _DBGKD_MANIPULATE_STATE64 * PDBGKD_MANIPULATE_STATE64
#define DbgKdExceptionStateChange
Definition: windbgkd.h:59
#define PACKET_TYPE_KD_STATE_CHANGE64
Definition: windbgkd.h:48
#define DbgKdContinueApi
Definition: windbgkd.h:80
#define PACKET_TYPE_KD_POLL_BREAKIN
Definition: windbgkd.h:49
struct _DBGKD_DEBUG_IO * PDBGKD_DEBUG_IO
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define KD_DEBUGGER_NOT_PRESENT
Definition: kdfuncs.h:133
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ Executive
Definition: ketypes.h:415
#define _vsnprintf
Definition: xmlstorage.h:202
char CHAR
Definition: xmlstorage.h:175