Author: greatlrd
Date: Sun Mar 4 02:45:23 2007
New Revision: 25979
URL:
http://svn.reactos.org/svn/reactos?rev=25979&view=rev
Log:
merge down 25795 and 25796
Modified:
branches/ros-branch-0_3_1/reactos/include/ndk/kdtypes.h
branches/ros-branch-0_3_1/reactos/ntoskrnl/include/internal/i386/asmmacro.S
branches/ros-branch-0_3_1/reactos/ntoskrnl/kd/kdmain.c
branches/ros-branch-0_3_1/reactos/ntoskrnl/ke/i386/exp.c
branches/ros-branch-0_3_1/reactos/ntoskrnl/ke/i386/trap.s
Modified: branches/ros-branch-0_3_1/reactos/include/ndk/kdtypes.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/includ…
==============================================================================
--- branches/ros-branch-0_3_1/reactos/include/ndk/kdtypes.h (original)
+++ branches/ros-branch-0_3_1/reactos/include/ndk/kdtypes.h Sun Mar 4 02:45:23 2007
@@ -52,6 +52,7 @@
#define BREAKPOINT_PROMPT 2
#define BREAKPOINT_LOAD_SYMBOLS 3
#define BREAKPOINT_UNLOAD_SYMBOLS 4
+#define BREAKPOINT_COMMAND_STRING 5
//
// Debug Control Codes for NtSystemDebugcontrol
Modified: branches/ros-branch-0_3_1/reactos/ntoskrnl/include/internal/i386/asmmacro.S
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/ntoskr…
==============================================================================
--- branches/ros-branch-0_3_1/reactos/ntoskrnl/include/internal/i386/asmmacro.S
(original)
+++ branches/ros-branch-0_3_1/reactos/ntoskrnl/include/internal/i386/asmmacro.S Sun Mar 4
02:45:23 2007
@@ -304,7 +304,7 @@
/* Set them */
mov dr6, ebx
mov dr7, ecx
- jz 3f
+ jmp 3f
.endm
//
@@ -482,12 +482,12 @@
/* Flush DR7 */
and dword ptr [ebp+KTRAP_FRAME_DR7], 0
-3:
/* Check if the thread was being debugged */
test byte ptr [ecx+KTHREAD_DEBUG_ACTIVE], 0xFF
jnz Dr_&Label
/* Set the Trap Frame Debug Header */
+3:
SET_TF_DEBUG_HEADER
.endm
@@ -1171,7 +1171,7 @@
mov dr3, esi
mov dr6, edi
mov dr7, ebx
- jz 4b
+ jmp 4b
7:
/* Restore real CS value */
Modified: branches/ros-branch-0_3_1/reactos/ntoskrnl/kd/kdmain.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/ntoskr…
==============================================================================
--- branches/ros-branch-0_3_1/reactos/ntoskrnl/kd/kdmain.c (original)
+++ branches/ros-branch-0_3_1/reactos/ntoskrnl/kd/kdmain.c Sun Mar 4 02:45:23 2007
@@ -107,8 +107,29 @@
{
KD_CONTINUE_TYPE Return;
- /* HACK (just like all this routine */
- if (ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) Context->Eip++;
+ ULONG ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
+
+ /* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
+ if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
+ (ExceptionRecord->NumberParameters > 0) &&
+ ((ExceptionCommand == BREAKPOINT_LOAD_SYMBOLS) ||
+ (ExceptionCommand == BREAKPOINT_UNLOAD_SYMBOLS) ||
+ (ExceptionCommand == BREAKPOINT_COMMAND_STRING) ||
+ (ExceptionCommand == BREAKPOINT_PRINT)))
+ {
+ /* Check if this is a debug print */
+ if (ExceptionCommand == BREAKPOINT_PRINT)
+ {
+ /* Print the string */
+ KdpServiceDispatcher(BREAKPOINT_PRINT,
+ (PVOID)ExceptionRecord->ExceptionInformation[1],
+ ExceptionRecord->ExceptionInformation[2]);
+ }
+
+ /* This we can handle: simply bump EIP */
+ Context->Eip++;
+ return TRUE;
+ }
/* Get out of here if the Debugger isn't connected */
if (KdDebuggerNotPresent) return FALSE;
Modified: branches/ros-branch-0_3_1/reactos/ntoskrnl/ke/i386/exp.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/ntoskr…
==============================================================================
--- branches/ros-branch-0_3_1/reactos/ntoskrnl/ke/i386/exp.c (original)
+++ branches/ros-branch-0_3_1/reactos/ntoskrnl/ke/i386/exp.c Sun Mar 4 02:45:23 2007
@@ -140,7 +140,7 @@
NewMask |= DR_MASK(DR7_OVERRIDE_V);
/* Set DR7 override */
- *DrMask = DR7_OVERRIDE_MASK;
+ *DrMask |= DR7_OVERRIDE_MASK;
}
else
{
@@ -210,10 +210,19 @@
KiEspToTrapFrame(IN PKTRAP_FRAME TrapFrame,
IN ULONG Esp)
{
- ULONG Previous = KiEspFromTrapFrame(TrapFrame);
+ KIRQL OldIrql;
+ ULONG Previous;
+
+ /* Raise to APC_LEVEL if needed */
+ OldIrql = KeGetCurrentIrql();
+ if (OldIrql < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
+
+ /* Get the old ESP */
+ Previous = KiEspFromTrapFrame(TrapFrame);
/* Check if this is user-mode or V86 */
- if ((TrapFrame->SegCs & MODE_MASK) || (TrapFrame->EFlags &
EFLAGS_V86_MASK))
+ if ((TrapFrame->SegCs & MODE_MASK) ||
+ (TrapFrame->EFlags & EFLAGS_V86_MASK))
{
/* Write it directly */
TrapFrame->HardwareEsp = Esp;
@@ -221,7 +230,11 @@
else
{
/* Don't allow ESP to be lowered, this is illegal */
- if (Esp < Previous) KeBugCheck(SET_OF_INVALID_CONTEXT);
+ if (Esp < Previous) KeBugCheckEx(SET_OF_INVALID_CONTEXT,
+ Esp,
+ Previous,
+ (ULONG_PTR)TrapFrame,
+ 0);
/* Create an edit frame, check if it was alrady */
if (!(TrapFrame->SegCs & FRAME_EDITED))
@@ -243,6 +256,9 @@
}
}
}
+
+ /* Restore IRQL */
+ if (OldIrql < APC_LEVEL) KeLowerIrql(OldIrql);
}
ULONG
@@ -316,12 +332,13 @@
PFX_SAVE_AREA FxSaveArea;
ULONG i;
BOOLEAN V86Switch = FALSE;
- KIRQL OldIrql = APC_LEVEL;
+ KIRQL OldIrql;
ULONG DrMask = 0;
PVOID SafeDr;
/* Do this at APC_LEVEL */
- if (KeGetCurrentIrql() < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
+ OldIrql = KeGetCurrentIrql();
+ if (OldIrql < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
/* Start with the basic Registers */
if ((ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL)
@@ -544,7 +561,7 @@
else
{
/* FIXME: Handle FPU Emulation */
- ASSERT(FALSE);
+ //ASSERT(FALSE);
}
}
@@ -600,11 +617,12 @@
FLOATING_SAVE_AREA UnalignedArea;
} FloatSaveBuffer;
FLOATING_SAVE_AREA *FloatSaveArea;
- KIRQL OldIrql = APC_LEVEL;
+ KIRQL OldIrql;
ULONG i;
/* Do this at APC_LEVEL */
- if (KeGetCurrentIrql() < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
+ OldIrql = KeGetCurrentIrql();
+ if (OldIrql < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
/* Start with the Control flags */
if ((Context->ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL)
@@ -817,11 +835,26 @@
/* Get a Context */
KeTrapFrameToContext(TrapFrame, ExceptionFrame, &Context);
- /* Fix up EIP */
- if (ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT)
- {
- /* Decrement EIP by one */
- Context.Eip--;
+ /* Look at our exception code */
+ switch (ExceptionRecord->ExceptionCode)
+ {
+ /* Breapoint */
+ case STATUS_BREAKPOINT:
+
+ /* Decrement EIP by one */
+ Context.Eip--;
+ break;
+
+ /* Internal exception */
+ case KI_EXCEPTION_ACCESS_VIOLATION:
+
+ /* Set correct code */
+ ExceptionRecord->ExceptionCode = STATUS_ACCESS_VIOLATION;
+ if (PreviousMode == UserMode)
+ {
+ /* FIXME: Handle no execute */
+ }
+ break;
}
/* Sanity check */
@@ -869,8 +902,8 @@
KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
ExceptionRecord->ExceptionCode,
(ULONG_PTR)ExceptionRecord->ExceptionAddress,
- ExceptionRecord->ExceptionInformation[0],
- ExceptionRecord->ExceptionInformation[1]);
+ (ULONG_PTR)TrapFrame,
+ 0);
}
else
{
@@ -995,8 +1028,8 @@
KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
ExceptionRecord->ExceptionCode,
(ULONG_PTR)ExceptionRecord->ExceptionAddress,
- ExceptionRecord->ExceptionInformation[0],
- ExceptionRecord->ExceptionInformation[1]);
+ (ULONG_PTR)TrapFrame,
+ 0);
}
Handled:
Modified: branches/ros-branch-0_3_1/reactos/ntoskrnl/ke/i386/trap.s
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/ntoskr…
==============================================================================
--- branches/ros-branch-0_3_1/reactos/ntoskrnl/ke/i386/trap.s (original)
+++ branches/ros-branch-0_3_1/reactos/ntoskrnl/ke/i386/trap.s Sun Mar 4 02:45:23 2007
@@ -11,6 +11,9 @@
#include <asm.h>
#include <internal/i386/asmmacro.S>
.intel_syntax noprefix
+
+#define Running 2
+#define WrDispatchInt 0x1F
/* GLOBALS *******************************************************************/
@@ -225,22 +228,6 @@
/* Copy the parameters */
rep movsd
-#ifdef DBG
- /*
- * The following lines are for the benefit of GDB. It will see the return
- * address of the "call ebx" below, find the last label before it and
- * thinks that that's the start of the function. It will then check to see
- * if it starts with a standard function prolog (push ebp, mov ebp,esp1).
- * When that standard function prolog is not found, it will stop the
- * stack backtrace. Since we do want to backtrace into usermode, let's
- * make GDB happy and create a standard prolog.
- */
-KiSystemService:
- push ebp
- mov ebp,esp
- pop ebp
-#endif
-
/* Do the System Call */
call ebx
@@ -479,50 +466,15 @@
TRAP_PROLOG kids
/* Increase EIP so we skip the INT3 */
- //inc dword ptr [ebp+KTRAP_FRAME_EIP]
+ inc dword ptr [ebp+KTRAP_FRAME_EIP]
/* Call debug service dispatcher */
mov eax, [ebp+KTRAP_FRAME_EAX]
mov ecx, [ebp+KTRAP_FRAME_ECX]
mov edx, [ebp+KTRAP_FRAME_EDX]
- /* Check for V86 mode */
- test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
- jnz NotUserMode
-
- /* Check if this is kernel or user-mode */
- test byte ptr [ebp+KTRAP_FRAME_CS], 1
- jz CallDispatch
- cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK
- jnz NotUserMode
-
- /* Re-enable interrupts */
-VdmProc:
- sti
-
- /* Call the debug routine */
-CallDispatch:
- mov esi, ecx
- mov edi, edx
- mov edx, eax
- mov ecx, 3
- push edi
- push esi
- push edx
- call _KdpServiceDispatcher@12
-
-NotUserMode:
-
- /* Get the current process */
- mov ebx, [fs:KPCR_CURRENT_THREAD]
- mov ebx, [ebx+KTHREAD_APCSTATE_PROCESS]
-
- /* Check if this is a VDM Process */
- //cmp dword ptr [ebx+EPROCESS_VDM_OBJECTS], 0
- //jz VdmProc
-
- /* Exit through common routine */
- jmp _Kei386EoiHelper@0
+ /* Jump to INT3 handler */
+ jmp PrepareInt3
.endfunc
.func NtRaiseException@12
@@ -652,7 +604,7 @@
/* Set the record in ECX and check if this was V86 */
mov ecx, esp
- test dword ptr [esp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
+ test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
jz SetPreviousMode
/* Set V86 mode */
@@ -661,9 +613,11 @@
SetPreviousMode:
- /* Calculate the previous mode */
+ /* Get the caller's CS */
mov eax, [ebp+KTRAP_FRAME_CS]
+
MaskMode:
+ /* Check if it was user-mode or kernel-mode */
and eax, MODE_MASK
/* Dispatch the exception */
@@ -816,7 +770,11 @@
/* Enter trap */
TRAP_PROLOG kit3
+ /* Set status code */
+ mov eax, 0 //STATUS_SUCCESS
+
/* Check for V86 */
+PrepareInt3:
test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
jnz V86Int3
@@ -833,6 +791,7 @@
sti
PrepInt3:
+
/* Prepare the exception */
mov esi, ecx
mov edi, edx
@@ -842,6 +801,7 @@
mov ebx, [ebp+KTRAP_FRAME_EIP]
dec ebx
mov ecx, 3
+ mov eax, STATUS_BREAKPOINT
call _CommonDispatchException
V86Int3:
@@ -2226,7 +2186,7 @@
/* Restore stack and exception list */
pop esp
- pop dword ptr [ebx]
+ pop dword ptr [ebx+KPCR_EXCEPTION_LIST]
pop ebp
CheckQuantum: