use inlined probing macros for basic types

svn path=/trunk/; revision=17466
This commit is contained in:
Thomas Bluemel 2005-08-21 17:38:07 +00:00
parent 632d85cc3b
commit 84f88f6480
9 changed files with 38 additions and 86 deletions

View file

@ -110,9 +110,7 @@ NtCreateEvent(OUT PHANDLE EventHandle,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(EventHandle, ProbeForWriteHandle(EventHandle);
sizeof(HANDLE),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();
@ -190,9 +188,7 @@ NtOpenEvent(OUT PHANDLE EventHandle,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(EventHandle, ProbeForWriteHandle(EventHandle);
sizeof(HANDLE),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();
@ -250,9 +246,7 @@ NtPulseEvent(IN HANDLE EventHandle,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(PreviousState, ProbeForWriteLong(PreviousState);
sizeof(LONG),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();
@ -386,9 +380,7 @@ NtResetEvent(IN HANDLE EventHandle,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(PreviousState, ProbeForWriteLong(PreviousState);
sizeof(LONG),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();
@ -453,9 +445,7 @@ NtSetEvent(IN HANDLE EventHandle,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(PreviousState, ProbeForWriteLong(PreviousState);
sizeof(LONG),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();

View file

@ -66,13 +66,11 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle,
DPRINT("NtCreateEventPair: 0x%p\n", EventPairHandle); DPRINT("NtCreateEventPair: 0x%p\n", EventPairHandle);
/* Check Output Safety */ /* Check Output Safety */
if(PreviousMode == UserMode) { if(PreviousMode != KernelMode) {
_SEH_TRY { _SEH_TRY {
ProbeForWrite(EventPairHandle, ProbeForWriteHandle(EventPairHandle);
sizeof(HANDLE),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();
@ -142,13 +140,11 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle,
PAGED_CODE(); PAGED_CODE();
/* Check Output Safety */ /* Check Output Safety */
if(PreviousMode == UserMode) { if(PreviousMode != KernelMode) {
_SEH_TRY { _SEH_TRY {
ProbeForWrite(EventPairHandle, ProbeForWriteHandle(EventPairHandle);
sizeof(HANDLE),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();

View file

@ -90,13 +90,11 @@ NtCreateMutant(OUT PHANDLE MutantHandle,
DPRINT("NtCreateMutant(0x%p, 0x%x, 0x%p)\n", MutantHandle, DesiredAccess, ObjectAttributes); DPRINT("NtCreateMutant(0x%p, 0x%x, 0x%p)\n", MutantHandle, DesiredAccess, ObjectAttributes);
/* Check Output Safety */ /* Check Output Safety */
if(PreviousMode == UserMode) { if(PreviousMode != KernelMode) {
_SEH_TRY { _SEH_TRY {
ProbeForWrite(MutantHandle, ProbeForWriteHandle(MutantHandle);
sizeof(HANDLE),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();
@ -169,13 +167,11 @@ NtOpenMutant(OUT PHANDLE MutantHandle,
DPRINT("NtOpenMutant(0x%p, 0x%x, 0x%p)\n", MutantHandle, DesiredAccess, ObjectAttributes); DPRINT("NtOpenMutant(0x%p, 0x%x, 0x%p)\n", MutantHandle, DesiredAccess, ObjectAttributes);
/* Check Output Safety */ /* Check Output Safety */
if(PreviousMode == UserMode) { if(PreviousMode != KernelMode) {
_SEH_TRY { _SEH_TRY {
ProbeForWrite(MutantHandle, ProbeForWriteHandle(MutantHandle);
sizeof(HANDLE),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();
@ -305,9 +301,7 @@ NtReleaseMutant(IN HANDLE MutantHandle,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(PreviousCount, ProbeForWriteLong(PreviousCount);
sizeof(LONG),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();

View file

@ -126,9 +126,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(ProfileHandle, ProbeForWriteHandle(ProfileHandle);
sizeof(HANDLE),
sizeof(ULONG));
ProbeForWrite(Buffer, ProbeForWrite(Buffer,
BufferSize, BufferSize,
@ -238,13 +236,9 @@ NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(PerformanceCounter, ProbeForWriteLargeInteger(PerformanceCounter);
sizeof(LARGE_INTEGER),
sizeof(ULONG));
ProbeForWrite(PerformanceFrequency, ProbeForWriteLargeInteger(PerformanceFrequency);
sizeof(LARGE_INTEGER),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode(); Status = _SEH_GetExceptionCode();
@ -412,9 +406,7 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
_SEH_TRY { _SEH_TRY {
ProbeForWrite(Interval, ProbeForWriteUlong(Interval);
sizeof(ULONG),
sizeof(ULONG));
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {

View file

@ -76,9 +76,7 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle,
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForWrite(SemaphoreHandle, ProbeForWriteHandle(SemaphoreHandle);
sizeof(HANDLE),
sizeof(ULONG));
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{ {
@ -162,9 +160,7 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle,
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForWrite(SemaphoreHandle, ProbeForWriteHandle(SemaphoreHandle);
sizeof(HANDLE),
sizeof(ULONG));
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{ {
@ -289,9 +285,7 @@ NtReleaseSemaphore(IN HANDLE SemaphoreHandle,
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForWrite(PreviousCount, ProbeForWriteLong(PreviousCount);
sizeof(LONG),
sizeof(ULONG));
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{ {

View file

@ -137,9 +137,7 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName,
sizeof(WCHAR)); sizeof(WCHAR));
if(ReturnLength != NULL) if(ReturnLength != NULL)
{ {
ProbeForWrite(ReturnLength, ProbeForWriteUlong(ReturnLength);
sizeof(ULONG),
sizeof(ULONG));
} }
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
@ -1548,7 +1546,7 @@ NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
/* SystemKernelDebuggerInformation needs only BOOLEAN alignment */ /* SystemKernelDebuggerInformation needs only BOOLEAN alignment */
ProbeForWrite(SystemInformation, Length, 1); ProbeForWrite(SystemInformation, Length, 1);
if (UnsafeResultLength != NULL) if (UnsafeResultLength != NULL)
ProbeForWrite(UnsafeResultLength, sizeof(ULONG), sizeof(ULONG)); ProbeForWriteUlong(UnsafeResultLength);
} }
/* Clear user buffer. */ /* Clear user buffer. */

View file

@ -161,15 +161,10 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForRead(SystemTime, NewSystemTime = ProbeForReadLargeInteger(SystemTime);
sizeof(LARGE_INTEGER),
sizeof(ULONG));
NewSystemTime = *SystemTime;
if(PreviousTime != NULL) if(PreviousTime != NULL)
{ {
ProbeForWrite(PreviousTime, ProbeForWriteLargeInteger(PreviousTime);
sizeof(LARGE_INTEGER),
sizeof(ULONG));
} }
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
@ -246,9 +241,7 @@ NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForRead(SystemTime, ProbeForWriteLargeInteger(SystemTime);
sizeof(LARGE_INTEGER),
sizeof(ULONG));
/* it's safe to pass the pointer directly to KeQuerySystemTime as it's just /* 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 a basic copy to these pointer, if it raises an exception nothing dangerous

View file

@ -271,9 +271,7 @@ NtCancelTimer(IN HANDLE TimerHandle,
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForWrite(CurrentState, ProbeForWriteBoolean(CurrentState);
sizeof(BOOLEAN),
sizeof(BOOLEAN));
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{ {
@ -403,9 +401,7 @@ NtCreateTimer(OUT PHANDLE TimerHandle,
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForWrite(TimerHandle, ProbeForWriteHandle(TimerHandle);
sizeof(HANDLE),
sizeof(ULONG));
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{ {
@ -493,9 +489,7 @@ NtOpenTimer(OUT PHANDLE TimerHandle,
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForWrite(TimerHandle, ProbeForWriteHandle(TimerHandle);
sizeof(HANDLE),
sizeof(ULONG));
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{ {
@ -633,16 +627,11 @@ NtSetTimer(IN HANDLE TimerHandle,
{ {
_SEH_TRY _SEH_TRY
{ {
ProbeForRead(DueTime, TimerDueTime = ProbeForReadLargeInteger(DueTime);
sizeof(LARGE_INTEGER),
sizeof(ULONG));
TimerDueTime = *DueTime;
if(PreviousState) if(PreviousState)
{ {
ProbeForWrite(PreviousState, ProbeForWriteBoolean(PreviousState);
sizeof(BOOLEAN),
sizeof(BOOLEAN));
} }
} }
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter) _SEH_EXCEPT(_SEH_ExSystemExceptionFilter)

View file

@ -106,6 +106,7 @@ RtlReleaseCapturedUnicodeString(
*(volatile Type *)(Ptr) = *(volatile Type *)(Ptr); \ *(volatile Type *)(Ptr) = *(volatile Type *)(Ptr); \
} while (0) } while (0)
#define ProbeForWriteBoolean(Ptr) ProbeForWriteGenericType(Ptr, BOOLEAN)
#define ProbeForWriteUchar(Ptr) ProbeForWriteGenericType(Ptr, UCHAR) #define ProbeForWriteUchar(Ptr) ProbeForWriteGenericType(Ptr, UCHAR)
#define ProbeForWriteChar(Ptr) ProbeForWriteGenericType(Ptr, Char) #define ProbeForWriteChar(Ptr) ProbeForWriteGenericType(Ptr, Char)
#define ProbeForWriteUshort(Ptr) ProbeForWriteGenericType(Ptr, USHORT) #define ProbeForWriteUshort(Ptr) ProbeForWriteGenericType(Ptr, USHORT)
@ -120,13 +121,16 @@ RtlReleaseCapturedUnicodeString(
#define ProbeForWritePointer(Ptr) ProbeForWriteGenericType(Ptr, PVOID) #define ProbeForWritePointer(Ptr) ProbeForWriteGenericType(Ptr, PVOID)
#define ProbeForWriteHandle(Ptr) ProbeForWriteGenericType(Ptr, HANDLE) #define ProbeForWriteHandle(Ptr) ProbeForWriteGenericType(Ptr, HANDLE)
#define ProbeForWriteLangid(Ptr) ProbeForWriteGenericType(Ptr, LANGID) #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) \ #define ProbeForReadGenericType(Ptr, Type, Default) \
(((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) || \ (((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) || \
(ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) ? \ (ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) ? \
ExRaiseStatus (STATUS_ACCESS_VIOLATION), Default : \ 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 ProbeForReadUchar(Ptr) ProbeForReadGenericType(Ptr, UCHAR, 0)
#define ProbeForReadChar(Ptr) ProbeForReadGenericType(Ptr, CHAR, 0) #define ProbeForReadChar(Ptr) ProbeForReadGenericType(Ptr, CHAR, 0)
#define ProbeForReadUshort(Ptr) ProbeForReadGenericType(Ptr, USHORT, 0) #define ProbeForReadUshort(Ptr) ProbeForReadGenericType(Ptr, USHORT, 0)
@ -140,6 +144,8 @@ RtlReleaseCapturedUnicodeString(
#define ProbeForReadPointer(Ptr) ProbeForReadGenericType(Ptr, PVOID, NULL) #define ProbeForReadPointer(Ptr) ProbeForReadGenericType(Ptr, PVOID, NULL)
#define ProbeForReadHandle(Ptr) ProbeForReadGenericType(Ptr, HANDLE, NULL) #define ProbeForReadHandle(Ptr) ProbeForReadGenericType(Ptr, HANDLE, NULL)
#define ProbeForReadLangid(Ptr) ProbeForReadGenericType(Ptr, LANGID, 0) #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 #endif