Author: cgutman
Date: Sat Dec 3 11:18:18 2011
New Revision: 54569
URL:
http://svn.reactos.org/svn/reactos?rev=54569&view=rev
Log:
[NTOSKRNL]
- Use SEH when copying values back to the caller from NtFreeVirtualMemory
Modified:
trunk/reactos/ntoskrnl/mm/anonmem.c
Modified: trunk/reactos/ntoskrnl/mm/anonmem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/anonmem.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] Sat Dec 3 11:18:18 2011
@@ -1033,11 +1033,11 @@
/* 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 @@
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);