KeStallExecutionProcessor

VOID __stdcall KeStallExecutionProcessor(ULONG MicroSeconds){
  void *v1; 
  void *v2; 
  unsigned __int64 v3; 
  KDPC *v5; 
  char v6; 
  int DeferredContext; 
  __int64 v8; 
  __int64 v9; 
  void *v10; 
  void *v11; 
  __int64 v12; 
  unsigned __int64 v13; 
  unsigned int v14; 
  unsigned __int128 v15; 
  unsigned __int64 v16; 
  unsigned __int64 Mask; 
  __int64 v18; 
  ULONG_PTR v19; 
  __int64 v20; 
  __int64 v21; 
  __int64 v22; 
  __int64 v23; 
  signed __int64 v24; 
  int v25; 
  __int64 v26; 
  bool v27; 
  __int64 v28; 
  unsigned __int64 v29; 
  signed __int64 v30; 
  unsigned int v31; 
  int v32[8]; 
  struct _GROUP_AFFINITY Affinity; 
  struct _GROUP_AFFINITY PreviousAffinity; 
  int v35; 
  if( HalpTimerProcessorsFrozen )
  {
    v19 = HalpAlwaysOnCounter;
    if( HalpAlwaysOnCounter )
    {
      if( *(_DWORD *)(HalpAlwaysOnCounter + 220) == 64 )
      {
        HalpTimerGetInternalData((KDPC *)HalpAlwaysOnCounter, v1, v2, (PVOID)v3);
        (*(void(__fastcall **)(__int64))(v19 + 112))(v20);
      }
      else
      {
        do
        {
          v21 = *(_QWORD *)(v19 + 208);
          do
          {
            v22 = *(_QWORD *)(v19 + 200);
            HalpTimerGetInternalData((KDPC *)v19, v1, v2, (PVOID)v3);
            v3 = (*(__int64(__fastcall **)(__int64))(v19 + 112))(v23);
            _InterlockedOr(v32, 0);
            v24 = *(_QWORD *)(v19 + 200);
          }
          while( v22 != v24 );
        }
        while( v21 != *(_QWORD *)(v19 + 208) );
        v25 = *(_DWORD *)(v19 + 220);
        if( ((v22 ^ v3) & (1i64 << ((unsigned __int8)v25 - 1))) != 0 )
        {
          v26 = 1i64 << v25;
          v27 = v25 == 64;
          v28 = -1i64;
          if( !v27 )
            v28 = v26 - 1;
          v29 = v22 & v28;
          v30 = v3 | v22 ^ v29;
          if( v3 < v29 )
            v30 += v26;
          _InterlockedCompareExchange64((volatile signed __int64 *)(v19 + 200), v30, v24);
        }
      }
    }
    KiCheckStall(KeGetCurrentPrcb(), 0);
  }
  v5 = HalpStallCounter;
  v6 = 0;
  Affinity = 0i64;
  DeferredContext = (int)HalpStallCounter[3].DeferredContext;
  PreviousAffinity = 0i64;
  if( (DeferredContext & 1) != 0
    && (unsigned int)KeQueryActiveProcessorCountEx(0xFFFFu) >= 2
    && KeGetCurrentIrql() < 2u
    && (v35 & 0x200) != 0
    && ((__int64)v5[2].DpcData & 0x20) == 0 )
  {
    v6 = 1;
    v31 = KiProcessorIndexToNumberMappingTable[*((unsigned int *)KeGetPcr() + 105)];
    Affinity.Reserved[1] = 0;
    Affinity.Reserved[2] = 0;
    *(_DWORD *)&Affinity.Group = (unsigned __int16)(v31 >> 6);
    Affinity.Mask = 1i64 << (v31 & 0x3F);
    KeSetSystemGroupAffinityThread(&Affinity, &PreviousAffinity);
  }
  HalpTimerGetInternalData(v5, v1, v2, (PVOID)v3);
  v9 = ((__int64(__fastcall *)(__int64))v5[1].SystemArgument2)(v8);
  HalpProcessorFence();
  v12 = 0i64;
  Affinity.Mask = 1i64 << HIDWORD(v5[3].DeferredRoutine);
  v13 = v9;
  v14 = 0;
  v15 = (*(_QWORD *)&v5[3].TargetInfoAsUlong * (unsigned __int64)(10 * MicroSeconds) + 9999999)
      * (unsigned __int128)0xD6BF94D5E57A42BDui64;
  v16 = (*(_QWORD *)&v5[3].TargetInfoAsUlong * (unsigned __int64)(10 * MicroSeconds) + 9999999) / 0x989680 + 1;
  if( (*(_QWORD *)&v5[3].TargetInfoAsUlong * (unsigned __int64)(10 * MicroSeconds) + 9999999) / 0x989680 != -1i64 )
  {
    Mask = Affinity.Mask;
    do
    {
      if( (++v14 & dword_140C4A13C) == 0 && qword_140C4A140 )
        qword_140C4A140(v14, *((_QWORD *)&v15 + 1), v10);
      else
        _mm_pause();
      HalpTimerGetInternalData(v5, *((PVOID *)&v15 + 1), v10, v11);
      *(_QWORD *)&v15 = ((__int64(__fastcall *)(__int64))v5[1].SystemArgument2)(v18);
      if( (unsigned __int64)v15 < v13 )
        v12 += Mask;
      v13 = v15;
    }
    while( (__int64)v15 + v12 - v9 < v16 );
  }
  if( v6 )
    KeRevertToUserGroupAffinityThread(&PreviousAffinity);
}

Referenced by:

BgpFwDisplayBugCheckProgressUpdate
BgpFwDisplayBugCheckScreen
ExpWaitForBootDevices
HalpApicStartProcessor
HalpInterruptResetThisProcessor
HalpInterruptWaitForProcessorStartUp
HalpNmiReboot
HalpPowerWriteResetCommand
HalpSfiTimerArm
HalpSfiTimerInitialize
HalpTimerMeasureFrequencies
HalpTimerMeasureProcessorsWorker
HalpTimerTestHypervisorTimer
HalpTimerWaitForPhase0Interrupt
HalpUsbLegacyStopOhciInterrupt
HalpUsbLegacyStopUhciInterrupt
HdlspBugCheckProcessing
HsaGetPageFault
HvlPrepareForRootCrashdump
IoWriteCrashDump
IvtInitializeIommu
IvtUpdateGlobalCommand
KeBugCheck2
KeFreezeExecution