Author: hbelusca
Date: Sat Mar 14 01:45:50 2015
New Revision: 66671
URL:
http://svn.reactos.org/svn/reactos?rev=66671&view=rev
Log:
[NTVDM]
- cpu.c: Convert the faulting address to "real" (VM) address before calling the
exception handler.
- ems.c: Simplify code by using ARRAY_INDEX; some poiters should point to physical
memory.
- ems.c: Memory hook addresses should be "real".
- memory.c: Remove an extra MemFastMoveMemory call; really use IsListEmpty (was commented
by error in my previous commit).
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/cpu/cpu.c
trunk/reactos/subsystems/mvdm/ntvdm/ems.c
trunk/reactos/subsystems/mvdm/ntvdm/memory.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/cpu/cpu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cpu/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/cpu/cpu.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/cpu/cpu.c [iso-8859-1] Sat Mar 14 01:45:50 2015
@@ -139,7 +139,7 @@
EXCEPTION_EXECUTE_HANDLER)
{
BOOLEAN Writing = (LocalExceptionRecord.ExceptionInformation[0] == 1);
- ULONG FaultAddress = (ULONG)LocalExceptionRecord.ExceptionInformation[1];
+ ULONG FaultAddress =
(ULONG)PHYS_TO_REAL(LocalExceptionRecord.ExceptionInformation[1]);
/* Make sure this was an access violation */
ASSERT(LocalExceptionRecord.ExceptionCode == EXCEPTION_ACCESS_VIOLATION);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ems.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ems.…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/ems.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/ems.c [iso-8859-1] Sat Mar 14 01:45:50 2015
@@ -23,7 +23,7 @@
static ULONG BitmapBuffer[(EMS_TOTAL_PAGES + sizeof(ULONG) - 1) / sizeof(ULONG)];
static EMS_PAGE PageTable[EMS_TOTAL_PAGES];
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES];
-static PVOID Mapping[EMS_PHYSICAL_PAGES] = { NULL };
+static PVOID Mapping[EMS_PHYSICAL_PAGES] = {{NULL}};
/* PRIVATE FUNCTIONS **********************************************************/
@@ -42,7 +42,7 @@
Entry = Entry->Flink)
{
PEMS_PAGE PageEntry = (PEMS_PAGE)CONTAINING_RECORD(Entry, EMS_PAGE, Entry);
- ULONG PageNumber = (ULONG)(((ULONG_PTR)PageEntry - (ULONG_PTR)PageTable) /
sizeof(EMS_PAGE));
+ ULONG PageNumber = ARRAY_INDEX(PageEntry, PageTable);
/* Free the page */
RtlClearBits(&AllocBitmap, PageNumber, 1);
@@ -223,10 +223,10 @@
break;
}
- SourcePtr = (PUCHAR)(EMS_ADDRESS
- + ARRAY_INDEX(PageEntry, PageTable)
- * EMS_PAGE_SIZE
- + Data->SourceOffset);
+ SourcePtr = (PUCHAR)REAL_TO_PHYS(EMS_ADDRESS
+ + ARRAY_INDEX(PageEntry, PageTable)
+ * EMS_PAGE_SIZE
+ + Data->SourceOffset);
}
else
{
@@ -253,10 +253,10 @@
break;
}
- DestPtr = (PUCHAR)(EMS_ADDRESS
- + ARRAY_INDEX(PageEntry, PageTable)
- * EMS_PAGE_SIZE
- + Data->DestOffset);
+ DestPtr = (PUCHAR)REAL_TO_PHYS(EMS_ADDRESS
+ + ARRAY_INDEX(PageEntry, PageTable)
+ * EMS_PAGE_SIZE
+ + Data->DestOffset);
}
else
{
@@ -324,7 +324,7 @@
InitializeListHead(&HandleTable[i].PageList);
}
- MemInstallFastMemoryHook(SEG_OFF_TO_PTR(EMS_SEGMENT, 0),
+ MemInstallFastMemoryHook((PVOID)TO_LINEAR(EMS_SEGMENT, 0),
EMS_PHYSICAL_PAGES * EMS_PAGE_SIZE,
EmsReadMemory,
EmsWriteMemory);
@@ -334,6 +334,6 @@
VOID EmsCleanup(VOID)
{
- MemRemoveFastMemoryHook(SEG_OFF_TO_PTR(EMS_SEGMENT, 0),
+ MemRemoveFastMemoryHook((PVOID)TO_LINEAR(EMS_SEGMENT, 0),
EMS_PHYSICAL_PAGES * EMS_PAGE_SIZE);
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/memory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/memo…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/memory.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/memory.c [iso-8859-1] Sat Mar 14 01:45:50 2015
@@ -36,7 +36,7 @@
} MEM_HOOK, *PMEM_HOOK;
static LIST_ENTRY HookList;
-static PMEM_HOOK PageTable[TOTAL_PAGES];
+static PMEM_HOOK PageTable[TOTAL_PAGES] = {{NULL}};
/* PRIVATE FUNCTIONS **********************************************************/
@@ -144,8 +144,6 @@
ULONG i, Offset, Length;
ULONG FirstPage = Address >> 12;
ULONG LastPage = (Address + Size - 1) >> 12;
-
- MemFastMoveMemory(Buffer, REAL_TO_PHYS(Address), Size);
if (FirstPage == LastPage)
{
@@ -538,8 +536,7 @@
SIZE_T MemorySize = MAX_ADDRESS;
PLIST_ENTRY Pointer;
- // while (!IsListEmpty(&HookList))
- while (HookList.Flink != &HookList)
+ while (!IsListEmpty(&HookList))
{
Pointer = RemoveHeadList(&HookList);
RtlFreeHeap(RtlGetProcessHeap(), 0, CONTAINING_RECORD(Pointer, MEM_HOOK,
Entry));