ReactOS 0.4.16-dev-2491-g3dc6630
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#include <cportlib/uartinfo.h>
20
21#define NDEBUG
22#include <debug.h>
23
24#undef KdSendPacket
25#undef KdReceivePacket
26
27/* GLOBALS *******************************************************************/
28
29#define KdpBufferSize (1024 * 512)
32static volatile ULONG KdpCurrentPosition = 0;
33static volatile ULONG KdpFreeBytes = 0;
37ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log");
38
42
43#define KdpScreenLineLengthDefault 80
46
50
52{
56#ifdef KDBG // See kdb_cli.c
57 KdpKdbgInit
58#endif
59};
60
61/* LOCKING FUNCTIONS *********************************************************/
62
67{
69
70 /* Acquire the spinlock without waiting at raised IRQL */
71 while (TRUE)
72 {
73 /* Loop until the spinlock becomes available */
74 while (!KeTestSpinLock(SpinLock));
75
76 /* Spinlock is free, raise IRQL to high level */
78
79 /* Try to get the spinlock */
81 break;
82
83 /* Someone else got the spinlock, lower IRQL back */
85 }
86
87 return OldIrql;
88}
89
90VOID
95{
96 /* Release the spinlock */
98 // KeReleaseSpinLockFromDpcLevel(SpinLock);
99
100 /* Restore the old IRQL */
102}
103
104/* FILE DEBUG LOG FUNCTIONS **************************************************/
105
106static VOID
107NTAPI
109{
110 ULONG beg, end, num;
112
114
116
117 while (TRUE)
118 {
120
121 /* Bug */
122 /* Keep KdpCurrentPosition and KdpFreeBytes values in local
123 * variables to avoid their possible change from Producer part,
124 * KdpPrintToLogFile function
125 */
128
129 /* Now securely calculate values, based on local variables */
130 beg = (end + num) % KdpBufferSize;
132
133 /* Nothing to do? */
134 if (num == 0)
135 continue;
136
137 if (end > beg)
138 {
140 KdpDebugBuffer + beg, num, NULL, NULL);
141 }
142 else
143 {
145 KdpDebugBuffer + beg, KdpBufferSize - beg, NULL, NULL);
146
149 }
150
152 }
153}
154
155static VOID
156NTAPI
160{
162 ULONG beg, end, num;
163
164 if (KdpDebugBuffer == NULL) return;
165
166 /* Acquire the printing spinlock without waiting at raised IRQL */
168
169 beg = KdpCurrentPosition;
171 if (num != 0)
172 {
173 end = (beg + num) % KdpBufferSize;
175 KdpFreeBytes -= num;
176
177 if (end > beg)
178 {
180 }
181 else
182 {
185 }
186 }
187
188 /* Release the spinlock */
190
191 /* Signal the logger thread */
194}
195
197NTAPI
200 _In_ ULONG BootPhase)
201{
203
204 if (!KdpDebugMode.File)
206
207 if (BootPhase == 0)
208 {
209 /* Write out the functions that we support for now */
210 DispatchTable->KdpPrintRoutine = KdpPrintToLogFile;
211
212 /* Register for BootPhase 1 initialization and as a Provider */
213 DispatchTable->KdpInitRoutine = KdpDebugLogInit;
214 InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
215 }
216 else if (BootPhase == 1)
217 {
218 /* Allocate a buffer for debug log */
221 TAG_KDBG);
222 if (!KdpDebugBuffer)
223 {
225 RemoveEntryList(&DispatchTable->KdProvidersList);
226 return STATUS_NO_MEMORY;
227 }
229
230 /* Initialize spinlock */
232
233 /* Register for later BootPhase 2 reinitialization */
234 DispatchTable->KdpInitRoutine = KdpDebugLogInit;
235
236 /* Announce ourselves */
237 HalDisplayString(" File log debugging enabled\r\n");
238 }
239 else if (BootPhase >= 2)
240 {
244 HANDLE ThreadHandle;
246
247 /* If we have already successfully opened the log file, bail out */
248 if (KdpLogFileHandle != NULL)
249 return STATUS_SUCCESS;
250
251 /* Setup the log name */
253 if (!NT_SUCCESS(Status))
254 goto Failure;
255
257 &FileName,
259 NULL,
260 NULL);
261
262 /* Create the log file */
263 Status = ZwCreateFile(&KdpLogFileHandle,
266 &Iosb,
267 NULL,
273 NULL,
274 0);
275
277
278 if (!NT_SUCCESS(Status))
279 {
280 DPRINT1("Failed to open log file: 0x%08lx\n", Status);
281
282 /* Schedule an I/O reinitialization if needed */
285 {
286 DispatchTable->KdpInitRoutine = KdpDebugLogInit;
287 return Status;
288 }
289 goto Failure;
290 }
291
295 {
297 FILE_POSITION_INFORMATION FilePosInfo;
298
299 Status = ZwQueryInformationFile(KdpLogFileHandle,
300 &Iosb,
301 &FileInfo,
302 sizeof(FileInfo),
304 DPRINT("Status: 0x%08lx - EOF offset: %I64d\n",
305 Status, FileInfo.EndOfFile.QuadPart);
306
307 Status = ZwQueryInformationFile(KdpLogFileHandle,
308 &Iosb,
309 &FilePosInfo,
310 sizeof(FilePosInfo),
312 DPRINT("Status: 0x%08lx - Position: %I64d\n",
313 Status, FilePosInfo.CurrentByteOffset.QuadPart);
314
315 FilePosInfo.CurrentByteOffset.QuadPart = FileInfo.EndOfFile.QuadPart;
316 Status = ZwSetInformationFile(KdpLogFileHandle,
317 &Iosb,
318 &FilePosInfo,
319 sizeof(FilePosInfo),
321 DPRINT("ZwSetInformationFile(FilePositionInfo) returned: 0x%08lx\n", Status);
322 }
326
327 /* Create the logger thread */
328 Status = PsCreateSystemThread(&ThreadHandle,
330 NULL,
331 NULL,
332 NULL,
334 NULL);
335 if (!NT_SUCCESS(Status))
336 {
337 DPRINT1("Failed to create log file thread: 0x%08lx\n", Status);
339 goto Failure;
340 }
341
343 ZwSetInformationThread(ThreadHandle,
345 &Priority,
346 sizeof(Priority));
347
348 ZwClose(ThreadHandle);
349 return Status;
350
351Failure:
352 KdpFreeBytes = 0;
356 RemoveEntryList(&DispatchTable->KdProvidersList);
357 }
358
359 return Status;
360}
361
362/* SERIAL FUNCTIONS **********************************************************/
363
364static VOID
365NTAPI
369{
370 PCCH pch = String;
372
373 /* Acquire the printing spinlock without waiting at raised IRQL */
375
376 /* Output the string */
377 while (pch < String + Length && *pch)
378 {
379 if (*pch == '\n')
380 {
382 }
384 ++pch;
385 }
386
387 /* Release the spinlock */
389}
390
392NTAPI
395 _In_ ULONG BootPhase)
396{
397 if (!KdpDebugMode.Serial)
399
400 if (BootPhase == 0)
401 {
402 /* Write out the functions that we support for now */
403 DispatchTable->KdpPrintRoutine = KdpSerialPrint;
404
405 /* Initialize the Port */
407 {
410 }
412
413 /* Initialize spinlock */
415
416 /* Register for BootPhase 1 initialization and as a Provider */
417 DispatchTable->KdpInitRoutine = KdpSerialInit;
418 InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
419 }
420 else if (BootPhase == 1)
421 {
422 /* Announce ourselves */
423 HalDisplayString(" Serial debugging enabled\r\n");
424 }
425
426 return STATUS_SUCCESS;
427}
428
429/* SCREEN FUNCTIONS **********************************************************/
430
431VOID
433{
434 if (InbvIsBootDriverInstalled() /* &&
435 !InbvCheckDisplayOwnership() */)
436 {
437 /* Acquire ownership and reset the display */
445 }
446}
447
448// extern VOID NTAPI InbvSetDisplayOwnership(IN BOOLEAN DisplayOwned);
449
450VOID
452{
455 {
456 /* Release the display */
457 // InbvSetDisplayOwnership(FALSE);
459 }
460}
461
462static VOID
463NTAPI
467{
468 PCCH pch = String;
469
470 while (pch < String + Length && *pch)
471 {
472 if (*pch == '\b')
473 {
474 /* HalDisplayString does not support '\b'. Workaround it and use '\r' */
475 if (KdpScreenLineLength > 0)
476 {
477 /* Remove last character from buffer */
480
481 /* Clear row and print line again */
482 HalDisplayString("\r");
484 }
485 }
486 else
487 {
490 }
491
493 {
494 /* Print buffered characters */
497
498 /* Clear line buffer */
499 KdpScreenLineBuffer[0] = '\0';
501 }
502
503 ++pch;
504 }
505
506 /* Print buffered characters */
508 {
511 }
512}
513
515NTAPI
518 _In_ ULONG BootPhase)
519{
520 if (!KdpDebugMode.Screen)
522
523 if (BootPhase == 0)
524 {
525 /* Write out the functions that we support for now */
526 DispatchTable->KdpPrintRoutine = KdpScreenPrint;
527
528 /* Register for BootPhase 1 initialization and as a Provider */
529 DispatchTable->KdpInitRoutine = KdpScreenInit;
530 InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
531 }
532 else if (BootPhase == 1)
533 {
534 /* Take control of the display */
536
537 /* Announce ourselves */
538 HalDisplayString(" Screen debugging enabled\r\n");
539 }
540
541 return STATUS_SUCCESS;
542}
543
544
545/* GENERAL FUNCTIONS *********************************************************/
546
547static VOID
551{
552 PLIST_ENTRY CurrentEntry;
553 PKD_DISPATCH_TABLE CurrentTable;
554
555 /* Call the registered providers */
556 for (CurrentEntry = KdProviders.Flink;
557 CurrentEntry != &KdProviders;
558 CurrentEntry = CurrentEntry->Flink)
559 {
560 CurrentTable = CONTAINING_RECORD(CurrentEntry,
562 KdProvidersList);
563
564 CurrentTable->KdpPrintRoutine(String, Length);
565 }
566}
567
568VOID
571{
573}
574
575VOID
579 ...)
580{
581 va_list ap;
583 CHAR Buffer[512];
584
585 /* Format the string */
588 sizeof(Buffer),
589 Format,
590 ap);
591 va_end(ap);
592
593 /* Send it to the display providers */
595}
596
597#ifdef KDBG
598extern const CSTRING KdbPromptStr;
599#endif
600
601VOID
602NTAPI
604 _In_ ULONG PacketType,
605 _In_ PSTRING MessageHeader,
606 _In_opt_ PSTRING MessageData,
608{
609 PDBGKD_DEBUG_IO DebugIo;
610
611 if (PacketType == PACKET_TYPE_KD_STATE_CHANGE32 ||
612 PacketType == PACKET_TYPE_KD_STATE_CHANGE64)
613 {
614 PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange = (PDBGKD_ANY_WAIT_STATE_CHANGE)MessageHeader->Buffer;
615
616 if (WaitStateChange->NewState == DbgKdLoadSymbolsStateChange)
617 return; // Ignore: invoked anytime a new module is loaded.
618
619 /* We should not get there, unless an exception has been raised */
620 if (WaitStateChange->NewState == DbgKdExceptionStateChange)
621 {
622 PEXCEPTION_RECORD64 ExceptionRecord = &WaitStateChange->u.Exception.ExceptionRecord;
623
624 /*
625 * Claim the debugger to be present, so that KdpSendWaitContinue()
626 * can call back KdReceivePacket(PACKET_TYPE_KD_STATE_MANIPULATE),
627 * which, in turn, informs KD that the exception cannot be handled.
628 */
630 SharedUserData->KdDebuggerEnabled |= 0x00000002;
631
632 KdIoPrintf("%s: Got exception 0x%08lx @ 0x%p, Flags 0x%08x, %s - Info[0]: 0x%p\n",
634 ExceptionRecord->ExceptionCode,
635 (PVOID)(ULONG_PTR)ExceptionRecord->ExceptionAddress,
636 ExceptionRecord->ExceptionFlags,
637 WaitStateChange->u.Exception.FirstChance ? "FirstChance" : "LastChance",
638 ExceptionRecord->ExceptionInformation[0]);
639#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_ARM64)
641 if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
643 {
644 PCONTEXT ContextRecord = &KeGetCurrentPrcb()->ProcessorState.ContextFrame;
645 ULONG Status =
646#if defined(_M_IX86)
647 ContextRecord->Eax;
648#elif defined(_M_AMD64)
649 (ULONG)ContextRecord->Rcx;
650#elif defined(_M_ARM)
651 ContextRecord->R0;
652#else // defined(_M_ARM64)
653 (ULONG)ContextRecord->X0;
654#endif
655 KdIoPrintf("STATUS_BREAKPOINT Status 0x%08lx\n", Status);
656 }
657// #else
658// #error Unknown architecture
659#endif
660 return;
661 }
662
663 KdIoPrintf("%s: PACKET_TYPE_KD_STATE_CHANGE32/64 NewState %d is UNIMPLEMENTED\n",
664 __FUNCTION__, WaitStateChange->NewState);
665 return;
666 }
667 else
668 if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
669 {
670 PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
671 KdIoPrintf("%s: PACKET_TYPE_KD_STATE_MANIPULATE for ApiNumber %lu\n",
672 __FUNCTION__, ManipulateState->ApiNumber);
673 return;
674 }
675
676 if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
677 {
678 KdIoPrintf("%s: PacketType %d is UNIMPLEMENTED\n", __FUNCTION__, PacketType);
679 return;
680 }
681
682 DebugIo = (PDBGKD_DEBUG_IO)MessageHeader->Buffer;
683
684 /* Validate API call */
685 if (MessageHeader->Length != sizeof(DBGKD_DEBUG_IO))
686 return;
687 if ((DebugIo->ApiNumber != DbgKdPrintStringApi) &&
688 (DebugIo->ApiNumber != DbgKdGetStringApi))
689 {
690 return;
691 }
692 if (!MessageData)
693 return;
694
695 /* NOTE: MessageData->Length should be equal to
696 * DebugIo.u.PrintString.LengthOfString, or to
697 * DebugIo.u.GetString.LengthOfPromptString */
698
699 if (!KdpDebugMode.Value)
700 return;
701
702 /* Print the string proper */
703 KdIoPrintString(MessageData->Buffer, MessageData->Length);
704}
705
707NTAPI
709 _In_ ULONG PacketType,
710 _Out_ PSTRING MessageHeader,
711 _Out_ PSTRING MessageData,
714{
715#ifdef KDBG
716 PDBGKD_DEBUG_IO DebugIo;
717 STRING ResponseString;
718 CHAR MessageBuffer[512];
719#endif
720
721 if (PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
722 {
723 /* We don't support breaks-in */
724 return KdPacketTimedOut;
725 }
726
727 if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
728 {
729 PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
730 RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength);
731
732 /* The exception (notified via DbgKdExceptionStateChange in
733 * KdSendPacket()) cannot be handled: return a failure code */
734 ManipulateState->ApiNumber = DbgKdContinueApi;
736 return KdPacketReceived;
737 }
738
739 if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
740 {
741 KdIoPrintf("%s: PacketType %d is UNIMPLEMENTED\n", __FUNCTION__, PacketType);
742 return KdPacketTimedOut;
743 }
744
745#ifdef KDBG
746 DebugIo = (PDBGKD_DEBUG_IO)MessageHeader->Buffer;
747
748 /* Validate API call */
749 if (MessageHeader->MaximumLength != sizeof(DBGKD_DEBUG_IO))
750 return KdPacketNeedsResend;
751 if (DebugIo->ApiNumber != DbgKdGetStringApi)
752 return KdPacketNeedsResend;
753
754 /* NOTE: We cannot use directly MessageData->Buffer here as it points
755 * to the temporary KdpMessageBuffer scratch buffer that is being
756 * shared with all the possible I/O KD operations that may happen. */
757 ResponseString.Buffer = MessageBuffer;
758 ResponseString.Length = 0;
759 ResponseString.MaximumLength = min(sizeof(MessageBuffer),
760 MessageData->MaximumLength);
761 ResponseString.MaximumLength = min(ResponseString.MaximumLength,
763
764 /* The prompt string has been printed by KdSendPacket; go to
765 * new line and print the kdb prompt -- for SYSREG2 support. */
766 KdIoPrintString("\n", 1);
767 KdIoPuts(KdbPromptStr.Buffer); // Alternatively, use "Input> "
768
771
772 /*
773 * Read a NULL-terminated line of user input and retrieve its length.
774 * Official documentation states that DbgPrompt() includes a terminating
775 * newline character but does not NULL-terminate. However, experiments
776 * show that this behaviour is left at the discretion of WinDbg itself.
777 * WinDbg NULL-terminates the string unless its buffer is too short,
778 * in which case the string is simply truncated without NULL-termination.
779 */
780 ResponseString.Length =
781 (USHORT)KdIoReadLine(ResponseString.Buffer,
782 ResponseString.MaximumLength);
783
786
787 /* Adjust and return the string length */
788 *DataLength = min(ResponseString.Length + sizeof(ANSI_NULL),
790 MessageData->Length = DebugIo->u.GetString.LengthOfStringRead = *DataLength;
791
792 /* Only now we can copy back the data into MessageData->Buffer */
793 RtlCopyMemory(MessageData->Buffer, ResponseString.Buffer, *DataLength);
794#endif
795
796 return KdPacketReceived;
797}
798
799/* EOF */
#define VOID
Definition: acefi.h:82
unsigned char BOOLEAN
Definition: actypes.h:127
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
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
@ 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 __cdecl
Definition: corecrt.h:121
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
char * va_list
Definition: vadefs.h:50
#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:393
VOID NTAPI InbvNotifyDisplayOwnershipLost(_In_ INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:410
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:319
VOID NTAPI InbvSetTextColor(_In_ ULONG Color)
Definition: inbv.c:466
BOOLEAN NTAPI InbvEnableDisplayString(_In_ BOOLEAN Enable)
Definition: inbv.c:376
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:437
VOID NTAPI InbvSetScrollRegion(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom)
Definition: inbv.c:454
VOID NTAPI InbvSolidColorFill(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ ULONG Color)
Definition: inbv.c:491
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:402
BOOLEAN NTAPI KdPortInitializeEx(PCPPORT PortInformation, ULONG ComPortNumber)
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
#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:87
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
VOID NTAPI RtlpBreakWithStatusInstruction(VOID)
static VOID NTAPI KdpLoggerThread(PVOID Context)
Definition: kdio.c:108
static volatile ULONG KdpFreeBytes
Definition: kdio.c:33
ULONG SerialPortNumber
Definition: kdio.c:40
VOID __cdecl KdIoPrintf(_In_ PCSTR Format,...)
Definition: kdio.c:577
NTSTATUS NTAPI KdpSerialInit(_In_ PKD_DISPATCH_TABLE DispatchTable, _In_ ULONG BootPhase)
Definition: kdio.c:393
static HANDLE KdpLogFileHandle
Definition: kdio.c:36
VOID NTAPI KdbpReleaseLock(_In_ PKSPIN_LOCK SpinLock, _In_ KIRQL OldIrql)
Definition: kdio.c:92
LIST_ENTRY KdProviders
Definition: kdio.c:48
static ULONG KdpScreenLineBufferPos
Definition: kdio.c:45
VOID NTAPI KdSendPacket(_In_ ULONG PacketType, _In_ PSTRING MessageHeader, _In_opt_ PSTRING MessageData, _Inout_ PKD_CONTEXT Context)
Definition: kdio.c:603
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:47
#define KdpBufferSize
Definition: kdio.c:29
KDSTATUS NTAPI KdReceivePacket(_In_ ULONG PacketType, _Out_ PSTRING MessageHeader, _Out_ PSTRING MessageData, _Out_ PULONG DataLength, _Inout_ PKD_CONTEXT Context)
Definition: kdio.c:708
VOID KdpScreenRelease(VOID)
Definition: kdio.c:451
KIRQL NTAPI KdbpAcquireLock(_In_ PKSPIN_LOCK SpinLock)
Definition: kdio.c:65
static PCHAR KdpDebugBuffer
Definition: kdio.c:31
static CHAR KdpScreenLineBuffer[KdpScreenLineLengthDefault+1]
Definition: kdio.c:44
static VOID KdIoPrintString(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:548
PKDP_INIT_ROUTINE InitRoutines[KdMax]
Definition: kdio.c:51
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:39
NTSTATUS NTAPI KdpScreenInit(_In_ PKD_DISPATCH_TABLE DispatchTable, _In_ ULONG BootPhase)
Definition: kdio.c:516
NTSTATUS NTAPI KdpDebugLogInit(_In_ PKD_DISPATCH_TABLE DispatchTable, _In_ ULONG BootPhase)
Definition: kdio.c:198
static KSPIN_LOCK KdpDebugLogSpinLock
Definition: kdio.c:34
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:35
static ULONG KdpScreenLineLength
Definition: kdio.c:45
VOID KdpScreenAcquire(VOID)
Definition: kdio.c:432
ANSI_STRING KdpLogFileName
Definition: kdio.c:37
static BOOLEAN KdpLoggingEnabled
Definition: kdio.c:30
CPPORT SerialPortInfo
Definition: kdio.c:41
static VOID NTAPI KdpScreenPrint(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:464
VOID KdIoPuts(_In_ PCSTR String)
Definition: kdio.c:569
static VOID NTAPI KdpPrintToLogFile(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:157
static volatile ULONG KdpCurrentPosition
Definition: kdio.c:32
static VOID NTAPI KdpSerialPrint(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:366
#define KdpScreenLineLengthDefault
Definition: kdio.c:43
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
static 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:1187
#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:1342
#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:666
#define ANSI_NULL
CONST CHAR * PCCH
Definition: ntbasedef.h:404
_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:264
#define STATUS_PORT_DISCONNECTED
Definition: ntstatus.h:385
#define DBG_EXCEPTION_NOT_HANDLED
Definition: ntstatus.h:109
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:522
#define SCREEN_WIDTH
Definition: pc98video.c:24
#define SCREEN_HEIGHT
Definition: pc98video.c:25
unsigned short USHORT
Definition: pedump.c:61
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#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
_In_ PVOID Context
Definition: storport.h:2269
PUCHAR Address
Definition: cportlib.h:28
CONST CHAR * Buffer
Definition: umtypes.h:161
DBGKM_EXCEPTION64 Exception
Definition: windbgkd.h:508
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3794 u
NTSTATUS ContinueStatus
Definition: windbgkd.h:579
DBGKD_GET_STRING GetString
Definition: windbgkd.h:427
union _DBGKD_DEBUG_IO::@3791 u
ULONG ApiNumber
Definition: windbgkd.h:421
ULONG LengthOfStringRead
Definition: windbgkd.h:413
union _DBGKD_MANIPULATE_STATE64::@3802 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:958
UCHAR File
Definition: kd.h:100
UCHAR Screen
Definition: kd.h:98
UCHAR Serial
Definition: kd.h:99
ULONG Value
Definition: kd.h:104
PKDP_PRINT_ROUTINE KdpPrintRoutine
Definition: kd.h:113
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TAG_KDBG
Definition: tag.h:38
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 DEFAULT_DEBUG_PORT
Definition: uartinfo.h:16
#define DEFAULT_DEBUG_BAUD_RATE
Definition: uartinfo.h:17
#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:2439
_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:467
#define _vsnprintf
Definition: xmlstorage.h:202
char CHAR
Definition: xmlstorage.h:175