HalRequestSoftwareInterrupt

VOID __stdcall HalRequestSoftwareInterrupt(UINT64 RequestIrql){
  unsigned int v1; 
  void(__fastcall *v2)(_QWORD, int *, __int128 *, _QWORD, int *); 
  INT64 v3; 
  unsigned __int16 Count; 
  unsigned __int16 i; 
  __int64 v6; 
  __int64 v7; 
  __int16 v8; 
  unsigned int *v9; 
  int v10; 
  unsigned __int64 Mask; 
  int v12; 
  unsigned __int8 v13; 
  __int64(__fastcall *v14)(_QWORD, int *, __int128 *, _QWORD, int *); 
  int v15; 
  unsigned __int64 v16; 
  __int64 v17; 
  unsigned __int64 v18; 
  __int64 v19; 
  __int64(__fastcall *v20)(_QWORD, int *, __int128 *, _QWORD, int *); 
  int v21; 
  unsigned __int64 v22; 
  __int64 v23; 
  unsigned __int64 v24; 
  __int64(__fastcall *v25)(_QWORD, int *, __int128 *, _QWORD, int *); 
  int v26; 
  _PROCESSOR_NUMBER ProcNumber; 
  __int128 v28; 
  __int64 v29; 
  int v30[2]; 
  int v31[2]; 
  int v32[2]; 
  int v33[2]; 
  int v34[2]; 
  int v35[2]; 
  int v36[2]; 
  int v37[4]; 
  __int128 v38; 
  __int64 v39; 
  _GROUP_AFFINITY Result; 
  _KAFFINITY_EX Affinity; 
  unsigned __int16 v42; 
  __int16 v43[87]; 
  int v44; 

  v1 = 31;
  if( (_BYTE)RequestIrql != 1 )
    v1 = 47;
  memset(Affinity.Bitmap, 0i64, sizeof(Affinity.Bitmap));
  v39 = 0i64;
  v38 = 0i64;
  if( (*(_DWORD *)(Controller + 220) & 0x40) != 0 && !HalpInterruptNoShorthand )
  {
    LODWORD(v38) = 3;
    v30[0] = -1;
    v30[1] = 1;
    v31[1] = *(_DWORD *)(qword_140C50700 + 20);
    v31[0] = *(_DWORD *)(qword_140C50700 + 16);
    v2 = *(void(__fastcall **)(_QWORD, int *, __int128 *, _QWORD, int *))(Controller + 120);
    _disable();
    v2(*(_QWORD *)(Controller + 16), v31, &v38, v1, v30);
    if( (v44 & 0x200) != 0 )
      _enable();
    return;
  }
  *(_DWORD *)&Affinity.Count = 1310721;
  memset(&Affinity.Reserved, 0i64, 0xA4u);
  LODWORD(v3) = KeGetPcr()->Prcb.Number;
  KeAddProcessorAffinityEx(&Affinity.Count, v3);
  Result = 0i64;
  memset(v43, 0i64, 0xA6u);
  v29 = 0i64;
  v28 = 0i64;
  if( qword_140C4A1E8 )
  {
    qword_140C4A1E8(&Affinity, v1);
    return;
  }
  Count = dword_140C4B7A0.Count;
  if( dword_140C4B7A0.Count >= Affinity.Count )
    Count = Affinity.Count;
  v42 = Count;
  for( i = 0; i < v42; *(_QWORD *)&v43[4 * v6 + 3] = Affinity.Bitmap[v6] & qword_140C4B7A8[v6] )
    v6 = i++;
  v43[0] = 20;
  *(_DWORD *)&v43[1] = 0;
  if( i < 0x14u )
  {
    do
    {
      v7 = i++;
      *(_QWORD *)&v43[4 * v7 + 3] = 0i64;
    }
    while( i < (unsigned int)v43[0] );
  }
  v8 = v44;
  if( *(&CmpDummyThreadEvent + 7160) )
  {
    v9 = (unsigned int *)*(&stru_140CF2E80 + 808);
    ProcNumber = 0;
    if( *(&stru_140CF2E80 + 808) < *(&stru_140CF2E80 + 809) )
    {
      do
      {
        KeAndGroupAffinityEx(&Affinity, (_GROUP_AFFINITY *)(v9 + 2), &Result);
        if( v10 )
        {
          Mask = Result.Mask;
          v12 = 0;
          LODWORD(v28) = 6;
          v13 = 0;
          *((_QWORD *)&v28 + 1) = *v9;
          ProcNumber.Group = Result.Group;
          for( ProcNumber.Number = 0; Mask; ProcNumber.Number = v13 )
          {
            if( (Mask & 1) != 0 )
            {
              v12 |= *(_DWORD *)(qword_140C50630
                               + 24i64 * (unsigned int)KeGetProcessorIndexFromNumber(&ProcNumber.Group)
                               + 12);
              HIDWORD(v28) = v12;
            }
            ++v13;
            Mask >>= 1;
          }
          v32[0] = -1;
          v32[1] = 1;
          v33[1] = *(_DWORD *)(qword_140C50700 + 20);
          v33[0] = *(_DWORD *)(qword_140C50700 + 16);
          v14 = *(__int64(__fastcall **)(_QWORD, int *, __int128 *, _QWORD, int *))(Controller + 120);
          _disable();
          v15 = v14(*(_QWORD *)(Controller + 16), v33, &v28, v1, v32);
          if( (v8 & 0x200) != 0 )
            _enable();
          if( v15 < 0 )
            return;
        }
        v9 += 6;
      }
      while( (unsigned __int64)v9 < *(&stru_140CF2E80 + 809) );
    }
LABEL_39:
    v22 = *(_QWORD *)&v43[3];
    LOWORD(v23) = 0;
    while( v22 )
    {
LABEL_43:
      _BitScanForward64(&v24, v22);
      LODWORD(v28) = 4;
      v22 &= ~(1i64 << v24);
      DWORD2(v28) = *(_DWORD *)(qword_140C50630
                              + 24i64
                              * (unsigned int)KiProcessorNumberToIndexMappingTable[64 * (unsigned __int16)v23
                                                                                 + (unsigned __int8)v24]
                              + 8);
      v37[1] = *(_DWORD *)(qword_140C50700 + 20);
      v37[0] = *(_DWORD *)(qword_140C50700 + 16);
      v25 = *(__int64(__fastcall **)(_QWORD, int *, __int128 *, _QWORD, int *))(Controller + 120);
      v36[0] = -1;
      v36[1] = 1;
      _disable();
      v26 = v25(*(_QWORD *)(Controller + 16), v37, &v28, v1, v36);
      if( (v8 & 0x200) != 0 )
        _enable();
      if( v26 < 0 )
        return;
    }
    while( 1 )
    {
      v23 = (unsigned __int16)(v23 + 1);
      if( (unsigned int)v23 >= v42 )
        return;
      v22 = *(_QWORD *)&v43[4 * v23 + 3];
      if( v22 )
        goto LABEL_43;
    }
  }
  if( *(&stru_140CF2E80 + 6616) )
    goto LABEL_39;
  v16 = Affinity.Bitmap[0];
  LOWORD(v17) = 0;
  LODWORD(v28) = 5;
  DWORD2(v28) = 0;
  while( v16 )
  {
LABEL_33:
    _BitScanForward64(&v18, v16);
    v16 &= ~(1i64 << v18);
    v19 = (unsigned __int8)v18 + ((unsigned __int16)v17 << 6);
    if( *(_DWORD *)(qword_140C50630 + 24i64 * (unsigned int)KiProcessorNumberToIndexMappingTable[v19]) == 5 )
      DWORD2(v28) |= *(_DWORD *)(qword_140C50630 + 24i64 * (unsigned int)KiProcessorNumberToIndexMappingTable[v19] + 8);
  }
  while( 1 )
  {
    v17 = (unsigned __int16)(v17 + 1);
    if( (unsigned int)v17 >= Affinity.Count )
      break;
    v16 = Affinity.Bitmap[v17];
    if( v16 )
      goto LABEL_33;
  }
  if( !DWORD2(v28) )
    goto LABEL_39;
  v34[0] = -1;
  v34[1] = 1;
  v35[1] = *(_DWORD *)(qword_140C50700 + 20);
  v35[0] = *(_DWORD *)(qword_140C50700 + 16);
  v20 = *(__int64(__fastcall **)(_QWORD, int *, __int128 *, _QWORD, int *))(Controller + 120);
  _disable();
  v21 = v20(*(_QWORD *)(Controller + 16), v35, &v28, v1, v34);
  if( (v8 & 0x200) != 0 )
    _enable();
  if( v21 >= 0 )
    goto LABEL_39;
}

Referenced by:

KeClockInterruptNotify
KiCheckForKernelApcDelivery
KiCheckForTimerExpiration
KiDetachProcess
KiDirectSwitchThread
KiInsertQueueDpc
KiIpiInterrupt
KiRequestSoftwareInterrupt
KiSignalThreadForApc
KiSpuriousDispatchNoEOI
KiStartThreadCycleAccumulation
KiSwInterrupt
KiUnstackDetachProcess
KiUpdateRunTime
KxIsrLinkage
SwapContext