ReactOS  0.4.15-dev-1377-ga59cecd
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)
23 static volatile ULONG KdpCurrentPosition = 0;
24 static volatile ULONG KdpFreeBytes = 0;
28 ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log");
29 
33 
34 #define KdpScreenLineLengthDefault 80
37 
38 const ULONG KdpDmesgBufferSize = 128 * 1024; // 512*1024; // 5*1024*1024;
41 volatile ULONG KdpDmesgFreeBytes = 0;
45 
46 KDP_DEBUG_MODE KdpDebugMode;
48 KD_DISPATCH_TABLE DispatchTable[KdMax];
49 
50 PKDP_INIT_ROUTINE InitRoutines[KdMax] = {KdpScreenInit,
53  KdpKdbgInit};
54 
60 
61 /* LOCKING FUNCTIONS *********************************************************/
62 
63 KIRQL
64 NTAPI
66 {
67  KIRQL OldIrql;
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 
89 VOID
90 NTAPI
93 {
94  /* Release the spinlock */
96  // KeReleaseSpinLockFromDpcLevel(SpinLock);
97 
98  /* Restore the old IRQL */
100 }
101 
102 /* FILE DEBUG LOG FUNCTIONS **************************************************/
103 
104 static VOID
105 NTAPI
107 {
108  ULONG beg, end, num;
110 
112 
113  while (TRUE)
114  {
116 
117  /* Bug */
118  /* Keep KdpCurrentPosition and KdpFreeBytes values in local
119  * variables to avoid their possible change from Producer part,
120  * KdpPrintToLogFile function
121  */
123  num = KdpFreeBytes;
124 
125  /* Now securely calculate values, based on local variables */
126  beg = (end + num) % KdpBufferSize;
127  num = KdpBufferSize - num;
128 
129  /* Nothing to do? */
130  if (num == 0)
131  continue;
132 
133  if (end > beg)
134  {
136  KdpDebugBuffer + beg, num, NULL, NULL);
137  }
138  else
139  {
141  KdpDebugBuffer + beg, KdpBufferSize - beg, NULL, NULL);
142 
145  }
146 
148  }
149 }
150 
151 static VOID
152 NTAPI
154  ULONG StringLength)
155 {
156  KIRQL OldIrql;
157  ULONG beg, end, num;
158 
159  if (KdpDebugBuffer == NULL) return;
160 
161  /* Acquire the printing spinlock without waiting at raised IRQL */
163 
164  beg = KdpCurrentPosition;
165  num = KdpFreeBytes;
166  if (StringLength < num)
167  num = StringLength;
168 
169  if (num != 0)
170  {
171  end = (beg + num) % KdpBufferSize;
173  KdpFreeBytes -= num;
174 
175  if (end > beg)
176  {
178  }
179  else
180  {
183  }
184  }
185 
186  /* Release the spinlock */
188 
189  /* Signal the logger thread */
192 }
193 
194 VOID
195 NTAPI
196 KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable,
197  ULONG BootPhase)
198 {
203  HANDLE ThreadHandle;
205 
206  if (!KdpDebugMode.File) return;
207 
208  if (BootPhase == 0)
209  {
211 
212  /* Write out the functions that we support for now */
213  DispatchTable->KdpInitRoutine = KdpDebugLogInit;
214  DispatchTable->KdpPrintRoutine = KdpPrintToLogFile;
215 
216  /* Register as a Provider */
217  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
218  }
219  else if (BootPhase == 1)
220  {
221  /* Allocate a buffer for debug log */
224 
225  /* Initialize spinlock */
227  }
228  else if (BootPhase == 2)
229  {
230  HalDisplayString("\r\n File log debugging enabled\r\n\r\n");
231  }
232  else if (BootPhase == 3)
233  {
234  /* Setup the log name */
236  if (!NT_SUCCESS(Status)) return;
237 
239  &FileName,
241  NULL,
242  NULL);
243 
244  /* Create the log file */
248  &Iosb,
249  NULL,
254  NULL,
255  0);
256 
258 
259  if (!NT_SUCCESS(Status))
260  return;
261 
263 
264  /* Create the logger thread */
265  Status = PsCreateSystemThread(&ThreadHandle,
267  NULL,
268  NULL,
269  NULL,
271  NULL);
272  if (!NT_SUCCESS(Status))
273  {
275  return;
276  }
277 
278  Priority = 7;
279  NtSetInformationThread(ThreadHandle,
281  &Priority,
282  sizeof(Priority));
283  }
284 }
285 
286 /* SERIAL FUNCTIONS **********************************************************/
287 
288 VOID
289 NTAPI
291  ULONG Length)
292 {
293  PCHAR pch = (PCHAR)Message;
294  KIRQL OldIrql;
295 
296  /* Acquire the printing spinlock without waiting at raised IRQL */
298 
299  /* Output the message */
300  while (pch < Message + Length && *pch != '\0')
301  {
302  if (*pch == '\n')
303  {
305  }
307  pch++;
308  }
309 
310  /* Release the spinlock */
312 }
313 
314 VOID
315 NTAPI
316 KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
317  ULONG BootPhase)
318 {
319  if (!KdpDebugMode.Serial) return;
320 
321  if (BootPhase == 0)
322  {
323  /* Write out the functions that we support for now */
324  DispatchTable->KdpInitRoutine = KdpSerialInit;
325  DispatchTable->KdpPrintRoutine = KdpSerialDebugPrint;
326 
327  /* Initialize the Port */
329  {
330  KdpDebugMode.Serial = FALSE;
331  return;
332  }
334 
335  /* Initialize spinlock */
337 
338  /* Register as a Provider */
339  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
340  }
341  else if (BootPhase == 2)
342  {
343  HalDisplayString("\r\n Serial debugging enabled\r\n\r\n");
344  }
345 }
346 
347 /* SCREEN FUNCTIONS **********************************************************/
348 
349 VOID
351 {
352  if (InbvIsBootDriverInstalled() /* &&
353  !InbvCheckDisplayOwnership() */)
354  {
355  /* Acquire ownership and reset the display */
363  }
364 }
365 
366 // extern VOID NTAPI InbvSetDisplayOwnership(IN BOOLEAN DisplayOwned);
367 
368 VOID
370 {
373  {
374  /* Release the display */
375  // InbvSetDisplayOwnership(FALSE);
377  }
378 }
379 
380 /*
381  * Screen debug logger function KdpScreenPrint() writes text messages into
382  * KdpDmesgBuffer, using it as a circular buffer. KdpDmesgBuffer contents could
383  * be later (re)viewed using dmesg command of kdbg. KdpScreenPrint() protects
384  * KdpDmesgBuffer from simultaneous writes by use of KdpDmesgLogSpinLock.
385  */
386 static VOID
387 NTAPI
389  ULONG Length)
390 {
391  PCHAR pch = (PCHAR)Message;
392  KIRQL OldIrql;
393  ULONG beg, end, num;
394 
395  while (pch < Message + Length && *pch)
396  {
397  if (*pch == '\b')
398  {
399  /* HalDisplayString does not support '\b'. Workaround it and use '\r' */
400  if (KdpScreenLineLength > 0)
401  {
402  /* Remove last character from buffer */
405 
406  /* Clear row and print line again */
407  HalDisplayString("\r");
409  }
410  }
411  else
412  {
415  }
416 
418  {
419  /* Print buffered characters */
422 
423  /* Clear line buffer */
424  KdpScreenLineBuffer[0] = '\0';
426  }
427 
428  ++pch;
429  }
430 
431  /* Print buffered characters */
433  {
436  }
437 
438  /* Dmesg: store Message in the buffer to show it later */
439  if (KdbpIsInDmesgMode)
440  return;
441 
442  if (KdpDmesgBuffer == NULL)
443  return;
444 
445  /* Acquire the printing spinlock without waiting at raised IRQL */
447 
448  /* Invariant: always_true(KdpDmesgFreeBytes == KdpDmesgBufferSize);
449  * set num to min(KdpDmesgFreeBytes, Length).
450  */
453  if (num != 0)
454  {
455  end = (beg + num) % KdpDmesgBufferSize;
456  if (end > beg)
457  {
459  }
460  else
461  {
464  }
466 
467  /* Counting the total bytes written */
469  }
470 
471  /* Release the spinlock */
473 
474  /* Optional step(?): find out a way to notify about buffer exhaustion,
475  * and possibly fall into kbd to use dmesg command: user will read
476  * debug messages before they will be wiped over by next writes.
477  */
478 }
479 
480 VOID
481 NTAPI
482 KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
483  ULONG BootPhase)
484 {
485  if (!KdpDebugMode.Screen) return;
486 
487  if (BootPhase == 0)
488  {
489  /* Write out the functions that we support for now */
490  DispatchTable->KdpInitRoutine = KdpScreenInit;
491  DispatchTable->KdpPrintRoutine = KdpScreenPrint;
492 
493  /* Register as a Provider */
494  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
495  }
496  else if (BootPhase == 1)
497  {
498  /* Allocate a buffer for dmesg log buffer. +1 for terminating null,
499  * see kdbp_cli.c:KdbpCmdDmesg()/2
500  */
505 
506  /* Take control of the display */
508 
509  /* Initialize spinlock */
511  }
512  else if (BootPhase == 2)
513  {
514  HalDisplayString("\r\n Screen debugging enabled\r\n\r\n");
515  }
516 }
517 
518 /* GENERAL FUNCTIONS *********************************************************/
519 
520 BOOLEAN
521 NTAPI
524 
525 extern STRING KdbPromptString;
526 
527 VOID
528 NTAPI
530  IN ULONG PacketType,
531  IN PSTRING MessageHeader,
532  IN PSTRING MessageData,
534 {
535  if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
536  {
537  PSTRING Output = MessageData;
538  PLIST_ENTRY CurrentEntry;
539  PKD_DISPATCH_TABLE CurrentTable;
540 
541  if (!KdpDebugMode.Value) return;
542 
543  /* Call the registered handlers */
544  CurrentEntry = KdProviders.Flink;
545  while (CurrentEntry != &KdProviders)
546  {
547  /* Get the current table */
548  CurrentTable = CONTAINING_RECORD(CurrentEntry,
549  KD_DISPATCH_TABLE,
550  KdProvidersList);
551 
552  /* Call it */
553  CurrentTable->KdpPrintRoutine(Output->Buffer, Output->Length);
554 
555  /* Next Table */
556  CurrentEntry = CurrentEntry->Flink;
557  }
558  return;
559  }
560  else if (PacketType == PACKET_TYPE_KD_STATE_CHANGE64)
561  {
562  PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange = (PDBGKD_ANY_WAIT_STATE_CHANGE)MessageHeader->Buffer;
563  if (WaitStateChange->NewState == DbgKdLoadSymbolsStateChange)
564  {
565 #ifdef KDBG
566  PLDR_DATA_TABLE_ENTRY LdrEntry;
567  if (!WaitStateChange->u.LoadSymbols.UnloadSymbols)
568  {
569  /* Load symbols. Currently implemented only for KDBG! */
570  if (KdbpSymFindModule((PVOID)(ULONG_PTR)WaitStateChange->u.LoadSymbols.BaseOfDll, NULL, -1, &LdrEntry))
571  {
572  KdbSymProcessSymbols(LdrEntry);
573  }
574  }
575 #endif
576  return;
577  }
578  else if (WaitStateChange->NewState == DbgKdExceptionStateChange)
579  {
581  KdbgExceptionRecord = WaitStateChange->u.Exception.ExceptionRecord;
582  KdbgFirstChanceException = WaitStateChange->u.Exception.FirstChance;
583  return;
584  }
585  }
586  else if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
587  {
588  PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
589  if (ManipulateState->ApiNumber == DbgKdGetContextApi)
590  {
591  KD_CONTINUE_TYPE Result;
592 
593 #ifdef KDBG
594  /* Check if this is an assertion failure */
596  {
597  /* Bump EIP to the instruction following the int 2C */
598  KdbgContext.Eip += 2;
599  }
600 
602  KdbgContext.SegCs & 1,
603  &KdbgContext,
605 #else
606  /* We'll manually dump the stack for the user... */
608  Result = kdHandleException;
609 #endif
610  if (Result != kdHandleException)
612  else
615  return;
616  }
617  else if (ManipulateState->ApiNumber == DbgKdSetContextApi)
618  {
620  return;
621  }
622  }
624 }
625 
626 KDSTATUS
627 NTAPI
629  IN ULONG PacketType,
630  OUT PSTRING MessageHeader,
631  OUT PSTRING MessageData,
634 {
635 #ifdef KDBG
636  KIRQL OldIrql;
637  STRING StringChar;
638  CHAR Response;
639  USHORT i;
640  ULONG DummyScanCode;
641  CHAR MessageBuffer[100];
642  STRING ResponseString;
643 #endif
644 
645  if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
646  {
647  PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
648  RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength);
650  {
651  ManipulateState->ApiNumber = DbgKdGetContextApi;
652  MessageData->Length = 0;
653  MessageData->Buffer = (PCHAR)&KdbgContext;
654  return KdPacketReceived;
655  }
657  {
658  ManipulateState->ApiNumber = DbgKdSetContextApi;
659  MessageData->Length = sizeof(KdbgContext);
660  MessageData->Buffer = (PCHAR)&KdbgContext;
661  return KdPacketReceived;
662  }
664  {
666  }
667  ManipulateState->ApiNumber = DbgKdContinueApi;
668  ManipulateState->u.Continue.ContinueStatus = KdbgContinueStatus;
669 
670  /* Prepare for next time */
673 
674  return KdPacketReceived;
675  }
676 
677  if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
678  return KdPacketTimedOut;
679 
680 #ifdef KDBG
681  ResponseString.Buffer = MessageBuffer;
682  ResponseString.Length = 0;
683  ResponseString.MaximumLength = min(sizeof(MessageBuffer), MessageData->MaximumLength);
684  StringChar.Buffer = &Response;
685  StringChar.Length = StringChar.MaximumLength = sizeof(Response);
686 
687  /* Display the string and print a new line for log neatness */
688  *StringChar.Buffer = '\n';
689  KdpPrintString(&StringChar);
690 
691  /* Print the kdb prompt */
693 
694  // TODO: Use an improved KdbpReadCommand() function for our purposes.
695 
696  /* Acquire the printing spinlock without waiting at raised IRQL */
698 
700  KbdDisableMouse();
701 
702  /* Loop the whole string */
703  for (i = 0; i < ResponseString.MaximumLength; i++)
704  {
705  /* Check if this is serial debugging mode */
707  {
708  /* Get the character from serial */
709  do
710  {
712  } while (Response == -1);
713  }
714  else
715  {
716  /* Get the response from the keyboard */
717  do
718  {
719  Response = KdbpTryGetCharKeyboard(&DummyScanCode, MAXULONG);
720  } while (Response == -1);
721  }
722 
723  /* Check for return */
724  if (Response == '\r')
725  {
726  /*
727  * We might need to discard the next '\n'.
728  * Wait a bit to make sure we receive it.
729  */
731 
732  /* Check the mode */
734  {
735  /* Read and discard the next character, if any */
737  }
738  else
739  {
740  /* Read and discard the next character, if any */
741  KdbpTryGetCharKeyboard(&DummyScanCode, 5);
742  }
743 
744  /*
745  * Null terminate the output string -- documentation states that
746  * DbgPrompt does not null terminate, but it does
747  */
748  *(PCHAR)(ResponseString.Buffer + i) = 0;
749  break;
750  }
751 
752  /* Write it back and print it to the log */
753  *(PCHAR)(ResponseString.Buffer + i) = Response;
755  KdpPrintString(&StringChar);
757  }
758 
759  /* Print a new line */
760  *StringChar.Buffer = '\n';
761  KdpPrintString(&StringChar);
762 
763  /* Return the length */
764  RtlCopyMemory(MessageData->Buffer, ResponseString.Buffer, i);
765  *DataLength = i;
766 
768  KbdEnableMouse();
769 
770  /* Release the spinlock */
772 
773 #endif
774  return KdPacketReceived;
775 }
776 
777 /* EOF */
signed char * PCHAR
Definition: retypes.h:7
static BOOLEAN KdpLoggingEnabled
Definition: kdio.c:21
static CHAR KdpScreenLineBuffer[KdpScreenLineLengthDefault+1]
Definition: kdio.c:35
#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:27
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:40
ULONG Eip
Definition: nt_native.h:1476
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static volatile ULONG KdpFreeBytes
Definition: kdio.c:24
PCHAR KdpDmesgBuffer
Definition: kdio.c:39
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
char CHAR
Definition: xmlstorage.h:175
static ULONG KdpScreenLineLength
Definition: kdio.c:36
static ULONG KdbgNextApiNumber
Definition: kdio.c:55
LONG NTSTATUS
Definition: precomp.h:26
#define SCREEN_WIDTH
Definition: pc98video.c:27
static KSPIN_LOCK KdpDmesgLogSpinLock
Definition: kdio.c:44
NTSTATUS ExceptionCode
Definition: rtltypes.h:190
union _DBGKD_MANIPULATE_STATE64::@3538 u
VOID NTAPI KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:316
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:716
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:65
#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
#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
LONG KPRIORITY
Definition: compat.h:662
#define pch(ap)
Definition: match.c:418
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:26
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:25
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:46
static VOID NTAPI KdpPrintToLogFile(PCHAR String, ULONG StringLength)
Definition: kdio.c:153
static VOID NTAPI KdpScreenPrint(PCHAR Message, ULONG Length)
Definition: kdio.c:388
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:482
STRING KdbPromptString
Definition: kdb_cli.c:143
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:369
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:59
_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:28
_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:42
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018
static VOID NTAPI KdpLoggerThread(PVOID Context)
Definition: kdio.c:106
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:350
#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:23
#define STATUS_ASSERTION_FAILURE
Definition: ntstatus.h:960
#define DEFAULT_DEBUG_BAUD_RATE
Definition: kdcom.c:28
PUCHAR KdComPortInUse
Definition: usage.c:17
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define KdPacketTimedOut
Definition: kddll.h:6
#define DbgKdLoadSymbolsStateChange
Definition: windbgkd.h:60
if(!(yy_init))
Definition: macro.lex.yy.c:714
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define InterlockedExchangeAddUL(Addend, Value)
Definition: ex.h:1505
#define DbgKdGetContextApi
Definition: windbgkd.h:76
VOID KbdDisableMouse(VOID)
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:91
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:34
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
Definition: ncftp.h:89
static PCHAR KdpDebugBuffer
Definition: kdio.c:22
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:58
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:290
#define DbgKdSetContextApi
Definition: windbgkd.h:77
volatile ULONG KdpDmesgFreeBytes
Definition: kdio.c:41
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:628
#define SYNCHRONIZE
Definition: nt_native.h:61
const ULONG KdpDmesgBufferSize
Definition: kdio.c:38
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
#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:20
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
unsigned short USHORT
Definition: pedump.c:61
static EXCEPTION_RECORD64 KdbgExceptionRecord
Definition: kdio.c:57
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
PKDP_INIT_ROUTINE InitRoutines[KdMax]
Definition: kdio.c:50
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:30
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:56
CPPORT SerialPortInfo
Definition: kdio.c:32
#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
ULONG SerialPortNumber
Definition: kdio.c:31
#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:529
static ULONG KdpScreenLineBufferPos
Definition: kdio.c:36
#define OUT
Definition: typedefs.h:40
volatile BOOLEAN KdbpIsInDmesgMode
Definition: kdio.c:43
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#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
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3530 u
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:196
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:47
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