MmFreeBootRegistry

VOID __stdcall MmFreeBootRegistry(){
  signed __int64 v0; 
  void *v1; 
  size_t v2; 
  signed __int64 v3; 
  size_t i; 
  MMPTE *PteAddress; 
  UINT64 v6; 
  __int64 v7; 
  UINT64 v8; 
  _MMPTE *v9; 
  v0 = _InterlockedCompareExchange64(&qword_140C4EC10, 1i64, 0i64);
  v1 = (void *)v0;
  if( v0 )
  {
    v2 = *(_QWORD *)v0;
    v3 = v0 + 8;
    qsort((WCHAR *)(v0 + 8), *(_QWORD *)v0, (const WCHAR *)8, MiRegistryVaSort);
    for( i = 0i64; i < v2; ++i )
    {
      PteAddress = MiGetPteAddress(*(PVOID *)v3);
      v8 = (UINT64)PteAddress;
      if( i == v2 - 1 || v7 + 4096 != *(_QWORD *)(v3 + 8) )
      {
        if( v6 == 1 )
        {
          v6 = 1i64;
          v9 = PteAddress;
        }
        else
        {
          v8 = (UINT64)PteAddress - 8 * v6;
          v9 = (_MMPTE *)(v8 + 8);
        }
        MiDeleteBootRange(v9, v6, v8);
      }
      v3 += 8i64;
    }
    ExFreePoolWithTag(v1, 0);
    qword_140C4EC10 = 0i64;
  }
}

Referenced by:

CmpFreeBootRegistry
HvpDropPagedBins
MmFreeLoaderBlock