ReactOS  0.4.15-dev-1171-gab82533
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 55 of file dbgctrl.c.

56 {
57  PEPROCESS ProcessToAttach, ProcessToKill;
58  ULONG_PTR PageInAddress;
61 
63 
64  /* Be sure we were started in an initialized state */
65  ASSERTMSG("ExpDebuggerWorker being entered in non-initialized state!\n",
68  {
69  /* An error happened, so get a chance to restart proper */
71  return;
72  }
73 
74  /* Get the processes to be attached or killed, and the address to page in */
75  ProcessToAttach = ExpDebuggerProcessAttach;
76  ProcessToKill = ExpDebuggerProcessKill;
77  PageInAddress = ExpDebuggerPageIn;
78 
79  /* Reset the state machine to its ready state */
84 
85  /* Default to the current process if we don't find the process to be attached or killed */
86  Process = NULL;
87 
88  /* Check if we need to attach or kill some process */
89  if (ProcessToAttach != NULL || ProcessToKill != NULL)
90  {
91  /* Find the process in the list */
93  while (Process)
94  {
95  /* Is this the process we want to attach to? */
96  if (Process == ProcessToAttach)
97  {
98  /* Yes, attach ourselves to it */
100  break;
101  }
102  /* Or is this the process we want to kill? */
103  else if (Process == ProcessToKill)
104  {
105  /* Yes, kill and dereference it, then return */
108  return;
109  }
110 
111  /* Get the next process */
113  }
114 
115  /* We either have found a process, or we default to the current process */
116  }
117 
118  /* If we have an address to page in... */
119  if (PageInAddress)
120  {
121  /* ... try to do it by attempting to read at this address */
122  _SEH2_TRY
123  {
124  ProbeForReadUchar(PageInAddress);
125  }
127  {
128  DPRINT1("Failed to page in address 0x%p, Status 0x%08lx\n", PageInAddress, _SEH2_GetExceptionCode());
129  }
130  _SEH2_END;
131  }
132 
133  /* Break into the process (or the current one if Process == NULL) */
135 
136  /* If we are attached to a process, not the current one... */
137  if (Process)
138  {
139  /* ... we can detach from the process */
141  /* Dereference the process which was referenced for us by PsGetNextProcess */
143  }
144 }
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:28
KAPC_STATE
Definition: ketypes.h:1279
#define DBG_TERMINATE_PROCESS
Definition: ntstatus.h:51
#define ProbeForReadUchar(Ptr)
Definition: probe.h:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:27
#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:701
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI PsTerminateProcess(IN PEPROCESS Process, IN NTSTATUS ExitStatus)
Definition: kill.c:129
ULONG_PTR ExpDebuggerPageIn
Definition: dbgctrl.c:29
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:753
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
#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:26
#define ULONG_PTR
Definition: config.h:101
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

Referenced by ExpWorkerThreadBalanceManager().

◆ NtSystemDebugControl()

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

Definition at line 186 of file dbgctrl.c.

192 {
193  switch (ControlCode)
194  {
197  case SysDbgSetTracepoint:
201  case SysDbgQueryVersion:
202  case SysDbgReadVirtual:
203  case SysDbgWriteVirtual:
204  case SysDbgReadPhysical:
205  case SysDbgWritePhysical:
208  case SysDbgReadIoSpace:
209  case SysDbgWriteIoSpace:
210  case SysDbgReadMsr:
211  case SysDbgWriteMsr:
212  case SysDbgReadBusData:
213  case SysDbgWriteBusData:
215  case SysDbgGetTriageDump:
216  return STATUS_NOT_IMPLEMENTED;
217  case SysDbgBreakPoint:
228  return KdSystemDebugControl(
229  ControlCode,
233  default:
235  }
236 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define KeGetPreviousMode()
Definition: ketypes.h:1107
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
NTSTATUS NTAPI KdSystemDebugControl(IN SYSDBG_COMMAND Command, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN OUT PULONG ReturnLength, IN KPROCESSOR_MODE PreviousMode)
Definition: kdmain.c:436
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t OutputBufferLength
Definition: cdrom.h:1437
CHAR InputBuffer[80]
Definition: conmgr.c:33
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID OutputBuffer
Definition: cdrom.h:1437
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t InputBufferLength
Definition: cdrom.h:1437

Variable Documentation

◆ ExpDebuggerPageIn

ULONG_PTR ExpDebuggerPageIn

Definition at line 29 of file dbgctrl.c.

Referenced by ExpDebuggerWorker().

◆ ExpDebuggerProcessAttach

PEPROCESS ExpDebuggerProcessAttach

Definition at line 27 of file dbgctrl.c.

Referenced by ExpDebuggerWorker().

◆ ExpDebuggerProcessKill

PEPROCESS ExpDebuggerProcessKill

Definition at line 28 of file dbgctrl.c.

Referenced by ExpDebuggerWorker().

◆ ExpDebuggerWork

WINKD_WORKER_STATE ExpDebuggerWork

Definition at line 26 of file dbgctrl.c.

Referenced by ExpDebuggerWorker(), and ExpWorkerThreadBalanceManager().

◆ ExpDebuggerWorkItem

WORK_QUEUE_ITEM ExpDebuggerWorkItem

Definition at line 21 of file dbgctrl.c.

Referenced by ExpWorkerThreadBalanceManager().