ViIrpAllocateLockedPacket

INT64 __fastcall ViIrpAllocateLockedPacket(INT8 a1, INT64 a2, VOID *a3){
  int v4; 
  INT64 v5; 
  UINT16 v6; 
  _IRP *PoolWithTagPriority; 
  unsigned int v8; 
  void *v9; 
  INT64 v10; 
  v4 = a2;
  v5 = 0i64;
  v6 = 72 * a1 + 208;
  PoolWithTagPriority = (_IRP *)VeAllocatePoolWithTagPriority((_POOL_TYPE)640, v6, 0x2B707249ui64, HighPoolPriority, a3);
  if( PoolWithTagPriority )
  {
    v8 = 0;
    v9 = 0i64;
    if( v4
      && (v8 = 4096,
          v9 = (void *)*((_QWORD *)KeGetCurrentThread() + 23),
          (int)PsChargeProcessNonPagedPoolQuota((__int64)v9, 0x1000ui64) < 0) )
    {
      ExFreePoolWithTag(PoolWithTagPriority, 0);
    }
    else
    {
      IoInitializeIrp(PoolWithTagPriority, v6, a1);
      LODWORD(v10) = VfPacketCreateAndLock((unsigned __int64)PoolWithTagPriority);
      v5 = v10;
      if( v10 )
      {
        *(_DWORD *)(v10 + 56) |= 0x200008u;
        _InterlockedIncrement((volatile signed __int32 *)(v10 + 20));
        ++*(_DWORD *)(v10 + 24);
        *((_DWORD *)PoolWithTagPriority + 4) |= 0x40000000u;
        if( v4 )
        {
          *((_BYTE *)PoolWithTagPriority + 71) |= 1u;
          *(_DWORD *)(v10 + 84) = v8;
          *(_QWORD *)(v10 + 88) = v9;
          ObfReferenceObjectWithTag(v9, 0x49667256u);
        }
      }
      else
      {
        ExFreePoolWithTag(PoolWithTagPriority, 0);
        if( v4 )
          PsReturnProcessNonPagedPoolQuota((ULONG_PTR)v9, v8);
      }
    }
  }
  return v5;
}

Referenced by:

IovAllocateIrp