Implemented ProbeForRead() and ProbeFor Write() (but no SEH yet).
authorEric Kohl <eric.kohl@reactos.org>
Thu, 14 Aug 2003 10:41:36 +0000 (10:41 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 14 Aug 2003 10:41:36 +0000 (10:41 +0000)
svn path=/trunk/; revision=5567

reactos/include/ddk/mmfuncs.h
reactos/ntoskrnl/mm/virtual.c
reactos/ntoskrnl/ntoskrnl.def
reactos/ntoskrnl/ntoskrnl.edf

index f78096b..c719655 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef _INCLUDE_DDK_MMFUNCS_H
 #define _INCLUDE_DDK_MMFUNCS_H
-/* $Id: mmfuncs.h,v 1.16 2003/06/19 17:13:27 gvg Exp $ */
+/* $Id: mmfuncs.h,v 1.17 2003/08/14 10:40:08 ekohl Exp $ */
 /* MEMORY MANAGMENT ******************************************************/
 
 
@@ -550,4 +550,17 @@ STDCALL
 MmUnsecureVirtualMemory (
        PVOID   SecureMem
        );
-#endif
+
+VOID STDCALL
+ProbeForRead (IN PVOID Address,
+             IN ULONG Length,
+             IN ULONG Alignment);
+
+VOID STDCALL
+ProbeForWrite (IN PVOID Address,
+              IN ULONG Length,
+              IN ULONG Alignment);
+
+#endif /* _INCLUDE_DDK_MMFUNCS_H */
+
+/* EOF */
index d7bca76..41acfd5 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: virtual.c,v 1.68 2003/07/11 01:23:15 royce Exp $
+/* $Id: virtual.c,v 1.69 2003/08/14 10:40:51 ekohl Exp $
  *
  * PROJECT:     ReactOS kernel
  * FILE:        ntoskrnl/mm/virtual.c
@@ -333,7 +333,7 @@ NtWriteVirtualMemory(IN     HANDLE  ProcessHandle,
    ObDereferenceObject(Process);
 
    if (Mdl->MappedSystemVa != NULL)
-     {      
+     {
        MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
      }
    MmUnlockPages(Mdl);
@@ -378,4 +378,66 @@ MmUnsecureVirtualMemory(PVOID SecureMem)
   UNIMPLEMENTED;
 }
 
+
+/*
+ * @implemented
+ */
+VOID STDCALL
+ProbeForRead (IN PVOID Address,
+             IN ULONG Length,
+             IN ULONG Alignment)
+{
+  assert (Alignment ==1 || Alignment == 2 || Alignment == 4 || Alignment == 8);
+
+  if (Length == 0)
+    return;
+
+  if (((ULONG_PTR)Address & (Alignment - 1)) != 0)
+    {
+      ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT);
+    }
+  else if ((ULONG_PTR)Address + Length < (ULONG_PTR)Address ||
+          (ULONG_PTR)Address + Length > (ULONG_PTR)MmUserProbeAddress)
+    {
+      ExRaiseStatus (STATUS_ACCESS_VIOLATION);
+    }
+}
+
+
+/*
+ * @implemented
+ */
+VOID STDCALL
+ProbeForWrite (IN PVOID Address,
+              IN ULONG Length,
+              IN ULONG Alignment)
+{
+  PULONG Ptr;
+  ULONG x;
+  ULONG i;
+
+  assert (Alignment ==1 || Alignment == 2 || Alignment == 4 || Alignment == 8);
+
+  if (Length == 0)
+    return;
+
+  if (((ULONG_PTR)Address & (Alignment - 1)) != 0)
+    {
+      ExRaiseStatus (STATUS_DATATYPE_MISALIGNMENT);
+    }
+  else if ((ULONG_PTR)Address + Length < (ULONG_PTR)Address ||
+          (ULONG_PTR)Address + Length > (ULONG_PTR)MmUserProbeAddress)
+    {
+      ExRaiseStatus (STATUS_ACCESS_VIOLATION);
+    }
+
+  /* Check for accessible pages */
+  for (i = 0; i < Length; i += PAGE_SIZE)
+    {
+      Ptr = (PULONG)(((ULONG_PTR)Address & ~(PAGE_SIZE - 1)) + i);
+      x = *Ptr;
+      *Ptr = x;
+    }
+}
+
 /* EOF */
index 8236f58..0db45e8 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntoskrnl.def,v 1.160 2003/08/11 18:50:12 chorns Exp $
+; $Id: ntoskrnl.def,v 1.161 2003/08/14 10:41:36 ekohl Exp $
 ;
 ; reactos/ntoskrnl/ntoskrnl.def
 ;
@@ -640,7 +640,8 @@ PoSetPowerState@12
 PoSetSystemState@4
 PoStartNextPowerIrp@4
 PoUnregisterSystemState@4
-;ProbeForWrite@12
+ProbeForRead@12
+ProbeForWrite@12
 PsAssignImpersonationToken@8
 ;PsChargePoolQuota@12
 PsCreateSystemProcess@12
index 6786302..eaa043c 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntoskrnl.edf,v 1.148 2003/08/11 18:50:12 chorns Exp $
+; $Id: ntoskrnl.edf,v 1.149 2003/08/14 10:41:36 ekohl Exp $
 ;
 ; reactos/ntoskrnl/ntoskrnl.def
 ;
@@ -639,7 +639,8 @@ PoSetPowerState=PoSetPowerState@12
 PoSetSystemState=PoSetSystemState@4
 PoStartNextPowerIrp=PoStartNextPowerIrp@4
 PoUnregisterSystemState=PoUnregisterSystemState@4
-;ProbeForWrite=ProbeForWrite@12
+ProbeForRead=ProbeForRead@12
+ProbeForWrite=ProbeForWrite@12
 PsAssignImpersonationToken=PsAssignImpersonationToken@8
 ;PsChargePoolQuota=PsChargePoolQuota@12
 PsCreateSystemProcess=PsCreateSystemProcess@12