added more irql checks

svn path=/trunk/; revision=13720
This commit is contained in:
Thomas Bluemel 2005-02-22 22:19:14 +00:00
parent 2c2b8c9796
commit 756ab632ca
12 changed files with 145 additions and 70 deletions

View file

@ -172,6 +172,8 @@ ExCreateCallback(
NTSTATUS Status;
HANDLE Handle;
PAGED_CODE();
/* Open a handle to the callback if it exists */
if (ObjectAttributes->ObjectName)
{
@ -347,6 +349,8 @@ ExRegisterCallback(
PCALLBACK_REGISTRATION CallbackRegistration = NULL;
KIRQL OldIrql;
PAGED_CODE();
/* Create reference to Callback Object */
ObReferenceObject (CallbackObject);
@ -412,6 +416,8 @@ ExUnregisterCallback(
PINT_CALLBACK_OBJECT CallbackObject;
KIRQL OldIrql;
PAGED_CODE();
/* Convert Handle to valid Structure Pointer */
CallbackRegistration = (PCALLBACK_REGISTRATION) CallbackRegistrationHandle;

View file

@ -88,6 +88,8 @@ NtClearEvent(IN HANDLE EventHandle)
PKEVENT Event;
NTSTATUS Status;
PAGED_CODE();
Status = ObReferenceObjectByHandle(EventHandle,
EVENT_MODIFY_STATE,
ExEventObjectType,
@ -119,6 +121,8 @@ NtCreateEvent(OUT PHANDLE EventHandle,
HANDLE hEvent;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode == UserMode)
@ -195,6 +199,8 @@ NtOpenEvent(OUT PHANDLE EventHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtOpenEvent(0x%x, 0x%x, 0x%x)\n", EventHandle, DesiredAccess, ObjectAttributes);
PreviousMode = ExGetPreviousMode();
@ -255,6 +261,8 @@ NtPulseEvent(IN HANDLE EventHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtPulseEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);
@ -323,6 +331,8 @@ NtQueryEvent(IN HANDLE EventHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
DefaultQueryInfoBufferCheck(EventInformationClass,
@ -396,6 +406,8 @@ NtResetEvent(IN HANDLE EventHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtResetEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);
@ -461,6 +473,8 @@ NtSetEvent(IN HANDLE EventHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtSetEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);

View file

@ -95,6 +95,8 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode == UserMode)
@ -169,6 +171,8 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode == UserMode)
@ -222,6 +226,8 @@ NtSetHighEventPair(IN HANDLE EventPairHandle)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetHighEventPair(EventPairHandle %x)\n",
EventPairHandle);
@ -253,6 +259,8 @@ NtSetHighWaitLowEventPair(IN HANDLE EventPairHandle)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetHighWaitLowEventPair(EventPairHandle %x)\n",
EventPairHandle);
@ -290,6 +298,8 @@ NtSetLowEventPair(IN HANDLE EventPairHandle)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetLowEventPair(EventPairHandle %x)\n",
EventPairHandle);
@ -321,6 +331,8 @@ NtSetLowWaitHighEventPair(IN HANDLE EventPairHandle)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetLowWaitHighEventPair(EventPairHandle %x)\n",
EventPairHandle);
@ -358,6 +370,8 @@ NtWaitLowEventPair(IN HANDLE EventPairHandle)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtWaitLowEventPair(EventPairHandle %x)\n",
EventPairHandle);
@ -391,6 +405,8 @@ NtWaitHighEventPair(IN HANDLE EventPairHandle)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtWaitHighEventPair(EventPairHandle %x)\n",
EventPairHandle);
@ -436,6 +452,8 @@ NtSetLowWaitHighThread(
NTSTATUS Status;
KIRQL Irql;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(!Thread->EventPair)
@ -490,6 +508,8 @@ NtSetHighWaitLowThread(
NTSTATUS Status;
KIRQL Irql;
PAGED_CODE();
Thread = PsGetCurrentThread();
if(!Thread->EventPair)

View file

@ -104,6 +104,8 @@ NtCreateMutant(OUT PHANDLE MutantHandle,
PKMUTEX Mutant;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode == UserMode)
@ -178,6 +180,8 @@ NtOpenMutant(OUT PHANDLE MutantHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtOpenMutant(0x%x, 0x%x, 0x%x)\n", MutantHandle, DesiredAccess, ObjectAttributes);
PreviousMode = ExGetPreviousMode();
@ -241,6 +245,8 @@ NtQueryMutant(IN HANDLE MutantHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
DefaultQueryInfoBufferCheck(MutantInformationClass,
@ -312,6 +318,8 @@ NtReleaseMutant(IN HANDLE MutantHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtReleaseMutant(MutantHandle 0%x PreviousCount 0%x)\n",
MutantHandle, PreviousCount);

View file

@ -109,6 +109,8 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(BufferSize == 0)
@ -271,6 +273,8 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode != KernelMode)
@ -329,6 +333,8 @@ NtStartProfile(IN HANDLE ProfileHandle)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
Status = ObReferenceObjectByHandle(ProfileHandle,
@ -353,6 +359,8 @@ NtStopProfile(IN HANDLE ProfileHandle)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
Status = ObReferenceObjectByHandle(ProfileHandle,

View file

@ -41,6 +41,8 @@ ExAcquireRundownProtectionEx (
{
ULONG_PTR PrevCount, Current;
PAGED_CODE();
Count <<= EX_RUNDOWN_COUNT_SHIFT;
/* Loop until successfully incremented the counter */
@ -74,6 +76,8 @@ ExInitializeRundownProtection (
IN PEX_RUNDOWN_REF RunRef
)
{
PAGED_CODE();
/* Set the count to zero */
RunRef->Count = 0;
}
@ -87,6 +91,8 @@ ExReInitializeRundownProtection (
IN PEX_RUNDOWN_REF RunRef
)
{
PAGED_CODE();
/* Reset the count */
#ifdef _WIN64
InterlockedExchangeAdd64((LONGLONG*)&RunRef->Count, 0LL);
@ -106,6 +112,8 @@ ExReleaseRundownProtectionEx (
IN ULONG Count
)
{
PAGED_CODE();
Count <<= EX_RUNDOWN_COUNT_SHIFT;
for (;;)
@ -200,7 +208,9 @@ ExRundownCompleted (
IN PEX_RUNDOWN_REF RunRef
)
{
/* mark the */
PAGED_CODE();
/* mark the counter as active */
#ifdef _WIN64
InterlockedExchange64((LONGLONG*)&RunRef->Count, (LONGLONG)EX_RUNDOWN_ACTIVE);
#else
@ -220,6 +230,8 @@ ExWaitForRundownProtectionRelease (
ULONG_PTR PrevCount, NewPtr, PrevPtr;
RUNDOWN_DESCRIPTOR RundownDescriptor;
PAGED_CODE();
PrevCount = RunRef->Count;
if (PrevCount != 0 && !(PrevCount & EX_RUNDOWN_ACTIVE))

View file

@ -92,6 +92,8 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode == UserMode)
@ -168,6 +170,8 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode == UserMode)
@ -228,6 +232,8 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
DefaultQueryInfoBufferCheck(SemaphoreInformationClass,
@ -299,6 +305,8 @@ NtReleaseSemaphore(IN HANDLE SemaphoreHandle,
PKSEMAPHORE Semaphore;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousCount != NULL && PreviousMode == UserMode)

View file

@ -101,6 +101,8 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode != KernelMode)
@ -246,6 +248,8 @@ NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
/*
@ -1372,6 +1376,8 @@ NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
NTSTATUS Status;
NTSTATUS FStatus;
PAGED_CODE();
/* DPRINT("NtQuerySystemInformation Start. Class:%d\n",
SystemInformationClass );
*/
@ -1448,6 +1454,8 @@ NtSetSystemInformation (
IN ULONG SystemInformationLength
)
{
PAGED_CODE();
/*
* If called from user mode, check
* possible unsafe arguments.
@ -1496,6 +1504,8 @@ NtFlushInstructionCache (
IN UINT NumberOfBytesToFlush
)
{
PAGED_CODE();
__asm__("wbinvd\n");
return STATUS_SUCCESS;
}

View file

@ -151,6 +151,8 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode != KernelMode)
@ -234,6 +236,8 @@ NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode != KernelMode)

View file

@ -209,12 +209,16 @@ NtCancelTimer(IN HANDLE TimerHandle,
OUT PBOOLEAN CurrentState OPTIONAL)
{
PETIMER Timer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
KPROCESSOR_MODE PreviousMode;
BOOLEAN State;
KIRQL OldIrql;
BOOLEAN KillTimer = FALSE;
PETHREAD TimerThread;
BOOLEAN KillTimer = FALSE;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
DPRINT("NtCancelTimer(0x%x, 0x%x)\n", TimerHandle, CurrentState);
@ -319,9 +323,13 @@ NtCreateTimer(OUT PHANDLE TimerHandle,
{
PETIMER Timer;
HANDLE hTimer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
DPRINT("NtCreateTimer(Handle: %x, Type: %d)\n", TimerHandle, TimerType);
/* Check Parameter Validity */
@ -398,9 +406,13 @@ NtOpenTimer(OUT PHANDLE TimerHandle,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
HANDLE hTimer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
DPRINT("NtOpenTimer(TimerHandle: %x)\n", TimerHandle);
/* Check Parameter Validity */
@ -452,10 +464,14 @@ NtQueryTimer(IN HANDLE TimerHandle,
OUT PULONG ReturnLength OPTIONAL)
{
PETIMER Timer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PTIMER_BASIC_INFORMATION BasicInfo = (PTIMER_BASIC_INFORMATION)TimerInformation;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
DPRINT("NtQueryTimer(TimerHandle: %x, Class: %d)\n", TimerHandle, TimerInformationClass);
/* Check Validity */
@ -522,13 +538,18 @@ NtSetTimer(IN HANDLE TimerHandle,
{
PETIMER Timer;
KIRQL OldIrql;
BOOLEAN KillTimer = FALSE;
BOOLEAN State;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PETHREAD CurrentThread = PsGetCurrentThread();
NTSTATUS Status = STATUS_SUCCESS;
KPROCESSOR_MODE PreviousMode;
PETHREAD CurrentThread;
LARGE_INTEGER TimerDueTime;
PETHREAD TimerThread;
BOOLEAN KillTimer = FALSE;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
CurrentThread = PsGetCurrentThread();
DPRINT("NtSetTimer(TimerHandle: %x, DueTime: %d, Apc: %x, Period: %d)\n", TimerHandle, DueTime->QuadPart, TimerApcRoutine, Period);

View file

@ -224,6 +224,8 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time,
ULONG IntRange;
NTSTATUS Status;
PAGED_CODE();
ExAcquireFastMutex(&UuidMutex);
if (!UuidSequenceInitialized)
@ -278,6 +280,8 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time,
NTSTATUS STDCALL
NtSetUuidSeed(IN PUCHAR Seed)
{
PAGED_CODE();
RtlCopyMemory(UuidSeed,
Seed,
SEED_BUFFER_SIZE);

View file

@ -125,46 +125,6 @@ RtlReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString,
}
}
NTSTATUS
RtlCaptureAnsiString(PANSI_STRING Dest,
PANSI_STRING UnsafeSrc)
{
PANSI_STRING Src;
NTSTATUS Status;
/*
* Copy the source string structure to kernel space.
*/
Status = MmCopyFromCaller(&Src, UnsafeSrc, sizeof(ANSI_STRING));
if (!NT_SUCCESS(Status))
{
return(Status);
}
/*
* Initialize the destination string.
*/
Dest->Length = Src->Length;
Dest->MaximumLength = Src->MaximumLength;
Dest->Buffer = ExAllocatePool(NonPagedPool, Dest->MaximumLength);
if (Dest->Buffer == NULL)
{
return(Status);
}
/*
* Copy the source string to kernel space.
*/
Status = MmCopyFromCaller(Dest->Buffer, Src->Buffer, Dest->Length);
if (!NT_SUCCESS(Status))
{
ExFreePool(Dest->Buffer);
return(Status);
}
return(STATUS_SUCCESS);
}
/*
* @unimplemented
*/