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 */
/* 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())
PETIMER Timer;
HANDLE hTimer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
- NTSTATUS Status = STATUS_SUCCESS;
+ NTSTATUS Status;
PAGED_CODE();
/* Check for correct timer type */
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 */
/* 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())
{
HANDLE hTimer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
- NTSTATUS Status = STATUS_SUCCESS;
+ NTSTATUS Status;
PAGED_CODE();
/* Check Parameter Validity */
{
_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 */
&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())
TimerInformationLength,
ReturnLength,
PreviousMode);
- if(!NT_SUCCESS(Status)) return Status;
+ if (!NT_SUCCESS(Status)) return Status;
/* Get the Timer Object */
Status = ObReferenceObjectByHandle(TimerHandle,
PreviousMode,
(PVOID*)&Timer,
NULL);
- if(NT_SUCCESS(Status))
+ if (NT_SUCCESS(Status))
{
/* Return the Basic Information */
_SEH2_TRY
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
+ /* Get the exception code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
/* 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
{
/* 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;
}