[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.

svn path=/trunk/; revision=60021
This commit is contained in:
Amine Khaldi 2013-09-10 22:21:52 +00:00
parent a56630f977
commit 1abc05ae78

View file

@ -1533,6 +1533,26 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle,
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 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle,
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())
{
@ -1663,9 +1686,6 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle,
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);
ASSERT(MemoryArea != NULL);