VeAllocatePoolWithTagPriority

VOID *__stdcall VeAllocatePoolWithTagPriority(
        POOL_TYPE PoolType,
        UINT64 NumberOfBytes,
        UINT64 Tag,
        _EX_POOL_PRIORITY Priority,
        VOID *CallingAddress){
  unsigned int v6; 
  _VF_TARGET_VERIFIED_DRIVER_DATA *VerifierData; 
  int v10; 
  NTSTATUS v11; 
  VOID *v12; 
  int v14; 
  UINT64 v15; 
  _SLIST_ENTRY *v16; 
  unsigned __int64 PoolWithTagPriority; 
  __int64 v18; 
  unsigned int v19; 
  UINT64 v20; 
  UINT64 v21; 
  UINT64 v22; 
  UINT64 NumberOfBytesa; 
  UINT64 Taga; 

  LODWORD(Taga) = Tag;
  v6 = Tag;
  VerifierData = 0i64;
  v10 = 0;
  v11 = MmKernelVerifierEnabled();
  v12 = CallingAddress;
  if( v11 )
  {
    if( (PoolType & 0x80u) == 0 )
    {
      PoolType |= 0x80u;
    }
    else
    {
      v10 = 1;
      VerifierData = VfTargetDriversGetVerifierData(CallingAddress);
      if( !VerifierData )
        return ExAllocatePoolWithTagPriority(PoolType, NumberOfBytes, v6, Priority);
    }
  }
  ExAllocatePoolSanityChecks(PoolType, NumberOfBytes, &Taga, v12);
  v14 = 0;
  if( !NumberOfBytes && (unsigned int)VfVerifyMode <= 1 )
  {
    NumberOfBytes = 1i64;
    v14 = 1;
  }
  v22 = NumberOfBytes;
  NumberOfBytesa = NumberOfBytes;
  _InterlockedIncrement(&dword_140C2A630);
  if( (PoolType & 2) != 0 )
  {
    if( (MmVerifierData & 8) != 0 && VfFaultsIsSystemSufficientlyBooted() )
      VerifierBugCheckIfAppropriate(0xC2ui64, 0x9Au, PoolType & 0xFFFFFF7F, NumberOfBytes, Taga, v21);
  }
  else if( (MmVerifierData & 4) != 0 )
  {
    if( !v10 )
    {
      v10 = 1;
      VerifierData = VfTargetDriversGetVerifierData(v12);
    }
    if( VerifierData )
    {
      v15 = (unsigned int)Taga;
      LODWORD(v15) = Taga & 0x7FFFFFFF;
      if( VfFaultsInjectPoolAllocationFailure(v15) )
      {
        VfAllocPoolNotification(0i64, NumberOfBytes);
LABEL_40:
        if( (PoolType & 0x10) != 0 )
          RtlRaiseStatus(-1073741670);
        return 0i64;
      }
    }
  }
  if( ((*(&stru_140CF2E80 + 7304) & 1) != 0 || (VfDifSetting & 1) != 0) && (Priority & 9) == 0 )
  {
    if( MmSpecialPoolCatchOverruns == 1 )
      Priority |= 8u;
    else
      Priority |= 9u;
  }
  v16 = 0i64;
  if( (MmVerifierData & 8) != 0 && (PoolType & 0x20) == 0 )
  {
    if( !v10 )
      VerifierData = VfTargetDriversGetVerifierData(v12);
    if( VerifierData && NumberOfBytes + 8 > NumberOfBytes )
    {
      v16 = RtlpInterlockedPopEntrySList(&VerifierData->PoolTrackers);
      if( v16 || (v16 = (_SLIST_ENTRY *)ViGrowPoolAllocation(VerifierData)) != 0i64 )
      {
        NumberOfBytes += 8i64;
        PoolType |= 0x40u;
      }
    }
    else
    {
      ++dword_140C2A658;
    }
  }
  PoolWithTagPriority = (unsigned __int64)ExAllocatePoolWithTagPriority(
                                            PoolType,
                                            NumberOfBytes,
                                            (unsigned int)Taga,
                                            Priority);
  if( !PoolWithTagPriority )
  {
    ++dword_140C2A648;
    if( (MmVerifierData & 0x1000) != 0 )
      ViTargetIncrementCounter(v12, 0xA8ui64);
    VfAllocPoolNotification(0i64, NumberOfBytes);
    if( v16 )
      RtlpInterlockedPushEntrySList(&VerifierData->PoolTrackers, v16);
    goto LABEL_40;
  }
  if( v14 )
  {
    v18 = 3i64 * (((unsigned __int8)_InterlockedExchangeAdd(&ViBugcheckWorkaroundLogIndex, 1u) + 1) & 0xF);
    *((_DWORD *)&ViBugcheckWorkaroundLog + 2 * v18) = 1;
    *((_QWORD *)&ViBugcheckWorkaroundLog + v18 + 1) = v12;
    *((_QWORD *)&ViBugcheckWorkaroundLog + v18 + 2) = PoolWithTagPriority;
  }
  v19 = 0;
  _InterlockedIncrement(&dword_140C2A634);
  if( ExIsSpecialPoolAddress((void *)PoolWithTagPriority) == 1 )
  {
    v19 = 1;
LABEL_48:
    _InterlockedIncrement(&dword_140C2A638);
    goto LABEL_49;
  }
  if( NumberOfBytes > 0xFE0 )
    goto LABEL_48;
LABEL_49:
  if( v16 )
  {
    *((_QWORD *)&v16->Next + 1) = v12;
    v16->Next = (_SLIST_ENTRY *)(PoolWithTagPriority | v19);
    v20 = v22;
    if( !v19 )
      v20 = NumberOfBytes;
    v16[1].Next = (_SLIST_ENTRY *)v20;
    *((_QWORD *)&v16[1].Next + 1) = (unsigned int)Taga;
    PoolWithTagPriority = (unsigned __int64)ViPostPoolAllocation((_VI_POOL_ENTRY *)v16, PoolType);
  }
  VfAllocPoolNotification((VOID *)PoolWithTagPriority, NumberOfBytesa);
  if( v16 && !v19 && (PoolType & 0x400) == 0 )
    VfFillAllocatedMemory((VOID *)PoolWithTagPriority, NumberOfBytesa);
  return(VOID *)PoolWithTagPriority;
}

Referenced by:

ExAllocateHeapPool
IovAllocateMdl
IovAllocateWorkItem
VerifierExAllocatePool
VerifierExAllocatePool2
VerifierExAllocatePool3
VerifierExAllocatePoolWithQuota
VerifierExAllocatePoolWithQuotaTag
VerifierExAllocatePoolWithTag
VerifierExAllocatePoolWithTagPriority
VerifierIoSetCompletionRoutineEx
ViIrpAllocateLockedPacket
ViRtlReplaceStringBuffer