MiWorkingSetManager

LARGE_INTEGER __fastcall MiWorkingSetManager(__int64 a1, int a2){
  UINT8 *v4; 
  __int64 v5; 
  int v6; 
  int v7; 
  int v8; 
  __int64 v9; 
  char v10; 
  char v11; 
  unsigned __int64 v12; 
  unsigned __int64 v13; 
  _BYTE result[112]; 
  memset((INT64)result, 0i64);
  v5 = *(_QWORD *)(a1 + 6848);
  v6 = 0;
  if( !*(_QWORD *)(v5 + 88) )
    *(_QWORD *)(v5 + 88) = KeGetCurrentThread();
  MiWakePageZeroing(a1, 0i64, v4);
  if( (ULONG_PTR *)a1 == &MiSystemPartition )
  {
    MiDeleteStaleCacheMaps();
    MiReclaimUnusedUltraMdlMaps();
    MiCheckLogPinDriverAddresses();
  }
  MiEmptyDecayClusterTimers((_MI_PARTITION *)a1);
  if( (*(_DWORD *)(a1 + 4) & 0x18) != 0 )
    MiEnumerateSlabAllocators(
      a1,
      (unsigned int(__fastcall *)(__int64, unsigned __int64, __int64))MiFreeSlabEntries,
      0i64);
  if( ++*(_DWORD *)(v5 + 32) == *(_DWORD *)(v5 + 36) )
  {
    v7 = *(_DWORD *)(v5 + 24);
    *(_DWORD *)(v5 + 32) = 0;
    v8 = ((_BYTE)v7 + 1) & 0xF;
    *(_DWORD *)(v5 + 24) = v8;
    v9 = ((_BYTE)v8 - 8) & 0xF;
    if( *(_QWORD *)(a1 + 40 * v9 + 3456) )
      KeSetEvent((PRKEVENT)(a1 + 8 * (v9 + 2 * v9 + 551)), 0);
  }
  if( (ULONG_PTR *)a1 == &MiSystemPartition && !a2 )
    KePulseEvent(&stru_140C4EB90, 0);
  result[4] = 1;
  MiProcessWorkingSets(a1, (INT64)result);
  v10 = result[4];
  if( result[4] != 1 )
  {
    v11 = 1;
    do
    {
      if( v11 == v10 )
      {
        result[4] = 1;
        ++*(_DWORD *)(v5 + 2576);
      }
      else
      {
        MiAdjustModifiedPageLoad((_MI_PARTITION *)a1, *(_QWORD *)(v5 + 2336), *(unsigned int *)(v5 + 120));
        ++*(_DWORD *)(v5 + 2572);
        MiScanPagefiles((_MI_PARTITION *)a1);
        v6 = 1;
      }
      v11 = result[4];
      MiProcessWorkingSets(a1, (INT64)result);
      v10 = result[4];
    }
    while( result[4] != 1 );
  }
  if( (ULONG_PTR *)a1 == &MiSystemPartition )
  {
    MiAdjustPteBins();
    MiAdjustCachedStacks();
    if( byte_140C4C872 == 1 )
      MiQueueExtentPfnDeletion(0i64);
  }
  if( !v6 )
  {
    MiAdjustModifiedPageLoad((_MI_PARTITION *)a1, *(_QWORD *)(v5 + 2336), *(unsigned int *)(v5 + 120));
    MiScanPagefiles((_MI_PARTITION *)a1);
  }
  MiCheckTrimUnusedPageFileRegions((_MI_PARTITION *)a1);
  v12 = *(_QWORD *)(a1 + 7488);
  v13 = *(_QWORD *)(a1 + 7600);
  if( v12 > v13 && v12 - v13 >= 0x320 )
    KeSetEvent((PRKEVENT)(a1 + 792), 0);
  MiSignalLargePageRebuild((_MI_PARTITION *)a1);
  return MiScheduleZeroPageThreads(a1);
}

Referenced by:

KeBalanceSetManager
MiPartitionWorkingSetManager