ReactOS  0.4.15-dev-4603-gb922b6d
dbgctrl.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for dbgctrl.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI ExpDebuggerWorker (IN PVOID Context)
 
NTSTATUS NTAPI NtSystemDebugControl (SYSDBG_COMMAND ControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG ReturnLength)
 

Variables

WORK_QUEUE_ITEM ExpDebuggerWorkItem
 
WINKD_WORKER_STATE ExpDebuggerWork
 
PEPROCESS ExpDebuggerProcessAttach
 
PEPROCESS ExpDebuggerProcessKill
 
ULONG_PTR ExpDebuggerPageIn
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file dbgctrl.c.

Function Documentation

◆ ExpDebuggerWorker()

VOID NTAPI ExpDebuggerWorker ( IN PVOID  Context)

Definition at line 52 of file dbgctrl.c.

53 {
54  PEPROCESS ProcessToAttach, ProcessToKill;
55  ULONG_PTR PageInAddress;
58 
60 
61  /* Be sure we were started in an initialized state */
62  ASSERTMSG("ExpDebuggerWorker being entered in non-initialized state!\n",
65  {
66  /* An error happened, so get a chance to restart proper */
68  return;
69  }
70 
71  /* Get the processes to be attached or killed, and the address to page in */
72  ProcessToAttach = ExpDebuggerProcessAttach;
73  ProcessToKill = ExpDebuggerProcessKill;
74  PageInAddress = ExpDebuggerPageIn;
75 
76  /* Reset the state machine to its ready state */
81 
82  /* Default to the current process if we don't find the process to be attached or killed */
83  Process = NULL;
84 
85  /* Check if we need to attach or kill some process */
86  if (ProcessToAttach != NULL || ProcessToKill != NULL)
87  {
88  /* Find the process in the list */
90  while (Process)
91  {
92  /* Is this the process we want to attach to? */
93  if (Process == ProcessToAttach)
94  {
95  /* Yes, attach ourselves to it */
97  break;
98  }
99  /* Or is this the process we want to kill? */
100  else if (Process == ProcessToKill)
101  {
102  /* Yes, kill and dereference it, then return */
105  return;
106  }
107 
108  /* Get the next process */
110  }
111 
112  /* We either have found a process, or we default to the current process */
113  }
114 
115  /* If we have an address to page in... */
116  if (PageInAddress)
117  {
118  /* ... try to do it by attempting to read at this address */
119  _SEH2_TRY
120  {
121  ProbeForReadUchar(PageInAddress);
122  }
124  {
125  DPRINT1("Failed to page in address 0x%p, Status 0x%08lx\n", PageInAddress, _SEH2_GetExceptionCode());
126  }
127  _SEH2_END;
128  }
129 
130  /* Break into the process (or the current one if Process == NULL) */
132 
133  /* If we are attached to a process, not the current one... */
134  if (Process)
135  {
136  /* ... we can detach from the process */
138  /* Dereference the process which was referenced for us by PsGetNextProcess */
140  }
141 }
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:27
KAPC_STATE
Definition: ketypes.h:1285
#define DBG_TERMINATE_PROCESS
Definition: ntstatus.h:51
#define ProbeForReadUchar(Ptr)
Definition: probe.h:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:26
#define DBG_STATUS_WORKER
Definition: kdtypes.h:45
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
NTSTATUS NTAPI PsTerminateProcess(IN PEPROCESS Process, IN NTSTATUS ExitStatus)
Definition: kill.c:129
#define ObDereferenceObject
Definition: obfuncs.h:203
ULONG_PTR ExpDebuggerPageIn
Definition: dbgctrl.c:28
PEPROCESS NTAPI PsGetNextProcess(IN PEPROCESS OldProcess OPTIONAL)
Definition: process.c:128
_SEH2_END
Definition: create.c:4400
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1700
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
WINKD_WORKER_STATE ExpDebuggerWork
Definition: dbgctrl.c:25
#define ULONG_PTR
Definition: config.h:101
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165

Referenced by ExpWorkerThreadBalanceManager().

◆ NtSystemDebugControl()

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:1108
_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

Variable Documentation

◆ ExpDebuggerPageIn

ULONG_PTR ExpDebuggerPageIn

Definition at line 28 of file dbgctrl.c.

Referenced by ExpDebuggerWorker().

◆ ExpDebuggerProcessAttach

PEPROCESS ExpDebuggerProcessAttach

Definition at line 26 of file dbgctrl.c.

Referenced by ExpDebuggerWorker().

◆ ExpDebuggerProcessKill

PEPROCESS ExpDebuggerProcessKill

Definition at line 27 of file dbgctrl.c.

Referenced by ExpDebuggerWorker().

◆ ExpDebuggerWork

WINKD_WORKER_STATE ExpDebuggerWork

Definition at line 25 of file dbgctrl.c.

Referenced by ExpDebuggerWorker(), and ExpWorkerThreadBalanceManager().

◆ ExpDebuggerWorkItem

WORK_QUEUE_ITEM ExpDebuggerWorkItem

Definition at line 20 of file dbgctrl.c.

Referenced by ExpWorkerThreadBalanceManager().