[NTOSKRNL]

- Use SEH when copying values back to the caller from NtFreeVirtualMemory

svn path=/trunk/; revision=54569
This commit is contained in:
Cameron Gutman
2011-12-03 11:18:18 +00:00
parent 5ab217133c
commit 5c0462dfe2
+25 -7
View File
@@ -1033,11 +1033,11 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
/* Check for user-mode parameters */
if (PreviousMode != KernelMode)
{
/* Make sure they are writable */
ProbeForWritePointer(UBaseAddress);
ProbeForWriteUlong(URegionSize);
/* Make sure they are readable */
ProbeForReadPointer(UBaseAddress);
ProbeForReadUlong(URegionSize);
}
/* Capture their values */
PBaseAddress = *UBaseAddress;
PRegionSize = *URegionSize;
@@ -1183,9 +1183,27 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
goto unlock_deref_and_return;
}
/* Copy rounded values back in success case */
*UBaseAddress = BaseAddress;
*URegionSize = RegionSize;
/* Enter SEH */
_SEH2_TRY
{
/* Check for user-mode parameters */
if (PreviousMode != KernelMode)
{
/* Make sure they are writable */
ProbeForWritePointer(UBaseAddress);
ProbeForWriteUlong(URegionSize);
}
/* Copy rounded values back in success case */
*UBaseAddress = BaseAddress;
*URegionSize = RegionSize;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
DPRINT1("Failed to copy values back! (Status: 0x%x)\n", Status);
}
_SEH2_END;
unlock_deref_and_return:
MmUnlockAddressSpace(AddressSpace);