HvpRemoveFreeCellHint

VOID __stdcall HvpRemoveFreeCellHint(_HHIVE *Hive, UINT64 Cell, UINT64 Index, _HSTORAGE_TYPE Type){
  __int64 v4; 
  char v6; 
  unsigned __int64 v7; 
  _HMAP_ENTRY *CellMap; 
  __int64 v9; 
  unsigned __int64 v10; 
  unsigned int v11; 
  unsigned int *v12; 
  __int64 v13; 
  int v14; 
  unsigned int v15; 
  __int64 v16; 
  UINT32 v17; 
  __int64 v18; 
  int v19; 
  _RTL_BITMAP *p_Display; 
  NTSTATUS SetBits; 
  unsigned int FreeSummary; 
  unsigned int v23; 
  unsigned int v24; 
  int v25; 

  v4 = Type;
  v6 = 0;
  v7 = (unsigned int)Cell;
  CellMap = HvpGetCellMap(Hive, Cell);
  if( !CellMap )
    KeBugCheckEx(0x51u, (PVOID)1, Hive, (PVOID)v7, (PVOID)0x310);
  v10 = CellMap->PermanentBinAddress & 0xFFFFFFFFFFFFFFF0ui64;
  v11 = *(_DWORD *)(v10 + 4);
  v12 = (unsigned int *)(v10 + 32);
  v13 = *(unsigned int *)(v10 + 8);
  v14 = ((_DWORD)v4 << 31) | (v11 + 32);
  if( v10 + 32 < v10 + v13 )
  {
    do
    {
      v15 = *v12;
      if( (*v12 & 0x80000000) == 0 )
      {
        v23 = (v15 >> 3) - 1;
        if( v23 >= 0x10 )
        {
          v24 = v23 >> 4;
          if( v24 > 0xFF )
          {
            v23 = 23;
          }
          else
          {
            _BitScanReverse(&v24, v24);
            v23 = v24 + 16;
          }
        }
        if( (_DWORD)v9 == v23 && v14 != (_DWORD)v7 && v14 != v25 )
        {
          v6 = 1;
          break;
        }
      }
      else
      {
        v15 = -v15;
      }
      v14 += v15;
      v12 = (unsigned int *)((char *)v12 + v15);
    }
    while( (unsigned __int64)v12 < v10 + v13 );
  }
  v16 = v4;
  v17 = v11 >> 12;
  v18 = v9;
  v19 = 1 << v9;
  p_Display = &Hive->Storage[v4].FreeDisplay[v9].Display;
  if( v6 )
  {
    Hive->Storage[v16].FreeSummary |= v19;
    *(unsigned int *)((char *)&Hive->Storage[0].FreeDisplay[v18].Hint + v16 * 632) = v17;
    RtlSetBits(p_Display, v17, *(_DWORD *)(v10 + 8) >> 12);
  }
  else
  {
    RtlClearBits(p_Display, v17, (unsigned int)v13 >> 12);
    SetBits = RtlFindSetBits((INT64)p_Display, 1ui64, v17);
    FreeSummary = Hive->Storage[v16].FreeSummary;
    if( SetBits == -1 )
    {
      Hive->Storage[v16].FreeSummary = FreeSummary & ~v19;
    }
    else
    {
      Hive->Storage[v16].FreeSummary = v19 | FreeSummary;
      *(unsigned int *)((char *)&Hive->Storage[0].FreeDisplay[v18].Hint + v16 * 632) = SetBits;
    }
  }
}

Referenced by:

HvFreeCell
HvpDelistFreeCell
HvpDoAllocateCell