PfFbBufferListAllocate

NTSTATUS __stdcall PfFbBufferListAllocate(PFFB_BUFFER_LIST *BufferList, INT64 AllocationSize, UINT64 BufferCount){
  __int64 v3; 
  int v4; 
  __int64 v6; 
  VOID **PoolWithTag; 
  _SLIST_ENTRY *v8; 
  char *v9; 
  char *v10; 
  NTSTATUS result; 
  INT64 v12; 

  v3 = (int)AllocationSize;
  v4 = BufferCount;
  if( (int)AllocationSize + _InterlockedExchangeAdd(BufferList + 26, AllocationSize) > BufferList[21] )
  {
    result = -1073741523;
LABEL_9:
    _InterlockedExchangeAdd(BufferList + 26, -(int)v3);
    return result;
  }
  v6 = (((int)AllocationSize - 32) / (unsigned int)BufferCount) & 0xFFFFFFF0;
  PoolWithTag = ExAllocatePoolWithTag((unsigned int)BufferList[18], (int)AllocationSize, (unsigned int)BufferList[17]);
  v8 = (_SLIST_ENTRY *)PoolWithTag;
  if( !PoolWithTag )
  {
    result = -1073741670;
    goto LABEL_9;
  }
  *PoolWithTag = 0i64;
  PoolWithTag[1] = 0i64;
  *((_DWORD *)PoolWithTag + 7) = 0;
  *((_DWORD *)PoolWithTag + 4) = v4;
  v9 = (char *)PoolWithTag + v3;
  *((_DWORD *)PoolWithTag + 6) = v3;
  v10 = (char *)(PoolWithTag + 4);
  *((_DWORD *)PoolWithTag + 5) = v6;
  while( &v10[v6] <= v9 )
  {
    LODWORD(v12) = 0;
    PfFbBufferListInsertInFree((_EX_RUNDOWN_REF *)BufferList, v10, (unsigned int)v6, 0i64, v12);
    v10 += (unsigned int)v6;
  }
  RtlpInterlockedPushEntrySList((PSLIST_HEADER)BufferList + 3, v8);
  return 0;
}

Referenced by:

PfTStart