DbgkForwardException

UINT8 __stdcall DbgkForwardException(
        _EXCEPTION_RECORD *ExceptionRecord,
        UINT8 DebugException,
        UINT8 SecondChance,
        INT64 a4,
        INT64 a5,
        INT64 a6,
        INT64 a7){
  _ETHREAD *CurrentThread; 
  _EPROCESS *Process; 
  _ADAPTER_OBJECT *DebugPort; 
  char v13; 
  NTSTATUS v15; 
  NTSTATUS v16; 
  __int64 a2[2]; 
  _DBGKM_APIMSG ApiMsg[68]; 

  a2[0] = 0i64;
  memset(ApiMsg, 0i64, sizeof(ApiMsg));
  if( SecondChance )
  {
    LODWORD(a2[0]) = 1;
    PsSetProcessFaultInformation((ULONG_PTR)KeGetCurrentThread()->ApcState.Process, (PROCESS_FAULT_INFORMATION *)a2);
  }
  ApiMsg[10] = 0;
  ApiMsg[0] = 13631656;
  ApiMsg[1] = 8;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  Process = CurrentThread->Tcb.ApcState.Process;
  if( DebugException )
  {
    if( (*(_DWORD *)&KeGetCurrentThread()[1].gapD8[8] & 4) != 0 )
      DebugPort = 0i64;
    else
      DebugPort = (_ADAPTER_OBJECT *)Process->DebugPort;
    v13 = 0;
  }
  else
  {
    DebugPort = (_ADAPTER_OBJECT *)PsCaptureExceptionPort(CurrentThread->Tcb.ApcState.Process);
    ApiMsg[1] = 7;
    v13 = 1;
  }
  if( !DebugPort && DebugException )
    return 0;
  KeCopyExceptionRecord((INT64)&ApiMsg[12], (INT64)ExceptionRecord);
  ApiMsg[50] = SecondChance == 0;
  if( v13 )
  {
    if( DebugPort )
    {
      v15 = DbgkpSendApiMessageLpc(ApiMsg, DebugPort, DebugException);
      HalPutDmaAdapter(DebugPort);
    }
    else
    {
      v15 = 0;
      ApiMsg[11] = -2147418111;
    }
  }
  else
  {
    v15 = DbgkpSendApiMessage(Process, DebugException != 0, ApiMsg);
  }
  if( v15 < 0 )
    return 0;
  v16 = ApiMsg[11];
  if( ApiMsg[11] == -2147418111 )
  {
    if( DebugException )
      return 0;
    v16 = DbgkpSendErrorMessage(ExceptionRecord, (_DBGKM_APIMSG *)2, ApiMsg);
  }
  return v16 >= 0;
}

Referenced by:

DbgkpSendErrorMessage
KiDispatchException
KiSchedulerApc
PsDispatchIumService