Implemented ProbeForRead() and ProbeFor Write() (but no SEH yet).

svn path=/trunk/; revision=5567
This commit is contained in:
Eric Kohl 2003-08-14 10:41:36 +00:00
parent ce57c8d26d
commit 1805517888
4 changed files with 85 additions and 8 deletions

View 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 */

View 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 */

View 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

View 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