MiFreePageFileHashPfns

VOID __stdcall MiFreePageFileHashPfns(_MI_PARTITION *Partition){
  UINT64 v1; 
  unsigned int v2; 
  _QWORD *v3; 
  __int64 v4; 
  union _SLIST_HEADER *v5; 
  PSLIST_ENTRY v6; 
  struct _SLIST_ENTRY *Next; 
  unsigned __int64 v8; 
  unsigned __int64 v9; 
  struct _KPRCB *CurrentPrcb; 
  __int64 v11; 
  bool v12; 
  signed __int32 v13; 
  v1 = 0i64;
  v2 = *((_DWORD *)Partition + 1734);
  if( v2 )
  {
    v3 = (_QWORD *)((char *)Partition + 6944);
    v4 = v2;
    do
    {
      v5 = (union _SLIST_HEADER *)(*v3 + 80i64);
      if( *(_WORD *)v5 )
      {
        v6 = RtlpInterlockedFlushSList(v5);
        if( v6 )
        {
          do
          {
            Next = v6->Next;
            v8 = (unsigned __int8)MiLockPageInline((INT64)v6);
            MiFreePageFileHashPfn(((char *)v6 - (char *)MmGetPfnDb()) / 48);
            _InterlockedAnd64((volatile signed __int64 *)&v6[1].Next + 1, 0x7FFFFFFFFFFFFFFFui64);
            __writecr8(v8);
            ++v1;
            v6 = Next;
          }
          while( Next );
        }
      }
      ++v3;
      --v4;
    }
    while( v4 );
    if( v1 )
    {
      MiReturnCommit(Partition, v1);
      v9 = v1;
      if( Partition == (_MI_PARTITION *)&MiSystemPartition )
      {
        CurrentPrcb = KeGetCurrentPrcb();
        v11 = *((int *)CurrentPrcb + 8391);
        if( (_DWORD)v11 != -1 )
        {
          if( v1 + v11 <= 0x100 )
          {
            do
            {
              if( v1 >= 0x80000 )
                break;
              v13 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, v11 + v1, v11);
              v12 = (_DWORD)v11 == v13;
              LODWORD(v11) = v13;
              if( v12 )
                goto LABEL_23;
            }
            while( v13 != -1 && v1 + v13 <= 0x100 );
          }
          if( (int)v11 > 192
            && (_DWORD)v11 != -1
            && (_DWORD)v11 == _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8391, 192, v11) )
          {
            v9 = v1 + (int)v11 - 192;
          }
        }
      }
      if( v9 )
        _InterlockedExchangeAdd64((volatile signed __int64 *)Partition + 896, v9);
LABEL_23:
      _InterlockedExchangeAdd64(&qword_140C4F568, -(__int64)v1);
    }
  }
}

Referenced by:

MiDeletePagefile
MiScanPagefiles