/* GLOBALS *******************************************************************/
-STATIC LONG KdbEntryCount = 0;
-STATIC CHAR KdbStack[KDB_STACK_SIZE];
-
-STATIC ULONG KdbBreakPointCount = 0; /* Number of used breakpoints in the array */
-STATIC KDB_BREAKPOINT KdbBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT] = {{0}}; /* Breakpoint array */
-STATIC ULONG KdbSwBreakPointCount = 0; /* Number of enabled software breakpoints */
-STATIC ULONG KdbHwBreakPointCount = 0; /* Number of enabled hardware breakpoints */
-STATIC PKDB_BREAKPOINT KdbSwBreakPoints[KDB_MAXIMUM_SW_BREAKPOINT_COUNT]; /* Enabled software breakpoints, orderless */
-STATIC PKDB_BREAKPOINT KdbHwBreakPoints[KDB_MAXIMUM_HW_BREAKPOINT_COUNT]; /* Enabled hardware breakpoints, orderless */
-STATIC PKDB_BREAKPOINT KdbBreakPointToReenable = NULL; /* Set to a breakpoint struct when single stepping after
+static LONG KdbEntryCount = 0;
+static CHAR KdbStack[KDB_STACK_SIZE];
+
+static ULONG KdbBreakPointCount = 0; /* Number of used breakpoints in the array */
+static KDB_BREAKPOINT KdbBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT] = {{0}}; /* Breakpoint array */
+static ULONG KdbSwBreakPointCount = 0; /* Number of enabled software breakpoints */
+static ULONG KdbHwBreakPointCount = 0; /* Number of enabled hardware breakpoints */
+static PKDB_BREAKPOINT KdbSwBreakPoints[KDB_MAXIMUM_SW_BREAKPOINT_COUNT]; /* Enabled software breakpoints, orderless */
+static PKDB_BREAKPOINT KdbHwBreakPoints[KDB_MAXIMUM_HW_BREAKPOINT_COUNT]; /* Enabled hardware breakpoints, orderless */
+static PKDB_BREAKPOINT KdbBreakPointToReenable = NULL; /* Set to a breakpoint struct when single stepping after
a software breakpoint was hit, to reenable it */
LONG KdbLastBreakPointNr = -1; /* Index of the breakpoint which cause KDB to be entered */
ULONG KdbNumSingleSteps = 0; /* How many single steps to do */
BOOLEAN KdbSingleStepOver = FALSE; /* Whether to step over calls/reps. */
ULONG KdbDebugState = 0; /* KDBG Settings (NOECHO, KDSERIAL) */
-STATIC BOOLEAN KdbEnteredOnSingleStep = FALSE; /* Set to true when KDB was entered because of single step */
+static BOOLEAN KdbEnteredOnSingleStep = FALSE; /* Set to true when KDB was entered because of single step */
PEPROCESS KdbCurrentProcess = NULL; /* The current process context in which KDB runs */
PEPROCESS KdbOriginalProcess = NULL; /* The process in whichs context KDB was intered */
PETHREAD KdbCurrentThread = NULL; /* The current thread context in which KDB runs */
PETHREAD KdbOriginalThread = NULL; /* The thread in whichs context KDB was entered */
PKDB_KTRAP_FRAME KdbCurrentTrapFrame = NULL; /* Pointer to the current trapframe */
-STATIC KDB_KTRAP_FRAME KdbTrapFrame = { { 0 } }; /* The trapframe which was passed to KdbEnterDebuggerException */
-STATIC KDB_KTRAP_FRAME KdbThreadTrapFrame = { { 0 } }; /* The trapframe of the current thread (KdbCurrentThread) */
-STATIC KAPC_STATE KdbApcState;
+static KDB_KTRAP_FRAME KdbTrapFrame = { { 0 } }; /* The trapframe which was passed to KdbEnterDebuggerException */
+static KDB_KTRAP_FRAME KdbThreadTrapFrame = { { 0 } }; /* The trapframe of the current thread (KdbCurrentThread) */
+static KAPC_STATE KdbApcState;
extern BOOLEAN KdbpBugCheckRequested;
/* Array of conditions when to enter KDB */
-STATIC KDB_ENTER_CONDITION KdbEnterConditions[][2] =
+static KDB_ENTER_CONDITION KdbEnterConditions[][2] =
{
/* First chance Last chance */
{ KdbDoNotEnter, KdbEnterFromKmode }, /* Zero devide */
};
/* Exception descriptions */
-STATIC CONST CHAR *ExceptionNrToString[] =
+static const CHAR *ExceptionNrToString[] =
{
"Divide Error",
"Debug Trap",
/* FUNCTIONS *****************************************************************/
-STATIC VOID
+static VOID
KdbpTrapFrameToKdbTrapFrame(PKTRAP_FRAME TrapFrame, PKDB_KTRAP_FRAME KdbTrapFrame)
{
ULONG TrapCr0, TrapCr2, TrapCr3, TrapCr4;
/* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */
}
-STATIC VOID
+static VOID
KdbpKdbTrapFrameToTrapFrame(PKDB_KTRAP_FRAME KdbTrapFrame, PKTRAP_FRAME TrapFrame)
{
/* Copy the TrapFrame only up to Eflags and zero the rest*/
/* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */
}
-STATIC VOID
+static VOID
KdbpKdbTrapFrameFromKernelStack(PVOID KernelStack,
PKDB_KTRAP_FRAME KdbTrapFrame)
{
RtlZeroMemory(KdbTrapFrame, sizeof(KDB_KTRAP_FRAME));
StackPtr = (ULONG_PTR *) KernelStack;
+#if _M_X86_
KdbTrapFrame->Tf.Ebp = StackPtr[3];
KdbTrapFrame->Tf.Edi = StackPtr[4];
KdbTrapFrame->Tf.Esi = StackPtr[5];
KdbTrapFrame->Tf.SegDs = KGDT_R0_DATA;
KdbTrapFrame->Tf.SegEs = KGDT_R0_DATA;
KdbTrapFrame->Tf.SegGs = KGDT_R0_DATA;
+#endif
/* FIXME: what about the other registers??? */
}
*
* \returns NTSTATUS
*/
-STATIC NTSTATUS
+static NTSTATUS
KdbpOverwriteInstruction(
IN PEPROCESS Process,
IN ULONG_PTR Address,
}
/* Get the interrupt descriptor */
- if (!NT_SUCCESS(KdbpSafeReadMemory(IntDesc, (PVOID)(Idtr.Base + (IntVect * 8)), sizeof (IntDesc))))
+ if (!NT_SUCCESS(KdbpSafeReadMemory(IntDesc, (PVOID)(ULONG_PTR)(Idtr.Base + (IntVect * 8)), sizeof (IntDesc))))
{
/*KdbpPrint("Couldn't access memory at 0x%p\n", (ULONG_PTR)Idtr.Base + (IntVect * 8));*/
return FALSE;
*
* \returns Breakpoint number, -1 on error.
*/
-STATIC LONG
+static LONG
KdbpIsBreakPointOurs(
IN NTSTATUS ExceptionCode,
IN PKTRAP_FRAME TrapFrame)
/* Get a pointer to the thread */
if (!NT_SUCCESS(PsLookupThreadByThreadId(ThreadId, &Thread)))
{
- KdbpPrint("Invalid thread id: 0x%08x\n", (ULONG)ThreadId);
+ KdbpPrint("Invalid thread id: 0x%08x\n", (ULONG_PTR)ThreadId);
return FALSE;
}
Process = Thread->ThreadsProcess;
/* Get a pointer to the process */
if (!NT_SUCCESS(PsLookupProcessByProcessId(ProcessId, &Process)))
{
- KdbpPrint("Invalid process id: 0x%08x\n", (ULONG)ProcessId);
+ KdbpPrint("Invalid process id: 0x%08x\n", (ULONG_PTR)ProcessId);
return FALSE;
}
ObDereferenceObject(Process);
if (Entry == &KdbCurrentProcess->ThreadListHead)
{
- KdbpPrint("No threads in process 0x%08x, cannot attach to process!\n", (ULONG)ProcessId);
+ KdbpPrint("No threads in process 0x%p, cannot attach to process!\n", ProcessId);
return FALSE;
}
/*!\brief Calls the main loop ...
*/
-STATIC VOID
-KdbpCallMainLoop()
+static VOID
+KdbpCallMainLoop(VOID)
{
KdbpCliMainLoop(KdbEnteredOnSingleStep);
}
*
* Disables interrupts, releases display ownership, ...
*/
-STATIC VOID
+static VOID
KdbpInternalEnter()
{
PETHREAD Thread;
SavedStackLimit = Thread->Tcb.StackLimit;
SavedKernelStack = Thread->Tcb.KernelStack;
Thread->Tcb.InitialStack = Thread->Tcb.StackBase = (char*)KdbStack + KDB_STACK_SIZE;
- Thread->Tcb.StackLimit = (ULONG)KdbStack;
+ Thread->Tcb.StackLimit = (ULONG_PTR)KdbStack;
Thread->Tcb.KernelStack = (char*)KdbStack + KDB_STACK_SIZE;
/*KdbpPrint("Switching to KDB stack 0x%08x-0x%08x (Current Stack is 0x%08x)\n", Thread->Tcb.StackLimit, Thread->Tcb.StackBase, Esp);*/
KbdEnableMouse();
}
-STATIC ULONG
+static ULONG
KdbpGetExceptionNumberFromStatus(IN NTSTATUS ExceptionCode)
{
ULONG Ret;
}
else
{
- CONST CHAR *ExceptionString = (ExpNr < RTL_NUMBER_OF(ExceptionNrToString)) ?
+ const CHAR *ExceptionString = (ExpNr < RTL_NUMBER_OF(ExceptionNrToString)) ?
(ExceptionNrToString[ExpNr]) :
("Unknown/User defined exception");