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

View file

@ -66,13 +66,11 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle,
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 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle,
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();

View file

@ -90,13 +90,11 @@ NtCreateMutant(OUT PHANDLE MutantHandle,
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 @@ NtOpenMutant(OUT PHANDLE MutantHandle,
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 @@ NtReleaseMutant(IN HANDLE MutantHandle,
_SEH_TRY {
ProbeForWrite(PreviousCount,
sizeof(LONG),
sizeof(ULONG));
ProbeForWriteLong(PreviousCount);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {
Status = _SEH_GetExceptionCode();

View file

@ -126,9 +126,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
_SEH_TRY {
ProbeForWrite(ProfileHandle,
sizeof(HANDLE),
sizeof(ULONG));
ProbeForWriteHandle(ProfileHandle);
ProbeForWrite(Buffer,
BufferSize,
@ -238,13 +236,9 @@ NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter,
_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 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
_SEH_TRY {
ProbeForWrite(Interval,
sizeof(ULONG),
sizeof(ULONG));
ProbeForWriteUlong(Interval);
} _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) {

View file

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

View file

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

View file

@ -161,15 +161,10 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
{
_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 @@ NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
{
_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

View file

@ -271,9 +271,7 @@ NtCancelTimer(IN HANDLE TimerHandle,
{
_SEH_TRY
{
ProbeForWrite(CurrentState,
sizeof(BOOLEAN),
sizeof(BOOLEAN));
ProbeForWriteBoolean(CurrentState);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
@ -403,9 +401,7 @@ NtCreateTimer(OUT PHANDLE TimerHandle,
{
_SEH_TRY
{
ProbeForWrite(TimerHandle,
sizeof(HANDLE),
sizeof(ULONG));
ProbeForWriteHandle(TimerHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
@ -493,9 +489,7 @@ NtOpenTimer(OUT PHANDLE TimerHandle,
{
_SEH_TRY
{
ProbeForWrite(TimerHandle,
sizeof(HANDLE),
sizeof(ULONG));
ProbeForWriteHandle(TimerHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
@ -633,16 +627,11 @@ NtSetTimer(IN HANDLE TimerHandle,
{
_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)

View file

@ -106,6 +106,7 @@ RtlReleaseCapturedUnicodeString(
*(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 @@ RtlReleaseCapturedUnicodeString(
#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 @@ RtlReleaseCapturedUnicodeString(
#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