mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
- Rework MiSyncThreadProcessViews
- Perform the Mm hack-sync in KiIdleLoop before switching context (thanks to Aleksey for writing this!) svn path=/trunk/; revision=35333
This commit is contained in:
parent
0a4815bc46
commit
ed3f476473
6 changed files with 31 additions and 41 deletions
|
@ -1552,16 +1552,12 @@ MmCheckSystemImage(
|
||||||
IN BOOLEAN PurgeSection
|
IN BOOLEAN PurgeSection
|
||||||
);
|
);
|
||||||
|
|
||||||
FORCEINLINE
|
/* ReactOS Mm Hack */
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
FASTCALL
|
||||||
MiSyncThreadProcessViews(IN PVOID Process,
|
MiSyncThreadProcessViews(
|
||||||
IN PVOID Address,
|
IN PKTHREAD NextThread
|
||||||
IN ULONG Size)
|
);
|
||||||
{
|
|
||||||
MmUpdatePageDir((PEPROCESS)Process, Address, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern PMM_AVL_TABLE MmKernelAddressSpace;
|
extern PMM_AVL_TABLE MmKernelAddressSpace;
|
||||||
|
|
||||||
|
|
|
@ -736,6 +736,10 @@ CheckNext:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SwapContext:
|
SwapContext:
|
||||||
|
/* ReactOS Mm Hack */
|
||||||
|
mov ecx, esi
|
||||||
|
call @MiSyncThreadProcessViews@4
|
||||||
|
|
||||||
/* Swap context at APC_LEVEL */
|
/* Swap context at APC_LEVEL */
|
||||||
mov ecx, APC_LEVEL
|
mov ecx, APC_LEVEL
|
||||||
call @KiSwapContextInternal@0
|
call @KiSwapContextInternal@0
|
||||||
|
|
|
@ -447,12 +447,8 @@ KeAttachProcess(IN PKPROCESS Process)
|
||||||
ASSERT_PROCESS(Process);
|
ASSERT_PROCESS(Process);
|
||||||
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
||||||
|
|
||||||
/* Make sure that we are in the right page directory */
|
/* Make sure that we are in the right page directory (ReactOS Mm Hack) */
|
||||||
MiSyncThreadProcessViews(Process,
|
MiSyncThreadProcessViews(Thread);
|
||||||
(PVOID)Thread->StackLimit,
|
|
||||||
Thread->LargeStack ?
|
|
||||||
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
|
|
||||||
MiSyncThreadProcessViews(Process, Thread, sizeof(ETHREAD));
|
|
||||||
|
|
||||||
/* Check if we're already in that process */
|
/* Check if we're already in that process */
|
||||||
if (Thread->ApcState.Process == Process) return;
|
if (Thread->ApcState.Process == Process) return;
|
||||||
|
@ -577,12 +573,8 @@ KeStackAttachProcess(IN PKPROCESS Process,
|
||||||
ASSERT_PROCESS(Process);
|
ASSERT_PROCESS(Process);
|
||||||
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
||||||
|
|
||||||
/* Make sure that we are in the right page directory */
|
/* Make sure that we are in the right page directory (ReactOS Mm Hack) */
|
||||||
MiSyncThreadProcessViews(Process,
|
MiSyncThreadProcessViews(Thread);
|
||||||
(PVOID)Thread->StackLimit,
|
|
||||||
Thread->LargeStack ?
|
|
||||||
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
|
|
||||||
MiSyncThreadProcessViews(Process, Thread, sizeof(ETHREAD));
|
|
||||||
|
|
||||||
/* Crash system if DPC is being executed! */
|
/* Crash system if DPC is being executed! */
|
||||||
if (KeIsExecutingDpc())
|
if (KeIsExecutingDpc())
|
||||||
|
|
|
@ -810,12 +810,8 @@ KeInitThread(IN OUT PKTHREAD Thread,
|
||||||
Thread->StackLimit = (ULONG_PTR)KernelStack - KERNEL_STACK_SIZE;
|
Thread->StackLimit = (ULONG_PTR)KernelStack - KERNEL_STACK_SIZE;
|
||||||
Thread->KernelStackResident = TRUE;
|
Thread->KernelStackResident = TRUE;
|
||||||
|
|
||||||
/* Make sure that we are in the right page directory */
|
/* Make sure that we are in the right page directory (ReactOS Mm Hack) */
|
||||||
MiSyncThreadProcessViews(Process,
|
MiSyncThreadProcessViews(Thread);
|
||||||
(PVOID)Thread->StackLimit,
|
|
||||||
Thread->LargeStack ?
|
|
||||||
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
|
|
||||||
MiSyncThreadProcessViews(Process, Thread, sizeof(ETHREAD));
|
|
||||||
|
|
||||||
/* Enter SEH to avoid crashes due to user mode */
|
/* Enter SEH to avoid crashes due to user mode */
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
|
@ -344,13 +344,7 @@ KiSwapThread(IN PKTHREAD CurrentThread,
|
||||||
WaitIrql = CurrentThread->WaitIrql;
|
WaitIrql = CurrentThread->WaitIrql;
|
||||||
|
|
||||||
/* REACTOS Mm Hack of Doom */
|
/* REACTOS Mm Hack of Doom */
|
||||||
MiSyncThreadProcessViews(PsGetCurrentProcess(),
|
MiSyncThreadProcessViews(NextThread);
|
||||||
((PETHREAD)NextThread)->ThreadsProcess,
|
|
||||||
sizeof(EPROCESS));
|
|
||||||
MiSyncThreadProcessViews(PsGetCurrentProcess(),
|
|
||||||
(PVOID)((PETHREAD)NextThread)->Tcb.StackLimit,
|
|
||||||
NextThread->LargeStack ?
|
|
||||||
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
|
|
||||||
|
|
||||||
/* Swap contexts */
|
/* Swap contexts */
|
||||||
ApcState = KiSwapContext(CurrentThread, NextThread);
|
ApcState = KiSwapContext(CurrentThread, NextThread);
|
||||||
|
@ -720,13 +714,7 @@ NtYieldExecution(VOID)
|
||||||
ASSERT(OldIrql <= DISPATCH_LEVEL);
|
ASSERT(OldIrql <= DISPATCH_LEVEL);
|
||||||
|
|
||||||
/* REACTOS Mm Hack of Doom */
|
/* REACTOS Mm Hack of Doom */
|
||||||
MiSyncThreadProcessViews(PsGetCurrentProcess(),
|
MiSyncThreadProcessViews(NextThread);
|
||||||
((PETHREAD)NextThread)->ThreadsProcess,
|
|
||||||
sizeof(EPROCESS));
|
|
||||||
MiSyncThreadProcessViews(PsGetCurrentProcess(),
|
|
||||||
(PVOID)((PETHREAD)NextThread)->Tcb.StackLimit,
|
|
||||||
NextThread->LargeStack ?
|
|
||||||
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
|
|
||||||
|
|
||||||
/* Swap to new thread */
|
/* Swap to new thread */
|
||||||
KiSwapContext(Thread, NextThread);
|
KiSwapContext(Thread, NextThread);
|
||||||
|
|
|
@ -24,6 +24,20 @@ MM_STATS MmStats;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
VOID
|
||||||
|
FASTCALL
|
||||||
|
MiSyncThreadProcessViews(IN PKTHREAD NextThread)
|
||||||
|
{
|
||||||
|
/* Hack Sync because Mm is broken */
|
||||||
|
MmUpdatePageDir(PsGetCurrentProcess(),
|
||||||
|
((PETHREAD)NextThread)->ThreadsProcess,
|
||||||
|
sizeof(EPROCESS));
|
||||||
|
MmUpdatePageDir(PsGetCurrentProcess(),
|
||||||
|
(PVOID)((PETHREAD)NextThread)->Tcb.StackLimit,
|
||||||
|
NextThread->LargeStack ?
|
||||||
|
KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue