Author: akhaldi
Date: Tue Sep 10 22:21:52 2013
New Revision: 60021
URL:
http://svn.reactos.org/svn/reactos?rev=60021&view=rev
Log:
[NTOSKRNL]
* Fix the locking in MiQueryBasicInformation to cover ARM3 too, not just RosMm. This makes
sure we don't change the address space while querying it (or vice-versa).
* Don't attempt to query information for a terminated process (fixes some kernel32
loader winetests, matches Windows behavior).
* Brought to you by Alex Ionescu.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/virtual.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/virtual.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/virtual.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] Tue Sep 10 22:21:52 2013
@@ -1533,6 +1533,26 @@
KeStackAttachProcess(&TargetProcess->Pcb, &ApcState);
}
+ /* Lock the address space and make sure the process isn't already dead */
+ MmLockAddressSpace(&TargetProcess->Vm);
+ if (TargetProcess->VmDeleted)
+ {
+ /* Unlock the address space of the process */
+ MmUnlockAddressSpace(&TargetProcess->Vm);
+
+ /* Check if we were attached */
+ if (ProcessHandle != NtCurrentProcess())
+ {
+ /* Detach and dereference the process */
+ KeUnstackDetachProcess(&ApcState);
+ ObDereferenceObject(TargetProcess);
+ }
+
+ /* Bail out */
+ DPRINT1("Process is dying\n");
+ return STATUS_PROCESS_IS_TERMINATING;
+ }
+
/* Loop the VADs */
ASSERT(TargetProcess->VadRoot.NumberGenericTableElements);
if (TargetProcess->VadRoot.NumberGenericTableElements)
@@ -1609,6 +1629,9 @@
MemoryInfo.RegionSize = (PCHAR)MM_HIGHEST_VAD_ADDRESS + 1 - (PCHAR)Address;
}
+ /* Unlock the address space of the process */
+ MmUnlockAddressSpace(&TargetProcess->Vm);
+
/* Check if we were attached */
if (ProcessHandle != NtCurrentProcess())
{
@@ -1662,9 +1685,6 @@
{
MemoryInfo.Type = MEM_MAPPED;
}
-
- /* Lock the address space of the process */
- MmLockAddressSpace(&TargetProcess->Vm);
/* Find the memory area the specified address belongs to */
MemoryArea = MmLocateMemoryAreaByAddress(&TargetProcess->Vm, BaseAddress);