ReactOS  0.4.15-dev-2504-g2b52f3b
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] = {KdpScreenInit,
55  KdpKdbgInit};
56 
62 
63 /* LOCKING FUNCTIONS *********************************************************/
64 
65 KIRQL
66 NTAPI
68 {
69  KIRQL OldIrql;
70 
71  /* Acquire the spinlock without waiting at raised IRQL */
72  while (TRUE)
73  {
74  /* Loop until the spinlock becomes available */
75  while (!KeTestSpinLock(SpinLock));
76 
77  /* Spinlock is free, raise IRQL to high level */
79 
80  /* Try to get the spinlock */
82  break;
83 
84  /* Someone else got the spinlock, lower IRQL back */
86  }
87 
88  return OldIrql;
89 }
90 
91 VOID
92 NTAPI
95 {
96  /* Release the spinlock */
98  // KeReleaseSpinLockFromDpcLevel(SpinLock);
99 
100  /* Restore the old IRQL */
102 }
103 
104 /* FILE DEBUG LOG FUNCTIONS **************************************************/
105 
106 static VOID
107 NTAPI
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  */
127  num = KdpFreeBytes;
128 
129  /* Now securely calculate values, based on local variables */
130  beg = (end + num) % KdpBufferSize;
131  num = KdpBufferSize - num;
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 
155 static VOID
156 NTAPI
158  ULONG StringLength)
159 {
160  KIRQL OldIrql;
161  ULONG beg, end, num;
162  BOOLEAN DoReinit = FALSE;
163 
164  if (KdpDebugBuffer == NULL) return;
165 
166  /* Acquire the printing spinlock without waiting at raised IRQL */
168 
169  beg = KdpCurrentPosition;
170  num = KdpFreeBytes;
171  if (StringLength < num)
172  num = StringLength;
173 
174  if (num != 0)
175  {
176  end = (beg + num) % KdpBufferSize;
178  KdpFreeBytes -= num;
179 
180  if (end > beg)
181  {
183  }
184  else
185  {
188  }
189  }
190 
191  /* Release the spinlock */
193  {
194  DoReinit = TRUE;
195  }
197 
198  if (DoReinit)
199  {
201  KdpDebugLogInit(NULL, 3);
202  }
203 
204  /* Signal the logger thread */
207 }
208 
209 VOID
210 NTAPI
211 KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable,
212  ULONG BootPhase)
213 {
218  HANDLE ThreadHandle;
220 
221  if (!KdpDebugMode.File) return;
222 
223  if (BootPhase == 0)
224  {
226 
227  /* Write out the functions that we support for now */
228  DispatchTable->KdpInitRoutine = KdpDebugLogInit;
229  DispatchTable->KdpPrintRoutine = KdpPrintToLogFile;
230 
231  /* Register as a Provider */
232  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
233  }
234  else if (BootPhase == 1)
235  {
236  /* Allocate a buffer for debug log */
239 
240  /* Initialize spinlock */
242 
243  HalDisplayString("\r\n File log debugging enabled\r\n\r\n");
244  }
245  else if (BootPhase == 3)
246  {
247  /* Setup the log name */
249  if (!NT_SUCCESS(Status)) return;
250 
252  &FileName,
254  NULL,
255  NULL);
256 
257  /* Create the log file */
258  Status = ZwCreateFile(&KdpLogFileHandle,
261  &Iosb,
262  NULL,
267  NULL,
268  0);
269 
271 
272  if (!NT_SUCCESS(Status))
273  {
274  DPRINT1("Failed to open log file: 0x%08x\n", Status);
275  return;
276  }
277 
279 
280  /* Create the logger thread */
281  Status = PsCreateSystemThread(&ThreadHandle,
283  NULL,
284  NULL,
285  NULL,
287  NULL);
288  if (!NT_SUCCESS(Status))
289  {
291  return;
292  }
293 
294  Priority = 7;
295  ZwSetInformationThread(ThreadHandle,
297  &Priority,
298  sizeof(Priority));
299 
300  ZwClose(ThreadHandle);
301  }
302 }
303 
304 /* SERIAL FUNCTIONS **********************************************************/
305 
306 VOID
307 NTAPI
309  ULONG Length)
310 {
311  PCHAR pch = (PCHAR)Message;
312  KIRQL OldIrql;
313 
314  /* Acquire the printing spinlock without waiting at raised IRQL */
316 
317  /* Output the message */
318  while (pch < Message + Length && *pch != '\0')
319  {
320  if (*pch == '\n')
321  {
323  }
325  pch++;
326  }
327 
328  /* Release the spinlock */
330 }
331 
332 VOID
333 NTAPI
334 KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
335  ULONG BootPhase)
336 {
337  if (!KdpDebugMode.Serial) return;
338 
339  if (BootPhase == 0)
340  {
341  /* Write out the functions that we support for now */
342  DispatchTable->KdpInitRoutine = KdpSerialInit;
343  DispatchTable->KdpPrintRoutine = KdpSerialDebugPrint;
344 
345  /* Initialize the Port */
347  {
348  KdpDebugMode.Serial = FALSE;
349  return;
350  }
352 
353  /* Initialize spinlock */
355 
356  /* Register as a Provider */
357  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
358  }
359  else if (BootPhase == 1)
360  {
361  HalDisplayString("\r\n Serial debugging enabled\r\n\r\n");
362  }
363 }
364 
365 /* SCREEN FUNCTIONS **********************************************************/
366 
367 VOID
369 {
370  if (InbvIsBootDriverInstalled() /* &&
371  !InbvCheckDisplayOwnership() */)
372  {
373  /* Acquire ownership and reset the display */
381  }
382 }
383 
384 // extern VOID NTAPI InbvSetDisplayOwnership(IN BOOLEAN DisplayOwned);
385 
386 VOID
388 {
391  {
392  /* Release the display */
393  // InbvSetDisplayOwnership(FALSE);
395  }
396 }
397 
398 /*
399  * Screen debug logger function KdpScreenPrint() writes text messages into
400  * KdpDmesgBuffer, using it as a circular buffer. KdpDmesgBuffer contents could
401  * be later (re)viewed using dmesg command of kdbg. KdpScreenPrint() protects
402  * KdpDmesgBuffer from simultaneous writes by use of KdpDmesgLogSpinLock.
403  */
404 static VOID
405 NTAPI
407  ULONG Length)
408 {
409  PCHAR pch = (PCHAR)Message;
410  KIRQL OldIrql;
411  ULONG beg, end, num;
412 
413  while (pch < Message + Length && *pch)
414  {
415  if (*pch == '\b')
416  {
417  /* HalDisplayString does not support '\b'. Workaround it and use '\r' */
418  if (KdpScreenLineLength > 0)
419  {
420  /* Remove last character from buffer */
423 
424  /* Clear row and print line again */
425  HalDisplayString("\r");
427  }
428  }
429  else
430  {
433  }
434 
436  {
437  /* Print buffered characters */
440 
441  /* Clear line buffer */
442  KdpScreenLineBuffer[0] = '\0';
444  }
445 
446  ++pch;
447  }
448 
449  /* Print buffered characters */
451  {
454  }
455 
456  /* Dmesg: store Message in the buffer to show it later */
457  if (KdbpIsInDmesgMode)
458  return;
459 
460  if (KdpDmesgBuffer == NULL)
461  return;
462 
463  /* Acquire the printing spinlock without waiting at raised IRQL */
465 
466  /* Invariant: always_true(KdpDmesgFreeBytes == KdpDmesgBufferSize);
467  * set num to min(KdpDmesgFreeBytes, Length).
468  */
471  if (num != 0)
472  {
473  end = (beg + num) % KdpDmesgBufferSize;
474  if (end > beg)
475  {
477  }
478  else
479  {
482  }
484 
485  /* Counting the total bytes written */
487  }
488 
489  /* Release the spinlock */
491 
492  /* Optional step(?): find out a way to notify about buffer exhaustion,
493  * and possibly fall into kbd to use dmesg command: user will read
494  * debug messages before they will be wiped over by next writes.
495  */
496 }
497 
498 VOID
499 NTAPI
500 KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
501  ULONG BootPhase)
502 {
503  if (!KdpDebugMode.Screen) return;
504 
505  if (BootPhase == 0)
506  {
507  /* Write out the functions that we support for now */
508  DispatchTable->KdpInitRoutine = KdpScreenInit;
509  DispatchTable->KdpPrintRoutine = KdpScreenPrint;
510 
511  /* Register as a Provider */
512  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
513  }
514  else if (BootPhase == 1)
515  {
516  /* Allocate a buffer for dmesg log buffer. +1 for terminating null,
517  * see kdbp_cli.c:KdbpCmdDmesg()/2
518  */
523 
524  /* Take control of the display */
526 
527  /* Initialize spinlock */
529 
530  HalDisplayString("\r\n Screen debugging enabled\r\n\r\n");
531  }
532 }
533 
534 /* GENERAL FUNCTIONS *********************************************************/
535 
536 BOOLEAN
537 NTAPI
540 
541 extern STRING KdbPromptString;
542 
543 VOID
544 NTAPI
546  IN ULONG PacketType,
547  IN PSTRING MessageHeader,
548  IN PSTRING MessageData,
550 {
551  if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
552  {
553  PSTRING Output = MessageData;
554  PLIST_ENTRY CurrentEntry;
555  PKD_DISPATCH_TABLE CurrentTable;
556 
557  if (!KdpDebugMode.Value) return;
558 
559  /* Call the registered handlers */
560  CurrentEntry = KdProviders.Flink;
561  while (CurrentEntry != &KdProviders)
562  {
563  /* Get the current table */
564  CurrentTable = CONTAINING_RECORD(CurrentEntry,
565  KD_DISPATCH_TABLE,
566  KdProvidersList);
567 
568  /* Call it */
569  CurrentTable->KdpPrintRoutine(Output->Buffer, Output->Length);
570 
571  /* Next Table */
572  CurrentEntry = CurrentEntry->Flink;
573  }
574  return;
575  }
576  else if (PacketType == PACKET_TYPE_KD_STATE_CHANGE64)
577  {
578  PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange = (PDBGKD_ANY_WAIT_STATE_CHANGE)MessageHeader->Buffer;
579  if (WaitStateChange->NewState == DbgKdLoadSymbolsStateChange)
580  {
581 #ifdef KDBG
582  PLDR_DATA_TABLE_ENTRY LdrEntry;
583  if (!WaitStateChange->u.LoadSymbols.UnloadSymbols)
584  {
585  /* Load symbols. Currently implemented only for KDBG! */
586  if (KdbpSymFindModule((PVOID)(ULONG_PTR)WaitStateChange->u.LoadSymbols.BaseOfDll, NULL, -1, &LdrEntry))
587  {
588  KdbSymProcessSymbols(LdrEntry);
589  }
590  }
591 #endif
592  return;
593  }
594  else if (WaitStateChange->NewState == DbgKdExceptionStateChange)
595  {
597  KdbgExceptionRecord = WaitStateChange->u.Exception.ExceptionRecord;
598  KdbgFirstChanceException = WaitStateChange->u.Exception.FirstChance;
599  return;
600  }
601  }
602  else if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
603  {
604  PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
605  if (ManipulateState->ApiNumber == DbgKdGetContextApi)
606  {
607  KD_CONTINUE_TYPE Result;
608 
609 #ifdef KDBG
610  /* Check if this is an assertion failure */
612  {
613  /* Bump EIP to the instruction following the int 2C */
615  }
616 
618  KdbgContext.SegCs & 1,
619  &KdbgContext,
621 #else
622  /* We'll manually dump the stack for the user... */
624  Result = kdHandleException;
625 #endif
626  if (Result != kdHandleException)
628  else
631  return;
632  }
633  else if (ManipulateState->ApiNumber == DbgKdSetContextApi)
634  {
636  return;
637  }
638  }
640 }
641 
642 KDSTATUS
643 NTAPI
645  IN ULONG PacketType,
646  OUT PSTRING MessageHeader,
647  OUT PSTRING MessageData,
650 {
651 #ifdef KDBG
652  KIRQL OldIrql;
653  STRING StringChar;
654  CHAR Response;
655  USHORT i;
656  ULONG DummyScanCode;
657  CHAR MessageBuffer[100];
658  STRING ResponseString;
659 #endif
660 
661  if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
662  {
663  PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
664  RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength);
666  {
667  ManipulateState->ApiNumber = DbgKdGetContextApi;
668  MessageData->Length = 0;
669  MessageData->Buffer = (PCHAR)&KdbgContext;
670  return KdPacketReceived;
671  }
673  {
674  ManipulateState->ApiNumber = DbgKdSetContextApi;
675  MessageData->Length = sizeof(KdbgContext);
676  MessageData->Buffer = (PCHAR)&KdbgContext;
677  return KdPacketReceived;
678  }
680  {
682  }
683  ManipulateState->ApiNumber = DbgKdContinueApi;
684  ManipulateState->u.Continue.ContinueStatus = KdbgContinueStatus;
685 
686  /* Prepare for next time */
689 
690  return KdPacketReceived;
691  }
692 
693  if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
694  return KdPacketTimedOut;
695 
696 #ifdef KDBG
697  ResponseString.Buffer = MessageBuffer;
698  ResponseString.Length = 0;
699  ResponseString.MaximumLength = min(sizeof(MessageBuffer), MessageData->MaximumLength);
700  StringChar.Buffer = &Response;
701  StringChar.Length = StringChar.MaximumLength = sizeof(Response);
702 
703  /* Display the string and print a new line for log neatness */
704  *StringChar.Buffer = '\n';
705  KdpPrintString(&StringChar);
706 
707  /* Print the kdb prompt */
709 
710  // TODO: Use an improved KdbpReadCommand() function for our purposes.
711 
712  /* Acquire the printing spinlock without waiting at raised IRQL */
714 
716  KbdDisableMouse();
717 
718  /* Loop the whole string */
719  for (i = 0; i < ResponseString.MaximumLength; i++)
720  {
721  /* Check if this is serial debugging mode */
723  {
724  /* Get the character from serial */
725  do
726  {
728  } while (Response == -1);
729  }
730  else
731  {
732  /* Get the response from the keyboard */
733  do
734  {
735  Response = KdbpTryGetCharKeyboard(&DummyScanCode, MAXULONG);
736  } while (Response == -1);
737  }
738 
739  /* Check for return */
740  if (Response == '\r')
741  {
742  /*
743  * We might need to discard the next '\n'.
744  * Wait a bit to make sure we receive it.
745  */
747 
748  /* Check the mode */
750  {
751  /* Read and discard the next character, if any */
753  }
754  else
755  {
756  /* Read and discard the next character, if any */
757  KdbpTryGetCharKeyboard(&DummyScanCode, 5);
758  }
759 
760  /*
761  * Null terminate the output string -- documentation states that
762  * DbgPrompt does not null terminate, but it does
763  */
764  *(PCHAR)(ResponseString.Buffer + i) = 0;
765  break;
766  }
767 
768  /* Write it back and print it to the log */
769  *(PCHAR)(ResponseString.Buffer + i) = Response;
771  KdpPrintString(&StringChar);
773  }
774 
775  /* Print a new line */
776  *StringChar.Buffer = '\n';
777  KdpPrintString(&StringChar);
778 
779  /* Return the length */
780  RtlCopyMemory(MessageData->Buffer, ResponseString.Buffer, i);
781  *DataLength = i;
782 
784  KbdEnableMouse();
785 
786  /* Release the spinlock */
788 
789 #endif
790  return KdPacketReceived;
791 }
792 
793 /* 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
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:638
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
#define IN
Definition: typedefs.h:39
struct _DBGKD_ANY_WAIT_STATE_CHANGE * PDBGKD_ANY_WAIT_STATE_CHANGE
DBGKD_CONTINUE Continue
Definition: windbgkd.h:779
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
static HANDLE KdpLogFileHandle
Definition: kdio.c:28
VOID NTAPI KdpKdbgInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdbg.c:21
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
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:45
VOID KdbSymProcessSymbols(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
Definition: kdb_symbols.c:434
#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:57
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
NTSTATUS ExceptionCode
Definition: rtltypes.h:190
VOID NTAPI KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:334
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:716
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3066
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:67
#define BV_COLOR_WHITE
Definition: display.h:30
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
#define DbgKdExceptionStateChange
Definition: windbgkd.h:59
#define InsertTailList(ListHead, Entry)
#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:66
LONG KPRIORITY
Definition: compat.h:662
#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
uint32_t ULONG_PTR
Definition: typedefs.h:65
static KSPIN_LOCK KdpDebugLogSpinLock
Definition: kdio.c:26
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:48
static VOID NTAPI KdpPrintToLogFile(PCHAR String, ULONG StringLength)
Definition: kdio.c:157
static VOID NTAPI KdpScreenPrint(PCHAR Message, ULONG Length)
Definition: kdio.c:406
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:500
STRING KdbPromptString
Definition: kdb_cli.c:165
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:35
_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:387
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
DBGKD_LOAD_SYMBOLS64 LoadSymbols
Definition: windbgkd.h:489
#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:61
_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
VOID KbdEnableMouse(VOID)
ANSI_STRING KdpLogFileName
Definition: kdio.c:29
_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:108
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 NTAPI InbvSetTextColor(IN ULONG Color)
Definition: inbv.c:692
VOID KdpScreenAcquire(VOID)
Definition: kdio.c:368
#define PCHAR
Definition: match.c:90
BOOLEAN FASTCALL KeTestSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:442
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:45
#define DbgKdLoadSymbolsStateChange
Definition: windbgkd.h:60
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define InterlockedExchangeAddUL(Addend, Value)
Definition: ex.h:1510
#define DbgKdGetContextApi
Definition: windbgkd.h:76
#define KeSetContextPc(Context, ProgramCounter)
Definition: ke.h:34
VOID KbdDisableMouse(VOID)
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:93
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
static PCHAR KdpDebugBuffer
Definition: kdio.c:23
GLuint GLuint end
Definition: gl.h:1545
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CHAR Message[80]
Definition: alive.c:5
std::wstring STRING
Definition: fontsub.cpp:33
#define PACKET_TYPE_KD_STATE_MANIPULATE
Definition: windbgkd.h:43
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:528
EXCEPTION_RECORD64 ExceptionRecord
Definition: windbgkd.h:303
_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:790
static BOOLEAN KdbgFirstChanceException
Definition: kdio.c:60
Definition: arc.h:85
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#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:1922
VOID NTAPI KdpSerialDebugPrint(PCHAR Message, ULONG Length)
Definition: kdio.c:308
#define DbgKdSetContextApi
Definition: windbgkd.h:77
volatile ULONG KdpDmesgFreeBytes
Definition: kdio.c:43
Definition: typedefs.h:119
KDSTATUS NTAPI KdReceivePacket(IN ULONG PacketType, OUT PSTRING MessageHeader, OUT PSTRING MessageData, OUT PULONG DataLength, IN OUT PKD_CONTEXT Context)
Definition: kdio.c:644
#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 InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:606
#define _In_
Definition: no_sal2.h:158
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:630
union _DBGKD_MANIPULATE_STATE64::@3505 u
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
struct _FileName FileName
Definition: fatprocs.h:893
BOOLEAN NTAPI KdpPrintString(_In_ PSTRING Output)
Definition: kdprint.c:22
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:664
#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
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3497 u
unsigned short USHORT
Definition: pedump.c:61
static EXCEPTION_RECORD64 KdbgExceptionRecord
Definition: kdio.c:59
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:559
unsigned int * PULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
static CONTEXT KdbgContext
Definition: kdio.c:58
CPPORT SerialPortInfo
Definition: kdio.c:34
#define NULL
Definition: types.h:112
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
DBGKM_EXCEPTION64 Exception
Definition: windbgkd.h:488
VOID NTAPI InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter)
Definition: inbv.c:622
#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:545
static ULONG KdpScreenLineBufferPos
Definition: kdio.c:38
#define OUT
Definition: typedefs.h:40
volatile BOOLEAN KdbpIsInDmesgMode
Definition: kdio.c:45
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:211
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:553
VOID NTAPI InbvSetScrollRegion(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom)
Definition: inbv.c:681
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:303
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:95
BOOLEAN KdbpSymFindModule(IN PVOID Address OPTIONAL, IN LPCWSTR Name OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Find a module...
Definition: kdb_symbols.c:84
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:1258
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14