MiInsertSlabEntry

VOID __stdcall MiInsertSlabEntry(IRP *Irp, DEVICE_OBJECT *DeviceObject){
  unsigned __int64 v2; 
  unsigned __int64 v4; 
  KIRQL v6; 
  unsigned __int64 v7; 
  unsigned __int64 v8; 
  bool v9; 
  int v10; 
  unsigned __int64 v11; 
  __int64 v12; 
  unsigned int v13; 
  v4 = v2;
  v6 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)DeviceObject + 4);
  v7 = *(_QWORD *)DeviceObject;
  v8 = v6;
  if( (*((_BYTE *)DeviceObject + 8) & 1) != 0 && v7 )
    v7 ^= (unsigned __int64)DeviceObject;
  v9 = 0;
  v10 = *((_BYTE *)DeviceObject + 8) & 1;
  if( v7 )
  {
    while( 1 )
    {
      if( (int)MiCompareSlabEntry((_QWORD *)(v4 + 24), v7) < 0 )
      {
        v11 = *(_QWORD *)v7;
        if( v10 )
        {
          if( !v11 )
            goto LABEL_15;
          v11 ^= v7;
        }
        if( !v11 )
        {
LABEL_15:
          v9 = 0;
          break;
        }
      }
      else
      {
        v11 = *(_QWORD *)(v7 + 8);
        if( v10 )
        {
          if( !v11 )
            goto LABEL_16;
          v11 ^= v7;
        }
        if( !v11 )
        {
LABEL_16:
          v9 = 1;
          break;
        }
      }
      v7 = v11;
    }
  }
  RtlRbInsertNodeEx((unsigned __int64 *)DeviceObject, v7, v9, v4);
  v12 = *((_QWORD *)DeviceObject + 3);
  if( !v12 || (v13 = *(_DWORD *)(v4 + 132), *(_DWORD *)(v12 + 132) > v13) && v13 )
    *((_QWORD *)DeviceObject + 3) = v4;
  *((_QWORD *)DeviceObject + 4) += *(unsigned int *)(v4 + 132);
  ++*((_QWORD *)DeviceObject + 5);
  _InterlockedExchangeAdd64((volatile signed __int64 *)Irp + 954, 0x200ui64);
  if( *(_DWORD *)(v4 + 132) == 512 )
  {
    *((_QWORD *)DeviceObject + 13) = KiQueryUnbiasedInterruptTime(1u);
    *((_DWORD *)DeviceObject + 14) |= 1u;
  }
  ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)DeviceObject + 2);
  __writecr8(v8);
}

Referenced by:

MiCreateBootSlabEntries
MiReplenishSlabAllocator
MmUpdateSlabRangeProtection