ReactOS 0.4.15-dev-6661-gcc6e444
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:83
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:792

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

2165{
2166 /* Handle some internal commands */
2167 switch ((ULONG)Command)
2168 {
2169#if DBG
2170 case ' soR': /* ROS-INTERNAL */
2171 {
2172 switch ((ULONG_PTR)InputBuffer)
2173 {
2174 case 0x21: // DumpAllThreads:
2176 break;
2177
2178 case 0x22: // DumpUserThreads:
2180 break;
2181
2182 case 0x24: // KdSpare3:
2184 break;
2185
2186 default:
2187 break;
2188 }
2189 return STATUS_SUCCESS;
2190 }
2191
2192#if defined(_M_IX86) && !defined(_WINKD_) // See ke/i386/traphdlr.c
2193 /* Register a debug callback */
2194 case 'CsoR':
2195 {
2196 switch (InputBufferLength)
2197 {
2198 case ID_Win32PreServiceHook:
2199 KeWin32PreServiceHook = InputBuffer;
2200 break;
2201
2202 case ID_Win32PostServiceHook:
2203 KeWin32PostServiceHook = InputBuffer;
2204 break;
2205
2206 }
2207 break;
2208 }
2209#endif
2210
2211 /* Special case for stack frame dumps */
2212 case 'DsoR':
2213 {
2215 break;
2216 }
2217#ifdef KDBG
2218 /* Register KDBG CLI callback */
2219 case 'RbdK':
2220 {
2222 }
2223#endif // KDBG
2224#endif
2225 default:
2226 break;
2227 }
2228
2229 /* Local kernel debugging is not yet supported */
2230 DbgPrint("KdSystemDebugControl is unimplemented!\n");
2232}
#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 2357 of file kdapi.c.

2360{
2361 PULONG Mask;
2362
2363 /* Check if the ID fits in the component table */
2365 {
2366 /* It does, so get the mask from there */
2368 }
2369 else if (ComponentId == MAXULONG)
2370 {
2371 /*
2372 * This is the internal ID used for DbgPrint messages without ID
2373 * and Level. Use the system-wide mask for those.
2374 */
2376 }
2377 else
2378 {
2379#if (NTDDI_VERSION >= NTDDI_VISTA)
2380 /* Use the default component ID */
2382 // Level = DPFLTR_INFO_LEVEL; // Override the Level.
2383#else
2384 /* Invalid ID, fail */
2386#endif
2387 }
2388
2389 /* Convert Level to bit field if required */
2390 if (Level < 32) Level = 1 << Level;
2391 Level &= ~DPFLTR_MASK;
2392
2393 /* Determine if this Level is filtered out */
2394 if ((Kd_WIN2000_Mask & Level) || (*Mask & Level))
2395 {
2396 /* This mask will get through to the debugger */
2397 return (NTSTATUS)TRUE;
2398 }
2399 else
2400 {
2401 /* This mask is filtered out */
2402 return (NTSTATUS)FALSE;
2403 }
2404}
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:144
ULONG KdComponentTableSize
Definition: kddata.c:485
ULONG Kd_DEFAULT_Mask
Definition: kddata.c:246
PULONG KdComponentTable[MAX_KD_COMPONENT_TABLE_ENTRIES]
Definition: kddata.c:315
#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 2411 of file kdapi.c.

2415{
2416 PULONG Mask;
2417
2418 /* Modifying debug filters requires the debug privilege */
2420 {
2421 /* Fail */
2422 return STATUS_ACCESS_DENIED;
2423 }
2424
2425 /* Check if the ID fits in the component table */
2427 {
2428 /* It does, so get the mask from there */
2430 }
2431 else if (ComponentId == MAXULONG)
2432 {
2433 /*
2434 * This is the internal ID used for DbgPrint messages without ID
2435 * and Level. Use the system-wide mask for those.
2436 */
2438 }
2439 else
2440 {
2441#if (NTDDI_VERSION >= NTDDI_VISTA)
2442 /* Use the default component ID */
2444#else
2445 /* Invalid ID, fail */
2447#endif
2448 }
2449
2450 /* Convert Level to bit field if required */
2451 if (Level < 32) Level = 1 << Level;
2452 Level &= ~DPFLTR_MASK;
2453
2454 /* Set or remove the Level */
2455 if (State)
2456 *Mask |= Level;
2457 else
2458 *Mask &= ~Level;
2459
2460 return STATUS_SUCCESS;
2461}
#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:2157
#define KeGetPreviousMode()
Definition: ketypes.h:1110
@ 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 
)