PspStorageFreeSlot

NTSTATUS __stdcall PspStorageFreeSlot(UINT64 StorageSlot){
  unsigned int v1; 
  _RTL_AVL_TABLE *p_RightChild; 
  NTSTATUS v3; 

  v1 = StorageSlot;
  if( (unsigned int)StorageSlot >= 0x20 )
  {
    v1 = StorageSlot - 32;
    p_RightChild = (_RTL_AVL_TABLE *)&PspStorageBitmap.BalancedRoot.RightChild;
    if( (unsigned int)(StorageSlot - 32) >= 0x100 )
      return -1073741811;
  }
  else
  {
    p_RightChild = &PspStorageBitmap;
  }
  ExAcquirePushLockExclusiveEx(&PspStorageBitmapLock, 0i64);
  if( _bittest64((const signed __int64 *)p_RightChild->BalancedRoot.LeftChild, v1) )
  {
    _bittestandreset((signed __int32 *)p_RightChild->BalancedRoot.LeftChild, v1);
    v3 = 0;
  }
  else
  {
    v3 = -1073741811;
  }
  if( (_InterlockedExchangeAdd64(&PspStorageBitmapLock._bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock(&PspStorageBitmapLock);
  KeAbPostRelease(&PspStorageBitmapLock);
  return v3;
}

Referenced by:

PsFreeSiloContextSlot
PsUnregisterSiloMonitor
PspInitializeSiloStructures