DbgkQueueUserExceptionReport

NTSTATUS __stdcall DbgkQueueUserExceptionReport(PADAPTER_OBJECT DmaAdapter){
  unsigned int v1; 
  __int64 v2; 
  unsigned __int64 v3; 
  char v4; 
  char v5; 
  __int64 v6; 
  VOID **PoolWithTag; 
  _OWORD *v10; 
  char v11; 
  PEPROCESS v12; 
  _ETHREAD *CurrentThread; 
  int v14; 
  _KAPC_STATE ApcState; 

  v3 = v1;
  v4 = 0;
  v5 = 0;
  v6 = v2;
  memset(&ApcState, 0, sizeof(ApcState));
  if( !DbgkEnableWerUserReporting )
    return -1073740970;
  if( (*(&DmaAdapter->AdapterObject.CrashDump.ScatterHint.Offset + 1) & 0x400) != 0
    || (IoThreadToProcess((PETHREAD)DmaAdapter)->Flags3 & 1) != 0 )
  {
    return -1073741637;
  }
  if( _interlockedbittestandset((volatile signed __int32 *)&DmaAdapter[2].AdapterObject.ContiguousMapRegisters, 0x15u) )
    return -1073740028;
  PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0xD0ui64, 1262961220i64);
  if( !PoolWithTag )
    return -1073741670;
  ObfReferenceObject(DmaAdapter);
  *PoolWithTag = DmaAdapter;
  v10 = PoolWithTag + 3;
  PoolWithTag[1] = (VOID *)v3;
  if( v6 )
  {
    *v10 = *(_OWORD *)v6;
    *(_OWORD *)(PoolWithTag + 5) = *(_OWORD *)(v6 + 16);
    *(_OWORD *)(PoolWithTag + 7) = *(_OWORD *)(v6 + 32);
    *(_OWORD *)(PoolWithTag + 9) = *(_OWORD *)(v6 + 48);
    *(_OWORD *)(PoolWithTag + 11) = *(_OWORD *)(v6 + 64);
    *(_OWORD *)(PoolWithTag + 13) = *(_OWORD *)(v6 + 80);
    *(_OWORD *)(PoolWithTag + 15) = *(_OWORD *)(v6 + 96);
    *(_OWORD *)(PoolWithTag + 17) = *(_OWORD *)(v6 + 112);
    *(_OWORD *)(PoolWithTag + 19) = *(_OWORD *)(v6 + 128);
    PoolWithTag[21] = *(VOID **)(v6 + 144);
    v11 = 1;
  }
  else
  {
    memset(v10, 0i64, 0x98u);
    v11 = 0;
  }
  *((_BYTE *)PoolWithTag + 16) = v11;
  PoolWithTag[22] = 0i64;
  PoolWithTag[24] = DbgkUserReportWorkRoutine;
  PoolWithTag[25] = PoolWithTag;
  v12 = IoThreadToProcess((PETHREAD)DmaAdapter);
  if( v12 != KeGetCurrentThread()->ApcState.Process )
  {
    KiStackAttachProcess(v12, 0i64, &ApcState);
    v5 = 1;
  }
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --CurrentThread->Tcb.KernelApcDisable;
  v14 = PsSuspendThread((_ETHREAD *)DmaAdapter, 0i64);
  if( v14 >= 0 )
  {
    v4 = 1;
    ExQueueWorkItem((PWORK_QUEUE_ITEM)(PoolWithTag + 22), DelayedWorkQueue);
  }
  KeLeaveCriticalRegion();
  if( v14 < 0 )
  {
    ExFreePoolWithTag(PoolWithTag, 0x4B474244u);
    _InterlockedAnd((volatile signed __int32 *)&DmaAdapter[2].AdapterObject.ContiguousMapRegisters, 0xFFDFFFFF);
    if( v4 )
      PsResumeThread((_ETHREAD *)DmaAdapter, 0i64);
    HalPutDmaAdapter(DmaAdapter);
  }
  if( v5 )
    KiUnstackDetachProcess(&ApcState, 0i64);
  return v14;
}

Referenced by:

MiForceCrashForInvalidAccess
SepLogLpacAccessFailure