ReactOS  0.4.15-dev-3207-ga415bd4
kdb.h File Reference
#include "internal/kd.h"
Include dependency graph for kdb.h:

Go to the source code of this file.

Classes

struct  _KDB_BREAKPOINT
 

Macros

#define TAG_KDBS   'SBDK'
 
#define TAG_KDBG   'GBDK'
 
#define KdbpGetCharKeyboard(ScanCode)   KdbpTryGetCharKeyboard(ScanCode, 0)
 
#define KdbpGetCharSerial()   KdbpTryGetCharSerial(0)
 

Typedefs

typedef CONTEXT KDB_KTRAP_FRAME
 
typedef CONTEXTPKDB_KTRAP_FRAME
 
typedef enum _KDB_BREAKPOINT_TYPE KDB_BREAKPOINT_TYPE
 
typedef enum _KDB_ACCESS_TYPE KDB_ACCESS_TYPE
 
typedef struct _KDB_BREAKPOINT KDB_BREAKPOINT
 
typedef struct _KDB_BREAKPOINTPKDB_BREAKPOINT
 
typedef enum _KDB_ENTER_CONDITION KDB_ENTER_CONDITION
 
typedef enum _KDB_OUTPUT_SETTINGS KDB_OUTPUT_SETTINGS
 

Enumerations

enum  _KDB_BREAKPOINT_TYPE { KdbBreakPointNone = 0, KdbBreakPointSoftware, KdbBreakPointHardware, KdbBreakPointTemporary }
 
enum  _KDB_ACCESS_TYPE { KdbAccessRead, KdbAccessWrite, KdbAccessReadWrite, KdbAccessExec }
 
enum  _KDB_ENTER_CONDITION { KdbDoNotEnter, KdbEnterAlways, KdbEnterFromKmode, KdbEnterFromUmode }
 
enum  _KDB_OUTPUT_SETTINGS { KD_DEBUG_KDSERIAL = 1, KD_DEBUG_KDNOECHO = 2 }
 

Functions

LONG KdbpDisassemble (IN ULONG Address, IN ULONG IntelSyntax)
 
LONG KdbpGetInstLength (IN ULONG Address)
 
VOID NTAPI KdbpStackSwitchAndCall (IN PVOID NewStack, IN VOID(*Function)(VOID))
 
BOOLEAN NTAPI KdbRegisterCliCallback (PVOID Callback, BOOLEAN Deregister)
 
VOID KdbpCliInit (VOID)
 Called when KDB is initialized. More...
 
VOID KdbpCliMainLoop (IN BOOLEAN EnteredOnSingleStep)
 KDB Main Loop. More...
 
VOID KdbpCliModuleLoaded (IN PUNICODE_STRING Name)
 Called when a module is loaded. More...
 
VOID KdbpCliInterpretInitFile (VOID)
 This function is called by KdbEnterDebuggerException... More...
 
VOID KdbpPrint (IN PCHAR Format, IN ... OPTIONAL)
 Prints the given string with printf-like formatting. More...
 
BOOLEAN NTAPI KdbpGetHexNumber (IN PCHAR pszNum, OUT ULONG_PTR *pulValue)
 
BOOLEAN KdbpRpnEvaluateExpression (IN PCHAR Expression, IN PKDB_KTRAP_FRAME TrapFrame, OUT PULONGLONG Result, OUT PLONG ErrOffset OPTIONAL, OUT PCHAR ErrMsg OPTIONAL)
 Evaluates the given expression. More...
 
PVOID KdbpRpnParseExpression (IN PCHAR Expression, OUT PLONG ErrOffset OPTIONAL, OUT PCHAR ErrMsg OPTIONAL)
 Parses the given expression and returns a "handle" to it. More...
 
BOOLEAN KdbpRpnEvaluateParsedExpression (IN PVOID Expression, IN PKDB_KTRAP_FRAME TrapFrame, OUT PULONGLONG Result, OUT PLONG ErrOffset OPTIONAL, OUT PCHAR ErrMsg OPTIONAL)
 Evaluates the given expression and returns the result. More...
 
BOOLEAN KdbpSymFindModule (IN PVOID Address OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
 Find a module... More...
 
BOOLEAN KdbSymPrintAddress (IN PVOID Address, IN PCONTEXT Context)
 Print address... More...
 
VOID KdbSymProcessSymbols (_Inout_ PLDR_DATA_TABLE_ENTRY LdrEntry, _In_ BOOLEAN Load)
 Load symbols from image mapping. If this fails,. More...
 
LONG KdbpGetNextBreakPointNr (IN ULONG Start OPTIONAL)
 Gets the number of the next breakpoint >= Start. More...
 
BOOLEAN KdbpGetBreakPointInfo (IN ULONG BreakPointNr, OUT ULONG_PTR *Address OPTIONAL, OUT KDB_BREAKPOINT_TYPE *Type OPTIONAL, OUT UCHAR *Size OPTIONAL, OUT KDB_ACCESS_TYPE *AccessType OPTIONAL, OUT UCHAR *DebugReg OPTIONAL, OUT BOOLEAN *Enabled OPTIONAL, OUT BOOLEAN *Global OPTIONAL, OUT PEPROCESS *Process OPTIONAL, OUT PCHAR *ConditionExpression OPTIONAL)
 Returns information of the specified breakpoint. More...
 
NTSTATUS KdbpInsertBreakPoint (IN ULONG_PTR Address, IN KDB_BREAKPOINT_TYPE Type, IN UCHAR Size OPTIONAL, IN KDB_ACCESS_TYPE AccessType OPTIONAL, IN PCHAR ConditionExpression OPTIONAL, IN BOOLEAN Global, OUT PLONG BreakPointNr OPTIONAL)
 Inserts a breakpoint into the breakpoint array. More...
 
BOOLEAN KdbpDeleteBreakPoint (IN LONG BreakPointNr OPTIONAL, IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL)
 Deletes a breakpoint. More...
 
BOOLEAN KdbpEnableBreakPoint (IN LONG BreakPointNr OPTIONAL, IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL)
 Enables a breakpoint. More...
 
BOOLEAN KdbpDisableBreakPoint (IN LONG BreakPointNr OPTIONAL, IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL)
 Disables a breakpoint. More...
 
BOOLEAN KdbpGetEnterCondition (IN LONG ExceptionNr, IN BOOLEAN FirstChance, OUT KDB_ENTER_CONDITION *Condition)
 Gets the first or last chance enter-condition for exception nr. ExceptionNr. More...
 
BOOLEAN KdbpSetEnterCondition (IN LONG ExceptionNr, IN BOOLEAN FirstChance, IN KDB_ENTER_CONDITION Condition)
 Sets the first or last chance enter-condition for exception nr. ExceptionNr. More...
 
BOOLEAN KdbpAttachToThread (PVOID ThreadId)
 Switches to another thread context. More...
 
BOOLEAN KdbpAttachToProcess (PVOID ProcessId)
 Switches to another process/thread context. More...
 
VOID NTAPI KdbpGetCommandLineSettings (PCHAR p1)
 
KD_CONTINUE_TYPE KdbEnterDebuggerException (IN PEXCEPTION_RECORD64 ExceptionRecord, IN KPROCESSOR_MODE PreviousMode, IN OUT PCONTEXT Context, IN BOOLEAN FirstChance)
 
KD_CONTINUE_TYPE KdbEnterDebuggerFirstChanceException (IN OUT PKTRAP_FRAME TrapFrame)
 
NTSTATUS KdbpSafeReadMemory (OUT PVOID Dest, IN PVOID Src, IN ULONG Bytes)
 
NTSTATUS KdbpSafeWriteMemory (OUT PVOID Dest, IN PVOID Src, IN ULONG Bytes)
 
CHAR KdbpTryGetCharKeyboard (PULONG ScanCode, ULONG Retry)
 
CHAR KdbpTryGetCharSerial (ULONG Retry)
 
VOID KdbEnter (VOID)
 
VOID DbgRDebugInit (VOID)
 
VOID DbgShowFiles (VOID)
 
VOID DbgEnableFile (PCH Filename)
 
VOID DbgDisableFile (PCH Filename)
 
VOID KbdDisableMouse (VOID)
 
VOID KbdEnableMouse (VOID)
 

Variables

PCHAR KdbInitFileBuffer
 
PEPROCESS KdbCurrentProcess
 
PETHREAD KdbCurrentThread
 
LONG KdbLastBreakPointNr
 
ULONG KdbNumSingleSteps
 
BOOLEAN KdbSingleStepOver
 
PKDB_KTRAP_FRAME KdbCurrentTrapFrame
 
ULONG KdbDebugState
 

Macro Definition Documentation

◆ KdbpGetCharKeyboard

#define KdbpGetCharKeyboard (   ScanCode)    KdbpTryGetCharKeyboard(ScanCode, 0)

Definition at line 263 of file kdb.h.

◆ KdbpGetCharSerial

#define KdbpGetCharSerial ( )    KdbpTryGetCharSerial(0)

Definition at line 267 of file kdb.h.

◆ TAG_KDBG

#define TAG_KDBG   'GBDK'

Definition at line 8 of file kdb.h.

◆ TAG_KDBS

#define TAG_KDBS   'SBDK'

Definition at line 7 of file kdb.h.

Typedef Documentation

◆ KDB_ACCESS_TYPE

◆ KDB_BREAKPOINT

◆ KDB_BREAKPOINT_TYPE

◆ KDB_ENTER_CONDITION

◆ KDB_KTRAP_FRAME

Definition at line 13 of file kdb.h.

◆ KDB_OUTPUT_SETTINGS

◆ PKDB_BREAKPOINT

◆ PKDB_KTRAP_FRAME

Definition at line 13 of file kdb.h.

Enumeration Type Documentation

◆ _KDB_ACCESS_TYPE

Enumerator
KdbAccessRead 
KdbAccessWrite 
KdbAccessReadWrite 
KdbAccessExec 

Definition at line 23 of file kdb.h.

24 {
enum _KDB_ACCESS_TYPE KDB_ACCESS_TYPE

◆ _KDB_BREAKPOINT_TYPE

Enumerator
KdbBreakPointNone 
KdbBreakPointSoftware 
KdbBreakPointHardware 
KdbBreakPointTemporary 

Definition at line 15 of file kdb.h.

◆ _KDB_ENTER_CONDITION

Enumerator
KdbDoNotEnter 
KdbEnterAlways 
KdbEnterFromKmode 
KdbEnterFromUmode 

Definition at line 52 of file kdb.h.

53 {
enum _KDB_ENTER_CONDITION KDB_ENTER_CONDITION

◆ _KDB_OUTPUT_SETTINGS

Enumerator
KD_DEBUG_KDSERIAL 
KD_DEBUG_KDNOECHO 

Definition at line 61 of file kdb.h.

62 {
enum _KDB_OUTPUT_SETTINGS KDB_OUTPUT_SETTINGS

Function Documentation

◆ DbgDisableFile()

VOID DbgDisableFile ( PCH  Filename)

◆ DbgEnableFile()

VOID DbgEnableFile ( PCH  Filename)

◆ DbgRDebugInit()

VOID DbgRDebugInit ( VOID  )

◆ DbgShowFiles()

VOID DbgShowFiles ( VOID  )

◆ KbdDisableMouse()

VOID KbdDisableMouse ( VOID  )

◆ KbdEnableMouse()

VOID KbdEnableMouse ( VOID  )

◆ KdbEnter()

VOID KdbEnter ( VOID  )

◆ KdbEnterDebuggerException()

KD_CONTINUE_TYPE KdbEnterDebuggerException ( IN PEXCEPTION_RECORD64  ExceptionRecord,
IN KPROCESSOR_MODE  PreviousMode,
IN OUT PCONTEXT  Context,
IN BOOLEAN  FirstChance 
)

◆ KdbEnterDebuggerFirstChanceException()

KD_CONTINUE_TYPE KdbEnterDebuggerFirstChanceException ( IN OUT PKTRAP_FRAME  TrapFrame)

Definition at line 1620 of file kdb.c.

1622 {
1623  EXCEPTION_RECORD64 ExceptionRecord;
1624  KD_CONTINUE_TYPE Return;
1625  CONTEXT Context;
1626 
1627  /* Copy TrapFrame to Context */
1628  RtlZeroMemory(&Context, sizeof(CONTEXT));
1630 #ifdef CONTEXT_EXTENDED_REGISTERS
1631  Context.ContextFlags |= CONTEXT_EXTENDED_REGISTERS;
1632 #endif
1633  KeTrapFrameToContext(TrapFrame, NULL, &Context);
1634 
1635  /* Create ExceptionRecord (assume breakpoint) */
1636  RtlZeroMemory(&ExceptionRecord, sizeof(EXCEPTION_RECORD64));
1637  ExceptionRecord.ExceptionCode = STATUS_BREAKPOINT;
1638 
1639  /* Call real function */
1640  Return = KdbEnterDebuggerException(&ExceptionRecord,
1641  KernelMode,
1642  &Context,
1643  TRUE);
1644 
1645  /* Copy back Context to TrapFrame */
1646  KeContextToTrapFrame(&Context, NULL, TrapFrame, Context.ContextFlags, KernelMode);
1647 
1648  return Return;
1649 }
VOID NTAPI KeContextToTrapFrame(PCONTEXT Context, PKEXCEPTION_FRAME ExeptionFrame, PKTRAP_FRAME TrapFrame, ULONG ContextFlags, KPROCESSOR_MODE PreviousMode)
#define CONTEXT_CONTROL
Definition: nt_native.h:1369
#define CONTEXT_EXTENDED_REGISTERS
#define TRUE
Definition: types.h:120
#define CONTEXT_FLOATING_POINT
Definition: nt_native.h:1372
NTSTATUS ExceptionCode
Definition: rtltypes.h:190
#define CONTEXT_SEGMENTS
Definition: nt_native.h:1371
#define STATUS_BREAKPOINT
Definition: ntstatus.h:184
VOID NTAPI KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN OUT PCONTEXT Context)
Definition: context.c:169
#define CONTEXT_DEBUG_REGISTERS
Definition: nt_native.h:1373
#define NULL
Definition: types.h:112
struct tagContext Context
Definition: acpixf.h:1034
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define CONTEXT_INTEGER
Definition: nt_native.h:1370
KD_CONTINUE_TYPE KdbEnterDebuggerException(IN PEXCEPTION_RECORD64 ExceptionRecord, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT Context, IN BOOLEAN FirstChance)
KDB Exception filter.
Definition: kdb.c:1258

◆ KdbpAttachToProcess()

BOOLEAN KdbpAttachToProcess ( PVOID  ProcessId)

Switches to another process/thread context.

This function switches to the first thread in the specified process.

Parameters
ProcessIdId of the process to switch to.
Return values
TRUESuccess.
FALSEFailure (i.e. invalid process id)

Definition at line 1113 of file kdb.c.

1115 {
1117  PETHREAD Thread;
1119 
1120  /* Get a pointer to the process */
1122  {
1123  KdbpPrint("Invalid process id: 0x%08x\n", (ULONG_PTR)ProcessId);
1124  return FALSE;
1125  }
1126 
1127  Entry = Process->ThreadListHead.Flink;
1130  {
1131  KdbpPrint("No threads in process 0x%p, cannot attach to process!\n", ProcessId);
1132  return FALSE;
1133  }
1134 
1135  Thread = CONTAINING_RECORD(Entry, ETHREAD, ThreadListEntry);
1136 
1138 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
struct _Entry Entry
Definition: kefuncs.h:627
BOOLEAN KdbpAttachToThread(PVOID ThreadId)
Switches to another thread context.
Definition: kdb.c:1032
PEPROCESS KdbCurrentProcess
Definition: kdb.c:47
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
LIST_ENTRY ThreadListHead
Definition: pstypes.h:1329
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CLIENT_ID Cid
Definition: pstypes.h:1128
#define ObDereferenceObject
Definition: obfuncs.h:203
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2716
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
HANDLE UniqueThread
Definition: compat.h:685
NTSTATUS NTAPI PsLookupProcessByProcessId(IN HANDLE ProcessId, OUT PEPROCESS *Process)
Definition: process.c:919
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
base of all file and directory entries
Definition: entries.h:82

Referenced by KdbpCmdProc().

◆ KdbpAttachToThread()

BOOLEAN KdbpAttachToThread ( PVOID  ThreadId)

Switches to another thread context.

Parameters
ThreadIdId of the thread to switch to.
Return values
TRUESuccess.
FALSEFailure (i.e. invalid thread id)

Definition at line 1032 of file kdb.c.

1034 {
1035  PETHREAD Thread = NULL;
1037 
1038  /* Get a pointer to the thread */
1039  if (!NT_SUCCESS(PsLookupThreadByThreadId(ThreadId, &Thread)))
1040  {
1041  KdbpPrint("Invalid thread id: 0x%08x\n", (ULONG_PTR)ThreadId);
1042  return FALSE;
1043  }
1044  Process = Thread->ThreadsProcess;
1045 
1047  {
1048  KdbpPrint("Cannot attach to thread within another process while executing a DPC.\n");
1050  return FALSE;
1051  }
1052 
1053  /* Save the current thread's context (if we previously attached to a thread) */
1055  {
1057  /* Actually, we can't save the context, there's no guarantee that there was a trap frame */
1058  }
1059  else
1060  {
1062  }
1063 
1064  /* Switch to the thread's context */
1065  if (Thread != KdbOriginalThread)
1066  {
1067  /* The thread we're attaching to isn't the thread on which we entered
1068  * kdb and so the thread we're attaching to is not running. There
1069  * is no guarantee that it actually has a trap frame. So we have to
1070  * peek directly at the registers which were saved on the stack when the
1071  * thread was preempted in the scheduler */
1075  }
1076  else /* Switching back to original thread */
1077  {
1079  }
1081 
1082  /* Attach to the thread's process */
1084  if (KdbCurrentProcess != Process)
1085  {
1086  if (KdbCurrentProcess != KdbOriginalProcess) /* detach from previously attached process */
1087  {
1089  }
1090 
1091  if (KdbOriginalProcess != Process)
1092  {
1094  }
1095 
1097  }
1098 
1100  return TRUE;
1101 }
#define TRUE
Definition: types.h:120
PETHREAD KdbOriginalThread
Definition: kdb.c:50
PEPROCESS KdbCurrentProcess
Definition: kdb.c:47
NTSTATUS NTAPI PsLookupThreadByThreadId(IN HANDLE ThreadId, OUT PETHREAD *Thread)
Definition: thread.c:643
KTHREAD Tcb
Definition: pstypes.h:1103
static VOID KdbpKdbTrapFrameFromKernelStack(PVOID KernelStack, PKDB_KTRAP_FRAME KdbTrapFrame)
Definition: kdb.c:114
BOOLEAN NTAPI KeIsExecutingDpc(VOID)
Definition: dpc.c:947
static KDB_KTRAP_FRAME KdbThreadTrapFrame
Definition: kdb.c:53
PEPROCESS KdbOriginalProcess
Definition: kdb.c:48
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
#define PsGetCurrentProcess
Definition: psfuncs.h:17
PVOID KernelStack
Definition: ketypes.h:1607
PKDB_KTRAP_FRAME KdbCurrentTrapFrame
Definition: kdb.c:51
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ObDereferenceObject
Definition: obfuncs.h:203
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2716
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
static KAPC_STATE KdbApcState
Definition: kdb.c:54
#define NULL
Definition: types.h:112
static KDB_KTRAP_FRAME KdbTrapFrame
Definition: kdb.c:52
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
PETHREAD KdbCurrentThread
Definition: kdb.c:49

Referenced by KdbpAttachToProcess(), and KdbpCmdThread().

◆ KdbpCliInit()

VOID KdbpCliInit ( VOID  )

Called when KDB is initialized.

Reads the KDBinit file from the SystemRoot\System32\drivers\etc directory and executes it.

Definition at line 3833 of file kdb_cli.c.

3834 {
3835  NTSTATUS Status;
3839  FILE_STANDARD_INFORMATION FileStdInfo;
3840  HANDLE hFile = NULL;
3841  INT FileSize;
3842  PCHAR FileBuffer;
3843  ULONG OldEflags;
3844 
3845  /* Initialize the object attributes */
3846  RtlInitUnicodeString(&FileName, L"\\SystemRoot\\System32\\drivers\\etc\\KDBinit");
3848  &FileName,
3850  NULL,
3851  NULL);
3852 
3853  /* Open the file */
3855  &ObjectAttributes, &Iosb, 0,
3858  if (!NT_SUCCESS(Status))
3859  {
3860  DPRINT("Could not open \\SystemRoot\\System32\\drivers\\etc\\KDBinit (Status 0x%x)", Status);
3861  return;
3862  }
3863 
3864  /* Get the size of the file */
3865  Status = ZwQueryInformationFile(hFile, &Iosb, &FileStdInfo, sizeof(FileStdInfo),
3867  if (!NT_SUCCESS(Status))
3868  {
3869  ZwClose(hFile);
3870  DPRINT("Could not query size of \\SystemRoot\\System32\\drivers\\etc\\KDBinit (Status 0x%x)", Status);
3871  return;
3872  }
3873  FileSize = FileStdInfo.EndOfFile.u.LowPart;
3874 
3875  /* Allocate memory for the file */
3876  FileBuffer = ExAllocatePool(PagedPool, FileSize + 1); /* add 1 byte for terminating '\0' */
3877  if (!FileBuffer)
3878  {
3879  ZwClose(hFile);
3880  DPRINT("Could not allocate %d bytes for KDBinit file\n", FileSize);
3881  return;
3882  }
3883 
3884  /* Load file into memory */
3885  Status = ZwReadFile(hFile, NULL, NULL, NULL, &Iosb, FileBuffer, FileSize, NULL, NULL);
3886  ZwClose(hFile);
3887 
3889  {
3890  ExFreePool(FileBuffer);
3891  DPRINT("Could not read KDBinit file into memory (Status 0x%lx)\n", Status);
3892  return;
3893  }
3894 
3895  FileSize = min(FileSize, (INT)Iosb.Information);
3896  FileBuffer[FileSize] = '\0';
3897 
3898  /* Enter critical section */
3899  OldEflags = __readeflags();
3900  _disable();
3901 
3902  /* Interpret the init file... */
3903  KdbInitFileBuffer = FileBuffer;
3904  //KdbEnter(); // FIXME
3906 
3907  /* Leave critical section */
3908  __writeeflags(OldEflags);
3909 
3910  ExFreePool(FileBuffer);
3911 }
signed char * PCHAR
Definition: retypes.h:7
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
int32_t INT
Definition: typedefs.h:58
#define STATUS_END_OF_FILE
Definition: shellext.h:67
#define FILE_NO_INTERMEDIATE_BUFFERING
Definition: from_kernel.h:28
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1675
#define FILE_READ_DATA
Definition: nt_native.h:628
Status
Definition: gdiplustypes.h:24
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
static const WCHAR L[]
Definition: oid.c:1250
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
Definition: intrin_x86.h:1670
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
#define SYNCHRONIZE
Definition: nt_native.h:61
_In_ HANDLE hFile
Definition: mswsock.h:90
struct _FileName FileName
Definition: fatprocs.h:893
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
#define FileStandardInformation
Definition: propsheet.cpp:61
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
void __cdecl _disable(void)
Definition: intrin_arm.h:365
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DPRINT
Definition: sndvol32.h:71
PCHAR KdbInitFileBuffer
Definition: kdb_cli.c:153
struct _LARGE_INTEGER::@2239 u
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ KdbpCliInterpretInitFile()

VOID KdbpCliInterpretInitFile ( VOID  )

This function is called by KdbEnterDebuggerException...

Used to interpret the init file in a context with a trapframe setup (KdbpCliInit call KdbEnter which will call KdbEnterDebuggerException which will call this function if KdbInitFileBuffer is not NULL.

Definition at line 3784 of file kdb_cli.c.

3785 {
3786  PCHAR p1, p2;
3787  INT i;
3788  CHAR c;
3789 
3790  /* Execute the commands in the init file */
3791  DPRINT("KDB: Executing KDBinit file...\n");
3792  p1 = KdbInitFileBuffer;
3793  while (p1[0] != '\0')
3794  {
3795  i = strcspn(p1, "\r\n");
3796  if (i > 0)
3797  {
3798  c = p1[i];
3799  p1[i] = '\0';
3800 
3801  /* Look for "break" command and comments */
3802  p2 = p1;
3803 
3804  while (isspace(p2[0]))
3805  p2++;
3806 
3807  if (strncmp(p2, "break", sizeof("break")-1) == 0 &&
3808  (p2[sizeof("break")-1] == '\0' || isspace(p2[sizeof("break")-1])))
3809  {
3810  /* break into the debugger */
3812  }
3813  else if (p2[0] != '#' && p2[0] != '\0') /* Ignore empty lines and comments */
3814  {
3815  KdbpDoCommand(p1);
3816  }
3817 
3818  p1[i] = c;
3819  }
3820 
3821  p1 += i;
3822  while (p1[0] == '\r' || p1[0] == '\n')
3823  p1++;
3824  }
3825  DPRINT("KDB: KDBinit executed\n");
3826 }
signed char * PCHAR
Definition: retypes.h:7
#define isspace(c)
Definition: acclib.h:69
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
char CHAR
Definition: xmlstorage.h:175
int32_t INT
Definition: typedefs.h:58
static BOOLEAN KdbpDoCommand(IN PCHAR Command)
Parses command line and executes command if found.
Definition: kdb_cli.c:3644
#define FALSE
Definition: types.h:117
VOID KdbpCliMainLoop(IN BOOLEAN EnteredOnSingleStep)
KDB Main Loop.
Definition: kdb_cli.c:3706
const GLubyte * c
Definition: glext.h:8905
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define c
Definition: ke_i.h:80
#define DPRINT
Definition: sndvol32.h:71
PCHAR KdbInitFileBuffer
Definition: kdb_cli.c:153

Referenced by KdbEnterDebuggerException().

◆ KdbpCliMainLoop()

VOID KdbpCliMainLoop ( IN BOOLEAN  EnteredOnSingleStep)

KDB Main Loop.

Parameters
EnteredOnSingleStepTRUE if KDB was entered on single step.

Definition at line 3706 of file kdb_cli.c.

3708 {
3709  static CHAR Command[1024];
3710  BOOLEAN Continue;
3711 
3712  if (EnteredOnSingleStep)
3713  {
3715  {
3717  }
3718 
3719  KdbpPrint(": ");
3721  {
3722  KdbpPrint("<INVALID>");
3723  }
3724  KdbpPrint("\n");
3725  }
3726 
3727  /* Flush the input buffer */
3729  {
3730  while (KdbpTryGetCharSerial(1) != -1);
3731  }
3732  else
3733  {
3734  ULONG ScanCode;
3735  while (KdbpTryGetCharKeyboard(&ScanCode, 1) != -1);
3736  }
3737 
3738  /* Main loop */
3739  do
3740  {
3741  /* Reset the number of rows/cols printed */
3743 
3744  /* Print the prompt */
3745  KdbpPrint(KdbPromptString.Buffer);
3746 
3747  /* Read a command and remember it */
3748  KdbpReadCommand(Command, sizeof(Command));
3750 
3751  /* Reset the number of rows/cols printed and output aborted state */
3754 
3755  /* Call the command */
3756  Continue = KdbpDoCommand(Command);
3758  }
3759  while (Continue);
3760 }
static VOID KdbpReadCommand(OUT PCHAR Buffer, IN ULONG Size)
Reads a line of user-input.
Definition: kdb_cli.c:3372
static VOID KdbpCommandHistoryAppend(IN PCHAR Command)
Appends a command to the command history.
Definition: kdb_cli.c:3298
ULONG ScanCode
Definition: api.c:39
BOOLEAN KdbSymPrintAddress(IN PVOID Address, IN PCONTEXT Context)
Print address...
Definition: kdb_symbols.c:148
ULONG KdbDebugState
Definition: kdb.c:45
char CHAR
Definition: xmlstorage.h:175
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2716
#define KeGetContextPc(Context)
Definition: ke.h:31
Definition: shell.h:41
CHAR KdbpTryGetCharSerial(ULONG Retry)
Definition: kdb_serial.c:19
CHAR KdbpTryGetCharKeyboard(PULONG ScanCode, ULONG Retry)
Definition: kdb_keyboard.c:104
static ULONG KdbNumberOfRowsPrinted
Definition: kdb_cli.c:146
static BOOLEAN KdbpDoCommand(IN PCHAR Command)
Parses command line and executes command if found.
Definition: kdb_cli.c:3644
#define FALSE
Definition: types.h:117
static ULONG KdbNumberOfColsPrinted
Definition: kdb_cli.c:147
unsigned char BOOLEAN
PKDB_KTRAP_FRAME KdbCurrentTrapFrame
Definition: kdb.c:51
static BOOLEAN KdbOutputAborted
Definition: kdb_cli.c:148
static BOOLEAN KdbUseIntelSyntax
Definition: kdb_cli.c:138
STRING KdbPromptString
Definition: kdb_cli.c:165
unsigned int ULONG
Definition: retypes.h:1
LONG KdbpDisassemble(IN ULONG Address, IN ULONG IntelSyntax)
Definition: i386-dis.c:121

Referenced by KdbpCallMainLoop(), and KdbpCliInterpretInitFile().

◆ KdbpCliModuleLoaded()

VOID KdbpCliModuleLoaded ( IN PUNICODE_STRING  Name)

Called when a module is loaded.

Parameters
NameFilename of the module which was loaded.

Definition at line 3767 of file kdb_cli.c.

3769 {
3770  if (!KdbBreakOnModuleLoad)
3771  return;
3772 
3773  KdbpPrint("Module %wZ loaded.\n", Name);
3775 }
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2716
static BOOLEAN KdbBreakOnModuleLoad
Definition: kdb_cli.c:139
#define DBG_STATUS_CONTROL_C
Definition: kdtypes.h:39
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)

◆ KdbpDeleteBreakPoint()

BOOLEAN KdbpDeleteBreakPoint ( IN LONG BreakPointNr  OPTIONAL,
IN OUT PKDB_BREAKPOINT BreakPoint  OPTIONAL 
)

Deletes a breakpoint.

Parameters
BreakPointNrNumber of the breakpoint to delete. Can be -1
BreakPointBreakpoint to delete. Can be NULL.
Return values
TRUESuccess.
FALSEFailure (invalid breakpoint number)

Definition at line 594 of file kdb.c.

597 {
598  if (BreakPointNr < 0)
599  {
600  ASSERT(BreakPoint);
601  BreakPointNr = BreakPoint - KdbBreakPoints;
602  }
603 
604  if (BreakPointNr < 0 || BreakPointNr >= KDB_MAXIMUM_BREAKPOINT_COUNT)
605  {
606  KdbpPrint("Invalid breakpoint: %d\n", BreakPointNr);
607  return FALSE;
608  }
609 
610  if (!BreakPoint)
611  {
612  BreakPoint = KdbBreakPoints + BreakPointNr;
613  }
614 
615  if (BreakPoint->Type == KdbBreakPointNone)
616  {
617  KdbpPrint("Invalid breakpoint: %d\n", BreakPointNr);
618  return FALSE;
619  }
620 
621  if (BreakPoint->Enabled && !KdbpDisableBreakPoint(-1, BreakPoint))
622  return FALSE;
623 
624  if (BreakPoint->Type != KdbBreakPointTemporary)
625  KdbpPrint("Breakpoint %d deleted.\n", BreakPointNr);
626 
627  BreakPoint->Type = KdbBreakPointNone;
629 
630  return TRUE;
631 }
static ULONG KdbBreakPointCount
Definition: kdb.c:33
#define KDB_MAXIMUM_BREAKPOINT_COUNT
Definition: kdb.c:21
#define TRUE
Definition: types.h:120
BOOLEAN KdbpDisableBreakPoint(IN LONG BreakPointNr OPTIONAL, IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL)
Disables a breakpoint.
Definition: kdb.c:864
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2716
static KDB_BREAKPOINT KdbBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT]
Definition: kdb.c:34

Referenced by KdbEnterDebuggerException(), and KdbpCmdEnableDisableClearBreakPoint().

◆ KdbpDisableBreakPoint()

BOOLEAN KdbpDisableBreakPoint ( IN LONG BreakPointNr  OPTIONAL,
IN OUT PKDB_BREAKPOINT BreakPoint  OPTIONAL 
)

Disables a breakpoint.

Parameters
BreakPointNrNumber of the breakpoint to disable. Can be -1
BreakPointBreakpoint to disable. Can be NULL.
Return values
TRUESuccess.
FALSEFailure.
See also
KdbpEnableBreakPoint

Definition at line 864 of file kdb.c.

867 {
868  ULONG i;
870 
871  if (BreakPointNr < 0)
872  {
873  ASSERT(BreakPoint);
874  BreakPointNr = BreakPoint - KdbBreakPoints;
875  }
876 
877  if (BreakPointNr < 0 || BreakPointNr >= KDB_MAXIMUM_BREAKPOINT_COUNT)
878  {
879  KdbpPrint("Invalid breakpoint: %d\n", BreakPointNr);
880  return FALSE;
881  }
882 
883  if (!BreakPoint)
884  {
885  BreakPoint = KdbBreakPoints + BreakPointNr;
886  }
887 
888  if (BreakPoint->Type == KdbBreakPointNone)
889  {
890  KdbpPrint("Invalid breakpoint: %d\n", BreakPointNr);
891  return FALSE;
892  }
893 
894  if (BreakPoint->Enabled == FALSE)
895  {
896  KdbpPrint("Breakpoint %d is not enabled.\n", BreakPointNr);
897  return TRUE;
898  }
899 
900  if (BreakPoint->Type == KdbBreakPointSoftware ||
901  BreakPoint->Type == KdbBreakPointTemporary)
902  {
904  Status = KdbpOverwriteInstruction(BreakPoint->Process, BreakPoint->Address,
905  BreakPoint->Data.SavedInstruction, NULL);
906 
907  if (!NT_SUCCESS(Status))
908  {
909  KdbpPrint("Couldn't restore original instruction.\n");
910  return FALSE;
911  }
912 
913  for (i = 0; i < KdbSwBreakPointCount; i++)
914  {
915  if (KdbSwBreakPoints[i] == BreakPoint)
916  {
918  i = -1; /* if the last breakpoint is disabled dont break with i >= KdbSwBreakPointCount */
919  break;
920  }
921  }
922 
923  if (i != MAXULONG) /* not found */
924  ASSERT(0);
925  }
926  else
927  {
928  ASSERT(BreakPoint->Type == KdbBreakPointHardware);
929 
930  /* Clear the breakpoint. */
931  KdbTrapFrame.Dr7 &= ~(0x3 << (BreakPoint->Data.Hw.DebugReg * 2));
932  if ((KdbTrapFrame.Dr7 & 0xFF) == 0)
933  {
934  /* If no breakpoints are enabled then clear the exact match flags. */
935  KdbTrapFrame.Dr7 &= 0xFFFFFCFF;
936  }
937 
938  for (i = 0; i < KdbHwBreakPointCount; i++)
939  {
940  if (KdbHwBreakPoints[i] == BreakPoint)
941  {
943  i = -1; /* if the last breakpoint is disabled dont break with i >= KdbHwBreakPointCount */
944  break;
945  }
946  }
947 
948  if (i != MAXULONG) /* not found */
949  ASSERT(0);
950  }
951 
952  BreakPoint->Enabled = FALSE;
953  if (BreakPoint->Type != KdbBreakPointTemporary)
954  KdbpPrint("Breakpoint %d disabled.\n", BreakPointNr);
955 
956  return TRUE;
957 }
#define KDB_MAXIMUM_BREAKPOINT_COUNT
Definition: kdb.c:21
#define TRUE
Definition: types.h:120
static ULONG KdbSwBreakPointCount
Definition: kdb.c:35
LONG NTSTATUS
Definition: precomp.h:26
ULONG Dr7
Definition: nt_native.h:1439
static PKDB_BREAKPOINT KdbHwBreakPoints[KDB_MAXIMUM_HW_BREAKPOINT_COUNT]
Definition: kdb.c:38
#define FALSE
Definition: types.h:117
static NTSTATUS KdbpOverwriteInstruction(IN PEPROCESS Process, IN ULONG_PTR Address, IN UCHAR NewInst, OUT PUCHAR OldInst OPTIONAL)
Overwrites the instruction at Address with NewInst and stores the old instruction in *OldInst.
Definition: kdb.c:150
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static PKDB_BREAKPOINT KdbSwBreakPoints[KDB_MAXIMUM_SW_BREAKPOINT_COUNT]
Definition: kdb.c:37
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2716
#define MAXULONG
Definition: typedefs.h:251
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
static KDB_KTRAP_FRAME KdbTrapFrame
Definition: kdb.c:52
unsigned int ULONG
Definition: retypes.h:1
static KDB_BREAKPOINT KdbBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT]
Definition: kdb.c:34
static ULONG KdbHwBreakPointCount
Definition: kdb.c:36

Referenced by KdbpCmdEnableDisableClearBreakPoint(), and KdbpDeleteBreakPoint().

◆ KdbpDisassemble()

LONG KdbpDisassemble ( IN ULONG  Address,
IN ULONG  IntelSyntax 
)

Definition at line 121 of file i386-dis.c.

122 {
124 
125  info.fprintf_func = KdbpPrintDisasm;
126  info.stream = NULL;
127  info.application_data = NULL;
129  info.arch = bfd_arch_i386;
131  info.insn_sets = 0;
132  info.flags = 0;
133  info.read_memory_func = KdbpReadMemory;
134  info.memory_error_func = KdbpMemoryError;
135  info.print_address_func = KdbpPrintAddressInCode;
136  info.symbol_at_address_func = NULL;
137  info.buffer = NULL;
138  info.buffer_vma = info.buffer_length = 0;
139  info.bytes_per_chunk = 0;
140  info.display_endian = BIG_ENDIAN_LITTLE;
141  info.disassembler_options = NULL;
142 
143  return(print_insn_i386(Address, &info));
144 }
#define bfd_mach_i386_i386_intel_syntax
Definition: i386-dis.c:32
#define bfd_mach_i386_i386
Definition: i386-dis.c:33
static void KdbpPrintAddressInCode(unsigned int Addr, struct disassemble_info *Ignored)
Definition: i386-dis.c:79
static WCHAR Address[46]
Definition: ping.c:68
int print_insn_i386(bfd_vma pc, struct disassemble_info *info)
Definition: i386-dis.c:2071
static void KdbpMemoryError(int Status, unsigned int Addr, struct disassemble_info *Ignored)
Definition: i386-dis.c:73
struct _test_info info[]
Definition: SetCursorPos.c:19
static int KdbpReadMemory(unsigned int Addr, unsigned char *Data, unsigned int Length, struct disassemble_info *Ignored)
Definition: i386-dis.c:66
#define NULL
Definition: types.h:112
int KdbpPrintDisasm(void *Ignored, const char *fmt,...)
Definition: i386-dis.c:46

Referenced by KdbpCliMainLoop(), and KdbpCmdDisassembleX().

◆ KdbpEnableBreakPoint()

BOOLEAN KdbpEnableBreakPoint ( IN LONG BreakPointNr  OPTIONAL,
IN OUT PKDB_BREAKPOINT BreakPoint  OPTIONAL 
)

Enables a breakpoint.

Parameters
BreakPointNrNumber of the breakpoint to enable Can be -1.
BreakPointBreakpoint to enable. Can be NULL.
Return values
TRUESuccess.
FALSEFailure.
See also
KdbpDisableBreakPoint

Definition at line 697 of file kdb.c.

700 {
702  INT i;
703  ULONG ul;
704 
705  if (BreakPointNr < 0)
706  {
707  ASSERT(BreakPoint);
708  BreakPointNr = BreakPoint - KdbBreakPoints;
709  }
710 
711  if (BreakPointNr < 0 || BreakPointNr >= KDB_MAXIMUM_BREAKPOINT_COUNT)
712  {
713  KdbpPrint("Invalid breakpoint: %d\n", BreakPointNr);
714  return FALSE;
715  }
716 
717  if (!BreakPoint)
718  {
719  BreakPoint = KdbBreakPoints + BreakPointNr;
720  }
721 
722  if (BreakPoint->Type == KdbBreakPointNone)
723  {
724  KdbpPrint("Invalid breakpoint: %d\n", BreakPointNr);
725  return FALSE;
726  }
727 
728  if (BreakPoint->Enabled)
729  {
730  KdbpPrint("Breakpoint %d is already enabled.\n", BreakPointNr);
731  return TRUE;
732  }
733 
734  if (BreakPoint->Type == KdbBreakPointSoftware ||
735  BreakPoint->Type == KdbBreakPointTemporary)
736  {
738  {
739  KdbpPrint("Maximum number of SW breakpoints (%d) used. "
740  "Disable another breakpoint in order to enable this one.\n",
742  return FALSE;
743  }
744 
745  Status = KdbpOverwriteInstruction(BreakPoint->Process, BreakPoint->Address,
746  0xCC, &BreakPoint->Data.SavedInstruction);
747  if (!NT_SUCCESS(Status))
748  {
749  KdbpPrint("Couldn't access memory at 0x%p\n", BreakPoint->Address);
750  return FALSE;
751  }
752 
753  KdbSwBreakPoints[KdbSwBreakPointCount++] = BreakPoint;
754  }
755  else
756  {
757  if (BreakPoint->Data.Hw.AccessType == KdbAccessExec)
758  ASSERT(BreakPoint->Data.Hw.Size == 1);
759 
760  ASSERT((BreakPoint->Address % BreakPoint->Data.Hw.Size) == 0);
761 
763  {
764  KdbpPrint("Maximum number of HW breakpoints (%d) already used. "
765  "Disable another breakpoint in order to enable this one.\n",
767 
768  return FALSE;
769  }
770 
771  /* Find unused hw breakpoint */
773  for (i = 0; i < KDB_MAXIMUM_HW_BREAKPOINT_COUNT; i++)
774  {
775  if ((KdbTrapFrame.Dr7 & (0x3 << (i * 2))) == 0)
776  break;
777  }
778 
780 
781  /* Set the breakpoint address. */
782  switch (i)
783  {
784  case 0:
785  KdbTrapFrame.Dr0 = BreakPoint->Address;
786  break;
787  case 1:
788  KdbTrapFrame.Dr1 = BreakPoint->Address;
789  break;
790  case 2:
791  KdbTrapFrame.Dr2 = BreakPoint->Address;
792  break;
793  case 3:
794  KdbTrapFrame.Dr3 = BreakPoint->Address;
795  break;
796  }
797 
798  /* Enable the global breakpoint */
799  KdbTrapFrame.Dr7 |= (0x2 << (i * 2));
800 
801  /* Enable the exact match bits. */
802  KdbTrapFrame.Dr7 |= 0x00000300;
803 
804  /* Clear existing state. */
805  KdbTrapFrame.Dr7 &= ~(0xF << (16 + (i * 4)));
806 
807  /* Set the breakpoint type. */
808  switch (BreakPoint->Data.Hw.AccessType)
809  {
810  case KdbAccessExec:
811  ul = 0;
812  break;
813  case KdbAccessWrite:
814  ul = 1;
815  break;
816  case KdbAccessRead:
817  case KdbAccessReadWrite:
818  ul = 3;
819  break;
820  default:
821  ASSERT(0);
822  return TRUE;
823  break;
824  }
825 
826  KdbTrapFrame.Dr7 |= (ul << (16 + (i * 4)));
827 
828  /* Set the breakpoint length. */
829  KdbTrapFrame.Dr7 |= ((BreakPoint->Data.Hw.Size - 1) << (18 + (i * 4)));
830 
831  /* Update KdbCurrentTrapFrame - values are taken from there by the CLI */
833  {
840  }
841 
842  BreakPoint->Data.Hw.DebugReg = i;
843  KdbHwBreakPoints[KdbHwBreakPointCount++] = BreakPoint;
844  }
845 
846  BreakPoint->Enabled = TRUE;
847  if (BreakPoint->Type != KdbBreakPointTemporary)
848  KdbpPrint("Breakpoint %d enabled.\n", BreakPointNr);
849 
850  return TRUE;
851 }
#define KDB_MAXIMUM_SW_BREAKPOINT_COUNT
Definition: kdb.c:23
#define KDB_MAXIMUM_BREAKPOINT_COUNT
Definition: kdb.c:21
#define TRUE
Definition: types.h:120
static ULONG KdbSwBreakPointCount
Definition: kdb.c:35
LONG NTSTATUS
Definition: precomp.h:26
int32_t INT
Definition: typedefs.h:58
ULONG Dr7
Definition: nt_native.h:1439
ULONG Dr3
Definition: nt_native.h:1437
static PKDB_BREAKPOINT KdbHwBreakPoints[KDB_MAXIMUM_HW_BREAKPOINT_COUNT]
Definition: kdb.c:38
#define FALSE
Definition: types.h:117
static NTSTATUS KdbpOverwriteInstruction(IN PEPROCESS Process, IN ULONG_PTR Address, IN UCHAR NewInst, OUT PUCHAR OldInst OPTIONAL)
Overwrites the instruction at Address with NewInst and stores the old instruction in *OldInst.
Definition: kdb.c:150
ULONG Dr1
Definition: nt_native.h:1435
ULONG Dr2
Definition: nt_native.h:1436
PKDB_KTRAP_FRAME KdbCurrentTrapFrame
Definition: kdb.c:51
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static PKDB_BREAKPOINT KdbSwBreakPoints[KDB_MAXIMUM_SW_BREAKPOINT_COUNT]
Definition: kdb.c:37
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2716
#define KDB_MAXIMUM_HW_BREAKPOINT_COUNT
Definition: kdb.c:22
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG Dr6
Definition: nt_native.h:1438
static KDB_KTRAP_FRAME KdbTrapFrame
Definition: kdb.c:52
ULONG Dr0
Definition: nt_native.h:1434
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN Enabled
Definition: kdb.h:34
static KDB_BREAKPOINT KdbBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT]
Definition: kdb.c:34
static ULONG KdbHwBreakPointCount
Definition: kdb.c:36

Referenced by KdbpCmdEnableDisableClearBreakPoint(), and KdbpInsertBreakPoint().

◆ KdbpGetBreakPointInfo()

BOOLEAN KdbpGetBreakPointInfo ( IN ULONG  BreakPointNr,
OUT ULONG_PTR *Address  OPTIONAL,
OUT KDB_BREAKPOINT_TYPE *Type  OPTIONAL,
OUT UCHAR *Size  OPTIONAL,
OUT KDB_ACCESS_TYPE *AccessType  OPTIONAL,
OUT UCHAR *DebugReg  OPTIONAL,
OUT BOOLEAN *Enabled  OPTIONAL,
OUT BOOLEAN *Global  OPTIONAL,
OUT PEPROCESS *Process  OPTIONAL,
OUT PCHAR *ConditionExpression  OPTIONAL 
)

Returns information of the specified breakpoint.

Parameters
BreakPointNrNumber of the breakpoint to return information of.
AddressReceives the address of the breakpoint.
TypeReceives the type of the breakpoint (hardware or software)
SizeSize - for memory breakpoints.
AccessTypeAccess type - for hardware breakpoints.
DebugRegDebug register - for enabled hardware breakpoints.
EnabledWhether the breakpoint is enabled or not.
ProcessThe owning process of the breakpoint.
ConditionExpressionThe expression which was given as condition for the bp.
Returns
NULL on failure, pointer to a KDB_BREAKPOINT struct on success.

Definition at line 404 of file kdb.c.

415 {
416  PKDB_BREAKPOINT bp;
417 
418  if (BreakPointNr >= RTL_NUMBER_OF(KdbBreakPoints) ||
419  KdbBreakPoints[BreakPointNr].Type == KdbBreakPointNone)
420  {
421  return FALSE;
422  }
423 
424  bp = KdbBreakPoints + BreakPointNr;
425  if (Address)
426  *Address = bp->Address;
427 
428  if (Type)
429  *Type = bp->Type;
430 
431  if (bp->Type == KdbBreakPointHardware)
432  {
433  if (Size)
434  *Size = bp->Data.Hw.Size;
435 
436  if (AccessType)
437  *AccessType = bp->Data.Hw.AccessType;
438 
439  if (DebugReg && bp->Enabled)
440  *DebugReg = bp->Data.Hw.DebugReg;
441  }
442 
443  if (Enabled)
444  *Enabled = bp->Enabled;
445 
446  if (Global)
447  *Global = bp->Global;
448 
449  if (Process)
450  *Process = bp->Process;
451 
452  if (ConditionExpression)
453  *ConditionExpression = bp->ConditionExpression;
454 
455  return TRUE;
456 }
BOOLEAN Global
Definition: kdb.h:36
#define TRUE
Definition: types.h:120
PCHAR ConditionExpression
Definition: kdb.h:38
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
UNICODE_STRING Global
Definition: symlink.c:37
struct _KDB_BREAKPOINT::@1762::@1763 Hw
#define FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
ULONG_PTR Address
Definition: kdb.h:35
Type
Definition: Type.h:6
PEPROCESS Process
Definition: kdb.h:37
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
union _KDB_BREAKPOINT::@1762 Data
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
BOOLEAN Enabled
Definition: kdb.h:34
static KDB_BREAKPOINT KdbBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT]
Definition: kdb.c:34
KDB_BREAKPOINT_TYPE Type
Definition: kdb.h:33

Referenced by KdbpCmdBreakPointList().

◆ KdbpGetCommandLineSettings()

VOID NTAPI KdbpGetCommandLineSettings ( PCHAR  p1)

Definition at line 1653 of file kdb.c.

1655 {
1656 #define CONST_STR_LEN(x) (sizeof(x)/sizeof(x[0]) - 1)
1657 
1658  while (p1 && (p1 = strchr(p1, ' ')))
1659  {
1660  /* Skip other spaces */
1661  while (*p1 == ' ') ++p1;
1662 
1663  if (!_strnicmp(p1, "KDSERIAL", CONST_STR_LEN("KDSERIAL")))
1664  {
1665  p1 += CONST_STR_LEN("KDSERIAL");
1667  KdpDebugMode.Serial = TRUE;
1668  }
1669  else if (!_strnicmp(p1, "KDNOECHO", CONST_STR_LEN("KDNOECHO")))
1670  {
1671  p1 += CONST_STR_LEN("KDNOECHO");
1673  }
1674  else if (!_strnicmp(p1, "FIRSTCHANCE", CONST_STR_LEN("FIRSTCHANCE")))
1675  {
1676  p1 += CONST_STR_LEN("FIRSTCHANCE");
1678  }
1679  }
1680 }
BOOLEAN KdbpSetEnterCondition(IN LONG ExceptionNr, IN BOOLEAN FirstChance, IN KDB_ENTER_CONDITION Condition)
Sets the first or last chance enter-condition for exception nr. ExceptionNr.
Definition: kdb.c:991
ULONG KdbDebugState
Definition: kdb.c:45
#define TRUE
Definition: types.h:120
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:48
#define CONST_STR_LEN(x)
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
char * strchr(const char *String, int ch)
Definition: utclib.c:501

Referenced by KdDebuggerInitialize0().

◆ KdbpGetEnterCondition()

BOOLEAN KdbpGetEnterCondition ( IN LONG  ExceptionNr,
IN BOOLEAN  FirstChance,
OUT KDB_ENTER_CONDITION Condition 
)

Gets the first or last chance enter-condition for exception nr. ExceptionNr.

Parameters
ExceptionNrNumber of the exception to get condition of.
FirstChanceWhether to get first or last chance condition.
ConditionReceives the condition setting.
Return values
TRUESuccess.
FALSEFailure (invalid exception nr)

Definition at line 969 of file kdb.c.

973 {
974  if (ExceptionNr >= (LONG)RTL_NUMBER_OF(KdbEnterConditions))
975  return FALSE;
976 
977  *Condition = KdbEnterConditions[ExceptionNr][FirstChance ? 0 : 1];
978  return TRUE;
979 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static KDB_ENTER_CONDITION KdbEnterConditions[][2]
Definition: kdb.c:58
long LONG
Definition: pedump.c:60
IN ULONG IN UCHAR Condition
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12

Referenced by KdbpCmdSet().

◆ KdbpGetHexNumber()

BOOLEAN NTAPI KdbpGetHexNumber ( IN PCHAR  pszNum,
OUT ULONG_PTR pulValue 
)

Definition at line 465 of file kdb_cli.c.

468 {
469  char *endptr;
470 
471  /* Skip optional '0x' prefix */
472  if ((pszNum[0] == '0') && ((pszNum[1] == 'x') || (pszNum[1] == 'X')))
473  pszNum += 2;
474 
475  /* Make a number from the string (hex) */
476  *pulValue = strtoul(pszNum, &endptr, 16);
477 
478  return (*endptr == '\0');
479 }
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696

◆ KdbpGetInstLength()

LONG KdbpGetInstLength ( IN ULONG  Address)

Definition at line 95 of file i386-dis.c.

96 {
98 
99  info.fprintf_func = KdbpNopPrintDisasm;
100  info.stream = NULL;
101  info.application_data = NULL;
103  info.arch = bfd_arch_i386;
104  info.mach = bfd_mach_i386_i386;
105  info.insn_sets = 0;
106  info.flags = 0;
107  info.read_memory_func = KdbpReadMemory;
108  info.memory_error_func = KdbpMemoryError;
109  info.print_address_func = KdbpNopPrintAddress;
110  info.symbol_at_address_func = NULL;
111  info.buffer = NULL;
112  info.buffer_vma = info.buffer_length = 0;
113  info.bytes_per_chunk = 0;
114  info.display_endian = BIG_ENDIAN_LITTLE;
115  info.disassembler_options = NULL;
116 
117  return(print_insn_i386(Address, &info));
118 }
#define bfd_mach_i386_i386
Definition: i386-dis.c:33
static WCHAR Address[46]
Definition: ping.c:68
int print_insn_i386(bfd_vma pc, struct disassemble_info *info)
Definition: i386-dis.c:2071
static void KdbpMemoryError(int Status, unsigned int Addr, struct disassemble_info *Ignored)
Definition: i386-dis.c:73
struct _test_info info[]
Definition: SetCursorPos.c:19
static int KdbpReadMemory(unsigned int Addr, unsigned char *Data, unsigned int Length, struct disassemble_info *Ignored)
Definition: i386-dis.c:66
#define NULL
Definition: types.h:112
static void KdbpNopPrintAddress(unsigned int Addr, struct disassemble_info *Ignored)
Definition: i386-dis.c:88
int KdbpNopPrintDisasm(void *Ignored, const char *fmt,...)
Definition: i386-dis.c:60

Referenced by KdbpStepOverInstruction().

◆ KdbpGetNextBreakPointNr()

LONG KdbpGetNextBreakPointNr ( IN ULONG Start  OPTIONAL)

Gets the number of the next breakpoint >= Start.

Parameters
StartBreakpoint number to start searching at. -1 if no more breakpoints are found.
Returns
Breakpoint number (-1 if no more breakpoints are found)

Definition at line 377 of file kdb.c.

379 {
381  {
383  return Start;
384  }
385 
386  return -1;
387 }
Type
Definition: Type.h:6
Definition: partlist.h:33
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static KDB_BREAKPOINT KdbBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT]
Definition: kdb.c:34

Referenced by KdbpCmdBreakPointList().

◆ KdbpInsertBreakPoint()

NTSTATUS KdbpInsertBreakPoint ( IN ULONG_PTR  Address,
IN KDB_BREAKPOINT_TYPE  Type,
IN UCHAR Size  OPTIONAL,
IN KDB_ACCESS_TYPE AccessType  OPTIONAL,
IN PCHAR ConditionExpression  OPTIONAL,
IN BOOLEAN  Global,
OUT PLONG BreakPointNr  OPTIONAL 
)

Inserts a breakpoint into the breakpoint array.

The Process of the breakpoint is set to KdbCurrentProcess

Parameters
AddressAddress at which to set the breakpoint.
TypeType of breakpoint (hardware or software)
SizeSize of breakpoint (for hardware/memory breakpoints)
AccessTypeAccess type (for hardware breakpoins)
ConditionExpressionExpression which must evaluate to true for conditional breakpoints.
GlobalWether the breakpoint is global or local to a process.
BreakPointNumberReceives the breakpoint number on success
Returns
NTSTATUS

Definition at line 473 of file kdb.c.

481 {
482  LONG i;
484  PCHAR ConditionExpressionDup;
485  LONG ErrOffset;
486  CHAR ErrMsg[128];
487 
489 
491  {
492  if ((Address % Size) != 0)
493  {
494  KdbpPrint("Address (0x%p) must be aligned to a multiple of the size (%d)\n", Address, Size);
495  return STATUS_UNSUCCESSFUL;
496  }
497 
498  if (AccessType == KdbAccessExec && Size != 1)
499  {
500  KdbpPrint("Size must be 1 for execution breakpoints.\n");
501  return STATUS_UNSUCCESSFUL;
502  }
503  }
504 
506  {
507  return STATUS_UNSUCCESSFUL;
508  }
509 
510  /* Parse conditon expression string and duplicate it */
511  if (ConditionExpression)
512  {
513  Condition = KdbpRpnParseExpression(ConditionExpression, &ErrOffset, ErrMsg);
514  if (!Condition)
515  {
516  if (ErrOffset >= 0)
517  KdbpPrint("Couldn't parse expression: %s at character %d\n", ErrMsg, ErrOffset);
518  else
519  KdbpPrint("Couldn't parse expression: %s", ErrMsg);
520 
521  return STATUS_UNSUCCESSFUL;
522  }
523 
524  i = strlen(ConditionExpression) + 1;
525  ConditionExpressionDup = ExAllocatePoolWithTag(NonPagedPool, i, TAG_KDBG);
526  RtlCopyMemory(ConditionExpressionDup, ConditionExpression, i);
527  }
528  else
529  {
530  Condition = NULL;
531  ConditionExpressionDup = NULL;
532  }
533 
534  /* Find unused breakpoint */
536  {
537  for (i = RTL_NUMBER_OF(KdbBreakPoints) - 1; i >= 0; i--)
538  {
540  break;
541  }
542  }
543  else
544  {
545  for (i = 0; i < (LONG)RTL_NUMBER_OF(KdbBreakPoints); i++)
546  {
548  break;
549  }
550  }
551 
553 
554  /* Set the breakpoint */
561  KdbBreakPoints[i].ConditionExpression = ConditionExpressionDup;
563 
565  {
566  KdbBreakPoints[i].Data.Hw.Size = Size;
567  KdbBreakPoints[i].Data.Hw.AccessType = AccessType;
568  }
569 
571 
573  KdbpPrint("Breakpoint %d inserted.\n", i);
574 
575  /* Try to enable the breakpoint */
577 
578  /* Return the breakpoint number */
579  if (BreakPointNr)
580  *BreakPointNr = i;
581 
582  return STATUS_SUCCESS;
583 }
#define TAG_KDBG
Definition: kdb.h:8
signed char * PCHAR
Definition: retypes.h:7
PVOID KdbpRpnParseExpression(IN PCHAR Expression, OUT PLONG ErrOffset OPTIONAL, OUT PCHAR ErrMsg OPTIONAL)
Parses the given expression and returns a "handle" to it.
Definition: kdb_expr.c:1143
BOOLEAN Global
Definition: kdb.h:36
static ULONG KdbBreakPointCount
Definition: kdb.c:33
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define KDB_MAXIMUM_BREAKPOINT_COUNT
Definition: kdb.c:21
PEPROCESS KdbCurrentProcess
Definition: kdb.c:47
char CHAR
Definition: xmlstorage.h:175
PCHAR ConditionExpression
Definition: kdb.h:38
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
UNICODE_STRING Global
Definition: symlink.c:37
struct _KDB_BREAKPOINT::@1762::@1763 Hw
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
static WCHAR Address[46]
Definition: ping.c:68
ULONG_PTR Address
Definition: kdb.h:35
PVOID Condition
Definition: kdb.h:39
IN ULONG IN UCHAR Condition
BOOLEAN KdbpEnableBreakPoint(IN LONG BreakPointNr OPTIONAL, IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL)
Enables a breakpoint.
Definition: kdb.c:697
#define ASSERT(a)
Definition: mode.c:44
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2716
Type
Definition: Type.h:6
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
PEPROCESS Process
Definition: kdb.h:37
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
union _KDB_BREAKPOINT::@1762 Data
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
BOOLEAN Enabled
Definition: kdb.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
static KDB_BREAKPOINT KdbBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT]
Definition: kdb.c:34
KDB_BREAKPOINT_TYPE Type
Definition: kdb.h:33

Referenced by KdbpCmdBreakPoint(), KdbpStepIntoInstruction(), and KdbpStepOverInstruction().

◆ KdbpPrint()

VOID KdbpPrint ( IN PCHAR  Format,
IN ...  OPTIONAL 
)

Prints the given string with printf-like formatting.

Parameters
FormatFormat of the string/arguments.
...Variable number of arguments matching the format specified in Format.
Note
Doesn't correctly handle \t and terminal escape sequences when calculating the number of lines required to print a single line from the Buffer in the terminal. Prints maximum 4096 chars, because of its buffer size. Uses KdpDPrintf internally (NOT DbgPrint!). Callers must already hold the debugger lock.

Definition at line 2716 of file kdb_cli.c.

2719 {
2720  static CHAR Buffer[4096];
2721  static BOOLEAN TerminalInitialized = FALSE;
2722  static BOOLEAN TerminalConnected = FALSE;
2723  static BOOLEAN TerminalReportsSize = TRUE;
2724  CHAR c = '\0';
2725  PCHAR p, p2;
2726  ULONG Length;
2727  ULONG i, j;
2728  LONG RowsPrintedByTerminal;
2729  ULONG ScanCode;
2730  va_list ap;
2731 
2732  /* Check if the user has aborted output of the current command */
2733  if (KdbOutputAborted)
2734  return;
2735 
2736  /* Initialize the terminal */
2737  if (!TerminalInitialized)
2738  {
2739  KdpDprintf("\x1b[7h"); /* Enable linewrap */
2740 
2741  /* Query terminal type */
2742  /*DbgPrint("\x1b[Z");*/
2743  KdpDprintf("\x05");
2744 
2745  TerminalInitialized = TRUE;
2746  Length = 0;
2747  KeStallExecutionProcessor(100000);
2748 
2749  for (;;)
2750  {
2751  c = KdbpTryGetCharSerial(5000);
2752  if (c == -1)
2753  break;
2754 
2755  Buffer[Length++] = c;
2756  if (Length >= (sizeof(Buffer) - 1))
2757  break;
2758  }
2759 
2760  Buffer[Length] = '\0';
2761  if (Length > 0)
2762  TerminalConnected = TRUE;
2763  }
2764 
2765  /* Get number of rows and columns in terminal */
2766  if ((KdbNumberOfRowsTerminal < 0) || (KdbNumberOfColsTerminal < 0) ||
2767  (KdbNumberOfRowsPrinted) == 0) /* Refresh terminal size each time when number of rows printed is 0 */
2768  {
2769  if ((KdbDebugState & KD_DEBUG_KDSERIAL) && TerminalConnected && TerminalReportsSize)
2770  {
2771  /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */
2772  TerminalReportsSize = FALSE;
2773  KeStallExecutionProcessor(100000);
2774  KdpDprintf("\x1b[18t");
2775  c = KdbpTryGetCharSerial(5000);
2776 
2777  if (c == KEY_ESC)
2778  {
2779  c = KdbpTryGetCharSerial(5000);
2780  if (c == '[')
2781  {
2782  Length = 0;
2783 
2784  for (;;)
2785  {
2786  c = KdbpTryGetCharSerial(5000);
2787  if (c == -1)
2788  break;
2789 
2790  Buffer[Length++] = c;
2791  if (isalpha(c) || Length >= (sizeof(Buffer) - 1))
2792  break;
2793  }
2794 
2795  Buffer[Length] = '\0';
2796  if (Buffer[0] == '8' && Buffer[1] == ';')
2797  {
2798  for (i = 2; (i < Length) && (Buffer[i] != ';'); i++);
2799 
2800  if (Buffer[i] == ';')
2801  {
2802  Buffer[i++] = '\0';
2803 
2804  /* Number of rows is now at Buffer + 2 and number of cols at Buffer + i */
2807  TerminalReportsSize = TRUE;
2808  }
2809  }
2810  }
2811  /* Clear further characters */
2812  while ((c = KdbpTryGetCharSerial(5000)) != -1);
2813  }
2814  }
2815 
2816  if (KdbNumberOfRowsTerminal <= 0)
2817  {
2818  /* Set number of rows to the default. */
2819  KdbNumberOfRowsTerminal = 23; //24; //Mna.: 23 for SCREEN debugport
2820  }
2821  else if (KdbNumberOfColsTerminal <= 0)
2822  {
2823  /* Set number of cols to the default. */
2824  KdbNumberOfColsTerminal = 75; //80; //Mna.: 75 for SCREEN debugport
2825  }
2826  }
2827 
2828  /* Get the string */
2829  va_start(ap, Format);
2830  Length = _vsnprintf(Buffer, sizeof(Buffer) - 1, Format, ap);
2831  Buffer[Length] = '\0';
2832  va_end(ap);
2833 
2834  p = Buffer;
2835  while (p[0] != '\0')
2836  {
2837  i = strcspn(p, "\n");
2838 
2839  /* Calculate the number of lines which will be printed in the terminal
2840  * when outputting the current line
2841  */
2842  if (i > 0)
2843  RowsPrintedByTerminal = (i + KdbNumberOfColsPrinted - 1) / KdbNumberOfColsTerminal;
2844  else
2845  RowsPrintedByTerminal = 0;
2846 
2847  if (p[i] == '\n')
2848  RowsPrintedByTerminal++;
2849 
2850  /*DbgPrint("!%d!%d!%d!%d!", KdbNumberOfRowsPrinted, KdbNumberOfColsPrinted, i, RowsPrintedByTerminal);*/
2851 
2852  /* Display a prompt if we printed one screen full of text */
2853  if (KdbNumberOfRowsTerminal > 0 &&
2854  (LONG)(KdbNumberOfRowsPrinted + RowsPrintedByTerminal) >= KdbNumberOfRowsTerminal)
2855  {
2857 
2858  if (KdbNumberOfColsPrinted > 0)
2859  KdpDprintf("\n");
2860 
2861  KdpDprintf("--- Press q to abort, any other key to continue ---");
2862  RowsPrintedByTerminal++; /* added by Mna. */
2863 
2865  c = KdbpGetCharSerial();
2866  else
2868 
2869  if (c == '\r')
2870  {
2871  /* Try to read '\n' which might follow '\r' - if \n is not received here
2872  * it will be interpreted as "return" when the next command should be read.
2873  */
2875  c = KdbpTryGetCharSerial(5);
2876  else
2878  }
2879 
2880  KdpDprintf("\n");
2881  if (c == 'q')
2882  {
2884  return;
2885  }
2886 
2889  }
2890 
2891  /* Insert a NUL after the line and print only the current line. */
2892  if (p[i] == '\n' && p[i + 1] != '\0')
2893  {
2894  c = p[i + 1];
2895  p[i + 1] = '\0';
2896  }
2897  else
2898  {
2899  c = '\0';
2900  }
2901 
2902  /* Remove escape sequences from the line if there's no terminal connected */
2903  if (!TerminalConnected)
2904  {
2905  while ((p2 = strrchr(p, '\x1b'))) /* Look for escape character */
2906  {
2907  size_t len = strlen(p2);
2908  if (p2[1] == '[')
2909  {
2910  j = 2;
2911  while (!isalpha(p2[j++]));
2912  memmove(p2, p2 + j, len + 1 - j);
2913  }
2914  else
2915  {
2916  memmove(p2, p2 + 1, len);
2917  }
2918  }
2919  }
2920 
2921  KdpDprintf("%s", p);
2922 
2923  if (c != '\0')
2924  p[i + 1] = c;
2925 
2926  /* Set p to the start of the next line and
2927  * remember the number of rows/cols printed
2928  */
2929  p += i;
2930  if (p[0] == '\n')
2931  {
2932  p++;
2934  }
2935  else
2936  {
2937  ASSERT(p[0] == '\0');
2939  }
2940 
2941  KdbNumberOfRowsPrinted += RowsPrintedByTerminal;
2942  }
2943 }
signed char * PCHAR
Definition: retypes.h:7
#define KEY_ESC
Definition: kdb_cli.c:39
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG ScanCode
Definition: api.c:39
ULONG KdbDebugState
Definition: kdb.c:45
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define KdbpGetCharKeyboard(ScanCode)
Definition: kdb.h:263
#define TRUE
Definition: types.h:120
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
char CHAR
Definition: xmlstorage.h:175
#define isalpha(c)
Definition: acclib.h:74
#define KdbpGetCharSerial()
Definition: kdb.h:267
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
CHAR KdbpTryGetCharSerial(ULONG Retry)
Definition: kdb_serial.c:19
CHAR KdbpTryGetCharKeyboard(PULONG ScanCode, ULONG Retry)
Definition: kdb_keyboard.c:104
static ULONG KdbNumberOfRowsPrinted
Definition: kdb_cli.c:146
#define va_end(ap)
Definition: acmsvcex.h:90
#define FALSE
Definition: types.h:117
static ULONG KdbNumberOfColsPrinted
Definition: kdb_cli.c:147
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
static BOOLEAN KdbRepeatLastCommand
Definition: kdb_cli.c:149
char * va_list
Definition: acmsvcex.h:78
Definition: bufpool.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static BOOLEAN KdbOutputAborted
Definition: kdb_cli.c:148
#define ASSERT(a)
Definition: mode.c:44
const GLubyte * c
Definition: glext.h:8905
static LONG KdbNumberOfRowsTerminal
Definition: kdb_cli.c:150
va_start(ap, x)
static LONG KdbNumberOfColsTerminal
Definition: kdb_cli.c:151
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#define _vsnprintf
Definition: xmlstorage.h:202
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:96
#define KdpDprintf(...)
Definition: mmdbg.c:19

Referenced by KdbEnterDebuggerException(), KdbpAttachToProcess(), KdbpAttachToThread(), KdbpCliMainLoop(), KdbpCliModuleLoaded(), KdbpCmdBackTrace(), KdbpCmdBreakPoint(), KdbpCmdBreakPointList(), KdbpCmdDisassembleX(), KdbpCmdDmesg(), KdbpCmdEnableDisableClearBreakPoint(), KdbpCmdEvalExpression(), KdbpCmdFilter(), KdbpCmdGdtLdtIdt(), KdbpCmdHelp(), KdbpCmdMod(), KdbpCmdPcr(), KdbpCmdProc(), KdbpCmdRegs(), KdbpCmdSet(), KdbpCmdStep(), KdbpCmdThread(), KdbpDeleteBreakPoint(), KdbpDisableBreakPoint(), KdbpDoCommand(), KdbpEnableBreakPoint(), KdbpEvaluateExpression(), KdbpInsertBreakPoint(), KdbpReadCommand(), and KdbpShouldStepOverInstruction().

◆ KdbpRpnEvaluateExpression()

BOOLEAN KdbpRpnEvaluateExpression ( IN PCHAR  Expression,
IN PKDB_KTRAP_FRAME  TrapFrame,
OUT PULONGLONG  Result,
OUT PLONG ErrOffset  OPTIONAL,
OUT PCHAR ErrMsg  OPTIONAL 
)

Evaluates the given expression.

Parameters
ExpressionExpression to evaluate.
TrapFrameRegister values.
ResultVariable which receives the result on success.
ErrOffsetVariable which receives character offset on parse error (-1 on other errors)
ErrMsgBuffer which receives an error message on failure (128 bytes)
Return values
TRUESuccess.
FALSEFailure.

Definition at line 1103 of file kdb_expr.c.

1109 {
1111 
1112  ASSERT(Expression);
1113  ASSERT(TrapFrame);
1114  ASSERT(Result);
1115 
1116  /* Clear the stack and parse the expression */
1118  if (!RpnpParseExpression(Stack, Expression, NULL, 0, ErrOffset, ErrMsg))
1119  return FALSE;
1120 
1121 #ifdef DEBUG_RPN
1123 #endif
1124 
1125  /* Evaluate the stack */
1126  if (!RpnpEvaluateStack(Stack, TrapFrame, Result, ErrOffset, ErrMsg))
1127  return FALSE;
1128 
1129  return TRUE;
1130 }
struct _RPN_STACK * PRPN_STACK
PCWSTR Expression
static BOOLEAN RpnpParseExpression(IN PRPN_STACK Stack, IN PCHAR Expression, OUT PCHAR *End OPTIONAL, IN ULONG CharacterOffset, OUT PLONG ErrOffset OPTIONAL, OUT PCHAR ErrMsg OPTIONAL)
Parses an expression.
Definition: kdb_expr.c:422
VOID RpnpDumpStack(IN PRPN_STACK Stack)
Dumps the given RPN stack content.
Definition: kdb_expr.c:250
#define TRUE
Definition: types.h:120
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
#define FALSE
Definition: types.h:117
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define ASSERT(a)
Definition: mode.c:44
static BOOLEAN RpnpEvaluateStack(IN PRPN_STACK Stack, IN PKDB_KTRAP_FRAME TrapFrame, OUT PULONGLONG Result, OUT PLONG ErrOffset OPTIONAL, OUT PCHAR ErrMsg OPTIONAL)
Evaluates the RPN op stack and returns the result.
Definition: kdb_expr.c:894
static struct @1766 RpnStack
#define NULL
Definition: types.h:112
static VOID RpnpClearStack(OUT PRPN_STACK Stack)
Clears the given RPN stack.
Definition: kdb_expr.c:325

Referenced by KdbpEvaluateExpression().

◆ KdbpRpnEvaluateParsedExpression()

BOOLEAN KdbpRpnEvaluateParsedExpression ( IN PVOID  Expression,
IN PKDB_KTRAP_FRAME  TrapFrame,
OUT PULONGLONG  Result,
OUT PLONG ErrOffset  OPTIONAL,
OUT PCHAR ErrMsg  OPTIONAL 
)

Evaluates the given expression and returns the result.

Parameters
ExpressionExpression "handle" returned by KdbpRpnParseExpression.
TrapFrameRegister values.
ResultVariable which receives the result on success.
ErrOffsetVariable which receives character offset on parse error (-1 on other errors)
ErrMsgBuffer which receives an error message on failure (128 bytes)
Returns
"Handle" for the expression, NULL on failure.
See also
KdbpRpnParseExpression

Definition at line 1197 of file kdb_expr.c.

1203 {
1205 
1206  ASSERT(Expression);
1207  ASSERT(TrapFrame);
1208  ASSERT(Result);
1209 
1210  /* Evaluate the stack */
1211  return RpnpEvaluateStack(Stack, TrapFrame, Result, ErrOffset, ErrMsg);
1212 }
struct _RPN_STACK * PRPN_STACK
PCWSTR Expression
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define ASSERT(a)
Definition: mode.c:44
static BOOLEAN RpnpEvaluateStack(IN PRPN_STACK Stack, IN PKDB_KTRAP_FRAME TrapFrame, OUT PULONGLONG Result, OUT PLONG ErrOffset OPTIONAL, OUT PCHAR ErrMsg OPTIONAL)
Evaluates the RPN op stack and returns the result.
Definition: kdb_expr.c:894

Referenced by KdbEnterDebuggerException().

◆ KdbpRpnParseExpression()

PVOID KdbpRpnParseExpression ( IN PCHAR  Expression,
OUT PLONG ErrOffset  OPTIONAL,
OUT PCHAR ErrMsg  OPTIONAL 
)

Parses the given expression and returns a "handle" to it.

Parameters
ExpressionExpression to evaluate.
ErrOffsetVariable which receives character offset on parse error (-1 on other errors)
ErrMsgBuffer which receives an error message on failure (128 bytes)
Returns
"Handle" for the expression, NULL on failure.
See also
KdbpRpnEvaluateExpression

Definition at line 1143 of file kdb_expr.c.

1147 {
1148  LONG Size;
1150  PRPN_STACK NewStack;
1151 
1152  ASSERT(Expression);
1153 
1154  /* Clear the stack and parse the expression */
1156  if (!RpnpParseExpression(Stack, Expression, NULL, 0, ErrOffset, ErrMsg))
1157  return FALSE;
1158 
1159 #ifdef DEBUG_RPN
1161 #endif
1162 
1163  /* Duplicate the stack and return a pointer/handle to it */
1164  ASSERT(Stack->Sp >= 1);
1165  Size = sizeof (RPN_STACK) + (RTL_FIELD_SIZE(RPN_STACK, Ops[0]) * (Stack->Sp - 1));
1167 
1168  if (!NewStack)
1169  {
1170  CONST_STRCPY(ErrMsg, "Out of memory");
1171 
1172  if (ErrOffset)
1173  *ErrOffset = -1;
1174 
1175  return NULL;
1176  }
1177 
1178  memcpy(NewStack, Stack, Size);
1179  NewStack->Size = NewStack->Sp;
1180 
1181  return NewStack;
1182 }
#define TAG_KDBG
Definition: kdb.h:8
struct _RPN_STACK * PRPN_STACK
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
PCWSTR Expression
static BOOLEAN RpnpParseExpression(IN PRPN_STACK Stack, IN PCHAR Expression, OUT PCHAR *End OPTIONAL, IN ULONG CharacterOffset, OUT PLONG ErrOffset OPTIONAL, OUT PCHAR ErrMsg OPTIONAL)
Parses an expression.
Definition: kdb_expr.c:422
RPN_OP Ops[RPN_OP_STACK_SIZE]
Definition: kdb_expr.c:98
VOID RpnpDumpStack(IN PRPN_STACK Stack)
Dumps the given RPN stack content.
Definition: kdb_expr.c:250
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
ULONG Size
Definition: kdb_expr.c:96
struct _RPN_STACK RPN_STACK
#define ASSERT(a)
Definition: mode.c:44
ULONG Sp
Definition: kdb_expr.c:75
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG Size
Definition: kdb_expr.c:74
static struct @1766 RpnStack
#define NULL
Definition: types.h:112
#define CONST_STRCPY(dst, src)
Definition: kdb_expr.c:87
static VOID RpnpClearStack(OUT PRPN_STACK Stack)
Clears the given RPN stack.
Definition: kdb_expr.c:325

Referenced by KdbpInsertBreakPoint().

◆ KdbpSafeReadMemory()

NTSTATUS KdbpSafeReadMemory ( OUT PVOID  Dest,
IN PVOID  Src,
IN ULONG  Bytes 
)

Definition at line 1683 of file kdb.c.

1687 {
1688  return KdpCopyMemoryChunks((ULONG64)(ULONG_PTR)Src,
1689  Dest,
1690  Bytes,
1691  0,
1693  NULL);
1694 }
NTSTATUS NTAPI KdpCopyMemoryChunks(_In_ ULONG64 Address, _In_ PVOID Buffer, _In_ ULONG TotalSize, _In_ ULONG ChunkSize, _In_ ULONG Flags, _Out_opt_ PULONG ActualSize)
Definition: kdapi.c:50
_In_ UINT Bytes
Definition: mmcopy.h:9
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned __int64 ULONG64
Definition: imports.h:198
#define MMDBG_COPY_UNSAFE
Definition: mm.h:66
#define NULL
Definition: types.h:112

Referenced by KdbpCmdBackTrace(), KdbpCmdDisassembleX(), KdbpCmdGdtLdtIdt(), KdbpCmdThread(), KdbpOverwriteInstruction(), KdbpReadMemory(), KdbpShouldStepOverInstruction(), KdbpStepIntoInstruction(), and RpnpEvaluateStack().

◆ KdbpSafeWriteMemory()

NTSTATUS KdbpSafeWriteMemory ( OUT PVOID  Dest,
IN PVOID  Src,
IN ULONG  Bytes 
)

Definition at line 1697 of file kdb.c.

1701 {
1702  return KdpCopyMemoryChunks((ULONG64)(ULONG_PTR)Dest,
1703  Src,
1704  Bytes,
1705  0,
1707  NULL);
1708 }
NTSTATUS NTAPI KdpCopyMemoryChunks(_In_ ULONG64 Address, _In_ PVOID Buffer, _In_ ULONG TotalSize, _In_ ULONG ChunkSize, _In_ ULONG Flags, _Out_opt_ PULONG ActualSize)
Definition: kdapi.c:50
_In_ UINT Bytes
Definition: mmcopy.h:9
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MMDBG_COPY_WRITE
Definition: mm.h:64
unsigned __int64 ULONG64
Definition: imports.h:198
#define MMDBG_COPY_UNSAFE
Definition: mm.h:66
#define NULL
Definition: types.h:112

Referenced by KdbpOverwriteInstruction().

◆ KdbpSetEnterCondition()

BOOLEAN KdbpSetEnterCondition ( IN LONG  ExceptionNr,
IN BOOLEAN  FirstChance,
IN KDB_ENTER_CONDITION  Condition 
)

Sets the first or last chance enter-condition for exception nr. ExceptionNr.

Parameters
ExceptionNrNumber of the exception to set condition of (-1 for all)
FirstChanceWhether to set first or last chance condition.
ConditionThe new condition setting.
Return values
TRUESuccess.
FALSEFailure (invalid exception nr)

Definition at line 991 of file kdb.c.

995 {
996  if (ExceptionNr < 0)
997  {
998  for (ExceptionNr = 0; ExceptionNr < (LONG)RTL_NUMBER_OF(KdbEnterConditions); ExceptionNr++)
999  {
1000  if (ExceptionNr == 1 || ExceptionNr == 8 ||
1001  ExceptionNr == 9 || ExceptionNr == 15) /* Reserved exceptions */
1002  {
1003  continue;
1004  }
1005 
1006  KdbEnterConditions[ExceptionNr][FirstChance ? 0 : 1] = Condition;
1007  }
1008  }
1009  else
1010  {
1011  if (ExceptionNr >= (LONG)RTL_NUMBER_OF(KdbEnterConditions) ||
1012  ExceptionNr == 1 || ExceptionNr == 8 || /* Do not allow changing of the debug */
1013  ExceptionNr == 9 || ExceptionNr == 15) /* trap or reserved exceptions */
1014  {
1015  return FALSE;
1016  }
1017 
1018  KdbEnterConditions[ExceptionNr][FirstChance ? 0 : 1] = Condition;
1019  }
1020 
1021  return TRUE;
1022 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static KDB_ENTER_CONDITION KdbEnterConditions[][2]
Definition: kdb.c:58
long LONG
Definition: pedump.c:60
IN ULONG IN UCHAR Condition
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12

Referenced by KdbpCmdSet(), and KdbpGetCommandLineSettings().

◆ KdbpStackSwitchAndCall()

VOID NTAPI KdbpStackSwitchAndCall ( IN PVOID  NewStack,
IN VOID(*)(VOID Function 
)

Referenced by KdbpInternalEnter().

◆ KdbpSymFindModule()

BOOLEAN KdbpSymFindModule ( IN PVOID Address  OPTIONAL,
IN INT Index  OPTIONAL,
OUT PLDR_DATA_TABLE_ENTRY pLdrEntry 
)

Find a module...

Parameters
AddressIf Address is not NULL the module containing Address is searched.
NameIf Name is not NULL the module named Name will be searched.
IndexIf Index is >= 0 the Index'th module will be returned.
pLdrEntryPointer to a PLDR_DATA_TABLE_ENTRY which is filled.
Return values
TRUEModule was found, pLdrEntry was filled.
FALSENo module was found.

Definition at line 75 of file kdb_symbols.c.

79 {
80  LONG Count = 0;
82 
83  /* First try to look up the module in the kernel module list. */
87  &Count,
88  Address,
89  Index,
90  pLdrEntry))
91  {
93  return TRUE;
94  }
96 
97  /* That didn't succeed. Try the module list of the current process now. */
99 
100  if(!CurrentProcess || !CurrentProcess->Peb || !CurrentProcess->Peb->Ldr)
101  return FALSE;
102 
103  return KdbpSymSearchModuleList(CurrentProcess->Peb->Ldr->InLoadOrderModuleList.Flink,
104  &CurrentProcess->Peb->Ldr->InLoadOrderModuleList,
105  &Count,
106  Address,
107  Index,
108  pLdrEntry);
109 }
#define TRUE
Definition: types.h:120
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:198
KSPIN_LOCK PsLoadedModuleSpinLock
Definition: sysldr.c:36
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define PsGetCurrentProcess
Definition: psfuncs.h:17
static WCHAR Address[46]
Definition: ping.c:68
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
int Count
Definition: noreturn.cpp:7
ULONG CurrentProcess
Definition: shell.c:125
_In_ WDFCOLLECTION _In_ ULONG Index
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:221
static BOOLEAN KdbpSymSearchModuleList(IN PLIST_ENTRY current_entry, IN PLIST_ENTRY end_entry, IN PLONG Count, IN PVOID Address, IN INT Index, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Definition: kdb_symbols.c:38

Referenced by KdbpCmdMod(), KdbSymPrintAddress(), and KdSendPacket().

◆ KdbpTryGetCharKeyboard()

CHAR KdbpTryGetCharKeyboard ( PULONG  ScanCode,
ULONG  Retry 
)

Definition at line 104 of file kdb_keyboard.c.

105 {
106  static byte_t last_key = 0;
107  static byte_t shift = 0;
108  char c;
109  BOOLEAN KeepRetrying = (Retry == 0);
110 
111  while (KeepRetrying || Retry-- > 0)
112  {
113  while (kbd_read_status() & KBD_STAT_OBF)
114  {
115  byte_t scancode;
116 
117  scancode = kbd_read_input();
118 
119  /* check for SHIFT-keys */
120  if (((scancode & 0x7F) == 42) || ((scancode & 0x7F) == 54))
121  {
122  shift = !(scancode & 0x80);
123  continue;
124  }
125 
126  /* ignore all other RELEASED-codes */
127  if (scancode & 0x80)
128  {
129  last_key = 0;
130  }
131  else if (last_key != scancode)
132  {
133  //printf("kbd: %d, %d, %c\n", scancode, last_key, keyb_layout[shift][scancode]);
134  last_key = scancode;
135  c = keyb_layout[shift][scancode];
136  *ScanCode = scancode;
137 
138  if (c > 0)
139  return c;
140  }
141  }
142  }
143 
144  return -1;
145 }
#define shift
Definition: input.c:1756
ULONG ScanCode
Definition: api.c:39
unsigned char BOOLEAN
static unsigned char keyb_layout[2][128]
Definition: kdb_keyboard.c:38
#define KBD_STAT_OBF
Definition: kdb_keyboard.c:22
#define kbd_read_input()
Definition: kdb_keyboard.c:35
const GLubyte * c
Definition: glext.h:8905
#define kbd_read_status()
Definition: kdb_keyboard.c:36
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:310
UCHAR byte_t
Definition: kdb_keyboard.c:57
#define c
Definition: ke_i.h:80

Referenced by KdbpCliMainLoop(), KdbpPager(), KdbpPrint(), KdbpReadCommand(), and KdReceivePacket().

◆ KdbpTryGetCharSerial()

CHAR KdbpTryGetCharSerial ( ULONG  Retry)

Definition at line 19 of file kdb_serial.c.

20 {
21  CHAR Result = -1;
22 
23  if (Retry == 0)
25  else
26  while (!KdPortGetByteEx(&SerialPortInfo, (PUCHAR)&Result) && Retry-- > 0);
27 
28  return Result;
29 }
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
BOOLEAN NTAPI KdPortGetByteEx(PCPPORT PortInformation, PUCHAR ByteReceived)
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:310
CPPORT SerialPortInfo
Definition: kdio.c:34

Referenced by KdbpCliMainLoop(), KdbpPager(), KdbpPrint(), KdbpReadCommand(), and KdReceivePacket().

◆ KdbRegisterCliCallback()

BOOLEAN NTAPI KdbRegisterCliCallback ( PVOID  Callback,
BOOLEAN  Deregister 
)

Definition at line 3563 of file kdb_cli.c.

3566 {
3567  ULONG i;
3568 
3569  /* Loop all entries */
3570  for (i = 0; i < _countof(KdbCliCallbacks); i++)
3571  {
3572  /* Check if deregistering was requested */
3573  if (Deregister)
3574  {
3575  /* Check if this entry is the one that was registered */
3576  if (KdbCliCallbacks[i] == Callback)
3577  {
3578  /* Delete it and report success */
3579  KdbCliCallbacks[i] = NULL;
3580  return TRUE;
3581  }
3582  }
3583  else
3584  {
3585  /* Check if this entry is free */
3586  if (KdbCliCallbacks[i] == NULL)
3587  {
3588  /* Set it and and report success */
3590  return TRUE;
3591  }
3592  }
3593  }
3594 
3595  /* Unsuccessful */
3596  return FALSE;
3597 }
static PKDBG_CLI_ROUTINE KdbCliCallbacks[10]
Definition: kdb_cli.c:137
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define _countof(array)
Definition: sndvol32.h:68
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1

Referenced by KdSystemDebugControl().

◆ KdbSymPrintAddress()

BOOLEAN KdbSymPrintAddress ( IN PVOID  Address,
IN PCONTEXT  Context 
)

Print address...

Tries to lookup line number, file name and function name for the given address and prints it. If no such information is found the address is printed in the format <module: offset>, otherwise the format will be <module: offset (filename:linenumber (functionname))>

Return values
TRUEModule containing Address was found, Address was printed.
FALSENo module containing Address was found, nothing was printed.

Definition at line 148 of file kdb_symbols.c.

151 {
152  PLDR_DATA_TABLE_ENTRY LdrEntry;
153  ULONG_PTR RelativeAddress;
154  BOOLEAN Printed = FALSE;
155  CHAR ModuleNameAnsi[64];
156 
157  if (!KdbpSymFindModule(Address, -1, &LdrEntry))
158  return FALSE;
159 
160  RelativeAddress = (ULONG_PTR)Address - (ULONG_PTR)LdrEntry->DllBase;
161 
163  ModuleNameAnsi,
164  sizeof(ModuleNameAnsi));
165 
166  if (LdrEntry->PatchInformation)
167  {
169  CHAR FileName[256];
170  CHAR FunctionName[256];
171 
173  {
174  STRING str;
175  /* Use KdpPrintString because KdpDprintf is limited wrt string size */
176  KdpDprintf("<%s:%x (", ModuleNameAnsi, RelativeAddress);
177  str.Buffer = FileName;
178  str.Length = strnlen(FileName, sizeof(FileName));
179  str.MaximumLength = sizeof(FileName);
181  KdpDprintf(":%d (%s))>", LineNumber, FunctionName);
182 
183  Printed = TRUE;
184  }
185  }
186 
187  if (!Printed)
188  {
189  /* Just print module & address */
190  KdpDprintf("<%s:%x>", ModuleNameAnsi, RelativeAddress);
191  }
192 
193  return TRUE;
194 }
BOOLEAN NTAPI KdpPrintString(_In_ PSTRING Output)
Definition: kdprint.c:22
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1926
#define FALSE
Definition: types.h:117
const WCHAR * str
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
BOOLEAN RosSymGetAddressInformation(PROSSYM_INFO RosSymInfo, ULONG_PTR RelativeAddress, ULONG *LineNumber, char *FileName, char *FunctionName)
Definition: find.c:94
static PCHAR NTAPI KdbpSymUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: kdb_symbols.c:114
PVOID PatchInformation
Definition: ldrtypes.h:164
std::wstring STRING
Definition: fontsub.cpp:33
Definition: btrfs_drv.h:1922
BOOLEAN KdbpSymFindModule(IN PVOID Address OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Find a module...
Definition: kdb_symbols.c:75
struct _FileName FileName
Definition: fatprocs.h:893
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 LineNumber
Definition: acpixf.h:1216
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
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 * FunctionName
Definition: acpixf.h:1274
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
#define KdpDprintf(...)
Definition: mmdbg.c:19

Referenced by KdbpCliMainLoop(), KdbpCmdBackTrace(), KdbpCmdDisassembleX(), KdbpPrintAddressInCode(), and KeRosDumpStackFrameArray().

◆ KdbSymProcessSymbols()

VOID KdbSymProcessSymbols ( _Inout_ PLDR_DATA_TABLE_ENTRY  LdrEntry,
_In_ BOOLEAN  Load 
)

Load symbols from image mapping. If this fails,.

Parameters
LdrEntryThe entry to load symbols from

Definition at line 298 of file kdb_symbols.c.

301 {
302  if (!LoadSymbols)
303  return;
304 
305  /* Check if this is unload */
306  if (!Load)
307  {
308  /* Did we process it */
309  if (LdrEntry->PatchInformation)
310  {
311  RosSymDelete(LdrEntry->PatchInformation);
312  LdrEntry->PatchInformation = NULL;
313  }
314  return;
315  }
316 
317  if (RosSymCreateFromMem(LdrEntry->DllBase, LdrEntry->SizeOfImage, (PROSSYM_INFO*)&LdrEntry->PatchInformation))
318  {
319  return;
320  }
321 
322  /* Add a ref until we really process it */
323  LdrEntry->LoadCount++;
324 
325  /* Tell our worker thread to read from it */
327  InsertTailList(&SymbolsToLoad, &LdrEntry->InInitializationOrderLinks);
329 
331 }
BOOLEAN RosSymCreateFromMem(PVOID ImageStart, ULONG_PTR ImageSize, PROSSYM_INFO *RosSymInfo)
Definition: frommem.c:20
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:198
VOID RosSymDelete(PROSSYM_INFO RosSymInfo)
Definition: delete.c:16
static LIST_ENTRY SymbolsToLoad
Definition: kdb_symbols.c:30
#define InsertTailList(ListHead, Entry)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
static KSPIN_LOCK SymbolsToLoadLock
Definition: kdb_symbols.c:31
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:221
#define NULL
Definition: types.h:112
#define IO_NO_INCREMENT
Definition: iotypes.h:598
static BOOLEAN LoadSymbols
Definition: kdb_symbols.c:29
static KEVENT SymbolsToLoadEvent
Definition: kdb_symbols.c:32

Referenced by KdbInitialize(), and KdSendPacket().

Variable Documentation

◆ KdbCurrentProcess

◆ KdbCurrentThread

PETHREAD KdbCurrentThread

Definition at line 49 of file kdb.c.

Referenced by KdbEnterDebuggerException(), KdbpAttachToThread(), KdbpCmdProc(), and KdbpCmdThread().

◆ KdbCurrentTrapFrame

◆ KdbDebugState

ULONG KdbDebugState

◆ KdbInitFileBuffer

PCHAR KdbInitFileBuffer

Definition at line 153 of file kdb_cli.c.

Referenced by KdbEnterDebuggerException(), KdbpCliInit(), and KdbpCliInterpretInitFile().

◆ KdbLastBreakPointNr

LONG KdbLastBreakPointNr

Definition at line 42 of file kdb.c.

Referenced by KdbEnterDebuggerException(), and KdbpCmdBreakPointList().

◆ KdbNumSingleSteps

ULONG KdbNumSingleSteps

Definition at line 43 of file kdb.c.

Referenced by KdbEnterDebuggerException(), and KdbpCmdStep().

◆ KdbSingleStepOver

BOOLEAN KdbSingleStepOver

Definition at line 44 of file kdb.c.

Referenced by KdbEnterDebuggerException(), and KdbpCmdStep().