ReactOS  0.4.15-dev-1392-g3014417
kdio.c File Reference
#include <ntoskrnl.h>
#include <reactos/buildno.h>
#include <debug.h>
Include dependency graph for kdio.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define KdpBufferSize   (1024 * 512)
 
#define KdpScreenLineLengthDefault   80
 

Functions

KIRQL NTAPI KdpAcquireLock (IN PKSPIN_LOCK SpinLock)
 
VOID NTAPI KdpReleaseLock (IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
 
static VOID NTAPI KdpLoggerThread (PVOID Context)
 
static VOID NTAPI KdpPrintToLogFile (PCHAR String, ULONG StringLength)
 
VOID NTAPI KdpDebugLogInit (PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
 
VOID NTAPI KdpSerialDebugPrint (PCHAR Message, ULONG Length)
 
VOID NTAPI KdpSerialInit (PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
 
VOID KdpScreenAcquire (VOID)
 
VOID KdpScreenRelease (VOID)
 
static VOID NTAPI KdpScreenPrint (PCHAR Message, ULONG Length)
 
VOID NTAPI KdpScreenInit (PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
 
BOOLEAN NTAPI KdpPrintString (_In_ PSTRING Output)
 
VOID NTAPI KdSendPacket (IN ULONG PacketType, IN PSTRING MessageHeader, IN PSTRING MessageData, IN OUT PKD_CONTEXT Context)
 
KDSTATUS NTAPI KdReceivePacket (IN ULONG PacketType, OUT PSTRING MessageHeader, OUT PSTRING MessageData, OUT PULONG DataLength, IN OUT PKD_CONTEXT Context)
 

Variables

static BOOLEAN KdpLoggingEnabled = FALSE
 
static PCHAR KdpDebugBuffer = NULL
 
static volatile ULONG KdpCurrentPosition = 0
 
static volatile ULONG KdpFreeBytes = 0
 
static KSPIN_LOCK KdpDebugLogSpinLock
 
static KEVENT KdpLoggerThreadEvent
 
static HANDLE KdpLogFileHandle
 
ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log")
 
static KSPIN_LOCK KdpSerialSpinLock
 
ULONG SerialPortNumber = DEFAULT_DEBUG_PORT
 
CPPORT SerialPortInfo = {0, DEFAULT_DEBUG_BAUD_RATE, 0}
 
static CHAR KdpScreenLineBuffer [KdpScreenLineLengthDefault+1] = ""
 
static ULONG KdpScreenLineBufferPos = 0
 
static ULONG KdpScreenLineLength = 0
 
const ULONG KdpDmesgBufferSize = 128 * 1024
 
PCHAR KdpDmesgBuffer = NULL
 
volatile ULONG KdpDmesgCurrentPosition = 0
 
volatile ULONG KdpDmesgFreeBytes = 0
 
volatile ULONG KdbDmesgTotalWritten = 0
 
volatile BOOLEAN KdbpIsInDmesgMode = FALSE
 
static KSPIN_LOCK KdpDmesgLogSpinLock
 
KDP_DEBUG_MODE KdpDebugMode
 
LIST_ENTRY KdProviders = {&KdProviders, &KdProviders}
 
KD_DISPATCH_TABLE DispatchTable [KdMax]
 
PKDP_INIT_ROUTINE InitRoutines [KdMax]
 
static ULONG KdbgNextApiNumber = DbgKdContinueApi
 
static CONTEXT KdbgContext
 
static EXCEPTION_RECORD64 KdbgExceptionRecord
 
static BOOLEAN KdbgFirstChanceException
 
static NTSTATUS KdbgContinueStatus = STATUS_SUCCESS
 
STRING KdbPromptString
 

Macro Definition Documentation

◆ KdpBufferSize

#define KdpBufferSize   (1024 * 512)

Definition at line 20 of file kdio.c.

◆ KdpScreenLineLengthDefault

#define KdpScreenLineLengthDefault   80

Definition at line 34 of file kdio.c.

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file kdio.c.

Function Documentation

◆ KdpAcquireLock()

KIRQL NTAPI KdpAcquireLock ( IN PKSPIN_LOCK  SpinLock)

Definition at line 65 of file kdio.c.

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 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define TRUE
Definition: types.h:120
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
BOOLEAN FASTCALL KeTestSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:442
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:303

Referenced by KdpPrintToLogFile(), KdpScreenPrint(), KdpSerialDebugPrint(), and KdReceivePacket().

◆ KdpDebugLogInit()

VOID NTAPI KdpDebugLogInit ( PKD_DISPATCH_TABLE  DispatchTable,
ULONG  BootPhase 
)

Definition at line 196 of file kdio.c.

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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
static HANDLE KdpLogFileHandle
Definition: kdio.c:27
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static volatile ULONG KdpFreeBytes
Definition: kdio.c:24
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
LONG KPRIORITY
Definition: compat.h:662
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:26
#define FILE_SHARE_READ
Definition: compat.h:136
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
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
#define FILE_WRITE_THROUGH
Definition: from_kernel.h:26
ANSI_STRING KdpLogFileName
Definition: kdio.c:28
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
Status
Definition: gdiplustypes.h:24
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)
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KdpBufferSize
Definition: kdio.c:20
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static PCHAR KdpDebugBuffer
Definition: kdio.c:22
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define SYNCHRONIZE
Definition: nt_native.h:61
struct _FileName FileName
Definition: fatprocs.h:893
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
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 NULL
Definition: types.h:112
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
VOID NTAPI KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:196
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
LIST_ENTRY KdProviders
Definition: kdio.c:47

◆ KdpLoggerThread()

static VOID NTAPI KdpLoggerThread ( PVOID  Context)
static

Definition at line 106 of file kdio.c.

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 }
static BOOLEAN KdpLoggingEnabled
Definition: kdio.c:21
static HANDLE KdpLogFileHandle
Definition: kdio.c:27
static volatile ULONG KdpFreeBytes
Definition: kdio.c:24
#define TRUE
Definition: types.h:120
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
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:26
#define FALSE
Definition: types.h:117
static volatile ULONG KdpCurrentPosition
Definition: kdio.c:23
return Iosb
Definition: create.c:4402
#define InterlockedExchangeAddUL(Addend, Value)
Definition: ex.h:1505
GLuint GLuint num
Definition: glext.h:9618
#define KdpBufferSize
Definition: kdio.c:20
static PCHAR KdpDebugBuffer
Definition: kdio.c:22
GLuint GLuint end
Definition: gl.h:1545
#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)
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1

Referenced by KdpDebugLogInit().

◆ KdpPrintString()

BOOLEAN NTAPI KdpPrintString ( _In_ PSTRING  Output)

Definition at line 22 of file kdprint.c.

24 {
26  DBGKD_DEBUG_IO DebugIo;
27  USHORT Length;
28 
29  /* Copy the string */
31  Output->Buffer,
32  Output->Length);
33 
34  /* Make sure we don't exceed the KD Packet size */
35  Length = Output->Length;
36  if ((sizeof(DBGKD_DEBUG_IO) + Length) > PACKET_MAX_SIZE)
37  {
38  /* Normalize length */
40  }
41 
42  /* Build the packet header */
45  DebugIo.Processor = KeGetCurrentPrcb()->Number;
47  Header.Length = sizeof(DBGKD_DEBUG_IO);
48  Header.Buffer = (PCHAR)&DebugIo;
49 
50  /* Build the data */
51  Data.Length = Length;
52  Data.Buffer = KdpMessageBuffer;
53 
54  /* Send the packet */
56 
57  /* Check if the user pressed CTRL+C */
59 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI KdpMoveMemory(_In_ PVOID Destination, _In_ PVOID Source, _In_ SIZE_T Length)
Definition: kdapi.c:22
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1075
#define PACKET_MAX_SIZE
Definition: windbgkd.h:18
ULONG ApiNumber
Definition: windbgkd.h:401
CHAR KdpMessageBuffer[0x1000]
Definition: kddata.c:127
Definition: Header.h:8
#define DbgKdPrintStringApi
Definition: windbgkd.h:122
struct _DBGKD_DEBUG_IO DBGKD_DEBUG_IO
union _DBGKD_DEBUG_IO::@3527 u
USHORT ProcessorLevel
Definition: windbgkd.h:402
BOOLEAN NTAPI KdpPollBreakInWithPortLock(VOID)
Definition: kdlock.c:35
KD_CONTEXT KdpContext
Definition: kddata.c:65
#define PCHAR
Definition: match.c:90
std::wstring STRING
Definition: fontsub.cpp:33
Definition: arc.h:85
DBGKD_PRINT_STRING PrintString
Definition: windbgkd.h:406
unsigned short USHORT
Definition: pedump.c:61
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
USHORT KeProcessorLevel
Definition: krnlinit.c:20
VOID NTAPI KdSendPacket(IN ULONG PacketType, IN PSTRING MessageHeader, IN PSTRING MessageData, IN OUT PKD_CONTEXT KdContext)
Definition: kddll.c:314
USHORT Processor
Definition: windbgkd.h:403

Referenced by KdpDprintf(), KdpPrint(), and KdReceivePacket().

◆ KdpPrintToLogFile()

static VOID NTAPI KdpPrintToLogFile ( PCHAR  String,
ULONG  StringLength 
)
static

Definition at line 153 of file kdio.c.

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 }
static BOOLEAN KdpLoggingEnabled
Definition: kdio.c:21
static volatile ULONG KdpFreeBytes
Definition: kdio.c:24
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:65
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:26
static KSPIN_LOCK KdpDebugLogSpinLock
Definition: kdio.c:25
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define FALSE
Definition: types.h:117
static volatile ULONG KdpCurrentPosition
Definition: kdio.c:23
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
static PCHAR KdpDebugBuffer
Definition: kdio.c:22
GLuint GLuint end
Definition: gl.h:1545
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by KdpDebugLogInit().

◆ KdpReleaseLock()

VOID NTAPI KdpReleaseLock ( IN PKSPIN_LOCK  SpinLock,
IN KIRQL  OldIrql 
)

Definition at line 91 of file kdio.c.

93 {
94  /* Release the spinlock */
96  // KeReleaseSpinLockFromDpcLevel(SpinLock);
97 
98  /* Restore the old IRQL */
100 }
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
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
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790

Referenced by KdpPrintToLogFile(), KdpScreenPrint(), KdpSerialDebugPrint(), and KdReceivePacket().

◆ KdpScreenAcquire()

VOID KdpScreenAcquire ( VOID  )

Definition at line 350 of file kdio.c.

351 {
352  if (InbvIsBootDriverInstalled() /* &&
353  !InbvCheckDisplayOwnership() */)
354  {
355  /* Acquire ownership and reset the display */
363  }
364 }
#define TRUE
Definition: types.h:120
#define SCREEN_WIDTH
Definition: pc98video.c:27
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:716
#define BV_COLOR_WHITE
Definition: display.h:30
VOID NTAPI InbvSetTextColor(IN ULONG Color)
Definition: inbv.c:692
#define SCREEN_HEIGHT
Definition: pc98video.c:28
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:528
BOOLEAN NTAPI InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:606
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:630
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:664
#define NULL
Definition: types.h:112
VOID NTAPI InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter)
Definition: inbv.c:622
#define BV_COLOR_BLACK
Definition: display.h:15
VOID NTAPI InbvSetScrollRegion(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom)
Definition: inbv.c:681

Referenced by KdbpInternalEnter(), and KdpScreenInit().

◆ KdpScreenInit()

VOID NTAPI KdpScreenInit ( PKD_DISPATCH_TABLE  DispatchTable,
ULONG  BootPhase 
)

Definition at line 482 of file kdio.c.

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 }
PCHAR KdpDmesgBuffer
Definition: kdio.c:39
static KSPIN_LOCK KdpDmesgLogSpinLock
Definition: kdio.c:44
#define InsertTailList(ListHead, Entry)
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:46
static VOID NTAPI KdpScreenPrint(PCHAR Message, ULONG Length)
Definition: kdio.c:388
VOID NTAPI KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:482
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
volatile ULONG KdbDmesgTotalWritten
Definition: kdio.c:42
VOID KdpScreenAcquire(VOID)
Definition: kdio.c:350
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
volatile ULONG KdpDmesgFreeBytes
Definition: kdio.c:41
const ULONG KdpDmesgBufferSize
Definition: kdio.c:38
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
LIST_ENTRY KdProviders
Definition: kdio.c:47

◆ KdpScreenPrint()

static VOID NTAPI KdpScreenPrint ( PCHAR  Message,
ULONG  Length 
)
static

Definition at line 388 of file kdio.c.

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 }
signed char * PCHAR
Definition: retypes.h:7
static CHAR KdpScreenLineBuffer[KdpScreenLineLengthDefault+1]
Definition: kdio.c:35
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
volatile ULONG KdpDmesgCurrentPosition
Definition: kdio.c:40
PCHAR KdpDmesgBuffer
Definition: kdio.c:39
static ULONG KdpScreenLineLength
Definition: kdio.c:36
static KSPIN_LOCK KdpDmesgLogSpinLock
Definition: kdio.c:44
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:65
#define pch(ap)
Definition: match.c:418
UCHAR KIRQL
Definition: env_spec_w32.h:591
volatile ULONG KdbDmesgTotalWritten
Definition: kdio.c:42
#define PCHAR
Definition: match.c:90
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:91
GLuint GLuint num
Definition: glext.h:9618
#define KdpScreenLineLengthDefault
Definition: kdio.c:34
GLuint GLuint end
Definition: gl.h:1545
CHAR Message[80]
Definition: alive.c:5
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
volatile ULONG KdpDmesgFreeBytes
Definition: kdio.c:41
const ULONG KdpDmesgBufferSize
Definition: kdio.c:38
#define NULL
Definition: types.h:112
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
static ULONG KdpScreenLineBufferPos
Definition: kdio.c:36
volatile BOOLEAN KdbpIsInDmesgMode
Definition: kdio.c:43
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by KdpScreenInit().

◆ KdpScreenRelease()

VOID KdpScreenRelease ( VOID  )

Definition at line 369 of file kdio.c.

370 {
373  {
374  /* Release the display */
375  // InbvSetDisplayOwnership(FALSE);
377  }
378 }
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:638
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:630
#define NULL
Definition: types.h:112
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:553

Referenced by KdbpInternalEnter().

◆ KdpSerialDebugPrint()

VOID NTAPI KdpSerialDebugPrint ( PCHAR  Message,
ULONG  Length 
)

Definition at line 290 of file kdio.c.

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 }
signed char * PCHAR
Definition: retypes.h:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:65
#define pch(ap)
Definition: match.c:418
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
#define PCHAR
Definition: match.c:90
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:91
CHAR Message[80]
Definition: alive.c:5
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:30
CPPORT SerialPortInfo
Definition: kdio.c:32

Referenced by KdpSerialInit().

◆ KdpSerialInit()

VOID NTAPI KdpSerialInit ( PKD_DISPATCH_TABLE  DispatchTable,
ULONG  BootPhase 
)

Definition at line 316 of file kdio.c.

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 }
VOID NTAPI KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:316
#define InsertTailList(ListHead, Entry)
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:46
BOOLEAN NTAPI KdPortInitializeEx(PCPPORT PortInformation, ULONG ComPortNumber)
#define FALSE
Definition: types.h:117
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
PUCHAR KdComPortInUse
Definition: usage.c:17
VOID NTAPI KdpSerialDebugPrint(PCHAR Message, ULONG Length)
Definition: kdio.c:290
PUCHAR Address
Definition: cportlib.h:29
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:30
CPPORT SerialPortInfo
Definition: kdio.c:32
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
ULONG SerialPortNumber
Definition: kdio.c:31
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
LIST_ENTRY KdProviders
Definition: kdio.c:47

◆ KdReceivePacket()

KDSTATUS NTAPI KdReceivePacket ( IN ULONG  PacketType,
OUT PSTRING  MessageHeader,
OUT PSTRING  MessageData,
OUT PULONG  DataLength,
IN OUT PKD_CONTEXT  Context 
)

Definition at line 628 of file kdio.c.

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 }
#define KdPacketReceived
Definition: kddll.h:5
DBGKD_CONTINUE Continue
Definition: windbgkd.h:779
ULONG KdbDebugState
Definition: kdb.c:45
char CHAR
Definition: xmlstorage.h:175
static ULONG KdbgNextApiNumber
Definition: kdio.c:55
union _DBGKD_MANIPULATE_STATE64::@3538 u
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:65
#define DbgKdContinueApi
Definition: windbgkd.h:80
CHAR KdbpTryGetCharSerial(ULONG Retry)
Definition: kdb_serial.c:19
CHAR KdbpTryGetCharKeyboard(PULONG ScanCode, ULONG Retry)
Definition: kdb_keyboard.c:104
UCHAR KIRQL
Definition: env_spec_w32.h:591
STRING KdbPromptString
Definition: kdb_cli.c:143
static NTSTATUS KdbgContinueStatus
Definition: kdio.c:59
VOID KbdEnableMouse(VOID)
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define PCHAR
Definition: match.c:90
#define KdPacketTimedOut
Definition: kddll.h:6
#define DbgKdGetContextApi
Definition: windbgkd.h:76
VOID KbdDisableMouse(VOID)
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:91
Definition: ncftp.h:89
std::wstring STRING
Definition: fontsub.cpp:33
#define PACKET_TYPE_KD_STATE_MANIPULATE
Definition: windbgkd.h:43
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define DbgKdSetContextApi
Definition: windbgkd.h:77
#define MAXULONG
Definition: typedefs.h:251
BOOLEAN NTAPI KdpPrintString(_In_ PSTRING Output)
Definition: kdprint.c:22
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
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:30
struct _DBGKD_MANIPULATE_STATE64 * PDBGKD_MANIPULATE_STATE64
NTSTATUS ContinueStatus
Definition: windbgkd.h:559
#define min(a, b)
Definition: monoChain.cc:55
static CONTEXT KdbgContext
Definition: kdio.c:56
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
struct Response Response
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:95

◆ KdSendPacket()

VOID NTAPI KdSendPacket ( IN ULONG  PacketType,
IN PSTRING  MessageHeader,
IN PSTRING  MessageData,
IN OUT PKD_CONTEXT  Context 
)

Definition at line 529 of file kdio.c.

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 }
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
struct _DBGKD_ANY_WAIT_STATE_CHANGE * PDBGKD_ANY_WAIT_STATE_CHANGE
ULONG Eip
Definition: nt_native.h:1476
VOID KdbSymProcessSymbols(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
Definition: kdb_symbols.c:434
static ULONG KdbgNextApiNumber
Definition: kdio.c:55
NTSTATUS ExceptionCode
Definition: rtltypes.h:190
#define DbgKdExceptionStateChange
Definition: windbgkd.h:59
#define DbgKdContinueApi
Definition: windbgkd.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:46
DBGKD_LOAD_SYMBOLS64 LoadSymbols
Definition: windbgkd.h:489
ULONG SegCs
Definition: nt_native.h:1477
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
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define STATUS_ASSERTION_FAILURE
Definition: ntstatus.h:960
#define DbgKdLoadSymbolsStateChange
Definition: windbgkd.h:60
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define DbgKdGetContextApi
Definition: windbgkd.h:76
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define PACKET_TYPE_KD_STATE_MANIPULATE
Definition: windbgkd.h:43
EXCEPTION_RECORD64 ExceptionRecord
Definition: windbgkd.h:303
#define PACKET_TYPE_KD_STATE_CHANGE64
Definition: windbgkd.h:48
static BOOLEAN KdbgFirstChanceException
Definition: kdio.c:58
Definition: arc.h:85
Definition: btrfs_drv.h:1922
#define DbgKdSetContextApi
Definition: windbgkd.h:77
Definition: typedefs.h:119
static EXCEPTION_RECORD64 KdbgExceptionRecord
Definition: kdio.c:57
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
struct _DBGKD_MANIPULATE_STATE64 * PDBGKD_MANIPULATE_STATE64
static CONTEXT KdbgContext
Definition: kdio.c:56
#define NULL
Definition: types.h:112
DBGKM_EXCEPTION64 Exception
Definition: windbgkd.h:488
#define UNIMPLEMENTED
Definition: debug.h:115
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3530 u
#define STATUS_SUCCESS
Definition: shellext.h:65
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

Variable Documentation

◆ DispatchTable

KD_DISPATCH_TABLE DispatchTable[KdMax]

Definition at line 48 of file kdio.c.

◆ InitRoutines

PKDP_INIT_ROUTINE InitRoutines[KdMax]
Initial value:
VOID NTAPI KdpKdbgInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdbg.c:21
VOID NTAPI KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:316
VOID NTAPI KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:482
VOID NTAPI KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:196

Definition at line 50 of file kdio.c.

Referenced by KdDebuggerInitialize0().

◆ KdbDmesgTotalWritten

volatile ULONG KdbDmesgTotalWritten = 0

Definition at line 42 of file kdio.c.

Referenced by KdbpCmdDmesg(), KdpScreenInit(), and KdpScreenPrint().

◆ KdbgContext

CONTEXT KdbgContext
static

Definition at line 56 of file kdio.c.

Referenced by KdReceivePacket(), and KdSendPacket().

◆ KdbgContinueStatus

NTSTATUS KdbgContinueStatus = STATUS_SUCCESS
static

Definition at line 59 of file kdio.c.

Referenced by KdReceivePacket(), and KdSendPacket().

◆ KdbgExceptionRecord

EXCEPTION_RECORD64 KdbgExceptionRecord
static

Definition at line 57 of file kdio.c.

Referenced by KdSendPacket().

◆ KdbgFirstChanceException

BOOLEAN KdbgFirstChanceException
static

Definition at line 58 of file kdio.c.

Referenced by KdSendPacket().

◆ KdbgNextApiNumber

ULONG KdbgNextApiNumber = DbgKdContinueApi
static

Definition at line 55 of file kdio.c.

Referenced by KdReceivePacket(), and KdSendPacket().

◆ KdbpIsInDmesgMode

volatile BOOLEAN KdbpIsInDmesgMode = FALSE

Definition at line 43 of file kdio.c.

Referenced by KdbpCmdDmesg(), and KdpScreenPrint().

◆ KdbPromptString

◆ KdpCurrentPosition

volatile ULONG KdpCurrentPosition = 0
static

Definition at line 23 of file kdio.c.

Referenced by KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpDebugBuffer

PCHAR KdpDebugBuffer = NULL
static

Definition at line 22 of file kdio.c.

Referenced by KdpDebugLogInit(), KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpDebugLogSpinLock

KSPIN_LOCK KdpDebugLogSpinLock
static

Definition at line 25 of file kdio.c.

Referenced by KdpDebugLogInit(), and KdpPrintToLogFile().

◆ KdpDebugMode

◆ KdpDmesgBuffer

PCHAR KdpDmesgBuffer = NULL

Definition at line 39 of file kdio.c.

Referenced by KdbpCmdDmesg(), KdpScreenInit(), and KdpScreenPrint().

◆ KdpDmesgBufferSize

const ULONG KdpDmesgBufferSize = 128 * 1024

Definition at line 38 of file kdio.c.

Referenced by KdbpCmdDmesg(), KdpScreenInit(), and KdpScreenPrint().

◆ KdpDmesgCurrentPosition

volatile ULONG KdpDmesgCurrentPosition = 0

Definition at line 40 of file kdio.c.

Referenced by KdbpCmdDmesg(), and KdpScreenPrint().

◆ KdpDmesgFreeBytes

volatile ULONG KdpDmesgFreeBytes = 0

Definition at line 41 of file kdio.c.

Referenced by KdbpCmdDmesg(), KdpScreenInit(), and KdpScreenPrint().

◆ KdpDmesgLogSpinLock

KSPIN_LOCK KdpDmesgLogSpinLock
static

Definition at line 44 of file kdio.c.

Referenced by KdpScreenInit(), and KdpScreenPrint().

◆ KdpFreeBytes

volatile ULONG KdpFreeBytes = 0
static

Definition at line 24 of file kdio.c.

Referenced by KdpDebugLogInit(), KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpLogFileHandle

HANDLE KdpLogFileHandle
static

Definition at line 27 of file kdio.c.

Referenced by KdpDebugLogInit(), and KdpLoggerThread().

◆ KdpLogFileName

ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log")

Definition at line 28 of file kdio.c.

Referenced by KdpDebugLogInit(), and KdpGetDebugMode().

◆ KdpLoggerThreadEvent

KEVENT KdpLoggerThreadEvent
static

Definition at line 26 of file kdio.c.

Referenced by KdpDebugLogInit(), KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpLoggingEnabled

BOOLEAN KdpLoggingEnabled = FALSE
static

Definition at line 21 of file kdio.c.

Referenced by KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdProviders

LIST_ENTRY KdProviders = {&KdProviders, &KdProviders}

◆ KdpScreenLineBuffer

CHAR KdpScreenLineBuffer[KdpScreenLineLengthDefault+1] = ""
static

Definition at line 35 of file kdio.c.

Referenced by KdpScreenPrint().

◆ KdpScreenLineBufferPos

ULONG KdpScreenLineBufferPos = 0
static

Definition at line 36 of file kdio.c.

Referenced by KdpScreenPrint().

◆ KdpScreenLineLength

ULONG KdpScreenLineLength = 0
static

Definition at line 36 of file kdio.c.

Referenced by KdpScreenPrint().

◆ KdpSerialSpinLock

KSPIN_LOCK KdpSerialSpinLock
static

Definition at line 30 of file kdio.c.

Referenced by KdpSerialDebugPrint(), KdpSerialInit(), and KdReceivePacket().

◆ SerialPortInfo

CPPORT SerialPortInfo = {0, DEFAULT_DEBUG_BAUD_RATE, 0}

Definition at line 32 of file kdio.c.

Referenced by KdbpTryGetCharSerial(), KdpGetDebugMode(), KdpSerialDebugPrint(), and KdpSerialInit().

◆ SerialPortNumber

ULONG SerialPortNumber = DEFAULT_DEBUG_PORT

Definition at line 31 of file kdio.c.

Referenced by KdpGetDebugMode(), and KdpSerialInit().