Author: tkreuzer
Date: Wed Dec 23 22:38:46 2015
New Revision: 70416
URL: http://svn.reactos.org/svn/reactos?rev=70416&view=rev
Log:
[NTOS/KDBK]
Fix the value for EIP used by KDBG after an INT3 set by KDBG itself. The address is already fixed by KiDispatchException, but only in the context frame, not in the trap frame and KDBG insists to use the trap frame for a lot of things. Also, after a cont from such an int3, KDBG uses a single step to re-enable the breakpoint (it needs to disable it after it was hit to be able to execute the actual instruction), but it used to dismiss *any* single steps after that. So make sure, that an actual single step, as created by the debugger is not being dismissed, but the break point is still restored after the next single step entry. You might expect that a kernel debugger would at least support setting breakpoints, but this is KDBG.
Modified:
trunk/reactos/ntoskrnl/kdbg/kdb.c
Modified: trunk/reactos/ntoskrnl/kdbg/kdb.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb.c?rev=70…
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb.c [iso-8859-1] Wed Dec 23 22:38:46 2015
@@ -38,6 +38,7 @@
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 */
+static BOOLEAN KdbpEvenThoughWeHaveABreakPointToReenableWeAlsoHaveARealSingleStep;
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. */
@@ -1407,6 +1408,15 @@
KdbpPrint("Couldn't restore original instruction after INT3! Cannot continue execution.\n");
KeBugCheck(0); // FIXME: Proper bugcode!
}
+
+ /* Also since we are past the int3 now, decrement EIP in the
+ TrapFrame. This is only needed because KDBG insists on working
+ with the TrapFrame instead of with the Context, as it is supposed
+ to do. The context has already EIP point to the int3, since
+ KiDispatchException accounts for that. Whatever we do here with
+ the TrapFrame does not matter anyway, since KiDispatchException
+ will overwrite it with the values from the Context! */
+ TrapFrame->Eip--;
}
if ((BreakPoint->Type == KdbBreakPointHardware) &&
@@ -1427,8 +1437,6 @@
/* Delete the temporary breakpoint which was used to step over or into the instruction. */
KdbpDeleteBreakPoint(-1, BreakPoint);
-
- TrapFrame->Eip--;
if (--KdbNumSingleSteps > 0)
{
@@ -1520,8 +1528,14 @@
if (KdbNumSingleSteps == 0)
Context->EFlags &= ~EFLAGS_TF;
- goto continue_execution; /* return */
- }
+ if (!KdbpEvenThoughWeHaveABreakPointToReenableWeAlsoHaveARealSingleStep)
+ {
+ goto continue_execution; /* return */
+ }
+ }
+
+ /* Quoth the raven, 'Nevermore!' */
+ KdbpEvenThoughWeHaveABreakPointToReenableWeAlsoHaveARealSingleStep = FALSE;
/* Check if we expect a single step */
if ((TrapFrame->Dr6 & 0xf) == 0 && KdbNumSingleSteps > 0)
@@ -1645,6 +1659,9 @@
/* Check if we should single step */
if (KdbNumSingleSteps > 0)
{
+ /* Variable explains itself! */
+ KdbpEvenThoughWeHaveABreakPointToReenableWeAlsoHaveARealSingleStep = TRUE;
+
if ((KdbSingleStepOver && KdbpStepOverInstruction(KdbCurrentTrapFrame->Tf.Eip)) ||
(!KdbSingleStepOver && KdbpStepIntoInstruction(KdbCurrentTrapFrame->Tf.Eip)))
{
Author: gedmurphy
Date: Wed Dec 23 11:26:28 2015
New Revision: 70408
URL: http://svn.reactos.org/svn/reactos?rev=70408&view=rev
Log:
[NTOSKRNL]
- Raise the IRQL when enumerating device lists so it doesn't get edited mid-listing
- Don't hardcode the pointer size when checking the buffer size
Modified:
trunk/reactos/ntoskrnl/io/iomgr/device.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/device.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/device.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/device.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/device.c [iso-8859-1] Wed Dec 23 11:26:28 2015
@@ -1088,6 +1088,10 @@
{
ULONG ActualDevices = 1;
PDEVICE_OBJECT CurrentDevice = DriverObject->DeviceObject;
+ KIRQL OldIrql;
+
+ /* Raise to dispatch level */
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
/* Find out how many devices we'll enumerate */
while ((CurrentDevice = CurrentDevice->NextDevice)) ActualDevices++;
@@ -1099,13 +1103,14 @@
*ActualNumberDeviceObjects = ActualDevices;
/* Check if we can support so many */
- if ((ActualDevices * 4) > DeviceObjectListSize)
+ if ((ActualDevices * sizeof(PDEVICE_OBJECT)) > DeviceObjectListSize)
{
/* Fail because the buffer was too small */
+ KeLowerIrql(OldIrql);
return STATUS_BUFFER_TOO_SMALL;
}
- /* Check if the caller only wanted the size */
+ /* Check if the caller wanted the device list */
if (DeviceObjectList)
{
/* Loop through all the devices */
@@ -1123,6 +1128,9 @@
DeviceObjectList++;
}
}
+
+ /* Return back to previous IRQL */
+ KeLowerIrql(OldIrql);
/* Return the status */
return STATUS_SUCCESS;