Author: tkreuzer
Date: Sat Jul 9 14:15:47 2011
New Revision: 52582
URL: http://svn.reactos.org/svn/reactos?rev=52582&view=rev
Log:
[NTOSKRNL]
In MmDbgCopyMemory do physical memory copy, if the virtual target address is valid, but not writable. Fixes Step-Over on user mode addresses with WinDbg (can write break points now)
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/mmdbg.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/mmdbg.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mmdbg.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/mmdbg.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/mmdbg.c [iso-8859-1] Sat Jul 9 14:15:47 2011
@@ -150,6 +150,8 @@
{
NTSTATUS Status;
PVOID TargetAddress;
+ ULONG64 PhysicalAddress;
+ PMMPTE PointerPte;
//
// No local kernel debugging support yet, so don't worry about locking
@@ -238,34 +240,30 @@
// No session space support yet
//
ASSERT(MmIsSessionAddress(TargetAddress) == FALSE);
- }
-
- //
- // If we are going to write to the address then make sure it is writeable too
- //
- if ((Flags & MMDBG_COPY_WRITE) &&
- (!MI_IS_PAGE_WRITEABLE(MiAddressToPte(TargetAddress))))
- {
- //
- // Check if we mapped anything
- //
- if (Flags & MMDBG_COPY_PHYSICAL)
- {
- //
- // Get rid of the mapping
- //
- MiDbgUnTranslatePhysicalAddress();
- }
-
- //
- // Fail
- //
- // FIXME: We should attempt to override the write protection instead of
- // failing here
- //
- KdpDprintf("MmDbgCopyMemory: Failing Write for Protected Address 0x%p\n",
- TargetAddress);
- return STATUS_UNSUCCESSFUL;
+
+ /* If we are going to write to the address, then check if its writable */
+ PointerPte = MiAddressToPte(TargetAddress);
+ if ((Flags & MMDBG_COPY_WRITE) && !MI_IS_PAGE_WRITEABLE(PointerPte))
+ {
+ /* Not writable, we need to do a physical copy */
+ Flags |= MMDBG_COPY_PHYSICAL;
+
+ /* Calculate the physical address */
+ PhysicalAddress = PointerPte->u.Hard.PageFrameNumber << PAGE_SHIFT;
+ PhysicalAddress += BYTE_OFFSET(Address);
+
+ /* Translate the physical address */
+ TargetAddress = MiDbgTranslatePhysicalAddress(PhysicalAddress, Flags);
+
+ /* Check if translation failed */
+ if (!TargetAddress)
+ {
+ /* Fail */
+ KdpDprintf("MmDbgCopyMemory: Failed to translate for write "
+ "%I64x (%I64x)\n", PhysicalAddress, Address);
+ return STATUS_UNSUCCESSFUL;
+ }
+ }
}
//