PfTAllocateBuffers

INT64 __fastcall PfTAllocateBuffers(INT64 a1, UINT64 a2, UINT64 a3, UINT64 a4){
  unsigned int v4; 
  UINT64 v5; 
  unsigned int v6; 
  unsigned int v7; 
  unsigned int v9; 
  _QWORD *PoolWithTag; 
  _QWORD *v11; 
  INT64 v12; 
  __int64 v13; 
  v4 = 0;
  v5 = (unsigned int)a2;
  v6 = a4;
  v7 = a3;
  *(_DWORD *)a1 = (16 * a2) | *(_DWORD *)a1 & 0xF;
  v9 = 0;
  if( (_DWORD)a3 )
  {
    while( 1 )
    {
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, v5, v6);
      if( !PoolWithTag )
        return(unsigned int)-1073741670;
      if( (*(_DWORD *)a1 & 0xF) != 0 )
      {
        memset((INT64)PoolWithTag, 0i64);
        PoolWithTag[1] = PoolWithTag;
        *PoolWithTag = PoolWithTag;
        *((_DWORD *)PoolWithTag + 8) = 2048;
      }
      else
      {
        PfTLbInitialize(PoolWithTag, (unsigned int)v5, 0i64);
      }
      *PoolWithTag = *(_QWORD *)(a1 + 16);
      ++*(_WORD *)(a1 + 10);
      ++v9;
      ++*(_DWORD *)(a1 + 4);
      *(_QWORD *)(a1 + 16) = PoolWithTag;
      if( v9 >= v7 )
        goto LABEL_6;
    }
  }
  else
  {
LABEL_6:
    v11 = PfTGetFreeBuffer(a1);
    v12 = a1 + 24;
    v13 = *(_QWORD *)v12;
    if( *(_QWORD *)(*(_QWORD *)v12 + 8i64) != v12 )
      __fastfail(3u);
    *v11 = v13;
    v11[1] = v12;
    *(_QWORD *)(v13 + 8) = v11;
    *(_QWORD *)v12 = v11;
  }
  return v4;
}

Referenced by:

PfTStart