ReactOS 0.4.15-dev-5666-gc548b97
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 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");
2227}
#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:3548
unsigned int ULONG
Definition: retypes.h:1
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
_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 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 */
2371 }
2372 else
2373 {
2374#if (NTDDI_VERSION >= NTDDI_VISTA)
2375 /* Use the default component ID */
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}
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
unsigned int * PULONG
Definition: retypes.h:1
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define MAXULONG
Definition: typedefs.h:251
_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 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 */
2433 }
2434 else
2435 {
2436#if (NTDDI_VERSION >= NTDDI_VISTA)
2437 /* Use the default component ID */
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}
#define ExGetPreviousMode
Definition: ex.h:139
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:2152
#define KeGetPreviousMode()
Definition: ketypes.h:1108
@ 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 
)