ReactOS  0.4.15-dev-5492-g47f3a4e
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 
15 #define NDEBUG
16 #include <debug.h>
17 
18 /* GLOBALS *******************************************************************/
19 
20 #define KdpBufferSize (1024 * 512)
24 static volatile ULONG KdpCurrentPosition = 0;
25 static volatile ULONG KdpFreeBytes = 0;
29 ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log");
31 
35 
36 #define KdpScreenLineLengthDefault 80
39 
40 const ULONG KdpDmesgBufferSize = 128 * 1024; // 512*1024; // 5*1024*1024;
43 volatile ULONG KdpDmesgFreeBytes = 0;
47 
48 KDP_DEBUG_MODE KdpDebugMode;
50 KD_DISPATCH_TABLE DispatchTable[KdMax];
51 
52 PKDP_INIT_ROUTINE InitRoutines[KdMax] =
53 {
57 #ifdef KDBG
58  KdpKdbgInit
59 #endif
60 };
61 
67 
68 /* LOCKING FUNCTIONS *********************************************************/
69 
70 KIRQL
71 NTAPI
74 {
75  KIRQL OldIrql;
76 
77  /* Acquire the spinlock without waiting at raised IRQL */
78  while (TRUE)
79  {
80  /* Loop until the spinlock becomes available */
81  while (!KeTestSpinLock(SpinLock));
82 
83  /* Spinlock is free, raise IRQL to high level */
85 
86  /* Try to get the spinlock */
88  break;
89 
90  /* Someone else got the spinlock, lower IRQL back */
92  }
93 
94  return OldIrql;
95 }
96 
97 VOID
98 NTAPI
102 {
103  /* Release the spinlock */
105  // KeReleaseSpinLockFromDpcLevel(SpinLock);
106 
107  /* Restore the old IRQL */
109 }
110 
111 /* FILE DEBUG LOG FUNCTIONS **************************************************/
112 
113 static VOID
114 NTAPI
116 {
117  ULONG beg, end, num;
119 
121 
123 
124  while (TRUE)
125  {
127 
128  /* Bug */
129  /* Keep KdpCurrentPosition and KdpFreeBytes values in local
130  * variables to avoid their possible change from Producer part,
131  * KdpPrintToLogFile function
132  */
134  num = KdpFreeBytes;
135 
136  /* Now securely calculate values, based on local variables */
137  beg = (end + num) % KdpBufferSize;
138  num = KdpBufferSize - num;
139 
140  /* Nothing to do? */
141  if (num == 0)
142  continue;
143 
144  if (end > beg)
145  {
147  KdpDebugBuffer + beg, num, NULL, NULL);
148  }
149  else
150  {
152  KdpDebugBuffer + beg, KdpBufferSize - beg, NULL, NULL);
153 
156  }
157 
159  }
160 }
161 
162 static VOID
163 NTAPI
165  ULONG Length)
166 {
167  KIRQL OldIrql;
168  ULONG beg, end, num;
169  BOOLEAN DoReinit = FALSE;
170 
171  if (KdpDebugBuffer == NULL) return;
172 
173  /* Acquire the printing spinlock without waiting at raised IRQL */
175 
176  beg = KdpCurrentPosition;
177  num = KdpFreeBytes;
178  if (Length < num)
179  num = Length;
180 
181  if (num != 0)
182  {
183  end = (beg + num) % KdpBufferSize;
185  KdpFreeBytes -= num;
186 
187  if (end > beg)
188  {
190  }
191  else
192  {
195  }
196  }
197 
198  /* Release the spinlock */
200  {
201  DoReinit = TRUE;
202  }
204 
205  if (DoReinit)
206  {
208  KdpDebugLogInit(NULL, 3);
209  }
210 
211  /* Signal the logger thread */
214 }
215 
216 VOID
217 NTAPI
218 KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable,
219  ULONG BootPhase)
220 {
225  HANDLE ThreadHandle;
227 
228  if (!KdpDebugMode.File) return;
229 
230  if (BootPhase == 0)
231  {
232  /* Write out the functions that we support for now */
233  DispatchTable->KdpInitRoutine = KdpDebugLogInit;
234  DispatchTable->KdpPrintRoutine = KdpPrintToLogFile;
235 
236  /* Register as a Provider */
237  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
238  }
239  else if (BootPhase == 1)
240  {
241  /* Allocate a buffer for debug log */
242  KdpDebugBuffer = ExAllocatePoolZero(NonPagedPool,
244  TAG_KDBG);
245  if (!KdpDebugBuffer)
246  {
247  KdpDebugMode.File = FALSE;
248  return;
249  }
251 
252  /* Initialize spinlock */
254 
255  HalDisplayString("\r\n File log debugging enabled\r\n\r\n");
256  }
257  else if (BootPhase == 3)
258  {
259  /* Setup the log name */
261  if (!NT_SUCCESS(Status)) return;
262 
264  &FileName,
266  NULL,
267  NULL);
268 
269  /* Create the log file */
270  Status = ZwCreateFile(&KdpLogFileHandle,
273  &Iosb,
274  NULL,
279  NULL,
280  0);
281 
283 
284  if (!NT_SUCCESS(Status))
285  {
286  DPRINT1("Failed to open log file: 0x%08x\n", Status);
287  return;
288  }
289 
291 
292  /* Create the logger thread */
293  Status = PsCreateSystemThread(&ThreadHandle,
295  NULL,
296  NULL,
297  NULL,
299  NULL);
300  if (!NT_SUCCESS(Status))
301  {
303  return;
304  }
305 
306  Priority = 7;
307  ZwSetInformationThread(ThreadHandle,
309  &Priority,
310  sizeof(Priority));
311 
312  ZwClose(ThreadHandle);
313  }
314 }
315 
316 /* SERIAL FUNCTIONS **********************************************************/
317 
318 static VOID
319 NTAPI
321  ULONG Length)
322 {
323  PCHAR pch = String;
324  KIRQL OldIrql;
325 
326  /* Acquire the printing spinlock without waiting at raised IRQL */
328 
329  /* Output the string */
330  while (pch < String + Length && *pch)
331  {
332  if (*pch == '\n')
333  {
335  }
337  pch++;
338  }
339 
340  /* Release the spinlock */
342 }
343 
344 VOID
345 NTAPI
346 KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
347  ULONG BootPhase)
348 {
349  if (!KdpDebugMode.Serial) return;
350 
351  if (BootPhase == 0)
352  {
353  /* Write out the functions that we support for now */
354  DispatchTable->KdpInitRoutine = KdpSerialInit;
355  DispatchTable->KdpPrintRoutine = KdpSerialPrint;
356 
357  /* Initialize the Port */
359  {
360  KdpDebugMode.Serial = FALSE;
361  return;
362  }
364 
365  /* Initialize spinlock */
367 
368  /* Register as a Provider */
369  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
370  }
371  else if (BootPhase == 1)
372  {
373  HalDisplayString("\r\n Serial debugging enabled\r\n\r\n");
374  }
375 }
376 
377 /* SCREEN FUNCTIONS **********************************************************/
378 
379 VOID
381 {
382  if (InbvIsBootDriverInstalled() /* &&
383  !InbvCheckDisplayOwnership() */)
384  {
385  /* Acquire ownership and reset the display */
393  }
394 }
395 
396 // extern VOID NTAPI InbvSetDisplayOwnership(IN BOOLEAN DisplayOwned);
397 
398 VOID
400 {
403  {
404  /* Release the display */
405  // InbvSetDisplayOwnership(FALSE);
407  }
408 }
409 
410 /*
411  * Screen debug logger function KdpScreenPrint() writes text strings into
412  * KdpDmesgBuffer, using it as a circular buffer. KdpDmesgBuffer contents could
413  * be later (re)viewed using dmesg command of kdbg. KdpScreenPrint() protects
414  * KdpDmesgBuffer from simultaneous writes by use of KdpDmesgLogSpinLock.
415  */
416 static VOID
417 NTAPI
419  ULONG Length)
420 {
421  PCHAR pch = String;
422  KIRQL OldIrql;
423  ULONG beg, end, num;
424 
425  while (pch < String + Length && *pch)
426  {
427  if (*pch == '\b')
428  {
429  /* HalDisplayString does not support '\b'. Workaround it and use '\r' */
430  if (KdpScreenLineLength > 0)
431  {
432  /* Remove last character from buffer */
435 
436  /* Clear row and print line again */
437  HalDisplayString("\r");
439  }
440  }
441  else
442  {
445  }
446 
448  {
449  /* Print buffered characters */
452 
453  /* Clear line buffer */
454  KdpScreenLineBuffer[0] = '\0';
456  }
457 
458  ++pch;
459  }
460 
461  /* Print buffered characters */
463  {
466  }
467 
468  /* Dmesg: store the string in the buffer to show it later */
469  if (KdbpIsInDmesgMode)
470  return;
471 
472  if (KdpDmesgBuffer == NULL)
473  return;
474 
475  /* Acquire the printing spinlock without waiting at raised IRQL */
477 
478  /* Invariant: always_true(KdpDmesgFreeBytes == KdpDmesgBufferSize);
479  * set num to min(KdpDmesgFreeBytes, Length).
480  */
483  if (num != 0)
484  {
485  end = (beg + num) % KdpDmesgBufferSize;
486  if (end > beg)
487  {
489  }
490  else
491  {
494  }
496 
497  /* Counting the total bytes written */
499  }
500 
501  /* Release the spinlock */
503 
504  /* Optional step(?): find out a way to notify about buffer exhaustion,
505  * and possibly fall into kbd to use dmesg command: user will read
506  * debug strings before they will be wiped over by next writes.
507  */
508 }
509 
510 VOID
511 NTAPI
512 KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
513  ULONG BootPhase)
514 {
515  if (!KdpDebugMode.Screen) return;
516 
517  if (BootPhase == 0)
518  {
519  /* Write out the functions that we support for now */
520  DispatchTable->KdpInitRoutine = KdpScreenInit;
521  DispatchTable->KdpPrintRoutine = KdpScreenPrint;
522 
523  /* Register as a Provider */
524  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
525  }
526  else if (BootPhase == 1)
527  {
528  /* Allocate a buffer for dmesg log buffer. +1 for terminating null,
529  * see kdbp_cli.c:KdbpCmdDmesg()/2
530  */
531  KdpDmesgBuffer = ExAllocatePoolZero(NonPagedPool,
532  KdpDmesgBufferSize + 1,
533  TAG_KDBG);
534  /* Ignore failure if KdpDmesgBuffer is NULL */
537 
538  /* Take control of the display */
540 
541  /* Initialize spinlock */
543 
544  HalDisplayString("\r\n Screen debugging enabled\r\n\r\n");
545  }
546 }
547 
548 #ifdef KDBG
549 /* KDBG FUNCTIONS ************************************************************/
550 
551 /* NOTE: This may be moved completely into kdb_symbols.c */
552 VOID NTAPI
553 KdbInitialize(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase);
554 
555 VOID
556 NTAPI
557 KdpKdbgInit(
558  PKD_DISPATCH_TABLE DispatchTable,
559  ULONG BootPhase)
560 {
561  /* Forward the call */
562  KdbInitialize(DispatchTable, BootPhase);
563 }
564 #endif
565 
566 
567 /* GENERAL FUNCTIONS *********************************************************/
568 
569 BOOLEAN
570 NTAPI
573 
574 extern STRING KdbPromptString;
575 
576 VOID
577 NTAPI
579  IN ULONG PacketType,
580  IN PSTRING MessageHeader,
581  IN PSTRING MessageData,
583 {
584  if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
585  {
586  PSTRING Output = MessageData;
587  PLIST_ENTRY CurrentEntry;
588  PKD_DISPATCH_TABLE CurrentTable;
589 
590  if (!KdpDebugMode.Value) return;
591 
592  /* Call the registered handlers */
593  CurrentEntry = KdProviders.Flink;
594  while (CurrentEntry != &KdProviders)
595  {
596  /* Get the current table */
597  CurrentTable = CONTAINING_RECORD(CurrentEntry,
598  KD_DISPATCH_TABLE,
599  KdProvidersList);
600 
601  /* Call it */
602  CurrentTable->KdpPrintRoutine(Output->Buffer, Output->Length);
603 
604  /* Next Table */
605  CurrentEntry = CurrentEntry->Flink;
606  }
607  return;
608  }
609  else if (PacketType == PACKET_TYPE_KD_STATE_CHANGE64)
610  {
611  PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange = (PDBGKD_ANY_WAIT_STATE_CHANGE)MessageHeader->Buffer;
612  if (WaitStateChange->NewState == DbgKdLoadSymbolsStateChange)
613  {
614 #ifdef KDBG
615  PLDR_DATA_TABLE_ENTRY LdrEntry;
616  /* Load symbols. Currently implemented only for KDBG! */
617  if (KdbpSymFindModule((PVOID)(ULONG_PTR)WaitStateChange->u.LoadSymbols.BaseOfDll, -1, &LdrEntry))
618  {
619  KdbSymProcessSymbols(LdrEntry, !WaitStateChange->u.LoadSymbols.UnloadSymbols);
620  }
621 #endif
622  return;
623  }
624  else if (WaitStateChange->NewState == DbgKdExceptionStateChange)
625  {
627  KdbgExceptionRecord = WaitStateChange->u.Exception.ExceptionRecord;
628  KdbgFirstChanceException = WaitStateChange->u.Exception.FirstChance;
629  return;
630  }
631  }
632  else if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
633  {
634  PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
635  if (ManipulateState->ApiNumber == DbgKdGetContextApi)
636  {
637  KD_CONTINUE_TYPE Result;
638 
639 #ifdef KDBG
640  /* Check if this is an assertion failure */
642  {
643  /* Bump EIP to the instruction following the int 2C */
645  }
646 
648  KdbgContext.SegCs & 1,
649  &KdbgContext,
651 #else
652  /* We'll manually dump the stack for the user... */
654  Result = kdHandleException;
655 #endif
656  if (Result != kdHandleException)
658  else
661  return;
662  }
663  else if (ManipulateState->ApiNumber == DbgKdSetContextApi)
664  {
666  return;
667  }
668  }
670 }
671 
672 KDSTATUS
673 NTAPI
675  IN ULONG PacketType,
676  OUT PSTRING MessageHeader,
677  OUT PSTRING MessageData,
680 {
681 #ifdef KDBG
682  KIRQL OldIrql;
683  STRING StringChar;
684  CHAR Response;
685  USHORT i;
686  ULONG DummyScanCode;
687  CHAR MessageBuffer[100];
688  STRING ResponseString;
689 #endif
690 
691  if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
692  {
693  PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
694  RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength);
696  {
697  ManipulateState->ApiNumber = DbgKdGetContextApi;
698  MessageData->Length = 0;
699  MessageData->Buffer = (PCHAR)&KdbgContext;
700  return KdPacketReceived;
701  }
703  {
704  ManipulateState->ApiNumber = DbgKdSetContextApi;
705  MessageData->Length = sizeof(KdbgContext);
706  MessageData->Buffer = (PCHAR)&KdbgContext;
707  return KdPacketReceived;
708  }
710  {
712  }
713  ManipulateState->ApiNumber = DbgKdContinueApi;
714  ManipulateState->u.Continue.ContinueStatus = KdbgContinueStatus;
715 
716  /* Prepare for next time */
719 
720  return KdPacketReceived;
721  }
722 
723  if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
724  return KdPacketTimedOut;
725 
726 #ifdef KDBG
727  ResponseString.Buffer = MessageBuffer;
728  ResponseString.Length = 0;
729  ResponseString.MaximumLength = min(sizeof(MessageBuffer), MessageData->MaximumLength);
730  StringChar.Buffer = &Response;
731  StringChar.Length = StringChar.MaximumLength = sizeof(Response);
732 
733  /* Display the string and print a new line for log neatness */
734  *StringChar.Buffer = '\n';
735  KdpPrintString(&StringChar);
736 
737  /* Print the kdb prompt */
739 
740  // TODO: Use an improved KdbpReadCommand() function for our purposes.
741 
742  /* Acquire the printing spinlock without waiting at raised IRQL */
744 
746  KbdDisableMouse();
747 
748  /* Loop the whole string */
749  for (i = 0; i < ResponseString.MaximumLength; i++)
750  {
751  /* Check if this is serial debugging mode */
753  {
754  /* Get the character from serial */
755  do
756  {
758  } while (Response == -1);
759  }
760  else
761  {
762  /* Get the response from the keyboard */
763  do
764  {
765  Response = KdbpTryGetCharKeyboard(&DummyScanCode, MAXULONG);
766  } while (Response == -1);
767  }
768 
769  /* Check for return */
770  if (Response == '\r')
771  {
772  /*
773  * We might need to discard the next '\n'.
774  * Wait a bit to make sure we receive it.
775  */
777 
778  /* Check the mode */
780  {
781  /* Read and discard the next character, if any */
783  }
784  else
785  {
786  /* Read and discard the next character, if any */
787  KdbpTryGetCharKeyboard(&DummyScanCode, 5);
788  }
789 
790  /*
791  * Null terminate the output string -- documentation states that
792  * DbgPrompt does not null terminate, but it does
793  */
794  *(PCHAR)(ResponseString.Buffer + i) = 0;
795  break;
796  }
797 
798  /* Write it back and print it to the log */
799  *(PCHAR)(ResponseString.Buffer + i) = Response;
801  KdpPrintString(&StringChar);
803  }
804 
805  /* Release the spinlock */
807 
808  /* Print a new line */
809  *StringChar.Buffer = '\n';
810  KdpPrintString(&StringChar);
811 
812  /* Return the length */
813  RtlCopyMemory(MessageData->Buffer, ResponseString.Buffer, i);
814  *DataLength = i;
815 
817  KbdEnableMouse();
818 
819 #endif
820  return KdPacketReceived;
821 }
822 
823 /* EOF */
signed char * PCHAR
Definition: retypes.h:7
static BOOLEAN KdpLoggingEnabled
Definition: kdio.c:21
static CHAR KdpScreenLineBuffer[KdpScreenLineLengthDefault+1]
Definition: kdio.c:37
#define KdPacketReceived
Definition: kddll.h:5
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
#define TAG_KDBG
Definition: tag.h:38
#define IN
Definition: typedefs.h:39
struct _DBGKD_ANY_WAIT_STATE_CHANGE * PDBGKD_ANY_WAIT_STATE_CHANGE
DBGKD_CONTINUE Continue
Definition: windbgkd.h:799
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
static HANDLE KdpLogFileHandle
Definition: kdio.c:28
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI InbvSetScrollRegion(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom)
Definition: inbv.c:447
volatile ULONG KdpDmesgCurrentPosition
Definition: kdio.c:42
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static volatile ULONG KdpFreeBytes
Definition: kdio.c:25
PCHAR KdpDmesgBuffer
Definition: kdio.c:41
ULONG KdbDebugState
Definition: kdb.c:52
VOID NTAPI KdbInitialize(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Initializes the KDB symbols implementation.
Definition: kdb_symbols.c:350
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
char CHAR
Definition: xmlstorage.h:175
static ULONG KdpScreenLineLength
Definition: kdio.c:38
static ULONG KdbgNextApiNumber
Definition: kdio.c:62
LONG NTSTATUS
Definition: precomp.h:26
#define SCREEN_WIDTH
Definition: pc98video.c:27
#define KeGetContextPc(Context)
Definition: ke.h:31
static KSPIN_LOCK KdpDmesgLogSpinLock
Definition: kdio.c:46
static VOID NTAPI KdpScreenPrint(PCHAR String, ULONG Length)
Definition: kdio.c:418
VOID NTAPI KdbpReleaseLock(_In_ PKSPIN_LOCK SpinLock, _In_ KIRQL OldIrql)
Definition: kdio.c:99
NTSTATUS ExceptionCode
Definition: rtltypes.h:190
VOID NTAPI KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:346
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3492 u
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3062
#define BV_COLOR_WHITE
Definition: display.h:30
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
#define DbgKdExceptionStateChange
Definition: windbgkd.h:59
VOID NTAPI InbvNotifyDisplayOwnershipLost(_In_ INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:403
#define InsertTailList(ListHead, Entry)
static VOID NTAPI KdpPrintToLogFile(PCHAR String, ULONG Length)
Definition: kdio.c:164
#define DbgKdContinueApi
Definition: windbgkd.h:80
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define FILE_APPEND_DATA
Definition: nt_native.h:634
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
ULONG ExpInitializationPhase
Definition: init.c:68
LONG KPRIORITY
Definition: compat.h:803
#define pch(ap)
Definition: match.c:418
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:27
CHAR KdbpTryGetCharSerial(ULONG Retry)
Definition: kdb_serial.c:19
#define FILE_SHARE_READ
Definition: compat.h:136
CHAR KdbpTryGetCharKeyboard(PULONG ScanCode, ULONG Retry)
Definition: kdb_keyboard.c:104
VOID KdbSymProcessSymbols(_Inout_ PLDR_DATA_TABLE_ENTRY LdrEntry, _In_ BOOLEAN Load)
Load symbols from image mapping. If this fails,.
Definition: kdb_symbols.c:298
KIRQL NTAPI KdbpAcquireLock(_In_ PKSPIN_LOCK SpinLock)
Definition: kdio.c:72
uint32_t ULONG_PTR
Definition: typedefs.h:65
static KSPIN_LOCK KdpDebugLogSpinLock
Definition: kdio.c:26
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:48
BOOLEAN NTAPI KdPortInitializeEx(PCPPORT PortInformation, ULONG ComPortNumber)
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
VOID NTAPI KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:512
STRING KdbPromptString
Definition: kdb_cli.c:167
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
#define DEFAULT_DEBUG_PORT
Definition: kdcom.c:25
VOID KdpScreenRelease(VOID)
Definition: kdio.c:399
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:240
DBGKD_LOAD_SYMBOLS64 LoadSymbols
Definition: windbgkd.h:509
#define FILE_WRITE_THROUGH
Definition: from_kernel.h:26
ULONG SegCs
Definition: nt_native.h:1477
unsigned char BOOLEAN
static NTSTATUS KdbgContinueStatus
Definition: kdio.c:66
VOID NTAPI InbvInstallDisplayStringFilter(_In_ INBV_DISPLAY_STRING_FILTER DisplayFilter)
Definition: inbv.c:386
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define _In_
Definition: ms_sal.h:308
VOID KbdEnableMouse(VOID)
ANSI_STRING KdpLogFileName
Definition: kdio.c:29
static VOID NTAPI KdpSerialPrint(PCHAR String, ULONG Length)
Definition: kdio.c:320
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
volatile ULONG KdbDmesgTotalWritten
Definition: kdio.c:44
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
static VOID NTAPI KdpLoggerThread(PVOID Context)
Definition: kdio.c:115
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
VOID KdpScreenAcquire(VOID)
Definition: kdio.c:380
#define PCHAR
Definition: match.c:90
BOOLEAN FASTCALL KeTestSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:475
Status
Definition: gdiplustypes.h:24
#define SCREEN_HEIGHT
Definition: pc98video.c:28
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
static volatile ULONG KdpCurrentPosition
Definition: kdio.c:24
#define STATUS_ASSERTION_FAILURE
Definition: ntstatus.h:960
#define DEFAULT_DEBUG_BAUD_RATE
Definition: kdcom.c:28
PUCHAR KdComPortInUse
Definition: usage.c:17
#define KdPacketTimedOut
Definition: kddll.h:6
#define ASSERT(a)
Definition: mode.c:44
#define DbgKdLoadSymbolsStateChange
Definition: windbgkd.h:60
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
union _DBGKD_MANIPULATE_STATE64::@3500 u
#define InterlockedExchangeAddUL(Addend, Value)
Definition: ex.h:1532
BOOLEAN KdbpSymFindModule(IN PVOID Address OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Find a module...
Definition: kdb_symbols.c:75
#define DbgKdGetContextApi
Definition: windbgkd.h:76
#define KeSetContextPc(Context, ProgramCounter)
Definition: ke.h:34
VOID KbdDisableMouse(VOID)
GLuint GLuint num
Definition: glext.h:9618
#define KdpBufferSize
Definition: kdio.c:20
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define KdpScreenLineLengthDefault
Definition: kdio.c:36
static BOOLEAN KdpLoggingStarting
Definition: kdio.c:22
Definition: ncftp.h:89
BOOLEAN NTAPI InbvEnableDisplayString(_In_ BOOLEAN Enable)
Definition: inbv.c:369
static PCHAR KdpDebugBuffer
Definition: kdio.c:23
GLuint GLuint end
Definition: gl.h:1545
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
std::wstring STRING
Definition: fontsub.cpp:33
#define PACKET_TYPE_KD_STATE_MANIPULATE
Definition: windbgkd.h:43
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:289
EXCEPTION_RECORD64 ExceptionRecord
Definition: windbgkd.h:312
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define PACKET_TYPE_KD_STATE_CHANGE64
Definition: windbgkd.h:48
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
static BOOLEAN KdbgFirstChanceException
Definition: kdio.c:65
Definition: arc.h:85
#define VOID
Definition: acefi.h:82
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)
Definition: btrfs_drv.h:1876
#define DbgKdSetContextApi
Definition: windbgkd.h:77
volatile ULONG KdpDmesgFreeBytes
Definition: kdio.c:43
Definition: typedefs.h:119
VOID NTAPI InbvSolidColorFill(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ ULONG Color)
Definition: inbv.c:484
KDSTATUS NTAPI KdReceivePacket(IN ULONG PacketType, OUT PSTRING MessageHeader, OUT PSTRING MessageData, OUT PULONG DataLength, IN OUT PKD_CONTEXT Context)
Definition: kdio.c:674
#define SYNCHRONIZE
Definition: nt_native.h:61
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
const ULONG KdpDmesgBufferSize
Definition: kdio.c:40
PUCHAR Address
Definition: cportlib.h:29
#define MAXULONG
Definition: typedefs.h:251
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:395
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
struct _FileName FileName
Definition: fatprocs.h:893
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:298
BOOLEAN NTAPI KdpPrintString(_In_ PSTRING Output)
Definition: kdprint.c:109
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:430
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short USHORT
Definition: pedump.c:61
static EXCEPTION_RECORD64 KdbgExceptionRecord
Definition: kdio.c:64
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
PKDP_INIT_ROUTINE InitRoutines[KdMax]
Definition: kdio.c:52
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:32
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
ULONG KDSTATUS
Definition: kddll.h:4
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
struct _DBGKD_MANIPULATE_STATE64 * PDBGKD_MANIPULATE_STATE64
NTSTATUS ContinueStatus
Definition: windbgkd.h:579
unsigned int * PULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
static CONTEXT KdbgContext
Definition: kdio.c:63
CPPORT SerialPortInfo
Definition: kdio.c:34
#define NULL
Definition: types.h:112
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
DBGKM_EXCEPTION64 Exception
Definition: windbgkd.h:508
#define BV_COLOR_BLACK
Definition: display.h:15
#define DPRINT1
Definition: precomp.h:8
ULONG SerialPortNumber
Definition: kdio.c:33
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
VOID NTAPI KdSendPacket(IN ULONG PacketType, IN PSTRING MessageHeader, IN PSTRING MessageData, IN OUT PKD_CONTEXT Context)
Definition: kdio.c:578
static ULONG KdpScreenLineBufferPos
Definition: kdio.c:38
#define OUT
Definition: typedefs.h:40
volatile BOOLEAN KdbpIsInDmesgMode
Definition: kdio.c:45
return Iosb
Definition: create.c:4402
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
#define UNIMPLEMENTED
Definition: debug.h:115
struct Response Response
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:218
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:315
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:309
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
VOID NTAPI InbvSetTextColor(_In_ ULONG Color)
Definition: inbv.c:459
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
LIST_ENTRY KdProviders
Definition: kdio.c:49
KD_CONTINUE_TYPE KdbEnterDebuggerException(IN PEXCEPTION_RECORD64 ExceptionRecord, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT Context, IN BOOLEAN FirstChance)
KDB Exception filter.
Definition: kdb.c:1265
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14