mirror of
https://github.com/reactos/reactos.git
synced 2024-08-02 17:40:58 +00:00
[NTOS]: Cleanup MiQueryAddressState.
svn path=/trunk/; revision=56516
This commit is contained in:
parent
747ae40486
commit
043a85aad1
|
@ -1308,7 +1308,7 @@ MiQueryAddressState(IN PVOID Va,
|
||||||
PMMPDE PointerPde;
|
PMMPDE PointerPde;
|
||||||
MMPTE TempPte;
|
MMPTE TempPte;
|
||||||
BOOLEAN DemandZeroPte = TRUE, ValidPte = FALSE;
|
BOOLEAN DemandZeroPte = TRUE, ValidPte = FALSE;
|
||||||
ULONG State = MEM_RESERVE, Protect = 0, LockChange;
|
ULONG State = MEM_RESERVE, Protect = 0;
|
||||||
ASSERT((Vad->StartingVpn <= ((ULONG_PTR)Va >> PAGE_SHIFT)) &&
|
ASSERT((Vad->StartingVpn <= ((ULONG_PTR)Va >> PAGE_SHIFT)) &&
|
||||||
(Vad->EndingVpn >= ((ULONG_PTR)Va >> PAGE_SHIFT)));
|
(Vad->EndingVpn >= ((ULONG_PTR)Va >> PAGE_SHIFT)));
|
||||||
|
|
||||||
|
@ -1322,31 +1322,23 @@ MiQueryAddressState(IN PVOID Va,
|
||||||
/* Return the next range */
|
/* Return the next range */
|
||||||
*NextVa = (PVOID)((ULONG_PTR)Va + PAGE_SIZE);
|
*NextVa = (PVOID)((ULONG_PTR)Va + PAGE_SIZE);
|
||||||
|
|
||||||
/* Loop to make sure the PDE is valid */
|
/* Is the PDE demand-zero? */
|
||||||
do
|
if (PointerPde->u.Long != 0)
|
||||||
{
|
{
|
||||||
/* Try again */
|
/* It is not. Is it valid? */
|
||||||
LockChange = 0;
|
if (PointerPde->u.Hard.Valid == 0)
|
||||||
|
|
||||||
/* Is the PDE empty? */
|
|
||||||
if (!PointerPde->u.Long)
|
|
||||||
{
|
{
|
||||||
/* No address in this range used yet, move to the next PDE range */
|
/* Is isn't, fault it in */
|
||||||
*NextVa = MiPdeToAddress(PointerPde + 1);
|
PointerPte = MiPteToAddress(PointerPde);
|
||||||
break;
|
MiMakeSystemAddressValid(PointerPte, TargetProcess);
|
||||||
|
ValidPte = TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* The PDE is not empty, but is it faulted in? */
|
else
|
||||||
if (!PointerPde->u.Hard.Valid)
|
{
|
||||||
{
|
/* It is, skip it and move to the next PDE */
|
||||||
/* It isn't, go ahead and do the fault */
|
*NextVa = MiPdeToAddress(PointerPde + 1);
|
||||||
LockChange = MiMakeSystemAddressValid(MiPdeToPte(PointerPde),
|
}
|
||||||
TargetProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the PDE was faulted in, making the PTE readable */
|
|
||||||
if (!LockChange) ValidPte = TRUE;
|
|
||||||
} while (LockChange);
|
|
||||||
|
|
||||||
/* Is it safe to try reading the PTE? */
|
/* Is it safe to try reading the PTE? */
|
||||||
if (ValidPte)
|
if (ValidPte)
|
||||||
|
@ -1355,27 +1347,38 @@ MiQueryAddressState(IN PVOID Va,
|
||||||
|
|
||||||
/* Capture the PTE */
|
/* Capture the PTE */
|
||||||
TempPte = *PointerPte;
|
TempPte = *PointerPte;
|
||||||
if (TempPte.u.Long)
|
if (TempPte.u.Long != 0)
|
||||||
{
|
{
|
||||||
/* The PTE is valid, so it's not zeroed out */
|
/* The PTE is valid, so it's not zeroed out */
|
||||||
DemandZeroPte = FALSE;
|
DemandZeroPte = FALSE;
|
||||||
|
|
||||||
/* Check if it's valid or has a valid protection mask */
|
/* Is it a decommited, invalid, or faulted PTE? */
|
||||||
ASSERT(TempPte.u.Soft.Prototype == 0);
|
if ((TempPte.u.Soft.Protection == MM_DECOMMIT) &&
|
||||||
if ((TempPte.u.Soft.Protection != MM_DECOMMIT) ||
|
(TempPte.u.Hard.Valid == 0) &&
|
||||||
(TempPte.u.Hard.Valid == 1))
|
((TempPte.u.Soft.Prototype == 0) ||
|
||||||
|
(TempPte.u.Soft.PageFileHigh == MI_PTE_LOOKUP_NEEDED)))
|
||||||
|
{
|
||||||
|
/* Otherwise our defaults should hold */
|
||||||
|
ASSERT(Protect == 0);
|
||||||
|
ASSERT(State == MEM_RESERVE);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* This means it's committed */
|
/* This means it's committed */
|
||||||
State = MEM_COMMIT;
|
State = MEM_COMMIT;
|
||||||
|
|
||||||
/* Get protection state of this page */
|
/* Get protection state of this page */
|
||||||
Protect = MiGetPageProtection(PointerPte);
|
Protect = MiGetPageProtection(PointerPte);
|
||||||
}
|
|
||||||
else
|
/* Check if this is an image-backed VAD */
|
||||||
{
|
if ((TempPte.u.Soft.Valid == 0) &&
|
||||||
/* Otherwise our defaults should hold */
|
(TempPte.u.Soft.Prototype == 1) &&
|
||||||
ASSERT(Protect == 0);
|
(Vad->u.VadFlags.PrivateMemory == 0) &&
|
||||||
ASSERT(State == MEM_RESERVE);
|
(Vad->ControlArea))
|
||||||
|
{
|
||||||
|
DPRINT1("Not supported\n");
|
||||||
|
ASSERT(FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1383,8 +1386,13 @@ MiQueryAddressState(IN PVOID Va,
|
||||||
/* Check if this was a demand-zero PTE, since we need to find the state */
|
/* Check if this was a demand-zero PTE, since we need to find the state */
|
||||||
if (DemandZeroPte)
|
if (DemandZeroPte)
|
||||||
{
|
{
|
||||||
/* Check if the VAD is for committed memory */
|
/* Check if this is private commited memory, or an image-backed VAD */
|
||||||
if (Vad->u.VadFlags.MemCommit)
|
if ((Vad->u.VadFlags.PrivateMemory == 0) && (Vad->ControlArea))
|
||||||
|
{
|
||||||
|
DPRINT1("Not supported\n");
|
||||||
|
ASSERT(FALSE);
|
||||||
|
}
|
||||||
|
else if (Vad->u.VadFlags.MemCommit)
|
||||||
{
|
{
|
||||||
/* This is committed memory */
|
/* This is committed memory */
|
||||||
State = MEM_COMMIT;
|
State = MEM_COMMIT;
|
||||||
|
|
Loading…
Reference in a new issue