KiSystemServiceHandler

VOID __stdcall KiSystemServiceHandler(
        _EXCEPTION_RECORD *ExceptionRecord,
        VOID *EstablisherFrame,
        _CONTEXT *ContextRecord,
        VOID *DispatcherContext){
  _ETHREAD *CurrentThread; 
  _KTRAP_FRAME *TrapFrame; 

  if( (ExceptionRecord->ExceptionFlags & 0x66) != 0 )
  {
    if( (ExceptionRecord->ExceptionFlags & 0x20) == 0 )
    {
      CurrentThread = (_ETHREAD *)KeGetCurrentThread();
      if( CurrentThread->Tcb.PreviousMode )
        KiBugCheckDispatch(0x3Au, EstablisherFrame, ContextRecord, DispatcherContext);
      TrapFrame = CurrentThread->Tcb.TrapFrame;
      CurrentThread->Tcb.TrapFrame = (_KTRAP_FRAME *)TrapFrame->TrapFrame;
      CurrentThread->Tcb.PreviousMode = TrapFrame->PreviousMode;
    }
  }
  else
  {
    if( &KiSystemServiceGdiTebAccess == ExceptionRecord->ExceptionAddress
      || &KiSystemServiceCopyStart <= ExceptionRecord->ExceptionAddress
      && &KiSystemServiceCopyEnd > ExceptionRecord->ExceptionAddress )
    {
      RtlUnwindEx(
        EstablisherFrame,
        &KiSystemServiceExit,
        ExceptionRecord,
        (VOID *)(unsigned int)ExceptionRecord->ExceptionCode,
        ContextRecord,
        0i64);
    }
    if( KeGetCurrentThread()->PreviousMode )
      KiBugCheckDispatch(
        0x3Bu,
        (void *)(unsigned int)ExceptionRecord->ExceptionCode,
        ExceptionRecord->ExceptionAddress,
        ContextRecord);
  }
}

Referenced by:

No references.