ReactOS 0.4.15-dev-8102-g108db8f
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 {
96 /* Try to acquire the lock */
99 {
100 /* Now get a packet */
102 NULL,
103 NULL,
104 NULL,
106 {
107 /* Successful breakin */
108 DoBreak = TRUE;
110 }
111
112 /* Let go of the port */
114 }
116 }
117
118 /* Re-enable interrupts */
120 }
121
122 /* Tell the caller to do a break */
123 return DoBreak;
124}
unsigned char BOOLEAN
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
KSPIN_LOCK KdpDebuggerLock
Definition: kddata.c:67
KD_CONTEXT KdpContext
Definition: kddata.c:65
BOOLEAN KdpControlCPressed
Definition: kddata.c:68
BOOLEAN KdDebuggerEnabled
Definition: kddata.c:82
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
VOID NTAPI KdpPortUnlock(VOID)
Definition: kdlock.c:27
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
FORCEINLINE BOOLEAN KeDisableInterrupts(VOID)
Definition: ke.h:239
FORCEINLINE VOID KeRestoreInterrupts(BOOLEAN WereEnabled)
Definition: ke.h:254
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:309
#define KdPacketReceived
Definition: kddll.h:5
BOOLEAN KdpControlCPending
Definition: windbgkd.h:227
#define PACKET_TYPE_KD_POLL_BREAKIN
Definition: windbgkd.h:49
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

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

◆ 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 2183 of file kdapi.c.

2191{
2192 /* Handle some internal commands */
2193 switch ((ULONG)Command)
2194 {
2195#if DBG
2196 case ' soR': /* ROS-INTERNAL */
2197 {
2198 switch ((ULONG_PTR)InputBuffer)
2199 {
2200 case 0x21: // DumpAllThreads:
2202 break;
2203
2204 case 0x22: // DumpUserThreads:
2206 break;
2207
2208 case 0x24: // KdSpare3:
2210 break;
2211
2212 default:
2213 break;
2214 }
2215 return STATUS_SUCCESS;
2216 }
2217
2218#if defined(_M_IX86) && !defined(_WINKD_) // See ke/i386/traphdlr.c
2219 /* Register a debug callback */
2220 case 'CsoR':
2221 {
2222 switch (InputBufferLength)
2223 {
2224 case ID_Win32PreServiceHook:
2225 KeWin32PreServiceHook = InputBuffer;
2226 break;
2227
2228 case ID_Win32PostServiceHook:
2229 KeWin32PostServiceHook = InputBuffer;
2230 break;
2231
2232 }
2233 break;
2234 }
2235#endif
2236
2237 /* Special case for stack frame dumps */
2238 case 'DsoR':
2239 {
2241 break;
2242 }
2243#ifdef KDBG
2244 /* Register KDBG CLI callback */
2245 case 'RbdK':
2246 {
2248 }
2249#endif // KDBG
2250#endif
2251 default:
2252 break;
2253 }
2254
2255 /* Local kernel debugging is not yet supported */
2256 DbgPrint("KdSystemDebugControl is unimplemented!\n");
2258}
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
#define DbgPrint
Definition: hal.h:12
VOID NTAPI PspDumpThreads(BOOLEAN SystemThreads)
BOOLEAN NTAPI KdbRegisterCliCallback(PVOID Callback, BOOLEAN Deregister)
Definition: kdb_cli.c:3125
VOID NTAPI MmDumpArmPfnDatabase(IN BOOLEAN StatusOnly)
Definition: mminit.c:1474
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: shell.h:41
uint32_t * PULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

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

◆ NtQueryDebugFilterState()

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

Definition at line 2383 of file kdapi.c.

2386{
2387 PULONG Mask;
2388
2389 /* Check if the ID fits in the component table */
2391 {
2392 /* It does, so get the mask from there */
2394 }
2395 else if (ComponentId == MAXULONG)
2396 {
2397 /*
2398 * This is the internal ID used for DbgPrint messages without ID
2399 * and Level. Use the system-wide mask for those.
2400 */
2402 }
2403 else
2404 {
2405#if (NTDDI_VERSION >= NTDDI_VISTA)
2406 /* Use the default component ID */
2408 // Level = DPFLTR_INFO_LEVEL; // Override the Level.
2409#else
2410 /* Invalid ID, fail */
2412#endif
2413 }
2414
2415 /* Convert Level to bit field if required */
2416 if (Level < 32) Level = 1 << Level;
2417 Level &= ~DPFLTR_MASK;
2418
2419 /* Determine if this Level is filtered out */
2420 if ((Kd_WIN2000_Mask & Level) || (*Mask & Level))
2421 {
2422 /* This mask will get through to the debugger */
2423 return (NTSTATUS)TRUE;
2424 }
2425 else
2426 {
2427 /* This mask is filtered out */
2428 return (NTSTATUS)FALSE;
2429 }
2430}
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:1281
LONG NTSTATUS
Definition: precomp.h:26
unsigned int Mask
Definition: fpcontrol.c:82
ULONG Kd_WIN2000_Mask
Definition: kddata.c:143
ULONG KdComponentTableSize
Definition: kddata.c:484
ULONG Kd_DEFAULT_Mask
Definition: kddata.c:245
PULONG KdComponentTable[MAX_KD_COMPONENT_TABLE_ENTRIES]
Definition: kddata.c:314
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define MAXULONG
Definition: typedefs.h:251
uint32_t * PULONG
Definition: typedefs.h:59
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56

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

◆ NtSetDebugFilterState()

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

Definition at line 2437 of file kdapi.c.

2441{
2442 PULONG Mask;
2443
2444 /* Modifying debug filters requires the debug privilege */
2446 {
2447 /* Fail */
2448 return STATUS_ACCESS_DENIED;
2449 }
2450
2451 /* Check if the ID fits in the component table */
2453 {
2454 /* It does, so get the mask from there */
2456 }
2457 else if (ComponentId == MAXULONG)
2458 {
2459 /*
2460 * This is the internal ID used for DbgPrint messages without ID
2461 * and Level. Use the system-wide mask for those.
2462 */
2464 }
2465 else
2466 {
2467#if (NTDDI_VERSION >= NTDDI_VISTA)
2468 /* Use the default component ID */
2470#else
2471 /* Invalid ID, fail */
2473#endif
2474 }
2475
2476 /* Convert Level to bit field if required */
2477 if (Level < 32) Level = 1 << Level;
2478 Level &= ~DPFLTR_MASK;
2479
2480 /* Set or remove the Level */
2481 if (State)
2482 *Mask |= Level;
2483 else
2484 *Mask &= ~Level;
2485
2486 return STATUS_SUCCESS;
2487}
#define ExGetPreviousMode
Definition: ex.h:140
const LUID SeDebugPrivilege
Definition: priv.c:39
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

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 {
206 case SysDbgReadMsr:
207 case SysDbgWriteMsr:
213 case SysDbgBreakPoint:
229 default:
231 }
232}
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
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:2183
#define KeGetPreviousMode()
Definition: ketypes.h:1115
@ SysDbgCheckLowMemory
Definition: kdtypes.h:82
@ SysDbgQuerySpecialCalls
Definition: kdtypes.h:67
@ SysDbgSetTracepoint
Definition: kdtypes.h:64
@ SysDbgReadPhysical
Definition: kdtypes.h:72
@ SysDbgGetPrintBufferSize
Definition: kdtypes.h:87
@ SysDbgQueryTraceInformation
Definition: kdtypes.h:63
@ SysDbgClearSpecialCalls
Definition: kdtypes.h:66
@ SysDbgReadMsr
Definition: kdtypes.h:78
@ SysDbgWriteControlSpace
Definition: kdtypes.h:75
@ SysDbgGetKdBlockEnable
Definition: kdtypes.h:92
@ SysDbgWriteBusData
Definition: kdtypes.h:81
@ SysDbgEnableKernelDebugger
Definition: kdtypes.h:83
@ SysDbgWriteVirtual
Definition: kdtypes.h:71
@ SysDbgWritePhysical
Definition: kdtypes.h:73
@ SysDbgGetKdUmExceptionEnable
Definition: kdtypes.h:89
@ SysDbgQueryVersion
Definition: kdtypes.h:69
@ SysDbgReadControlSpace
Definition: kdtypes.h:74
@ SysDbgReadBusData
Definition: kdtypes.h:80
@ SysDbgBreakPoint
Definition: kdtypes.h:68
@ SysDbgSetKdUmExceptionEnable
Definition: kdtypes.h:90
@ SysDbgReadIoSpace
Definition: kdtypes.h:76
@ SysDbgGetAutoKdEnable
Definition: kdtypes.h:85
@ SysDbgWriteMsr
Definition: kdtypes.h:79
@ SysDbgReadVirtual
Definition: kdtypes.h:70
@ SysDbgSetPrintBufferSize
Definition: kdtypes.h:88
@ SysDbgQueryModuleInformation
Definition: kdtypes.h:62
@ SysDbgSetAutoKdEnable
Definition: kdtypes.h:86
@ SysDbgGetTriageDump
Definition: kdtypes.h:91
@ SysDbgDisableKernelDebugger
Definition: kdtypes.h:84
@ SysDbgWriteIoSpace
Definition: kdtypes.h:77
@ SysDbgSetSpecialCall
Definition: kdtypes.h:65
@ SysDbgSetKdBlockEnable
Definition: kdtypes.h:93
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55

◆ 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 
)