KiSpuriousDispatchNoEOI

VOID __stdcall KiSpuriousDispatchNoEOI(INT64 a1, INT64 a2, INT64 CurrentThread, INT64 a4, CHAR a5){
  __int64 v5; 
  __int64 v6; 
  unsigned __int8 CurrentIrql; 
  struct _KPRCB *CurrentPrcb; 
  UINT64 v9; 
  __int64 v10; 
  UINT64 v11; 
  int v12; 
  struct _KPRCB *v13; 
  unsigned __int64 v14; 
  INT64 v15; 
  _ETHREAD *v16; 
  _ETHREAD *v17; 
  INT64 v18; 
  INT64 v19; 
  unsigned __int8 BpbUserSpecCtrl; 
  unsigned __int8 v21; 
  CHAR v24; 
  void *retaddr; 
  __int16 v26; 
  int v27; 
  void *v28; 
  __int16 v29; 

  CurrentIrql = KeGetCurrentIrql();
  __writecr8(0xFui64);
  *(_BYTE *)(v5 - 87) = CurrentIrql;
  CurrentPrcb = KeGetCurrentPrcb();
  if( ++CurrentPrcb->NestingLevel == 1 )
  {
    CurrentThread = (INT64)CurrentPrcb->CurrentThread;
    v9 = __rdtsc() - CurrentPrcb->StartCycles;
    *(_QWORD *)(CurrentThread + 72) += v9;
    v10 = *(unsigned int *)(CurrentThread + 80);
    CurrentPrcb->StartCycles += v9;
    v11 = v9 + v10;
    v12 = v11;
    a2 = HIDWORD(v11);
    if( a2 )
      v12 = -1;
    *(_DWORD *)(CurrentThread + 80) = v12;
    if( (*(_BYTE *)(CurrentThread + 2) & 0x3E) != 0 )
      KiEndThreadAccountingPeriod(KeGetCurrentPrcb(), (_KTHREAD *)CurrentThread, v9);
  }
  _enable();
  ++*(_DWORD *)(v6 + 116);
  _disable();
  v13 = KeGetCurrentPrcb();
  if( v13->NestingLevel <= 1u )
  {
    v14 = __rdtsc();
    a2 = (unsigned __int64)HIDWORD(v14) << 32;
    v15 = (a2 | (unsigned int)v14) - v13->StartCycles;
    v13->CycleTime += v15;
    v13->StartCycles += v15;
    CurrentThread = v15;
    if( (v13->CurrentThread->Tcb.gap0[2] & 0x72) != 0 )
    {
      KiBeginThreadAccountingPeriod(v13, 0i64, v15);
      v13 = KeGetCurrentPrcb();
      ++v13->NestingLevel;
    }
    LOBYTE(a2) = v13->InterruptRequest;
    v13->InterruptRequest = 0;
    if( !v13->IdleHalt )
    {
      if( (_BYTE)a2 )
      {
        if( *(_BYTE *)(v5 - 87) < 2u )
        {
          v13->NestingLevel = 0;
          KiDpcInterruptBypass();
          goto LABEL_15;
        }
        HalRequestSoftwareInterrupt(2ui64);
        v13 = KeGetCurrentPrcb();
      }
    }
  }
  --v13->NestingLevel;
LABEL_15:
  __writecr8(*(unsigned __int8 *)(v5 - 87));
  _disable();
  if( (*(_BYTE *)(v5 + 240) & 1) == 0 )
  {
    _mm_setcsr(*(_DWORD *)(v5 - 84));
    __iretq(retaddr, v26, v27, v28, v29);
  }
  if( (_BYTE)KeSmapEnabled )
    __stac();
  while( (KeGetCurrentThread()->ApcState.UserApcPendingAll & 3) != 0 )
  {
    __writecr8(1ui64);
    _enable();
    KiInitiateUserApc((_KTRAP_FRAME *)1);
    _disable();
    __writecr8(0i64);
  }
  if( (*((_BYTE *)&KeGetPcr()->Prcb.2 + 14) & 2) != 0 )
    KiUpdateStibpPairing(0i64);
  v16 = (_ETHREAD *)KeGetCurrentThread();
  if( (*(_DWORD *)v16->Tcb.gap0 & 0x8000000) != 0 )
    KiRestoreSetContextState((INT64)v16, a2, CurrentThread, a4, v24);
  v17 = (_ETHREAD *)KeGetCurrentThread();
  if( (*(_DWORD *)v17->Tcb.gap0 & 0x40010000) != 0 && (v17->Tcb.gap0[2] & 1) != 0 )
    KiCopyCounters(&v17->Tcb);
  _mm_setcsr(*(_DWORD *)(v5 - 84));
  if( *(_WORD *)(v5 + 128) )
    KiRestoreDebugRegisterState();
  v18 = *(_QWORD *)(v5 - 48);
  v19 = *(_QWORD *)(v5 - 56);
  __writegsbyte(0x853u, 0);
  BpbUserSpecCtrl = KeGetPcr()->Prcb.BpbUserSpecCtrl;
  if( KeGetPcr()->Prcb.BpbCurrentSpecCtrl != BpbUserSpecCtrl )
  {
    __writegsbyte(0x27Au, BpbUserSpecCtrl);
    __writemsr(0x48u, BpbUserSpecCtrl);
  }
  v21 = _bittestandreset16(MK_FP(__GS__, 632i64), 2u);
  if( v21 )
    __writemsr(0x49u, 1ui64);
  v21 = _bittestandreset16(MK_FP(__GS__, 632i64), 5u);
  if( v21 )
    __flush_rsb();
  if( (KiKvaShadow & 1) == 0 )
  {
    __swapgs();
    __iretq(retaddr, v26, v27, v28, v29);
  }
  KiKernelExit(*(_QWORD *)(v5 - 72), *(_QWORD *)(v5 - 64), v19, v18, a5);
}

Referenced by:

No references.