ReactOS  0.4.15-dev-2771-g6d441f7
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 LPCWSTR Name 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 (IN PLDR_DATA_TABLE_ENTRY LdrEntry)
 
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 1619 of file kdb.c.

1621 {
1622  EXCEPTION_RECORD64 ExceptionRecord;
1623  KD_CONTINUE_TYPE Return;
1624  CONTEXT Context;
1625 
1626  /* Copy TrapFrame to Context */
1627  RtlZeroMemory(&Context, sizeof(CONTEXT));
1629 #ifdef CONTEXT_EXTENDED_REGISTERS
1630  Context.ContextFlags |= CONTEXT_EXTENDED_REGISTERS;
1631 #endif
1632  KeTrapFrameToContext(TrapFrame, NULL, &Context);
1633 
1634  /* Create ExceptionRecord (assume breakpoint) */
1635  RtlZeroMemory(&ExceptionRecord, sizeof(EXCEPTION_RECORD64));
1636  ExceptionRecord.ExceptionCode = STATUS_BREAKPOINT;
1637 
1638  /* Call real function */
1639  Return = KdbEnterDebuggerException(&ExceptionRecord,
1640  KernelMode,
1641  &Context,
1642  TRUE);
1643 
1644  /* Copy back Context to TrapFrame */
1645  KeContextToTrapFrame(&Context, NULL, TrapFrame, Context.ContextFlags, KernelMode);
1646 
1647  return Return;
1648 }
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:2715
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
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:2715
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
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 3832 of file kdb_cli.c.

3833 {
3834  NTSTATUS Status;
3838  FILE_STANDARD_INFORMATION FileStdInfo;
3839  HANDLE hFile = NULL;
3840  INT FileSize;
3841  PCHAR FileBuffer;
3842  ULONG OldEflags;
3843 
3844  /* Initialize the object attributes */
3845  RtlInitUnicodeString(&FileName, L"\\SystemRoot\\System32\\drivers\\etc\\KDBinit");
3847  &FileName,
3849  NULL,
3850  NULL);
3851 
3852  /* Open the file */
3854  &ObjectAttributes, &Iosb, 0,
3857  if (!NT_SUCCESS(Status))
3858  {
3859  DPRINT("Could not open \\SystemRoot\\System32\\drivers\\etc\\KDBinit (Status 0x%x)", Status);
3860  return;
3861  }
3862 
3863  /* Get the size of the file */
3864  Status = ZwQueryInformationFile(hFile, &Iosb, &FileStdInfo, sizeof(FileStdInfo),
3866  if (!NT_SUCCESS(Status))
3867  {
3868  ZwClose(hFile);
3869  DPRINT("Could not query size of \\SystemRoot\\System32\\drivers\\etc\\KDBinit (Status 0x%x)", Status);
3870  return;
3871  }
3872  FileSize = FileStdInfo.EndOfFile.u.LowPart;
3873 
3874  /* Allocate memory for the file */
3875  FileBuffer = ExAllocatePool(PagedPool, FileSize + 1); /* add 1 byte for terminating '\0' */
3876  if (!FileBuffer)
3877  {
3878  ZwClose(hFile);
3879  DPRINT("Could not allocate %d bytes for KDBinit file\n", FileSize);
3880  return;
3881  }
3882 
3883  /* Load file into memory */
3884  Status = ZwReadFile(hFile, NULL, NULL, NULL, &Iosb, FileBuffer, FileSize, NULL, NULL);
3885  ZwClose(hFile);
3886 
3888  {
3889  ExFreePool(FileBuffer);
3890  DPRINT("Could not read KDBinit file into memory (Status 0x%lx)\n", Status);
3891  return;
3892  }
3893 
3894  FileSize = min(FileSize, (INT)Iosb.Information);
3895  FileBuffer[FileSize] = '\0';
3896 
3897  /* Enter critical section */
3898  OldEflags = __readeflags();
3899  _disable();
3900 
3901  /* Interpret the init file... */
3902  KdbInitFileBuffer = FileBuffer;
3903  //KdbEnter(); // FIXME
3905 
3906  /* Leave critical section */
3907  __writeeflags(OldEflags);
3908 
3909  ExFreePool(FileBuffer);
3910 }
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 _LARGE_INTEGER::@2276 u
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
#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 3783 of file kdb_cli.c.

3784 {
3785  PCHAR p1, p2;
3786  INT i;
3787  CHAR c;
3788 
3789  /* Execute the commands in the init file */
3790  DPRINT("KDB: Executing KDBinit file...\n");
3791  p1 = KdbInitFileBuffer;
3792  while (p1[0] != '\0')
3793  {
3794  i = strcspn(p1, "\r\n");
3795  if (i > 0)
3796  {
3797  c = p1[i];
3798  p1[i] = '\0';
3799 
3800  /* Look for "break" command and comments */
3801  p2 = p1;
3802 
3803  while (isspace(p2[0]))
3804  p2++;
3805 
3806  if (strncmp(p2, "break", sizeof("break")-1) == 0 &&
3807  (p2[sizeof("break")-1] == '\0' || isspace(p2[sizeof("break")-1])))
3808  {
3809  /* break into the debugger */
3811  }
3812  else if (p2[0] != '#' && p2[0] != '\0') /* Ignore empty lines and comments */
3813  {
3814  KdbpDoCommand(p1);
3815  }
3816 
3817  p1[i] = c;
3818  }
3819 
3820  p1 += i;
3821  while (p1[0] == '\r' || p1[0] == '\n')
3822  p1++;
3823  }
3824  DPRINT("KDB: KDBinit executed\n");
3825 }
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:3643
#define FALSE
Definition: types.h:117
VOID KdbpCliMainLoop(IN BOOLEAN EnteredOnSingleStep)
KDB Main Loop.
Definition: kdb_cli.c:3705
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 3705 of file kdb_cli.c.

3707 {
3708  static CHAR Command[1024];
3709  BOOLEAN Continue;
3710 
3711  if (EnteredOnSingleStep)
3712  {
3714  {
3716  }
3717 
3718  KdbpPrint(": ");
3720  {
3721  KdbpPrint("<INVALID>");
3722  }
3723  KdbpPrint("\n");
3724  }
3725 
3726  /* Flush the input buffer */
3728  {
3729  while (KdbpTryGetCharSerial(1) != -1);
3730  }
3731  else
3732  {
3733  ULONG ScanCode;
3734  while (KdbpTryGetCharKeyboard(&ScanCode, 1) != -1);
3735  }
3736 
3737  /* Main loop */
3738  do
3739  {
3740  /* Reset the number of rows/cols printed */
3742 
3743  /* Print the prompt */
3744  KdbpPrint(KdbPromptString.Buffer);
3745 
3746  /* Read a command and remember it */
3747  KdbpReadCommand(Command, sizeof(Command));
3749 
3750  /* Reset the number of rows/cols printed and output aborted state */
3753 
3754  /* Call the command */
3757  }
3758  while (Continue);
3759 }
static VOID KdbpReadCommand(OUT PCHAR Buffer, IN ULONG Size)
Reads a line of user-input.
Definition: kdb_cli.c:3371
static VOID KdbpCommandHistoryAppend(IN PCHAR Command)
Appends a command to the command history.
Definition: kdb_cli.c:3297
ULONG ScanCode
Definition: api.c:39
BOOLEAN KdbSymPrintAddress(IN PVOID Address, IN PCONTEXT Context)
Print address...
Definition: kdb_symbols.c:156
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:2715
#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:3643
#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
volatile int Continue
Definition: gdblib.c:102
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 3766 of file kdb_cli.c.

3768 {
3769  if (!KdbBreakOnModuleLoad)
3770  return;
3771 
3772  KdbpPrint("Module %wZ loaded.\n", Name);
3774 }
VOID KdbpPrint(IN PCHAR Format, IN ... OPTIONAL)
Prints the given string with printf-like formatting.
Definition: kdb_cli.c:2715
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:2715
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:2715
#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:2715
#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 }
union _KDB_BREAKPOINT::@1799 Data
struct _KDB_BREAKPOINT::@1799::@1800 Hw
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
#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
_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 1652 of file kdb.c.

1654 {
1655 #define CONST_STR_LEN(x) (sizeof(x)/sizeof(x[0]) - 1)
1656 
1657  while (p1 && (p1 = strchr(p1, ' ')))
1658  {
1659  /* Skip other spaces */
1660  while (*p1 == ' ') ++p1;
1661 
1662  if (!_strnicmp(p1, "KDSERIAL", CONST_STR_LEN("KDSERIAL")))
1663  {
1664  p1 += CONST_STR_LEN("KDSERIAL");
1666  KdpDebugMode.Serial = TRUE;
1667  }
1668  else if (!_strnicmp(p1, "KDNOECHO", CONST_STR_LEN("KDNOECHO")))
1669  {
1670  p1 += CONST_STR_LEN("KDNOECHO");
1672  }
1673  else if (!_strnicmp(p1, "FIRSTCHANCE", CONST_STR_LEN("FIRSTCHANCE")))
1674  {
1675  p1 += CONST_STR_LEN("FIRSTCHANCE");
1677  }
1678  }
1679 }
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
union _KDB_BREAKPOINT::@1799 Data
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
struct _KDB_BREAKPOINT::@1799::@1800 Hw
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
#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:2715
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
#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.

Definition at line 2715 of file kdb_cli.c.

2718 {
2719  static CHAR Buffer[4096];
2720  static BOOLEAN TerminalInitialized = FALSE;
2721  static BOOLEAN TerminalConnected = FALSE;
2722  static BOOLEAN TerminalReportsSize = TRUE;
2723  CHAR c = '\0';
2724  PCHAR p, p2;
2725  ULONG Length;
2726  ULONG i, j;
2727  LONG RowsPrintedByTerminal;
2728  ULONG ScanCode;
2729  va_list ap;
2730 
2731  /* Check if the user has aborted output of the current command */
2732  if (KdbOutputAborted)
2733  return;
2734 
2735  /* Initialize the terminal */
2736  if (!TerminalInitialized)
2737  {
2738  DbgPrint("\x1b[7h"); /* Enable linewrap */
2739 
2740  /* Query terminal type */
2741  /*DbgPrint("\x1b[Z");*/
2742  DbgPrint("\x05");
2743 
2744  TerminalInitialized = TRUE;
2745  Length = 0;
2746  KeStallExecutionProcessor(100000);
2747 
2748  for (;;)
2749  {
2750  c = KdbpTryGetCharSerial(5000);
2751  if (c == -1)
2752  break;
2753 
2754  Buffer[Length++] = c;
2755  if (Length >= (sizeof(Buffer) - 1))
2756  break;
2757  }
2758 
2759  Buffer[Length] = '\0';
2760  if (Length > 0)
2761  TerminalConnected = TRUE;
2762  }
2763 
2764  /* Get number of rows and columns in terminal */
2765  if ((KdbNumberOfRowsTerminal < 0) || (KdbNumberOfColsTerminal < 0) ||
2766  (KdbNumberOfRowsPrinted) == 0) /* Refresh terminal size each time when number of rows printed is 0 */
2767  {
2768  if ((KdbDebugState & KD_DEBUG_KDSERIAL) && TerminalConnected && TerminalReportsSize)
2769  {
2770  /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */
2771  TerminalReportsSize = FALSE;
2772  KeStallExecutionProcessor(100000);
2773  DbgPrint("\x1b[18t");
2774  c = KdbpTryGetCharSerial(5000);
2775 
2776  if (c == KEY_ESC)
2777  {
2778  c = KdbpTryGetCharSerial(5000);
2779  if (c == '[')
2780  {
2781  Length = 0;
2782 
2783  for (;;)
2784  {
2785  c = KdbpTryGetCharSerial(5000);
2786  if (c == -1)
2787  break;
2788 
2789  Buffer[Length++] = c;
2790  if (isalpha(c) || Length >= (sizeof(Buffer) - 1))
2791  break;
2792  }
2793 
2794  Buffer[Length] = '\0';
2795  if (Buffer[0] == '8' && Buffer[1] == ';')
2796  {
2797  for (i = 2; (i < Length) && (Buffer[i] != ';'); i++);
2798 
2799  if (Buffer[i] == ';')
2800  {
2801  Buffer[i++] = '\0';
2802 
2803  /* Number of rows is now at Buffer + 2 and number of cols at Buffer + i */
2806  TerminalReportsSize = TRUE;
2807  }
2808  }
2809  }
2810  /* Clear further characters */
2811  while ((c = KdbpTryGetCharSerial(5000)) != -1);
2812  }
2813  }
2814 
2815  if (KdbNumberOfRowsTerminal <= 0)
2816  {
2817  /* Set number of rows to the default. */
2818  KdbNumberOfRowsTerminal = 23; //24; //Mna.: 23 for SCREEN debugport
2819  }
2820  else if (KdbNumberOfColsTerminal <= 0)
2821  {
2822  /* Set number of cols to the default. */
2823  KdbNumberOfColsTerminal = 75; //80; //Mna.: 75 for SCREEN debugport
2824  }
2825  }
2826 
2827  /* Get the string */
2828  va_start(ap, Format);
2829  Length = _vsnprintf(Buffer, sizeof(Buffer) - 1, Format, ap);
2830  Buffer[Length] = '\0';
2831  va_end(ap);
2832 
2833  p = Buffer;
2834  while (p[0] != '\0')
2835  {
2836  i = strcspn(p, "\n");
2837 
2838  /* Calculate the number of lines which will be printed in the terminal
2839  * when outputting the current line
2840  */
2841  if (i > 0)
2842  RowsPrintedByTerminal = (i + KdbNumberOfColsPrinted - 1) / KdbNumberOfColsTerminal;
2843  else
2844  RowsPrintedByTerminal = 0;
2845 
2846  if (p[i] == '\n')
2847  RowsPrintedByTerminal++;
2848 
2849  /*DbgPrint("!%d!%d!%d!%d!", KdbNumberOfRowsPrinted, KdbNumberOfColsPrinted, i, RowsPrintedByTerminal);*/
2850 
2851  /* Display a prompt if we printed one screen full of text */
2852  if (KdbNumberOfRowsTerminal > 0 &&
2853  (LONG)(KdbNumberOfRowsPrinted + RowsPrintedByTerminal) >= KdbNumberOfRowsTerminal)
2854  {
2856 
2857  if (KdbNumberOfColsPrinted > 0)
2858  DbgPrint("\n");
2859 
2860  DbgPrint("--- Press q to abort, any other key to continue ---");
2861  RowsPrintedByTerminal++; /* added by Mna. */
2862 
2864  c = KdbpGetCharSerial();
2865  else
2867 
2868  if (c == '\r')
2869  {
2870  /* Try to read '\n' which might follow '\r' - if \n is not received here
2871  * it will be interpreted as "return" when the next command should be read.
2872  */
2874  c = KdbpTryGetCharSerial(5);
2875  else
2877  }
2878 
2879  DbgPrint("\n");
2880  if (c == 'q')
2881  {
2883  return;
2884  }
2885 
2888  }
2889 
2890  /* Insert a NUL after the line and print only the current line. */
2891  if (p[i] == '\n' && p[i + 1] != '\0')
2892  {
2893  c = p[i + 1];
2894  p[i + 1] = '\0';
2895  }
2896  else
2897  {
2898  c = '\0';
2899  }
2900 
2901  /* Remove escape sequences from the line if there's no terminal connected */
2902  if (!TerminalConnected)
2903  {
2904  while ((p2 = strrchr(p, '\x1b'))) /* Look for escape character */
2905  {
2906  size_t len = strlen(p2);
2907  if (p2[1] == '[')
2908  {
2909  j = 2;
2910  while (!isalpha(p2[j++]));
2911  memmove(p2, p2 + j, len + 1 - j);
2912  }
2913  else
2914  {
2915  memmove(p2, p2 + 1, len);
2916  }
2917  }
2918  }
2919 
2920  DbgPrint("%s", p);
2921 
2922  if (c != '\0')
2923  p[i + 1] = c;
2924 
2925  /* Set p to the start of the next line and
2926  * remember the number of rows/cols printed
2927  */
2928  p += i;
2929  if (p[0] == '\n')
2930  {
2931  p++;
2933  }
2934  else
2935  {
2936  ASSERT(p[0] == '\0');
2938  }
2939 
2940  KdbNumberOfRowsPrinted += RowsPrintedByTerminal;
2941  }
2942 }
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
#define DbgPrint
Definition: loader.c:25
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:88

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
static struct @1803 RpnStack
_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
#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
static struct @1803 RpnStack
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
#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 1682 of file kdb.c.

1686 {
1687  return KdpCopyMemoryChunks((ULONG64)(ULONG_PTR)Src,
1688  Dest,
1689  Bytes,
1690  0,
1692  NULL);
1693 }
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:59
#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 1696 of file kdb.c.

1700 {
1701  return KdpCopyMemoryChunks((ULONG64)(ULONG_PTR)Dest,
1702  Src,
1703  Bytes,
1704  0,
1706  NULL);
1707 }
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:57
unsigned __int64 ULONG64
Definition: imports.h:198
#define MMDBG_COPY_UNSAFE
Definition: mm.h:59
#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 LPCWSTR Name  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 84 of file kdb_symbols.c.

89 {
90  LONG Count = 0;
92 
93  /* First try to look up the module in the kernel module list. */
96  &Count,
97  Address,
98  Name,
99  Index,
100  pLdrEntry))
101  {
102  return TRUE;
103  }
104 
105  /* That didn't succeed. Try the module list of the current process now. */
107 
108  if(!CurrentProcess || !CurrentProcess->Peb || !CurrentProcess->Peb->Ldr)
109  return FALSE;
110 
111  return KdbpSymSearchModuleList(CurrentProcess->Peb->Ldr->InLoadOrderModuleList.Flink,
112  &CurrentProcess->Peb->Ldr->InLoadOrderModuleList,
113  &Count,
114  Address,
115  Name,
116  Index,
117  pLdrEntry);
118 }
static BOOLEAN KdbpSymSearchModuleList(IN PLIST_ENTRY current_entry, IN PLIST_ENTRY end_entry, IN PLONG Count, IN PVOID Address, IN LPCWSTR Name, IN INT Index, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Definition: kdb_symbols.c:45
#define TRUE
Definition: types.h:120
#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

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
IN PSCSI_REQUEST_BLOCK IN OUT NTSTATUS IN OUT BOOLEAN * Retry
Definition: class2.h:49
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
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
IN PSCSI_REQUEST_BLOCK IN OUT NTSTATUS IN OUT BOOLEAN * Retry
Definition: class2.h:49
BOOLEAN NTAPI KdPortGetByteEx(PCPPORT PortInformation, PUCHAR ByteReceived)
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 3562 of file kdb_cli.c.

3565 {
3566  ULONG i;
3567 
3568  /* Loop all entries */
3569  for (i = 0; i < _countof(KdbCliCallbacks); i++)
3570  {
3571  /* Check if deregistering was requested */
3572  if (Deregister)
3573  {
3574  /* Check if this entry is the one that was registered */
3575  if (KdbCliCallbacks[i] == Callback)
3576  {
3577  /* Delete it and report success */
3578  KdbCliCallbacks[i] = NULL;
3579  return TRUE;
3580  }
3581  }
3582  else
3583  {
3584  /* Check if this entry is free */
3585  if (KdbCliCallbacks[i] == NULL)
3586  {
3587  /* Set it and and report success */
3589  return TRUE;
3590  }
3591  }
3592  }
3593 
3594  /* Unsuccessful */
3595  return FALSE;
3596 }
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 156 of file kdb_symbols.c.

159 {
160  PLDR_DATA_TABLE_ENTRY LdrEntry;
161  ULONG_PTR RelativeAddress;
164  CHAR FileName[256];
165  CHAR FunctionName[256];
166  CHAR ModuleNameAnsi[64];
167 
168  if (!KdbpSymbolsInitialized || !KdbpSymFindModule(Address, NULL, -1, &LdrEntry))
169  return FALSE;
170 
172  ModuleNameAnsi,
173  sizeof(ModuleNameAnsi));
174 
175  RelativeAddress = (ULONG_PTR)Address - (ULONG_PTR)LdrEntry->DllBase;
177  RelativeAddress,
178  &LineNumber,
179  FileName,
180  FunctionName);
181  if (NT_SUCCESS(Status))
182  {
183  DbgPrint("<%s:%x (%s:%d (%s))>",
184  ModuleNameAnsi, RelativeAddress, FileName, LineNumber, FunctionName);
185  }
186  else
187  {
188  DbgPrint("<%s:%x>", ModuleNameAnsi, RelativeAddress);
189  }
190 
191  return TRUE;
192 }
BOOLEAN KdbpSymbolsInitialized
Definition: kdb_symbols.c:32
#define DbgPrint
Definition: loader.c:25
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1926
static NTSTATUS KdbSymGetAddressInformation(IN PROSSYM_INFO RosSymInfo, IN ULONG_PTR RelativeAddress, OUT PULONG LineNumber OPTIONAL, OUT PCH FileName OPTIONAL, OUT PCH FunctionName OPTIONAL)
Get information for an address (source file, line number, function name)
Definition: kdb_symbols.c:212
#define FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
Status
Definition: gdiplustypes.h:24
PVOID PatchInformation
Definition: ldrtypes.h:164
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PCHAR NTAPI KdbpSymUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: kdb_symbols.c:122
Definition: btrfs_drv.h:1922
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
#define NULL
Definition: types.h:112
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
BOOLEAN KdbpSymFindModule(IN PVOID Address OPTIONAL, IN LPCWSTR Name OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Find a module...
Definition: kdb_symbols.c:84

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

◆ KdbSymProcessSymbols()

VOID KdbSymProcessSymbols ( IN PLDR_DATA_TABLE_ENTRY  LdrEntry)

Definition at line 434 of file kdb_symbols.c.

436 {
437  if (!LoadSymbols)
438  {
439  LdrEntry->PatchInformation = NULL;
440  return;
441  }
442 
443  /* Remove symbol info if it already exists */
444  if (LdrEntry->PatchInformation)
445  KdbpSymRemoveCachedFile(LdrEntry->PatchInformation);
446 
447  /* Load new symbol information */
448  if (! RosSymCreateFromMem(LdrEntry->DllBase,
449  LdrEntry->SizeOfImage,
450  (PROSSYM_INFO*)&LdrEntry->PatchInformation))
451  {
452  /* Error loading symbol info, try to load it from file */
453  KdbpSymLoadModuleSymbols(&LdrEntry->FullDllName,
454  (PROSSYM_INFO*)&LdrEntry->PatchInformation);
455 
456  /* It already added symbols to cache */
457  }
458  else
459  {
460  /* Add file to cache */
461  KdbpSymAddCachedFile(&LdrEntry->FullDllName, LdrEntry->PatchInformation);
462  }
463 
464  DPRINT("Installed symbols: %wZ@%p-%p %p\n",
465  &LdrEntry->BaseDllName,
466  LdrEntry->DllBase,
467  (PVOID)(LdrEntry->SizeOfImage + (ULONG_PTR)LdrEntry->DllBase),
468  LdrEntry->PatchInformation);
469 
470 }
static VOID KdbpSymAddCachedFile(IN PUNICODE_STRING FileName, IN PROSSYM_INFO RosSymInfo)
Add a symbol file to the cache.
Definition: kdb_symbols.c:284
BOOLEAN RosSymCreateFromMem(PVOID ImageStart, ULONG_PTR ImageSize, PROSSYM_INFO *RosSymInfo)
Definition: frommem.c:20
uint32_t ULONG_PTR
Definition: typedefs.h:65
static VOID KdbpSymLoadModuleSymbols(IN PUNICODE_STRING FileName, OUT PROSSYM_INFO *RosSymInfo)
Loads a symbol file.
Definition: kdb_symbols.c:366
#define NULL
Definition: types.h:112
static VOID KdbpSymRemoveCachedFile(IN PROSSYM_INFO RosSymInfo)
Remove a symbol file (reference) from the cache.
Definition: kdb_symbols.c:322
static BOOLEAN LoadSymbols
Definition: kdb_symbols.c:29
#define DPRINT
Definition: sndvol32.h:71

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().