ReactOS  0.4.15-dev-1397-g19779b3
kdfuncs.h File Reference
#include <umtypes.h>
#include <kdtypes.h>
Include dependency graph for kdfuncs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NTSTATUS NTAPI KdSystemDebugControl (_In_ SYSDBG_COMMAND Command, _In_ PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_ PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _Inout_ PULONG ReturnLength, _In_ KPROCESSOR_MODE PreviousMode)
 
BOOLEAN NTAPI KdPollBreakIn (VOID)
 
NTSYSCALLAPI NTSTATUS NTAPI NtQueryDebugFilterState (_In_ ULONG ComponentId, _In_ ULONG Level)
 
NTSYSCALLAPI NTSTATUS NTAPI NtSetDebugFilterState (_In_ ULONG ComponentId, _In_ ULONG Level, _In_ BOOLEAN State)
 
NTSYSCALLAPI NTSTATUS NTAPI NtSystemDebugControl (SYSDBG_COMMAND ControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG ReturnLength)
 
NTSYSAPI NTSTATUS NTAPI ZwQueryDebugFilterState (ULONG ComponentId, ULONG Level)
 
NTSYSAPI NTSTATUS NTAPI ZwSetDebugFilterState (ULONG ComponentId, ULONG Level, BOOLEAN State)
 
NTSYSAPI NTSTATUS NTAPI ZwSystemDebugControl (SYSDBG_COMMAND ControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG ReturnLength)
 

Function Documentation

◆ KdPollBreakIn()

BOOLEAN NTAPI KdPollBreakIn ( VOID  )

Definition at line 75 of file kdlock.c.

76 {
77  BOOLEAN DoBreak = FALSE, Enable;
78 
79  /* First make sure that KD is enabled */
81  {
82  /* Disable interrupts */
84 
85  /* Check if a CTRL-C is in the queue */
87  {
88  /* Set it and prepare for break */
90  DoBreak = TRUE;
92  }
93  else
94  {
95  /* Try to acquire the lock */
97  {
98  /* Now get a packet */
100  NULL,
101  NULL,
102  NULL,
104  {
105  /* Successful breakin */
106  DoBreak = TRUE;
108  }
109 
110  /* Let go of the port */
111  KdpPortUnlock();
112  }
113  }
114 
115  /* Re-enable interrupts if they were enabled previously */
116  if (Enable) _enable();
117  }
118 
119  /* Tell the caller to do a break */
120  return DoBreak;
121 }
BOOLEAN KdDebuggerEnabled
Definition: kddata.c:83
#define KdPacketReceived
Definition: kddll.h:5
#define TRUE
Definition: types.h:120
void __cdecl _enable(void)
Definition: intrin_arm.h:373
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
KDP_STATUS NTAPI KdReceivePacket(IN ULONG PacketType, OUT PSTRING MessageHeader, OUT PSTRING MessageData, OUT PULONG DataLength, IN OUT PKD_CONTEXT KdContext)
Definition: kddll.c:80
KSPIN_LOCK KdpDebuggerLock
Definition: kddata.c:67
VOID NTAPI KdpPortUnlock(VOID)
Definition: kdlock.c:27
BOOLEAN KdpControlCPressed
Definition: kddata.c:68
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
FORCEINLINE BOOLEAN KeDisableInterrupts(VOID)
Definition: ke.h:176
KD_CONTEXT KdpContext
Definition: kddata.c:65
BOOLEAN KdpControlCPending
Definition: windbgkd.h:227
#define NULL
Definition: types.h:112
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:303
#define PACKET_TYPE_KD_POLL_BREAKIN
Definition: windbgkd.h:49

Referenced by KdInitSystem(), KeUpdateSystemTime(), KiInitializeSystem(), KiSystemStartup(), and KiSystemStartupReal().

◆ KdSystemDebugControl()

NTSTATUS NTAPI KdSystemDebugControl ( _In_ SYSDBG_COMMAND  Command,
_In_ PVOID  InputBuffer,
_In_ ULONG  InputBufferLength,
_Out_ PVOID  OutputBuffer,
_In_ ULONG  OutputBufferLength,
_Inout_ PULONG  ReturnLength,
_In_ KPROCESSOR_MODE  PreviousMode 
)

Definition at line 2152 of file kdapi.c.

2160 {
2161  /* Handle some internal commands */
2162  switch ((ULONG)Command)
2163  {
2164 #if DBG
2165  case ' soR': /* ROS-INTERNAL */
2166  {
2167  switch ((ULONG_PTR)InputBuffer)
2168  {
2169  case 0x21: // DumpAllThreads:
2171  break;
2172 
2173  case 0x22: // DumpUserThreads:
2175  break;
2176 
2177  case 0x24: // KdSpare3:
2179  break;
2180 
2181  default:
2182  break;
2183  }
2184  return STATUS_SUCCESS;
2185  }
2186 
2187 #if defined(_M_IX86) && !defined(_WINKD_) // See ke/i386/traphdlr.c
2188  /* Register a debug callback */
2189  case 'CsoR':
2190  {
2191  switch (InputBufferLength)
2192  {
2193  case ID_Win32PreServiceHook:
2194  KeWin32PreServiceHook = InputBuffer;
2195  break;
2196 
2197  case ID_Win32PostServiceHook:
2198  KeWin32PostServiceHook = InputBuffer;
2199  break;
2200 
2201  }
2202  break;
2203  }
2204 #endif
2205 
2206  /* Special case for stack frame dumps */
2207  case 'DsoR':
2208  {
2210  break;
2211  }
2212 #if defined(KDBG)
2213  /* Register KDBG CLI callback */
2214  case 'RbdK':
2215  {
2217  }
2218 #endif /* KDBG */
2219 #endif
2220  default:
2221  break;
2222  }
2223 
2224  /* Local kernel debugging is not yet supported */
2225  DbgPrint("KdSystemDebugControl is unimplemented!\n");
2226  return STATUS_NOT_IMPLEMENTED;
2227 }
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
#define DbgPrint
Definition: loader.c:25
#define TRUE
Definition: types.h:120
VOID NTAPI MmDumpArmPfnDatabase(IN BOOLEAN StatusOnly)
Definition: mminit.c:1474
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:318
Definition: shell.h:41
VOID NTAPI PspDumpThreads(BOOLEAN SystemThreads)
uint32_t ULONG_PTR
Definition: typedefs.h:65
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:949
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN NTAPI KdbRegisterCliCallback(PVOID Callback, BOOLEAN Deregister)
Definition: kdb_cli.c:3465
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by DriverEntry(), i8042KbdInterruptService(), KdRosDumpStackFrames(), KdRosSetDebugCallback(), and NtSystemDebugControl().

◆ NtQueryDebugFilterState()

NTSYSCALLAPI NTSTATUS NTAPI NtQueryDebugFilterState ( _In_ ULONG  ComponentId,
_In_ ULONG  Level 
)

Definition at line 2352 of file kdapi.c.

2355 {
2356  PULONG Mask;
2357 
2358  /* Check if the ID fits in the component table */
2360  {
2361  /* It does, so get the mask from there */
2363  }
2364  else if (ComponentId == MAXULONG)
2365  {
2366  /*
2367  * This is the internal ID used for DbgPrint messages without ID
2368  * and Level. Use the system-wide mask for those.
2369  */
2370  Mask = &Kd_WIN2000_Mask;
2371  }
2372  else
2373  {
2374 #if (NTDDI_VERSION >= NTDDI_VISTA)
2375  /* Use the default component ID */
2376  Mask = &Kd_DEFAULT_Mask;
2377  // Level = DPFLTR_INFO_LEVEL; // Override the Level.
2378 #else
2379  /* Invalid ID, fail */
2381 #endif
2382  }
2383 
2384  /* Convert Level to bit field if required */
2385  if (Level < 32) Level = 1 << Level;
2386  Level &= ~DPFLTR_MASK;
2387 
2388  /* Determine if this Level is filtered out */
2389  if ((Kd_WIN2000_Mask & Level) || (*Mask & Level))
2390  {
2391  /* This mask will get through to the debugger */
2392  return (NTSTATUS)TRUE;
2393  }
2394  else
2395  {
2396  /* This mask is filtered out */
2397  return (NTSTATUS)FALSE;
2398  }
2399 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
ULONG KdComponentTableSize
Definition: kddata.c:484
#define DPFLTR_MASK
Definition: kdtypes.h:34
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 ComponentId
Definition: acpixf.h:1274
#define FALSE
Definition: types.h:117
ULONG Kd_WIN2000_Mask
Definition: kddata.c:143
PULONG KdComponentTable[MAX_KD_COMPONENT_TABLE_ENTRIES]
Definition: kddata.c:314
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
processorSet Mask
#define MAXULONG
Definition: typedefs.h:251
ULONG Kd_DEFAULT_Mask
Definition: kddata.c:245
unsigned int * PULONG
Definition: retypes.h:1

Referenced by DbgQueryDebugFilterState(), KdpPrint(), and vDbgPrintExWithPrefixInternal().

◆ NtSetDebugFilterState()

NTSYSCALLAPI NTSTATUS NTAPI NtSetDebugFilterState ( _In_ ULONG  ComponentId,
_In_ ULONG  Level,
_In_ BOOLEAN  State 
)

Definition at line 2406 of file kdapi.c.

2410 {
2411  PULONG Mask;
2412 
2413  /* Modifying debug filters requires the debug privilege */
2415  {
2416  /* Fail */
2417  return STATUS_ACCESS_DENIED;
2418  }
2419 
2420  /* Check if the ID fits in the component table */
2422  {
2423  /* It does, so get the mask from there */
2425  }
2426  else if (ComponentId == MAXULONG)
2427  {
2428  /*
2429  * This is the internal ID used for DbgPrint messages without ID
2430  * and Level. Use the system-wide mask for those.
2431  */
2432  Mask = &Kd_WIN2000_Mask;
2433  }
2434  else
2435  {
2436 #if (NTDDI_VERSION >= NTDDI_VISTA)
2437  /* Use the default component ID */
2438  Mask = &Kd_DEFAULT_Mask;
2439 #else
2440  /* Invalid ID, fail */
2442 #endif
2443  }
2444 
2445  /* Convert Level to bit field if required */
2446  if (Level < 32) Level = 1 << Level;
2447  Level &= ~DPFLTR_MASK;
2448 
2449  /* Set or remove the Level */
2450  if (State)
2451  *Mask |= Level;
2452  else
2453  *Mask &= ~Level;
2454 
2455  return STATUS_SUCCESS;
2456 }
const LUID SeDebugPrivilege
Definition: priv.c:37
ULONG KdComponentTableSize
Definition: kddata.c:484
#define DPFLTR_MASK
Definition: kdtypes.h:34
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:520
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3066
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 ComponentId
Definition: acpixf.h:1274
ULONG Kd_WIN2000_Mask
Definition: kddata.c:143
PULONG KdComponentTable[MAX_KD_COMPONENT_TABLE_ENTRIES]
Definition: kddata.c:314
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
processorSet Mask
#define MAXULONG
Definition: typedefs.h:251
ULONG Kd_DEFAULT_Mask
Definition: kddata.c:245
unsigned int * PULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by DbgSetDebugFilterState(), and KdbpCmdFilter().

◆ NtSystemDebugControl()

NTSYSCALLAPI NTSTATUS NTAPI NtSystemDebugControl ( SYSDBG_COMMAND  ControlCode,
PVOID  InputBuffer,
ULONG  InputBufferLength,
PVOID  OutputBuffer,
ULONG  OutputBufferLength,
PULONG  ReturnLength 
)

Definition at line 182 of file dbgctrl.c.

188 {
189  switch (ControlCode)
190  {
193  case SysDbgSetTracepoint:
197  case SysDbgQueryVersion:
198  case SysDbgReadVirtual:
199  case SysDbgWriteVirtual:
200  case SysDbgReadPhysical:
201  case SysDbgWritePhysical:
204  case SysDbgReadIoSpace:
205  case SysDbgWriteIoSpace:
206  case SysDbgReadMsr:
207  case SysDbgWriteMsr:
208  case SysDbgReadBusData:
209  case SysDbgWriteBusData:
211  case SysDbgGetTriageDump:
212  return STATUS_NOT_IMPLEMENTED;
213  case SysDbgBreakPoint:
224  return KdSystemDebugControl(
225  ControlCode,
229  default:
231  }
232 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define KeGetPreviousMode()
Definition: ketypes.h:1107
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:318
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:318
return STATUS_NOT_IMPLEMENTED
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:859
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:949
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
NTSTATUS NTAPI KdSystemDebugControl(_In_ SYSDBG_COMMAND Command, _In_ PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_ PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _Inout_ PULONG ReturnLength, _In_ KPROCESSOR_MODE PreviousMode)
Definition: kdapi.c:2152

◆ ZwQueryDebugFilterState()

NTSYSAPI NTSTATUS NTAPI ZwQueryDebugFilterState ( ULONG  ComponentId,
ULONG  Level 
)

◆ ZwSetDebugFilterState()

NTSYSAPI NTSTATUS NTAPI ZwSetDebugFilterState ( ULONG  ComponentId,
ULONG  Level,
BOOLEAN  State 
)

◆ ZwSystemDebugControl()

NTSYSAPI NTSTATUS NTAPI ZwSystemDebugControl ( SYSDBG_COMMAND  ControlCode,
PVOID  InputBuffer,
ULONG  InputBufferLength,
PVOID  OutputBuffer,
ULONG  OutputBufferLength,
PULONG  ReturnLength 
)