use inlined probing macros for basic types
Modified: trunk/reactos/ntoskrnl/ex/event.c
Modified: trunk/reactos/ntoskrnl/ex/evtpair.c
Modified: trunk/reactos/ntoskrnl/ex/mutant.c
Modified: trunk/reactos/ntoskrnl/ex/profile.c
Modified: trunk/reactos/ntoskrnl/ex/sem.c
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
Modified: trunk/reactos/ntoskrnl/ex/time.c
Modified: trunk/reactos/ntoskrnl/ex/timer.c
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
_____
Modified: trunk/reactos/ntoskrnl/ex/event.c
--- trunk/reactos/ntoskrnl/ex/event.c 2005-08-21 15:54:48 UTC (rev
17465)
+++ trunk/reactos/ntoskrnl/ex/event.c 2005-08-21 17:38:07 UTC (rev
17466)
@@ -110,9 +110,7 @@
_SEH_TRY {
- ProbeForWrite(EventHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(EventHandle);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
@@ -190,9 +188,7 @@
_SEH_TRY {
- ProbeForWrite(EventHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(EventHandle);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
@@ -250,9 +246,7 @@
_SEH_TRY {
- ProbeForWrite(PreviousState,
- sizeof(LONG),
- sizeof(ULONG));
+ ProbeForWriteLong(PreviousState);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
@@ -386,9 +380,7 @@
_SEH_TRY {
- ProbeForWrite(PreviousState,
- sizeof(LONG),
- sizeof(ULONG));
+ ProbeForWriteLong(PreviousState);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
@@ -453,9 +445,7 @@
_SEH_TRY {
- ProbeForWrite(PreviousState,
- sizeof(LONG),
- sizeof(ULONG));
+ ProbeForWriteLong(PreviousState);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
_____
Modified: trunk/reactos/ntoskrnl/ex/evtpair.c
--- trunk/reactos/ntoskrnl/ex/evtpair.c 2005-08-21 15:54:48 UTC (rev
17465)
+++ trunk/reactos/ntoskrnl/ex/evtpair.c 2005-08-21 17:38:07 UTC (rev
17466)
@@ -66,13 +66,11 @@
DPRINT("NtCreateEventPair: 0x%p\n", EventPairHandle);
/* Check Output Safety */
- if(PreviousMode == UserMode) {
+ if(PreviousMode != KernelMode) {
_SEH_TRY {
- ProbeForWrite(EventPairHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(EventPairHandle);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
@@ -142,13 +140,11 @@
PAGED_CODE();
/* Check Output Safety */
- if(PreviousMode == UserMode) {
+ if(PreviousMode != KernelMode) {
_SEH_TRY {
- ProbeForWrite(EventPairHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(EventPairHandle);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
_____
Modified: trunk/reactos/ntoskrnl/ex/mutant.c
--- trunk/reactos/ntoskrnl/ex/mutant.c 2005-08-21 15:54:48 UTC (rev
17465)
+++ trunk/reactos/ntoskrnl/ex/mutant.c 2005-08-21 17:38:07 UTC (rev
17466)
@@ -90,13 +90,11 @@
DPRINT("NtCreateMutant(0x%p, 0x%x, 0x%p)\n", MutantHandle,
DesiredAccess, ObjectAttributes);
/* Check Output Safety */
- if(PreviousMode == UserMode) {
+ if(PreviousMode != KernelMode) {
_SEH_TRY {
- ProbeForWrite(MutantHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(MutantHandle);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
@@ -169,13 +167,11 @@
DPRINT("NtOpenMutant(0x%p, 0x%x, 0x%p)\n", MutantHandle,
DesiredAccess, ObjectAttributes);
/* Check Output Safety */
- if(PreviousMode == UserMode) {
+ if(PreviousMode != KernelMode) {
_SEH_TRY {
- ProbeForWrite(MutantHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(MutantHandle);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
@@ -305,9 +301,7 @@
_SEH_TRY {
- ProbeForWrite(PreviousCount,
- sizeof(LONG),
- sizeof(ULONG));
+ ProbeForWriteLong(PreviousCount);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
_____
Modified: trunk/reactos/ntoskrnl/ex/profile.c
--- trunk/reactos/ntoskrnl/ex/profile.c 2005-08-21 15:54:48 UTC (rev
17465)
+++ trunk/reactos/ntoskrnl/ex/profile.c 2005-08-21 17:38:07 UTC (rev
17466)
@@ -126,9 +126,7 @@
_SEH_TRY {
- ProbeForWrite(ProfileHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(ProfileHandle);
ProbeForWrite(Buffer,
BufferSize,
@@ -238,13 +236,9 @@
_SEH_TRY {
- ProbeForWrite(PerformanceCounter,
- sizeof(LARGE_INTEGER),
- sizeof(ULONG));
+ ProbeForWriteLargeInteger(PerformanceCounter);
- ProbeForWrite(PerformanceFrequency,
- sizeof(LARGE_INTEGER),
- sizeof(ULONG));
+ ProbeForWriteLargeInteger(PerformanceFrequency);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();
@@ -412,9 +406,7 @@
_SEH_TRY {
- ProbeForWrite(Interval,
- sizeof(ULONG),
- sizeof(ULONG));
+ ProbeForWriteUlong(Interval);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
_____
Modified: trunk/reactos/ntoskrnl/ex/sem.c
--- trunk/reactos/ntoskrnl/ex/sem.c 2005-08-21 15:54:48 UTC (rev
17465)
+++ trunk/reactos/ntoskrnl/ex/sem.c 2005-08-21 17:38:07 UTC (rev
17466)
@@ -76,9 +76,7 @@
{
_SEH_TRY
{
- ProbeForWrite(SemaphoreHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(SemaphoreHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
@@ -162,9 +160,7 @@
{
_SEH_TRY
{
- ProbeForWrite(SemaphoreHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(SemaphoreHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
@@ -289,9 +285,7 @@
{
_SEH_TRY
{
- ProbeForWrite(PreviousCount,
- sizeof(LONG),
- sizeof(ULONG));
+ ProbeForWriteLong(PreviousCount);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
_____
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
--- trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-08-21 15:54:48 UTC (rev
17465)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c 2005-08-21 17:38:07 UTC (rev
17466)
@@ -137,9 +137,7 @@
sizeof(WCHAR));
if(ReturnLength != NULL)
{
- ProbeForWrite(ReturnLength,
- sizeof(ULONG),
- sizeof(ULONG));
+ ProbeForWriteUlong(ReturnLength);
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
@@ -1548,7 +1546,7 @@
/* SystemKernelDebuggerInformation needs only BOOLEAN
alignment */
ProbeForWrite(SystemInformation, Length, 1);
if (UnsafeResultLength != NULL)
- ProbeForWrite(UnsafeResultLength, sizeof(ULONG),
sizeof(ULONG));
+ ProbeForWriteUlong(UnsafeResultLength);
}
/* Clear user buffer. */
_____
Modified: trunk/reactos/ntoskrnl/ex/time.c
--- trunk/reactos/ntoskrnl/ex/time.c 2005-08-21 15:54:48 UTC (rev
17465)
+++ trunk/reactos/ntoskrnl/ex/time.c 2005-08-21 17:38:07 UTC (rev
17466)
@@ -161,15 +161,10 @@
{
_SEH_TRY
{
- ProbeForRead(SystemTime,
- sizeof(LARGE_INTEGER),
- sizeof(ULONG));
- NewSystemTime = *SystemTime;
+ NewSystemTime = ProbeForReadLargeInteger(SystemTime);
if(PreviousTime != NULL)
{
- ProbeForWrite(PreviousTime,
- sizeof(LARGE_INTEGER),
- sizeof(ULONG));
+ ProbeForWriteLargeInteger(PreviousTime);
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
@@ -246,9 +241,7 @@
{
_SEH_TRY
{
- ProbeForRead(SystemTime,
- sizeof(LARGE_INTEGER),
- sizeof(ULONG));
+ ProbeForWriteLargeInteger(SystemTime);
/* it's safe to pass the pointer directly to KeQuerySystemTime as
it's just
a basic copy to these pointer, if it raises an exception
nothing dangerous
_____
Modified: trunk/reactos/ntoskrnl/ex/timer.c
--- trunk/reactos/ntoskrnl/ex/timer.c 2005-08-21 15:54:48 UTC (rev
17465)
+++ trunk/reactos/ntoskrnl/ex/timer.c 2005-08-21 17:38:07 UTC (rev
17466)
@@ -271,9 +271,7 @@
{
_SEH_TRY
{
- ProbeForWrite(CurrentState,
- sizeof(BOOLEAN),
- sizeof(BOOLEAN));
+ ProbeForWriteBoolean(CurrentState);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
@@ -403,9 +401,7 @@
{
_SEH_TRY
{
- ProbeForWrite(TimerHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(TimerHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
@@ -493,9 +489,7 @@
{
_SEH_TRY
{
- ProbeForWrite(TimerHandle,
- sizeof(HANDLE),
- sizeof(ULONG));
+ ProbeForWriteHandle(TimerHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
@@ -633,16 +627,11 @@
{
_SEH_TRY
{
- ProbeForRead(DueTime,
- sizeof(LARGE_INTEGER),
- sizeof(ULONG));
- TimerDueTime = *DueTime;
+ TimerDueTime = ProbeForReadLargeInteger(DueTime);
if(PreviousState)
{
- ProbeForWrite(PreviousState,
- sizeof(BOOLEAN),
- sizeof(BOOLEAN));
+ ProbeForWriteBoolean(PreviousState);
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
_____
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
--- trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h 2005-08-21
15:54:48 UTC (rev 17465)
+++ trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h 2005-08-21
17:38:07 UTC (rev 17466)
@@ -106,6 +106,7 @@
*(volatile Type *)(Ptr) = *(volatile Type *)(Ptr);
\
} while (0)
+#define ProbeForWriteBoolean(Ptr) ProbeForWriteGenericType(Ptr,
BOOLEAN)
#define ProbeForWriteUchar(Ptr) ProbeForWriteGenericType(Ptr, UCHAR)
#define ProbeForWriteChar(Ptr) ProbeForWriteGenericType(Ptr, Char)
#define ProbeForWriteUshort(Ptr) ProbeForWriteGenericType(Ptr, USHORT)
@@ -120,13 +121,16 @@
#define ProbeForWritePointer(Ptr) ProbeForWriteGenericType(Ptr, PVOID)
#define ProbeForWriteHandle(Ptr) ProbeForWriteGenericType(Ptr, HANDLE)
#define ProbeForWriteLangid(Ptr) ProbeForWriteGenericType(Ptr, LANGID)
+#define ProbeForWriteLargeInteger(Ptr)
ProbeForWriteGenericType(&(Ptr)->QuadPart, LONGLONG)
+#define ProbeForWriteUlargeInteger(Ptr)
ProbeForWriteGenericType(&(Ptr)->QuadPart, ULONGLONG)
#define ProbeForReadGenericType(Ptr, Type, Default)
\
(((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) ||
\
(ULONG_PTR)(Ptr) + sizeof(Type) - 1 >=
(ULONG_PTR)MmUserProbeAddress) ? \
ExRaiseStatus (STATUS_ACCESS_VIOLATION), Default :
\
- *(volatile Type *)(Ptr))
+ *(Type *)(Ptr))
+#define ProbeForReadBoolean(Ptr) ProbeForReadGenericType(Ptr, BOOLEAN,
FALSE)
#define ProbeForReadUchar(Ptr) ProbeForReadGenericType(Ptr, UCHAR, 0)
#define ProbeForReadChar(Ptr) ProbeForReadGenericType(Ptr, CHAR, 0)
#define ProbeForReadUshort(Ptr) ProbeForReadGenericType(Ptr, USHORT, 0)
@@ -140,6 +144,8 @@
#define ProbeForReadPointer(Ptr) ProbeForReadGenericType(Ptr, PVOID,
NULL)
#define ProbeForReadHandle(Ptr) ProbeForReadGenericType(Ptr, HANDLE,
NULL)
#define ProbeForReadLangid(Ptr) ProbeForReadGenericType(Ptr, LANGID, 0)
+#define ProbeForReadLargeInteger(Ptr)
((LARGE_INTEGER)ProbeForReadGenericType(&(Ptr)->QuadPart, LONGLONG, 0))
+#define ProbeForReadUlargeInteger(Ptr)
((ULARGE_INTEGER)ProbeForReadGenericType(&(Ptr)->QuadPart, ULONGLONG,
0))
#endif