- Make use of _SEH2_YIELD in Ex, Io, Ob, Ps and Se.

- Don't call ExSystemExceptionFilter() if we know the caller is user mode.
- Get rid of a couple of dependencies on the NTSTATUS being initialized with STATUS_SUCCESS -- indicate success where properly instead.

svn path=/trunk/; revision=42942
This commit is contained in:
Stefan Ginsberg 2009-08-26 17:31:02 +00:00
parent 08db367162
commit f11466d9c0
35 changed files with 686 additions and 911 deletions

View file

@ -90,7 +90,7 @@ NtAddAtom(IN PWSTR AtomName,
OUT PRTL_ATOM Atom)
{
PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
LPWSTR CapturedName;
ULONG CapturedSize;
@ -145,32 +145,30 @@ NtAddAtom(IN PWSTR AtomName,
if (Atom) ProbeForWriteUshort(Atom);
}
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
/* Make sure probe worked */
if (NT_SUCCESS(Status))
/* Call the runtime function */
Status = RtlAddAtomToAtomTable(AtomTable, CapturedName, &SafeAtom);
if (NT_SUCCESS(Status) && (Atom))
{
/* Call the runtime function */
Status = RtlAddAtomToAtomTable(AtomTable, CapturedName, &SafeAtom);
if (NT_SUCCESS(Status) && (Atom))
/* Success and caller wants the atom back.. .enter SEH */
_SEH2_TRY
{
/* Success and caller wants the atom back.. .enter SEH */
_SEH2_TRY
{
/* Return the atom */
*Atom = SafeAtom;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
/* Return the atom */
*Atom = SafeAtom;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
}
/* If we captured anything, free it */
@ -242,7 +240,7 @@ NtFindAtom(IN PWSTR AtomName,
OUT PRTL_ATOM Atom)
{
PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
LPWSTR CapturedName = NULL;
ULONG CapturedSize;
@ -297,6 +295,24 @@ NtFindAtom(IN PWSTR AtomName,
if (Atom) ProbeForWriteUshort(Atom);
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
/* Call the runtime function */
Status = RtlLookupAtomInAtomTable(AtomTable, CapturedName, &SafeAtom);
if (NT_SUCCESS(Status) && (Atom))
{
/* Success and caller wants the atom back.. .enter SEH */
_SEH2_TRY
{
/* Return the atom */
*Atom = SafeAtom;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
Status = _SEH2_GetExceptionCode();
@ -304,27 +320,6 @@ NtFindAtom(IN PWSTR AtomName,
_SEH2_END;
}
/* Make sure probe worked */
if (NT_SUCCESS(Status))
{
/* Call the runtime function */
Status = RtlLookupAtomInAtomTable(AtomTable, CapturedName, &SafeAtom);
if (NT_SUCCESS(Status) && (Atom))
{
/* Success and caller wants the atom back.. .enter SEH */
_SEH2_TRY
{
/* Return the atom */
*Atom = SafeAtom;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
}
}
/* If we captured anything, free it */
if ((CapturedName) && (CapturedName != AtomName)) ExFreePool(CapturedName);

View file

@ -101,13 +101,13 @@ NtCreateEvent(OUT PHANDLE EventHandle,
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PKEVENT Event;
HANDLE hEvent;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtCreateEvent(0x%p, 0x%x, 0x%p)\n",
EventHandle, DesiredAccess, ObjectAttributes);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -115,14 +115,12 @@ NtCreateEvent(OUT PHANDLE EventHandle,
/* Check handle pointer */
ProbeForWriteHandle(EventHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the Object */
@ -163,6 +161,7 @@ NtCreateEvent(OUT PHANDLE EventHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -184,13 +183,13 @@ NtOpenEvent(OUT PHANDLE EventHandle,
{
HANDLE hEvent;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtOpenEvent(0x%p, 0x%x, 0x%p)\n",
EventHandle, DesiredAccess, ObjectAttributes);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -198,14 +197,12 @@ NtOpenEvent(OUT PHANDLE EventHandle,
/* Check handle pointer */
ProbeForWriteHandle(EventHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
@ -218,7 +215,7 @@ NtOpenEvent(OUT PHANDLE EventHandle,
&hEvent);
/* Check for success */
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/* Enter SEH for return */
_SEH2_TRY
@ -228,6 +225,7 @@ NtOpenEvent(OUT PHANDLE EventHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -247,7 +245,7 @@ NtPulseEvent(IN HANDLE EventHandle,
{
PKEVENT Event;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtPulseEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);
@ -261,14 +259,12 @@ NtPulseEvent(IN HANDLE EventHandle,
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousState);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
@ -297,6 +293,7 @@ NtPulseEvent(IN HANDLE EventHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -320,7 +317,7 @@ NtQueryEvent(IN HANDLE EventHandle,
{
PKEVENT Event;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PEVENT_BASIC_INFORMATION BasicInfo =
(PEVENT_BASIC_INFORMATION)EventInformation;
PAGED_CODE();
@ -365,6 +362,7 @@ NtQueryEvent(IN HANDLE EventHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -387,13 +385,13 @@ NtResetEvent(IN HANDLE EventHandle,
{
PKEVENT Event;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtResetEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);
/* Check if we were called from user-mode */
if((PreviousState) && (PreviousMode != KernelMode))
if ((PreviousState) && (PreviousMode != KernelMode))
{
/* Entry SEH Block */
_SEH2_TRY
@ -401,14 +399,12 @@ NtResetEvent(IN HANDLE EventHandle,
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousState);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
@ -437,6 +433,7 @@ NtResetEvent(IN HANDLE EventHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -457,7 +454,7 @@ NtSetEvent(IN HANDLE EventHandle,
{
PKEVENT Event;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);
@ -471,14 +468,12 @@ NtSetEvent(IN HANDLE EventHandle,
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousState);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */

View file

@ -61,12 +61,12 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle,
PKEVENT_PAIR EventPair;
HANDLE hEventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtCreateEventPair: 0x%p\n", EventPairHandle);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -74,14 +74,12 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle,
/* Check handle pointer */
ProbeForWriteHandle(EventPairHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the Object */
@ -97,7 +95,7 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle,
(PVOID*)&EventPair);
/* Check for Success */
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/* Initalize the Event */
DPRINT("Initializing EventPair\n");
@ -111,15 +109,18 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle,
NULL,
&hEventPair);
/* Check for success and return handle */
if(NT_SUCCESS(Status))
/* Check for success */
if (NT_SUCCESS(Status))
{
/* Enter SEH */
_SEH2_TRY
{
/* Return the handle */
*EventPairHandle = hEventPair;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -138,11 +139,11 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle,
{
HANDLE hEventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -150,14 +151,12 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle,
/* Check handle pointer */
ProbeForWriteHandle(EventPairHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
@ -169,15 +168,18 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle,
NULL,
&hEventPair);
/* Check for success and return handle */
if(NT_SUCCESS(Status))
/* Check for success */
if (NT_SUCCESS(Status))
{
/* Enter SEH */
_SEH2_TRY
{
/* Return the handle */
*EventPairHandle = hEventPair;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;

View file

@ -620,17 +620,16 @@ NtRaiseHardError(IN NTSTATUS ErrorStatus,
}
}
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Free captured buffer */
if (SafeParams) ExFreePool(SafeParams);
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* If we failed to capture/probe, bail out */
if (!NT_SUCCESS(Status)) return Status;
/* Call the system function directly, because we probed */
ExpRaiseHardError(ErrorStatus,
NumberOfParameters,
@ -668,8 +667,9 @@ NtRaiseHardError(IN NTSTATUS ErrorStatus,
/* Return the response */
*Response = SafeResponse;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;

View file

@ -84,13 +84,13 @@ NtCreateMutant(OUT PHANDLE MutantHandle,
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
HANDLE hMutant;
PKMUTANT Mutant;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtCreateMutant(0x%p, 0x%x, 0x%p)\n",
MutantHandle, DesiredAccess, ObjectAttributes);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -98,14 +98,12 @@ NtCreateMutant(OUT PHANDLE MutantHandle,
/* Check handle pointer */
ProbeForWriteHandle(MutantHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the Mutant Object*/
@ -135,7 +133,7 @@ NtCreateMutant(OUT PHANDLE MutantHandle,
&hMutant);
/* Check for success */
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/* Enter SEH for return */
_SEH2_TRY
@ -145,6 +143,7 @@ NtCreateMutant(OUT PHANDLE MutantHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -166,13 +165,13 @@ NtOpenMutant(OUT PHANDLE MutantHandle,
{
HANDLE hMutant;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtOpenMutant(0x%p, 0x%x, 0x%p)\n",
MutantHandle, DesiredAccess, ObjectAttributes);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -180,14 +179,12 @@ NtOpenMutant(OUT PHANDLE MutantHandle,
/* Check handle pointer */
ProbeForWriteHandle(MutantHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
@ -232,7 +229,7 @@ NtQueryMutant(IN HANDLE MutantHandle,
{
PKMUTANT Mutant;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PMUTANT_BASIC_INFORMATION BasicInfo =
(PMUTANT_BASIC_INFORMATION)MutantInformation;
PAGED_CODE();
@ -260,7 +257,7 @@ NtQueryMutant(IN HANDLE MutantHandle,
(PVOID*)&Mutant,
NULL);
/* Check for Status */
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/* Enter SEH Block for return */
_SEH2_TRY
@ -273,7 +270,7 @@ NtQueryMutant(IN HANDLE MutantHandle,
BasicInfo->AbandonedState = Mutant->Abandoned;
/* Return the Result Length if requested */
if(ResultLength) *ResultLength = sizeof(MUTANT_BASIC_INFORMATION);
if (ResultLength) *ResultLength = sizeof(MUTANT_BASIC_INFORMATION);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
@ -299,14 +296,14 @@ NtReleaseMutant(IN HANDLE MutantHandle,
{
PKMUTANT Mutant;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtReleaseMutant(MutantHandle 0x%p PreviousCount 0x%p)\n",
MutantHandle,
PreviousCount);
/* Check if we were called from user-mode */
if((PreviousCount) && (PreviousMode != KernelMode))
if ((PreviousCount) && (PreviousMode != KernelMode))
{
/* Entry SEH Block */
_SEH2_TRY
@ -314,14 +311,12 @@ NtReleaseMutant(IN HANDLE MutantHandle,
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousCount);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
@ -333,7 +328,7 @@ NtReleaseMutant(IN HANDLE MutantHandle,
NULL);
/* Check for Success and release if such */
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/*
* Release the mutant. doing so might raise an exception which we're
@ -348,10 +343,11 @@ NtReleaseMutant(IN HANDLE MutantHandle,
FALSE);
/* Return the previous count if requested */
if(PreviousCount) *PreviousCount = Prev;
if (PreviousCount) *PreviousCount = Prev;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;

View file

@ -102,7 +102,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
PEPROCESS pProcess;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
ULONG Log2 = 0;
PVOID Segment = NULL;
PAGED_CODE();
@ -164,14 +164,12 @@ NtCreateProfile(OUT PHANDLE ProfileHandle,
BufferSize,
sizeof(ULONG));
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if we failed */
if(!NT_SUCCESS(Status)) return Status;
}
/* Check if a process was specified */
@ -281,7 +279,7 @@ NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter,
NTSTATUS Status = STATUS_SUCCESS;
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Entry SEH Block */
_SEH2_TRY
@ -293,14 +291,12 @@ NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter,
ProbeForWriteLargeInteger(PerformanceFrequency);
}
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* If the pointers are invalid, bail out */
if(!NT_SUCCESS(Status)) return Status;
}
/* Enter a new SEH Block */
@ -310,10 +306,11 @@ NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter,
*PerformanceCounter = KeQueryPerformanceCounter(&PerfFrequency);
/* Return Frequency if requested */
if(PerformanceFrequency) *PerformanceFrequency = PerfFrequency;
if (PerformanceFrequency) *PerformanceFrequency = PerfFrequency;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -380,21 +377,14 @@ NtStartProfile(IN HANDLE ProfileHandle)
MmProbeAndLockPages(Profile->Mdl, PreviousMode, IoWriteAccess);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
/* Fail if we raised an exception */
if (!NT_SUCCESS(Status))
{
/* Release our lock, free the buffer, dereference and return */
KeReleaseMutex(&ExpProfileMutex, FALSE);
ObDereferenceObject(Profile);
ExFreePool(ProfileObject);
return Status;
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Map the pages */
TempLockedBufferAddress = MmMapLockedPages(Profile->Mdl, KernelMode);
@ -482,7 +472,7 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -490,14 +480,12 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
/* Validate interval */
ProbeForWriteUlong(Interval);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* If pointer was invalid, bail out */
if(!NT_SUCCESS(Status)) return Status;
}
/* Query the Interval */
@ -511,12 +499,13 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
/* Return Success */
return STATUS_SUCCESS;
return Status;
}
NTSTATUS

View file

@ -72,11 +72,11 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle,
PKSEMAPHORE Semaphore;
HANDLE hSemaphore;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -84,14 +84,12 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle,
/* Check handle pointer */
ProbeForWriteHandle(SemaphoreHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Make sure the counts make sense */
@ -131,7 +129,7 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle,
&hSemaphore);
/* Check for success */
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/* Enter SEH Block for return */
_SEH2_TRY
@ -141,6 +139,7 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -162,11 +161,11 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle,
{
HANDLE hSemaphore;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH2_TRY
@ -174,14 +173,12 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle,
/* Check handle pointer */
ProbeForWriteHandle(SemaphoreHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
@ -194,7 +191,7 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle,
&hSemaphore);
/* Check for success */
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/* Enter SEH Block for return */
_SEH2_TRY
@ -204,6 +201,7 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -222,11 +220,11 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle,
IN SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
OUT PVOID SemaphoreInformation,
IN ULONG SemaphoreInformationLength,
OUT PULONG ReturnLength OPTIONAL)
OUT PULONG ReturnLength OPTIONAL)
{
PKSEMAPHORE Semaphore;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check buffers and class validity */
@ -238,7 +236,7 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle,
SemaphoreInformationLength,
ReturnLength,
PreviousMode);
if(!NT_SUCCESS(Status))
if (!NT_SUCCESS(Status))
{
/* Invalid buffers */
DPRINT("NtQuerySemaphore() failed, Status: 0x%x\n", Status);
@ -254,7 +252,7 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle,
NULL);
/* Check for success */
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/* Entry SEH Block */
_SEH2_TRY
@ -267,10 +265,11 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle,
BasicInfo->MaximumCount = Semaphore->Limit;
/* Return the length */
if(ReturnLength) *ReturnLength = sizeof(*BasicInfo);
if (ReturnLength) *ReturnLength = sizeof(*BasicInfo);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -294,11 +293,11 @@ NtReleaseSemaphore(IN HANDLE SemaphoreHandle,
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PKSEMAPHORE Semaphore;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we were called from user-mode */
if((PreviousCount) && (PreviousMode != KernelMode))
if ((PreviousCount) && (PreviousMode != KernelMode))
{
/* Entry SEH Block */
_SEH2_TRY
@ -306,14 +305,12 @@ NtReleaseSemaphore(IN HANDLE SemaphoreHandle,
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousCount);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Make sure count makes sense */
@ -344,14 +341,16 @@ NtReleaseSemaphore(IN HANDLE SemaphoreHandle,
FALSE);
/* Return the old count if requested */
if(PreviousCount) *PreviousCount = PrevCount;
if (PreviousCount) *PreviousCount = PrevCount;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
/* Dereference the Semaphore */
ObDereferenceObject(Semaphore);
}

View file

@ -228,8 +228,7 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName,
ANSI_STRING AValue;
UNICODE_STRING WValue;
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
@ -248,13 +247,12 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName,
if (ReturnLength != NULL) ProbeForWriteUlong(ReturnLength);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/*

View file

@ -190,7 +190,7 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -198,14 +198,12 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
NewSystemTime = ProbeForReadLargeInteger(SystemTime);
if(PreviousTime) ProbeForWriteLargeInteger(PreviousTime);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* If the pointers were invalid, bail out */
if(!NT_SUCCESS(Status)) return Status;
}
else
{
@ -214,7 +212,7 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
}
/* Make sure we have permission to change the time */
if(!SeSinglePrivilegeCheck(SeSystemtimePrivilege, PreviousMode))
if (!SeSinglePrivilegeCheck(SeSystemtimePrivilege, PreviousMode))
{
DPRINT1("NtSetSystemTime: Caller requires the "
"SeSystemtimePrivilege privilege!\n");
@ -230,7 +228,7 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
KeSetSystemTime(&NewSystemTime, &OldSystemTime, FALSE, NULL);
/* Check if caller wanted previous time */
if(PreviousTime)
if (PreviousTime)
{
/* Enter SEH Block for return */
_SEH2_TRY
@ -240,6 +238,7 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -264,7 +263,7 @@ NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -278,9 +277,10 @@ NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
*/
KeQuerySystemTime(SystemTime);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
}

View file

@ -254,22 +254,23 @@ NtCancelTimer(IN HANDLE TimerHandle,
KIRQL OldIrql;
PETHREAD TimerThread;
ULONG DerefsToDo = 1;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check Parameter Validity */
/* Check if we need to probe */
if ((CurrentState) && (PreviousMode != KernelMode))
{
_SEH2_TRY
{
/* Make sure the pointer is valid */
ProbeForWriteBoolean(CurrentState);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Get the Timer Object */
@ -341,11 +342,12 @@ NtCancelTimer(IN HANDLE TimerHandle,
/* Dereference the Object */
ObDereferenceObjectEx(Timer, DerefsToDo);
/* Make sure it's safe to write to the handle */
/* Check if caller wants the state */
if (CurrentState)
{
_SEH2_TRY
{
/* Return the Timer State */
*CurrentState = State;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
@ -370,7 +372,7 @@ NtCreateTimer(OUT PHANDLE TimerHandle,
PETIMER Timer;
HANDLE hTimer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check for correct timer type */
@ -381,19 +383,20 @@ NtCreateTimer(OUT PHANDLE TimerHandle,
return STATUS_INVALID_PARAMETER_4;
}
/* Check Parameter Validity */
/* Check if we need to probe */
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
/* Make sure the pointer is valid */
ProbeForWriteHandle(TimerHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the Object */
@ -431,9 +434,10 @@ NtCreateTimer(OUT PHANDLE TimerHandle,
/* Check for success */
if (NT_SUCCESS(Status))
{
/* Make sure it's safe to write to the handle */
/* Enter SEH */
_SEH2_TRY
{
/* Return the Timer Handle */
*TimerHandle = hTimer;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
@ -456,7 +460,7 @@ NtOpenTimer(OUT PHANDLE TimerHandle,
{
HANDLE hTimer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check Parameter Validity */
@ -464,14 +468,15 @@ NtOpenTimer(OUT PHANDLE TimerHandle,
{
_SEH2_TRY
{
/* Make sure the pointer is valid */
ProbeForWriteHandle(TimerHandle);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Timer */
@ -484,9 +489,10 @@ NtOpenTimer(OUT PHANDLE TimerHandle,
&hTimer);
if (NT_SUCCESS(Status))
{
/* Make sure it's safe to write to the handle */
/* Enter SEH */
_SEH2_TRY
{
/* Return the Timer Handle */
*TimerHandle = hTimer;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
@ -523,7 +529,7 @@ NtQueryTimer(IN HANDLE TimerHandle,
TimerInformationLength,
ReturnLength,
PreviousMode);
if(!NT_SUCCESS(Status)) return Status;
if (!NT_SUCCESS(Status)) return Status;
/* Get the Timer Object */
Status = ObReferenceObjectByHandle(TimerHandle,
@ -532,7 +538,7 @@ NtQueryTimer(IN HANDLE TimerHandle,
PreviousMode,
(PVOID*)&Timer,
NULL);
if(NT_SUCCESS(Status))
if (NT_SUCCESS(Status))
{
/* Return the Basic Information */
_SEH2_TRY
@ -550,6 +556,7 @@ NtQueryTimer(IN HANDLE TimerHandle,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -586,20 +593,23 @@ NtSetTimer(IN HANDLE TimerHandle,
/* Check for a valid Period */
if (Period < 0) return STATUS_INVALID_PARAMETER_6;
/* Check Parameter Validity */
/* Check if we need to probe */
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
/* Probe and capture the due time */
TimerDueTime = ProbeForReadLargeInteger(DueTime);
/* Probe the state pointer if one was passed */
if (PreviousState) ProbeForWriteBoolean(PreviousState);
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
else
{
@ -715,15 +725,18 @@ NtSetTimer(IN HANDLE TimerHandle,
/* Dereference if it was previously enabled */
if (DerefsToDo) ObDereferenceObjectEx(Timer, DerefsToDo);
/* Make sure it's safe to write to the handle */
/* Check if we need to return the State */
if (PreviousState)
{
/* Enter SEH */
_SEH2_TRY
{
/* Return the Timer State */
*PreviousState = State;
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
}
_SEH2_END;
}

View file

@ -259,7 +259,7 @@ NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
{
LUID NewLuid;
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
@ -275,14 +275,9 @@ NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
return Status;
}
}
Status = ExpAllocateLocallyUniqueId(&NewLuid);

View file

@ -1271,6 +1271,7 @@ IopSecurityFile(IN PVOID ObjectBody,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -1506,7 +1507,7 @@ IopQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes,
IN ULONG FileInformationSize,
OUT PVOID FileInformation)
{
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
KPROCESSOR_MODE AccessMode = ExGetPreviousMode();
DUMMY_FILE_OBJECT DummyFileObject;
FILE_NETWORK_OPEN_INFORMATION NetworkOpenInfo;
@ -1527,13 +1528,10 @@ IopQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail on exception */
if (!NT_SUCCESS(Status))return Status;
}
/* Check if this is a basic or full request */
@ -1658,7 +1656,7 @@ IoCreateFile(OUT PHANDLE FileHandle,
HANDLE LocalHandle = 0;
LARGE_INTEGER SafeAllocationSize;
PVOID SystemEaBuffer = NULL;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
OPEN_PACKET OpenPacket;
ULONG EaErrorOffset;
@ -1705,8 +1703,7 @@ IoCreateFile(OUT PHANDLE FileHandle,
TAG_EA);
if(!SystemEaBuffer)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
_SEH2_LEAVE;
_SEH2_YIELD(return STATUS_INSUFFICIENT_RESOURCES);
}
RtlCopyMemory(SystemEaBuffer, EaBuffer, EaLength);
@ -1719,23 +1716,22 @@ IoCreateFile(OUT PHANDLE FileHandle,
{
DPRINT1("FIXME: IoCheckEaBufferValidity() failed with "
"Status: %lx\n",Status);
/* Free EA Buffer and return the error */
ExFreePoolWithTag(SystemEaBuffer, TAG_EA);
_SEH2_YIELD(return Status);
}
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
/* Free SystemEaBuffer if needed */
if (SystemEaBuffer) ExFreePoolWithTag(SystemEaBuffer, TAG_EA);
/* Return failure status */
return Status;
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
else
{
@ -2538,7 +2534,6 @@ NtCreateMailslotFile(OUT PHANDLE FileHandle,
IN PLARGE_INTEGER TimeOut)
{
MAILSLOT_CREATE_PARAMETERS Buffer;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check for Timeout */
@ -2555,13 +2550,10 @@ NtCreateMailslotFile(OUT PHANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Return the exception */
if (!NT_SUCCESS(Status)) return Status;
}
else
{
@ -2617,7 +2609,6 @@ NtCreateNamedPipeFile(OUT PHANDLE FileHandle,
IN PLARGE_INTEGER DefaultTimeout)
{
NAMED_PIPE_CREATE_PARAMETERS Buffer;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check for Timeout */
@ -2635,13 +2626,10 @@ NtCreateNamedPipeFile(OUT PHANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Return the exception */
if (!NT_SUCCESS(Status)) return Status;
}
else
{
@ -2776,7 +2764,7 @@ NtCancelIoFile(IN HANDLE FileHandle,
BOOLEAN OurIrpsInList = FALSE;
LARGE_INTEGER Interval;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PLIST_ENTRY ListHead, NextEntry;
PAGED_CODE();
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
@ -2792,13 +2780,10 @@ NtCancelIoFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Return exception code on failure */
if (!NT_SUCCESS(Status)) return Status;
}
/* Reference the file object */

View file

@ -258,7 +258,7 @@ NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle,
PKQUEUE Queue;
HANDLE hIoCompletionHandle;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if this was a user-mode call */
@ -272,13 +272,10 @@ NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail on exception */
if (!NT_SUCCESS(Status)) return Status;
}
/* Create the Object */
@ -332,7 +329,7 @@ NtOpenIoCompletion(OUT PHANDLE IoCompletionHandle,
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
HANDLE hIoCompletionHandle;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if this was a user-mode call */
@ -346,13 +343,10 @@ NtOpenIoCompletion(OUT PHANDLE IoCompletionHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail on exception */
if (!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
@ -393,7 +387,7 @@ NtQueryIoCompletion(IN HANDLE IoCompletionHandle,
{
PKQUEUE Queue;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check buffers and parameters */
@ -457,7 +451,7 @@ NtRemoveIoCompletion(IN HANDLE IoCompletionHandle,
PIOP_MINI_COMPLETION_PACKET Packet;
PLIST_ENTRY ListEntry;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PIRP Irp;
PVOID Apc, Key;
IO_STATUS_BLOCK IoStatus;
@ -484,13 +478,10 @@ NtRemoveIoCompletion(IN HANDLE IoCompletionHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail on exception */
if (!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */

View file

@ -196,7 +196,7 @@ IopDeviceFsIoControl(IN HANDLE DeviceHandle,
IN ULONG OutputBufferLength OPTIONAL,
IN BOOLEAN IsDevIoCtl)
{
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PFILE_OBJECT FileObject;
PDEVICE_OBJECT DeviceObject;
PIRP Irp;
@ -258,11 +258,10 @@ IopDeviceFsIoControl(IN HANDLE DeviceHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Don't check for access rights right now, KernelMode can do anything */
@ -427,12 +426,11 @@ IopDeviceFsIoControl(IN HANDLE DeviceHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Cleanup after exception */
/* Cleanup after exception and return */
IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
break;
/* Direct I/O */
@ -484,12 +482,11 @@ IopDeviceFsIoControl(IN HANDLE DeviceHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Cleanup after exception */
/* Cleanup after exception and return */
IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
break;
case METHOD_NEITHER:
@ -958,7 +955,7 @@ NtFlushBuffersFile(IN HANDLE FileHandle,
PFILE_OBJECT FileObject;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PDEVICE_OBJECT DeviceObject;
PKEVENT Event = NULL;
BOOLEAN LocalEvent = FALSE;
@ -978,13 +975,10 @@ NtFlushBuffersFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Return exception code, if any */
if (!NT_SUCCESS(Status)) return Status;
}
/* Get the File Object */
@ -1095,7 +1089,7 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle,
PFILE_OBJECT FileObject;
PIO_STACK_LOCATION IoStack;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
BOOLEAN LockedForSync = FALSE;
PAGED_CODE();
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
@ -1114,14 +1108,11 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Check if probing failed */
if (!NT_SUCCESS(Status)) return Status;
/* Check if CompletionFilter is valid */
if (!CompletionFilter || (CompletionFilter & ~FILE_NOTIFY_VALID_MASK))
{
@ -1229,7 +1220,7 @@ NtLockFile(IN HANDLE FileHandle,
BOOLEAN LockedForSync = FALSE;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
LARGE_INTEGER CapturedByteOffset, CapturedLength;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
OBJECT_HANDLE_INFORMATION HandleInformation;
PAGED_CODE();
CapturedByteOffset.QuadPart = 0;
@ -1267,19 +1258,12 @@ NtLockFile(IN HANDLE FileHandle,
CapturedLength = ProbeForReadLargeInteger(Length);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
/* Check if probing failed */
if (!NT_SUCCESS(Status))
{
/* Dereference the object and return exception code */
ObDereferenceObject(FileObject);
return Status;
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
else
{
@ -1351,15 +1335,14 @@ NtLockFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, Event, NULL);
if (LocalLength) ExFreePool(LocalLength);
/* Get status */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
/* Set Parameters */
StackPtr->Parameters.LockControl.ByteOffset = CapturedByteOffset;
@ -1401,7 +1384,7 @@ NtQueryDirectoryFile(IN HANDLE FileHandle,
PFILE_OBJECT FileObject;
PIO_STACK_LOCATION StackPtr;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
BOOLEAN LockedForSynch = FALSE;
PKEVENT Event = NULL;
PVOID AuxBuffer = NULL;
@ -1456,14 +1439,11 @@ NtQueryDirectoryFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception code and free the buffer */
/* Free buffer and return the exception code */
if (AuxBuffer) ExFreePool(AuxBuffer);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Return status on failure */
if (!NT_SUCCESS(Status)) return Status;
}
/* Get File Object */
@ -1547,15 +1527,14 @@ NtQueryDirectoryFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, Event, NULL);
if (AuxBuffer) ExFreePool(AuxBuffer);
/* Get status */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
/* Set the buffer and flags */
Irp->UserBuffer = FileInformation;
@ -1573,10 +1552,9 @@ NtQueryDirectoryFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, Event, NULL);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return Status);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
@ -1647,7 +1625,7 @@ NtQueryInformationFile(IN HANDLE FileHandle,
{
OBJECT_HANDLE_INFORMATION HandleInformation;
PFILE_OBJECT FileObject;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PIRP Irp;
PDEVICE_OBJECT DeviceObject;
PIO_STACK_LOCATION StackPtr;
@ -1689,11 +1667,10 @@ NtQueryInformationFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
else
{
@ -1811,12 +1788,11 @@ NtQueryInformationFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, NULL, Event);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
/* Set the flags */
Irp->Flags |= (IRP_BUFFERED_IO |
@ -1957,7 +1933,7 @@ NtReadFile(IN HANDLE FileHandle,
IN PLARGE_INTEGER ByteOffset OPTIONAL,
IN PULONG Key OPTIONAL)
{
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PFILE_OBJECT FileObject;
PIRP Irp;
PDEVICE_OBJECT DeviceObject;
@ -1973,7 +1949,7 @@ NtReadFile(IN HANDLE FileHandle,
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
/* Validate User-Mode Buffers */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -1995,13 +1971,10 @@ NtReadFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Check for probe failure */
if (!NT_SUCCESS(Status)) return Status;
}
else
{
@ -2116,12 +2089,11 @@ NtReadFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
/* Set the buffer and flags */
Irp->UserBuffer = Buffer;
@ -2148,10 +2120,9 @@ NtReadFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return Status);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
@ -2229,7 +2200,7 @@ NtSetInformationFile(IN HANDLE FileHandle,
IN FILE_INFORMATION_CLASS FileInformationClass)
{
PFILE_OBJECT FileObject;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PIRP Irp;
PDEVICE_OBJECT DeviceObject;
PIO_STACK_LOCATION StackPtr;
@ -2278,13 +2249,10 @@ NtSetInformationFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Check if probing failed */
if (!NT_SUCCESS(Status)) return Status;
}
else
{
@ -2417,12 +2385,11 @@ NtSetInformationFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, NULL, Event);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
/* Set the flags */
Irp->Flags |= (IRP_BUFFERED_IO |
@ -2626,7 +2593,7 @@ NtUnlockFile(IN HANDLE FileHandle,
BOOLEAN LocalEvent = FALSE;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
LARGE_INTEGER CapturedByteOffset, CapturedLength;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
OBJECT_HANDLE_INFORMATION HandleInformation;
IO_STATUS_BLOCK KernelIosb;
PAGED_CODE();
@ -2665,19 +2632,12 @@ NtUnlockFile(IN HANDLE FileHandle,
CapturedLength = ProbeForReadLargeInteger(Length);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
/* Check if probing failed */
if (!NT_SUCCESS(Status))
{
/* Dereference the object and return exception code */
ObDereferenceObject(FileObject);
return Status;
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
else
{
@ -2747,15 +2707,14 @@ NtUnlockFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, NULL, Event);
if (LocalLength) ExFreePool(LocalLength);
/* Get exception status */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
/* Set Parameters */
StackPtr->Parameters.LockControl.ByteOffset = CapturedByteOffset;
@ -2801,7 +2760,7 @@ NtWriteFile(IN HANDLE FileHandle,
IN PLARGE_INTEGER ByteOffset OPTIONAL,
IN PULONG Key OPTIONAL)
{
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PFILE_OBJECT FileObject;
PIRP Irp;
PDEVICE_OBJECT DeviceObject;
@ -2827,7 +2786,7 @@ NtWriteFile(IN HANDLE FileHandle,
if (!NT_SUCCESS(Status)) return Status;
/* Validate User-Mode Buffers */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -2864,13 +2823,10 @@ NtWriteFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Check for probe failure */
if (!NT_SUCCESS(Status)) return Status;
}
else
{
@ -2990,10 +2946,9 @@ NtWriteFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return Status);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
@ -3019,10 +2974,9 @@ NtWriteFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return Status);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
@ -3088,7 +3042,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
PKEVENT Event = NULL;
BOOLEAN LocalEvent = FALSE;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
IO_STATUS_BLOCK KernelIosb;
PAGED_CODE();
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
@ -3122,11 +3076,10 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Get File Object */
@ -3191,12 +3144,11 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, NULL, Event);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
/* Set the flags for this buffered + deferred I/O */
Irp->Flags |= (IRP_BUFFERED_IO |
@ -3251,7 +3203,7 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
PKEVENT Event = NULL;
BOOLEAN LocalEvent = FALSE;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
IO_STATUS_BLOCK KernelIosb;
PAGED_CODE();
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
@ -3285,11 +3237,10 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Get File Object */
@ -3357,12 +3308,11 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Allocating failed, clean up */
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, NULL, Event);
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
/* Set the flags for this buffered + deferred I/O */
Irp->Flags |= (IRP_BUFFERED_IO | IRP_DEALLOCATE_BUFFER);

View file

@ -712,12 +712,11 @@ IoBuildAsynchronousFsdRequest(IN ULONG MajorFunction,
/* Free the IRP and its MDL */
IoFreeMdl(Irp->MdlAddress);
IoFreeIrp(Irp);
Irp = NULL;
/* Fail */
_SEH2_YIELD(return NULL);
}
_SEH2_END;
/* This is how we know if we failed during the probe */
if (!Irp) return NULL;
}
else
{
@ -908,12 +907,11 @@ IoBuildDeviceIoControlRequest(IN ULONG IoControlCode,
/* Free the input buffer and IRP */
if (InputBuffer) ExFreePool(Irp->AssociatedIrp.SystemBuffer);
IoFreeIrp(Irp);
Irp = NULL;
/* Fail */
_SEH2_YIELD(return NULL);
}
_SEH2_END;
/* This is how we know if probing failed */
if (!Irp) return NULL;
}
break;

View file

@ -197,14 +197,11 @@ IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
if (Name.Buffer) ExFreePool(Name.Buffer);
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
if (!NT_SUCCESS(Status) && Name.Buffer)
{
ExFreePool(Name.Buffer);
}
return Status;
}
@ -212,7 +209,7 @@ static NTSTATUS
IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
{
PDEVICE_OBJECT DeviceObject = NULL;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
UNICODE_STRING DeviceInstance;
ULONG BufferSize;
ULONG Property = 0;
@ -237,16 +234,11 @@ IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
ExFreePool(DeviceInstance.Buffer);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status))
{
ExFreePool(DeviceInstance.Buffer);
return Status;
}
/* Get the device object */
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
ExFreePool(DeviceInstance.Buffer);
@ -319,16 +311,11 @@ IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
ExFreePool(TargetDeviceInstance.Buffer);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status))
{
ExFreePool(TargetDeviceInstance.Buffer);
return Status;
}
RtlInitUnicodeString(&RootDeviceName,
L"HTREE\\ROOT\\0");
if (RtlEqualUnicodeString(&TargetDeviceInstance,
@ -426,7 +413,7 @@ IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
ULONG DeviceStatus = 0;
ULONG DeviceProblem = 0;
UNICODE_STRING DeviceInstance;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
DPRINT("IopDeviceStatus() called\n");
@ -446,17 +433,11 @@ IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
if (DeviceInstance.Buffer) ExFreePool(DeviceInstance.Buffer);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status))
{
if (DeviceInstance.Buffer)
ExFreePool(DeviceInstance.Buffer);
return Status;
}
/* Get the device object */
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
ExFreePool(DeviceInstance.Buffer);
@ -766,8 +747,6 @@ NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
IN OUT PVOID Buffer,
IN ULONG BufferLength)
{
NTSTATUS Status = STATUS_SUCCESS;
DPRINT("NtPlugPlayControl(%lu %p %lu) called\n",
PlugPlayControlClass, Buffer, BufferLength);
@ -795,15 +774,10 @@ NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status))
{
return Status;
}
switch (PlugPlayControlClass)
{
case PlugPlayControlUserResponse:

View file

@ -362,7 +362,7 @@ NtOpenDirectoryObject(OUT PHANDLE DirectoryHandle,
{
HANDLE Directory;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we need to do any probing */
@ -375,11 +375,10 @@ NtOpenDirectoryObject(OUT PHANDLE DirectoryHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the error code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the directory object */
@ -465,7 +464,7 @@ NtQueryDirectoryObject(IN HANDLE DirectoryHandle,
POBJECT_DIRECTORY Directory;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
ULONG SkipEntries = 0;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PVOID LocalBuffer;
POBJECT_DIRECTORY_INFORMATION DirectoryInfo;
ULONG Length, TotalLength;
@ -499,11 +498,10 @@ NtQueryDirectoryObject(IN HANDLE DirectoryHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
else if (!RestartScan)
{
@ -692,6 +690,7 @@ Quickie:
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -736,11 +735,11 @@ NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle,
POBJECT_DIRECTORY Directory;
HANDLE NewHandle;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we need to do any probing */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -749,11 +748,10 @@ NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the error code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the object */

View file

@ -3221,7 +3221,7 @@ NtDuplicateObject(IN HANDLE SourceProcessHandle,
PEPROCESS SourceProcess, TargetProcess, Target;
HANDLE hTarget;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
OBTRACE(OB_HANDLE_DEBUG,
"%s - Duplicating handle: %lx for %lx into %lx.\n",
__FUNCTION__,
@ -3241,11 +3241,10 @@ NtDuplicateObject(IN HANDLE SourceProcessHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception status */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Now reference the input handle */

View file

@ -466,8 +466,7 @@ ObpCaptureObjectCreateInformation(IN POBJECT_ATTRIBUTES ObjectAttributes,
(ObjectAttributes->Attributes & ~OBJ_VALID_ATTRIBUTES))
{
/* Invalid combination, fail */
Status = STATUS_INVALID_PARAMETER;
_SEH2_LEAVE;
_SEH2_YIELD(return STATUS_INVALID_PARAMETER);
}
/* Set some Create Info */
@ -487,11 +486,11 @@ ObpCaptureObjectCreateInformation(IN POBJECT_ATTRIBUTES ObjectAttributes,
TRUE,
&ObjectCreateInfo->
SecurityDescriptor);
if(!NT_SUCCESS(Status))
if (!NT_SUCCESS(Status))
{
/* Capture failed, quit */
ObjectCreateInfo->SecurityDescriptor = NULL;
_SEH2_LEAVE;
_SEH2_YIELD(return Status);
}
/* Save the probe mode and security descriptor size */
@ -525,38 +524,36 @@ ObpCaptureObjectCreateInformation(IN POBJECT_ATTRIBUTES ObjectAttributes,
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
/* Get the exception */
Status = _SEH2_GetExceptionCode();
/* Cleanup and return the exception code */
ObpReleaseObjectCreateInformation(ObjectCreateInfo);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (NT_SUCCESS(Status))
/* Now check if the Object Attributes had an Object Name */
if (LocalObjectName)
{
/* Now check if the Object Attributes had an Object Name */
if (LocalObjectName)
{
Status = ObpCaptureObjectName(ObjectName,
LocalObjectName,
AccessMode,
AllocateFromLookaside);
}
else
{
/* Clear the string */
RtlInitEmptyUnicodeString(ObjectName, NULL, 0);
Status = ObpCaptureObjectName(ObjectName,
LocalObjectName,
AccessMode,
AllocateFromLookaside);
}
else
{
/* Clear the string */
RtlInitEmptyUnicodeString(ObjectName, NULL, 0);
/* He can't have specified a Root Directory */
if (ObjectCreateInfo->RootDirectory)
{
Status = STATUS_OBJECT_NAME_INVALID;
}
/* He can't have specified a Root Directory */
if (ObjectCreateInfo->RootDirectory)
{
Status = STATUS_OBJECT_NAME_INVALID;
}
}
/* Cleanup if we failed */
if (!NT_SUCCESS(Status))
{
ObpReleaseObjectCreateInformation(ObjectCreateInfo);
ObpReleaseObjectCreateInformation(ObjectCreateInfo);
}
/* Return status to caller */
@ -1411,7 +1408,7 @@ NtQueryObject(IN HANDLE ObjectHandle,
POBJECT_BASIC_INFORMATION BasicInfo;
ULONG InfoLength;
PVOID Object = NULL;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PAGED_CODE();
@ -1429,13 +1426,10 @@ NtQueryObject(IN HANDLE ObjectHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail if we raised an exception */
if (!NT_SUCCESS(Status)) return Status;
}
/*
@ -1632,7 +1626,7 @@ NtSetInformationObject(IN HANDLE ObjectHandle,
IN PVOID ObjectInformation,
IN ULONG Length)
{
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
OBP_SET_HANDLE_ATTRIBUTES_CONTEXT Context;
PVOID ObjectTable;
KAPC_STATE ApcState;
@ -1653,13 +1647,16 @@ NtSetInformationObject(IN HANDLE ObjectHandle,
return STATUS_INFO_LENGTH_MISMATCH;
}
/* Save the previous mode and actual information */
/* Save the previous mode */
Context.PreviousMode = ExGetPreviousMode();
/* Check if we were called from user mode */
if (Context.PreviousMode != KernelMode)
{
/* Enter SEH */
_SEH2_TRY
{
/* Probe and capture the attribute buffer */
ProbeForRead(ObjectInformation,
sizeof(OBJECT_HANDLE_ATTRIBUTE_INFORMATION),
sizeof(BOOLEAN));
@ -1668,15 +1665,17 @@ NtSetInformationObject(IN HANDLE ObjectHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
else
{
/* Just copy the buffer directly */
Context.Information = *(POBJECT_HANDLE_ATTRIBUTE_INFORMATION)
ObjectInformation;
}
/* Check if this is a kernel handle */
if (ObIsKernelHandle(ObjectHandle, Context.PreviousMode))
@ -1708,6 +1707,11 @@ NtSetInformationObject(IN HANDLE ObjectHandle,
/* Some failure */
Status = STATUS_ACCESS_DENIED;
}
else
{
/* We are done */
Status = STATUS_SUCCESS;
}
/* De-attach if we were attached, and return status */
if (AttachedToProcess) KeUnstackDetachProcess(&ApcState);

View file

@ -238,11 +238,11 @@ NtCreateSymbolicLinkObject(OUT PHANDLE LinkHandle,
POBJECT_SYMBOLIC_LINK SymbolicLink;
UNICODE_STRING CapturedLinkTarget;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we need to probe parameters */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -257,13 +257,10 @@ NtCreateSymbolicLinkObject(OUT PHANDLE LinkHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Exception, get the error code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Probing failed, return the error code */
if(!NT_SUCCESS(Status)) return Status;
}
else
{
@ -380,11 +377,11 @@ NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle,
{
HANDLE hLink;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we need to probe parameters */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -393,13 +390,10 @@ NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Exception, get the error code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Probing failed, return the error code */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the object */
@ -458,11 +452,11 @@ NtQuerySymbolicLinkObject(IN HANDLE LinkHandle,
UNICODE_STRING SafeLinkTarget = { 0, 0, NULL };
POBJECT_SYMBOLIC_LINK SymlinkObject;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
ULONG LengthUsed;
PAGED_CODE();
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -476,17 +470,14 @@ NtQuerySymbolicLinkObject(IN HANDLE LinkHandle,
sizeof(WCHAR));
/* Probe the return length */
if(ResultLength) ProbeForWriteUlong(ResultLength);
if (ResultLength) ProbeForWriteUlong(ResultLength);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Probe failure: get exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Probe failed, return status */
if(!NT_SUCCESS(Status)) return Status;
}
else
{

View file

@ -804,7 +804,7 @@ NtQuerySecurityObject(IN HANDLE Handle,
POBJECT_HEADER Header;
POBJECT_TYPE Type;
ACCESS_MASK DesiredAccess;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if we came from user mode */
@ -819,13 +819,10 @@ NtQuerySecurityObject(IN HANDLE Handle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail if we got an access violation */
if (!NT_SUCCESS(Status)) return Status;
}
/* Get the required access rights for the operation */

View file

@ -62,7 +62,7 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount,
PHANDLE_TABLE HandleTable;
ACCESS_MASK GrantedAccess;
PVOID DefaultObject;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Enter a critical region since we'll play with handles */
@ -89,7 +89,7 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount,
_SEH2_TRY
{
/* Check if the call came from user mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
/* Check if we have a timeout */
if (TimeOut)
@ -116,14 +116,11 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail if we raised an exception */
if (!NT_SUCCESS(Status)) goto Quickie;
/* Check if we can use the internal Wait Array */
if (ObjectCount > THREAD_WAIT_OBJECTS)
{
@ -359,7 +356,7 @@ NtWaitForSingleObject(IN HANDLE ObjectHandle,
PVOID Object, WaitableObject;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
LARGE_INTEGER SafeTimeOut;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
/* Check if we came with a timeout from user mode */
if ((TimeOut) && (PreviousMode != KernelMode))
@ -373,11 +370,10 @@ NtWaitForSingleObject(IN HANDLE ObjectHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Get the Object */
@ -460,7 +456,7 @@ NtSignalAndWaitForSingleObject(IN HANDLE ObjectHandleToSignal,
PVOID SignalObj, WaitObj, WaitableObject;
LARGE_INTEGER SafeTimeOut;
OBJECT_HANDLE_INFORMATION HandleInfo;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
/* Check if we came with a timeout from user mode */
if ((TimeOut) && (PreviousMode != KernelMode))
@ -474,11 +470,10 @@ NtSignalAndWaitForSingleObject(IN HANDLE ObjectHandleToSignal,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Start by getting the signal object*/

View file

@ -103,7 +103,7 @@ PsGetContextThread(IN PETHREAD Thread,
{
GET_SET_CTX_CONTEXT GetSetContext;
ULONG Size = 0, Flags = 0;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
/* Enter SEH */
_SEH2_TRY
@ -133,14 +133,11 @@ PsGetContextThread(IN PETHREAD Thread,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Check if we got success */
if (!NT_SUCCESS(Status)) return Status;
/* Initialize the wait event */
KeInitializeEvent(&GetSetContext.Event, NotificationEvent, FALSE);
@ -167,6 +164,9 @@ PsGetContextThread(IN PETHREAD Thread,
/* Leave the guarded region */
KeLeaveGuardedRegion();
/* We are done */
Status = STATUS_SUCCESS;
}
else
{
@ -204,6 +204,7 @@ PsGetContextThread(IN PETHREAD Thread,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
@ -223,7 +224,7 @@ PsSetContextThread(IN PETHREAD Thread,
{
GET_SET_CTX_CONTEXT GetSetContext;
ULONG Size = 0, Flags = 0;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
/* Enter SEH */
_SEH2_TRY
@ -256,14 +257,11 @@ PsSetContextThread(IN PETHREAD Thread,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Check if we got success */
if (!NT_SUCCESS(Status)) return Status;
/* Initialize the wait event */
KeInitializeEvent(&GetSetContext.Event, NotificationEvent, FALSE);
@ -290,6 +288,9 @@ PsSetContextThread(IN PETHREAD Thread,
/* Leave the guarded region */
KeLeaveGuardedRegion();
/* We are done */
Status = STATUS_SUCCESS;
}
else
{

View file

@ -226,7 +226,7 @@ NtCreateJobObject (
PEJOB Job;
KPROCESSOR_MODE PreviousMode;
PEPROCESS CurrentProcess;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
@ -234,7 +234,7 @@ NtCreateJobObject (
CurrentProcess = PsGetCurrentProcess();
/* check for valid buffers */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -242,14 +242,9 @@ NtCreateJobObject (
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
return Status;
}
}
Status = ObCreateObject(PreviousMode,
@ -397,52 +392,44 @@ NtOpenJobObject (
{
KPROCESSOR_MODE PreviousMode;
HANDLE hJob;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
/* check for valid buffers */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
ProbeForWriteHandle(JobHandle);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
Status = ObOpenObjectByName(ObjectAttributes,
PsJobType,
PreviousMode,
NULL,
DesiredAccess,
NULL,
&hJob);
if(NT_SUCCESS(Status))
{
_SEH2_TRY
{
*JobHandle = hJob;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
return Status;
}
}
if(NT_SUCCESS(Status))
{
Status = ObOpenObjectByName(ObjectAttributes,
PsJobType,
PreviousMode,
NULL,
DesiredAccess,
NULL,
&hJob);
if(NT_SUCCESS(Status))
{
_SEH2_TRY
{
*JobHandle = hJob;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
}
}
return Status;

View file

@ -1247,14 +1247,14 @@ NtCreateProcessEx(OUT PHANDLE ProcessHandle,
IN HANDLE ExceptionPort OPTIONAL,
IN BOOLEAN InJob)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status;
PAGED_CODE();
PSTRACE(PS_PROCESS_DEBUG,
"ParentProcess: %p Flags: %lx\n", ParentProcess, Flags);
/* Check if we came from user mode */
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -1263,11 +1263,10 @@ NtCreateProcessEx(OUT PHANDLE ProcessHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Make sure there's a parent process */
@ -1346,7 +1345,7 @@ NtOpenProcess(OUT PHANDLE ProcessHandle,
BOOLEAN HasObjectName = FALSE;
PETHREAD Thread = NULL;
PEPROCESS Process = NULL;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
ACCESS_STATE AccessState;
AUX_ACCESS_DATA AuxData;
PAGED_CODE();
@ -1383,11 +1382,10 @@ NtOpenProcess(OUT PHANDLE ProcessHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
else
{

View file

@ -63,7 +63,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
{
PEPROCESS Process;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
ULONG Length = 0;
PPROCESS_BASIC_INFORMATION ProcessBasicInfo =
(PPROCESS_BASIC_INFORMATION)ProcessInformation;
@ -86,18 +86,20 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
/* Prepare to probe parameters */
_SEH2_TRY
{
/* Probe the buffer */
ProbeForWrite(ProcessInformation,
ProcessInformationLength,
sizeof(ULONG));
/* Probe the return length if required */
if (ReturnLength) ProbeForWriteUlong(ReturnLength);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the error code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
if((ProcessInformationClass == ProcessCookie) &&
@ -761,6 +763,9 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
Length = sizeof(ULONG);
}
/* Indicate success */
Status = STATUS_SUCCESS;
/* Enter SEH to protect write */
_SEH2_TRY
{
@ -882,11 +887,10 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Get the LPC Port */
Status = ObReferenceObjectByHandle(PortHandle,
@ -927,11 +931,10 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Assign the actual token */
Status = PspSetPrimaryToken(Process, TokenHandle, NULL);
@ -980,11 +983,10 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Setting the session id requires the SeTcbPrivilege */
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
@ -1048,11 +1050,10 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Check for invalid PriorityClass value */
if (PriorityClass.PriorityClass > PROCESS_PRIORITY_CLASS_ABOVE_NORMAL)
@ -1250,11 +1251,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Validate it */
if ((Priority > HIGH_PRIORITY) ||
@ -1286,11 +1286,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Validate it */
if ((Priority > THREAD_BASE_PRIORITY_MAX) ||
@ -1332,11 +1331,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Validate it */
if (!Affinity)
@ -1400,11 +1398,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Assign the actual token */
Status = PsAssignImpersonationToken(Thread, TokenHandle);
@ -1427,11 +1424,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Set the address */
Thread->Win32StartAddress = Address;
@ -1454,11 +1450,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Validate it */
if (IdealProcessor > MAXIMUM_PROCESSORS)
@ -1502,11 +1497,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* Call the kernel */
KeSetDisableBoostThread(&Thread->Tcb, (BOOLEAN)DisableBoost);
@ -1529,11 +1523,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) break;
/* This is only valid for the current thread */
if (Thread != PsGetCurrentThread())
@ -1614,7 +1607,7 @@ NtQueryInformationThread(IN HANDLE ThreadHandle,
{
PETHREAD Thread;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
ULONG Access;
ULONG Length = 0;
PTHREAD_BASIC_INFORMATION ThreadBasicInfo =
@ -1623,26 +1616,26 @@ NtQueryInformationThread(IN HANDLE ThreadHandle,
KIRQL OldIrql;
PAGED_CODE();
/* Check if we were called from user mode */
if (PreviousMode != KernelMode)
{
/* Enter SEH */
_SEH2_TRY
{
/* Probe the buffer */
ProbeForWrite(ThreadInformation,
ThreadInformationLength,
sizeof(ULONG));
if (ReturnLength)
{
ProbeForWriteUlong(ReturnLength);
}
/* Probe the return length if required */
if (ReturnLength) ProbeForWriteUlong(ReturnLength);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Check what class this is */

View file

@ -349,7 +349,7 @@ NtOpenProcessTokenEx(IN HANDLE ProcessHandle,
PACCESS_TOKEN Token;
HANDLE hToken;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
PSTRACE(PS_SECURITY_DEBUG,
"Process: %p DesiredAccess: %lx\n", ProcessHandle, DesiredAccess);
@ -365,13 +365,10 @@ NtOpenProcessTokenEx(IN HANDLE ProcessHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail on exception */
if (!NT_SUCCESS(Status)) return Status;
}
/* Open the process token */
@ -938,7 +935,7 @@ NtImpersonateThread(IN HANDLE ThreadHandle,
PETHREAD Thread;
PETHREAD ThreadToImpersonate;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
PSTRACE(PS_SECURITY_DEBUG,
"Threads: %p %p\n", ThreadHandle, ThreadToImpersonateHandle);
@ -960,13 +957,10 @@ NtImpersonateThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception status */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Fail on exception */
if (!NT_SUCCESS(Status)) return Status;
}
/* Reference the thread */

View file

@ -48,7 +48,7 @@ NTAPI
PsSuspendThread(IN PETHREAD Thread,
OUT PULONG PreviousCount OPTIONAL)
{
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
ULONG OldCount = 0;
PAGED_CODE();
@ -60,6 +60,9 @@ PsSuspendThread(IN PETHREAD Thread,
{
/* Do the suspend */
OldCount = KeSuspendThread(&Thread->Tcb);
/* We are done */
Status = STATUS_SUCCESS;
}
else
{
@ -89,6 +92,9 @@ PsSuspendThread(IN PETHREAD Thread,
/* Release rundown protection */
ExReleaseRundownProtection(&Thread->RundownProtect);
/* We are done */
Status = STATUS_SUCCESS;
}
else
{
@ -99,6 +105,7 @@ PsSuspendThread(IN PETHREAD Thread,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Don't fail if we merely couldn't write the handle back */
@ -216,7 +223,7 @@ NtAlertResumeThread(IN HANDLE ThreadHandle,
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PETHREAD Thread;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
ULONG PreviousState;
/* Check if we came from user mode with a suspend count */
@ -230,11 +237,10 @@ NtAlertResumeThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
/* Reference the Object */
@ -282,7 +288,7 @@ NtResumeThread(IN HANDLE ThreadHandle,
PETHREAD Thread;
ULONG Prev;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if caller gave a suspend count from user mode */
@ -296,11 +302,10 @@ NtResumeThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Get the Thread Object */
@ -345,7 +350,7 @@ NtSuspendThread(IN HANDLE ThreadHandle,
PETHREAD Thread;
ULONG Prev;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
/* Check if caller gave a suspend count from user mode */
@ -359,11 +364,10 @@ NtSuspendThread(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Get the Thread Object */

View file

@ -475,9 +475,6 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Thread insertion failed, thread is dead */
PspSetCrossThreadFlag(Thread, CT_DEAD_THREAD_BIT);
@ -492,9 +489,11 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
/* Close its handle, killing it */
ObCloseHandle(ThreadHandle, PreviousMode);
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
else
{
@ -879,7 +878,6 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
IN BOOLEAN CreateSuspended)
{
INITIAL_TEB SafeInitialTeb;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PSTRACE(PS_THREAD_DEBUG,
"ProcessHandle: %p Context: %p\n", ProcessHandle, ThreadContext);
@ -897,7 +895,7 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
ProbeForWriteHandle(ThreadHandle);
/* Check if the caller wants a client id */
if(ClientId)
if (ClientId)
{
/* Make sure we can write to it */
ProbeForWrite(ClientId, sizeof(CLIENT_ID), sizeof(ULONG));
@ -912,10 +910,10 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
else
{
@ -951,7 +949,7 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
CLIENT_ID SafeClientId;
ULONG Attributes = 0;
HANDLE hThread = NULL;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PETHREAD Thread;
BOOLEAN HasObjectName = FALSE;
ACCESS_STATE AccessState;
@ -990,11 +988,10 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status)) return Status;
}
else
{

View file

@ -131,7 +131,7 @@ NtW32Call(IN ULONG RoutineIndex,
{
PVOID RetResult;
ULONG RetResultLength;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
ASSERT(KeGetPreviousMode() != KernelMode);
/* Enter SEH for probing */
@ -143,36 +143,32 @@ NtW32Call(IN ULONG RoutineIndex,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get exception code */
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
/* Make sure we got success */
/* Call kernel function */
Status = KeUserModeCallback(RoutineIndex,
Argument,
ArgumentLength,
&RetResult,
&RetResultLength);
if (NT_SUCCESS(Status))
{
/* Call kernel function */
Status = KeUserModeCallback(RoutineIndex,
Argument,
ArgumentLength,
&RetResult,
&RetResultLength);
if (NT_SUCCESS(Status))
/* Enter SEH for write back */
_SEH2_TRY
{
/* Enter SEH for write back */
_SEH2_TRY
{
/* Return results to user mode */
*Result = RetResult;
*ResultLength = RetResultLength;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
/* Return results to user mode */
*Result = RetResult;
*ResultLength = RetResultLength;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
}
/* Return the result */

View file

@ -278,7 +278,7 @@ SepCaptureAcl(IN PACL InputAcl,
PAGED_CODE();
if(AccessMode != KernelMode)
if (AccessMode != KernelMode)
{
_SEH2_TRY
{
@ -292,35 +292,34 @@ SepCaptureAcl(IN PACL InputAcl,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(NT_SUCCESS(Status))
NewAcl = ExAllocatePool(PoolType,
AclSize);
if(NewAcl != NULL)
{
NewAcl = ExAllocatePool(PoolType,
AclSize);
if(NewAcl != NULL)
_SEH2_TRY
{
_SEH2_TRY
{
RtlCopyMemory(NewAcl,
InputAcl,
AclSize);
*CapturedAcl = NewAcl;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ExFreePool(NewAcl);
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
RtlCopyMemory(NewAcl,
InputAcl,
AclSize);
*CapturedAcl = NewAcl;
}
else
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
/* Free the ACL and return the exception code */
ExFreePool(NewAcl);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
else
{
Status = STATUS_INSUFFICIENT_RESOURCES;
}
}
else if(!CaptureIfKernel)

View file

@ -215,14 +215,10 @@ SeCaptureLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Src,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status))
{
return Status;
}
}
/* allocate enough memory or check if the provided buffer is
@ -391,7 +387,7 @@ NtPrivilegeCheck (IN HANDLE ClientToken,
ULONG Length;
BOOLEAN CheckResult;
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
@ -415,8 +411,7 @@ NtPrivilegeCheck (IN HANDLE ClientToken,
Privilege[PrivilegeCount]) /
sizeof(RequiredPrivileges->Privilege[0]) != PrivilegeCount)
{
Status = STATUS_INVALID_PARAMETER;
_SEH2_LEAVE;
_SEH2_YIELD(return STATUS_INVALID_PARAMETER);
}
/* probe all of the array */
@ -429,14 +424,10 @@ NtPrivilegeCheck (IN HANDLE ClientToken,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status))
{
return Status;
}
}
else
{

View file

@ -397,7 +397,7 @@ SeCaptureSecurityDescriptor(IN PSECURITY_DESCRIPTOR _OriginalSecurityDescriptor,
ULONG OwnerSize = 0, GroupSize = 0;
ULONG SaclSize = 0, DaclSize = 0;
ULONG DescriptorSize = 0;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
if(OriginalSecurityDescriptor != NULL)
{
@ -417,8 +417,7 @@ SeCaptureSecurityDescriptor(IN PSECURITY_DESCRIPTOR _OriginalSecurityDescriptor,
if(OriginalSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
Status = STATUS_UNKNOWN_REVISION;
_SEH2_LEAVE;
_SEH2_YIELD(return STATUS_UNKNOWN_REVISION);
}
/* make a copy on the stack */
@ -452,14 +451,10 @@ SeCaptureSecurityDescriptor(IN PSECURITY_DESCRIPTOR _OriginalSecurityDescriptor,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
return Status;
}
}
else if(!CaptureIfKernel)
{
@ -547,14 +542,10 @@ sizeof(ULONG)); \
} \
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) \
{ \
Status = _SEH2_GetExceptionCode(); \
_SEH2_YIELD(return _SEH2_GetExceptionCode()); \
} \
_SEH2_END; \
\
if(!NT_SUCCESS(Status)) \
{ \
return Status; \
} \
} \
else \
{ \
@ -591,14 +582,10 @@ sizeof(ULONG)); \
} \
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) \
{ \
Status = _SEH2_GetExceptionCode(); \
_SEH2_YIELD(return _SEH2_GetExceptionCode()); \
} \
_SEH2_END; \
\
if(!NT_SUCCESS(Status)) \
{ \
return Status; \
} \
} \
else \
{ \
@ -686,22 +673,17 @@ Offset += ROUND_UP(Type##Size, sizeof(ULONG)); \
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* we failed to copy the data to the new descriptor */
ExFreePool(NewDescriptor);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(NT_SUCCESS(Status))
{
/* we're finally done! copy the pointer to the captured descriptor to
to the caller */
*CapturedSecurityDescriptor = NewDescriptor;
return STATUS_SUCCESS;
}
else
{
/* we failed to copy the data to the new descriptor */
ExFreePool(NewDescriptor);
}
/* we're finally done! copy the pointer to the captured descriptor to
to the caller */
*CapturedSecurityDescriptor = NewDescriptor;
return STATUS_SUCCESS;
}
else
{

View file

@ -232,11 +232,11 @@ SepCaptureSid(IN PSID InputSid,
{
ULONG SidSize = 0;
PISID NewSid, Sid = (PISID)InputSid;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
if(AccessMode != KernelMode)
if (AccessMode != KernelMode)
{
_SEH2_TRY
{
@ -251,36 +251,35 @@ SepCaptureSid(IN PSID InputSid,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(NT_SUCCESS(Status))
/* allocate a SID and copy it */
NewSid = ExAllocatePool(PoolType,
SidSize);
if(NewSid != NULL)
{
/* allocate a SID and copy it */
NewSid = ExAllocatePool(PoolType,
SidSize);
if(NewSid != NULL)
_SEH2_TRY
{
_SEH2_TRY
{
RtlCopyMemory(NewSid,
Sid,
SidSize);
*CapturedSid = NewSid;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ExFreePool(NewSid);
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
RtlCopyMemory(NewSid,
Sid,
SidSize);
*CapturedSid = NewSid;
}
else
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
/* Free the SID and return the exception code */
ExFreePool(NewSid);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
}
else
{
Status = STATUS_INSUFFICIENT_RESOURCES;
}
}
else if(!CaptureIfKernel)

View file

@ -1413,7 +1413,7 @@ NtSetInformationToken(IN HANDLE TokenHandle,
PTOKEN Token;
KPROCESSOR_MODE PreviousMode;
ULONG NeededAccess = TOKEN_ADJUST_DEFAULT;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
@ -1453,7 +1453,7 @@ NtSetInformationToken(IN HANDLE TokenHandle,
if(TokenInformationLength >= sizeof(TOKEN_OWNER))
{
PTOKEN_OWNER to = (PTOKEN_OWNER)TokenInformation;
PSID InputSid = NULL;
PSID InputSid = NULL, CapturedSid;
_SEH2_TRY
{
@ -1461,28 +1461,23 @@ NtSetInformationToken(IN HANDLE TokenHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
Status = SepCaptureSid(InputSid,
PreviousMode,
PagedPool,
FALSE,
&CapturedSid);
if(NT_SUCCESS(Status))
{
PSID CapturedSid;
Status = SepCaptureSid(InputSid,
PreviousMode,
PagedPool,
FALSE,
&CapturedSid);
if(NT_SUCCESS(Status))
{
RtlCopySid(RtlLengthSid(CapturedSid),
Token->UserAndGroups[Token->DefaultOwnerIndex].Sid,
CapturedSid);
SepReleaseSid(CapturedSid,
PreviousMode,
FALSE);
}
RtlCopySid(RtlLengthSid(CapturedSid),
Token->UserAndGroups[Token->DefaultOwnerIndex].Sid,
CapturedSid);
SepReleaseSid(CapturedSid,
PreviousMode,
FALSE);
}
}
else
@ -1497,7 +1492,7 @@ NtSetInformationToken(IN HANDLE TokenHandle,
if(TokenInformationLength >= sizeof(TOKEN_PRIMARY_GROUP))
{
PTOKEN_PRIMARY_GROUP tpg = (PTOKEN_PRIMARY_GROUP)TokenInformation;
PSID InputSid = NULL;
PSID InputSid = NULL, CapturedSid;
_SEH2_TRY
{
@ -1505,28 +1500,23 @@ NtSetInformationToken(IN HANDLE TokenHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
Status = SepCaptureSid(InputSid,
PreviousMode,
PagedPool,
FALSE,
&CapturedSid);
if(NT_SUCCESS(Status))
{
PSID CapturedSid;
Status = SepCaptureSid(InputSid,
PreviousMode,
PagedPool,
FALSE,
&CapturedSid);
if(NT_SUCCESS(Status))
{
RtlCopySid(RtlLengthSid(CapturedSid),
Token->PrimaryGroup,
CapturedSid);
SepReleaseSid(CapturedSid,
PreviousMode,
FALSE);
}
RtlCopySid(RtlLengthSid(CapturedSid),
Token->PrimaryGroup,
CapturedSid);
SepReleaseSid(CapturedSid,
PreviousMode,
FALSE);
}
}
else
@ -1549,42 +1539,39 @@ NtSetInformationToken(IN HANDLE TokenHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(NT_SUCCESS(Status))
if(InputAcl != NULL)
{
if(InputAcl != NULL)
PACL CapturedAcl;
/* capture and copy the dacl */
Status = SepCaptureAcl(InputAcl,
PreviousMode,
PagedPool,
TRUE,
&CapturedAcl);
if(NT_SUCCESS(Status))
{
PACL CapturedAcl;
/* capture and copy the dacl */
Status = SepCaptureAcl(InputAcl,
PreviousMode,
PagedPool,
TRUE,
&CapturedAcl);
if(NT_SUCCESS(Status))
{
/* free the previous dacl if present */
if(Token->DefaultDacl != NULL)
{
ExFreePool(Token->DefaultDacl);
}
/* set the new dacl */
Token->DefaultDacl = CapturedAcl;
}
}
else
{
/* clear and free the default dacl if present */
/* free the previous dacl if present */
if(Token->DefaultDacl != NULL)
{
ExFreePool(Token->DefaultDacl);
Token->DefaultDacl = NULL;
}
/* set the new dacl */
Token->DefaultDacl = CapturedAcl;
}
}
else
{
/* clear and free the default dacl if present */
if(Token->DefaultDacl != NULL)
{
ExFreePool(Token->DefaultDacl);
Token->DefaultDacl = NULL;
}
}
}
@ -1606,21 +1593,18 @@ NtSetInformationToken(IN HANDLE TokenHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(NT_SUCCESS(Status))
if(!SeSinglePrivilegeCheck(SeTcbPrivilege,
PreviousMode))
{
if(!SeSinglePrivilegeCheck(SeTcbPrivilege,
PreviousMode))
{
Status = STATUS_PRIVILEGE_NOT_HELD;
break;
}
Token->SessionId = SessionId;
Status = STATUS_PRIVILEGE_NOT_HELD;
break;
}
Token->SessionId = SessionId;
break;
}
@ -1660,13 +1644,13 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle,
PTOKEN NewToken;
PSECURITY_QUALITY_OF_SERVICE CapturedSecurityQualityOfService;
BOOLEAN QoSPresent;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
PreviousMode = KeGetPreviousMode();
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -1674,14 +1658,10 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
return Status;
}
}
Status = SepCaptureSecurityQualityOfService(ObjectAttributes,
@ -1964,7 +1944,7 @@ NtCreateToken(OUT PHANDLE TokenHandle,
KPROCESSOR_MODE PreviousMode;
ULONG nTokenPrivileges = 0;
LARGE_INTEGER LocalExpirationTime = {{0, 0}};
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
@ -2004,14 +1984,10 @@ NtCreateToken(OUT PHANDLE TokenHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
return Status;
}
}
else
{
@ -2198,13 +2174,13 @@ NtOpenThreadTokenEx(IN HANDLE ThreadHandle,
SECURITY_DESCRIPTOR SecurityDescriptor;
PACL Dacl = NULL;
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode != KernelMode)
if (PreviousMode != KernelMode)
{
_SEH2_TRY
{
@ -2212,14 +2188,10 @@ NtOpenThreadTokenEx(IN HANDLE ThreadHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
return Status;
}
}
/*
@ -2373,7 +2345,7 @@ NtCompareTokens(IN HANDLE FirstTokenHandle,
KPROCESSOR_MODE PreviousMode;
PTOKEN FirstToken, SecondToken;
BOOLEAN IsEqual;
NTSTATUS Status = STATUS_SUCCESS;
NTSTATUS Status;
PAGED_CODE();
@ -2387,12 +2359,10 @@ NtCompareTokens(IN HANDLE FirstTokenHandle,
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
/* Return the exception code */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
if (!NT_SUCCESS(Status))
return Status;
}
Status = ObReferenceObjectByHandle(FirstTokenHandle,