IoAllocateMdl

_MDL *__stdcall IoAllocateMdl(VOID *VirtualAddress, UINT64 Length, UINT8 SecondaryBuffer, UINT8 ChargeQuota, _IRP *Irp){
  __int16 v5; 
  unsigned int v6; 
  __int16 v8; 
  unsigned __int64 v9; 
  struct _KPRCB *CurrentPrcb; 
  _GENERAL_LOOKASIDE *P; 
  _MDL *result; 
  unsigned int Number; 
  _GENERAL_LOOKASIDE *L; 
  __int64 Size; 
  void *(__fastcall *AllocateEx)(_POOL_TYPE, unsigned __int64, unsigned int, _LOOKASIDE_LIST_EX *); 
  __int64 Tag; 
  __int64 Type; 
  unsigned int v19; 
  _MDL *MdlAddress; 
  _MDL *i; 

  v5 = (__int16)VirtualAddress;
  v6 = Length;
  v8 = 0;
  v9 = (((unsigned __int16)VirtualAddress & 0xFFF) + (unsigned __int64)(unsigned int)Length + 4095) >> 12;
  if( (unsigned int)v9 > 0x11 )
  {
    v19 = 8 * v9 + 48;
  }
  else
  {
    v8 = 8;
    CurrentPrcb = KeGetCurrentPrcb();
    P = CurrentPrcb->PPLookasideList[3].P;
    ++P->TotalAllocates;
    result = (_MDL *)RtlpInterlockedPopEntrySList(&P->ListHead);
    if( result )
      goto LABEL_3;
    ++P->AllocateMisses;
    L = CurrentPrcb->PPLookasideList[3].L;
    ++L->TotalAllocates;
    result = (_MDL *)RtlpInterlockedPopEntrySList(&L->ListHead);
    if( result
      || (Size = L->Size,
          AllocateEx = L->AllocateEx,
          Tag = L->Tag,
          Type = (unsigned int)L->Type,
          ++L->AllocateMisses,
          (result = (_MDL *)((__int64(__fastcall *)(__int64, __int64, __int64))AllocateEx)(Type, Size, Tag)) != 0i64) )
    {
LABEL_3:
      LODWORD(result->Next) = CurrentPrcb->Number;
    }
    if( result )
    {
      LOWORD(Number) = result->Next;
      goto LABEL_6;
    }
    v19 = 184;
  }
  result = (_MDL *)ExAllocatePoolWithTag(0x200ui64, v19, 543974477i64);
  if( !result )
    return result;
  Number = KeGetPcr()->Prcb.Number;
LABEL_6:
  result->AllocationProcessorNumber = Number;
  result->Next = 0i64;
  result->Size = 8 * (v9 + 6);
  result->StartVa = (void *)((unsigned __int64)VirtualAddress & 0xFFFFFFFFFFFFF000ui64);
  result->ByteOffset = v5 & 0xFFF;
  result->ByteCount = v6;
  result->MdlFlags = v8;
  if( Irp )
  {
    if( SecondaryBuffer )
    {
      MdlAddress = Irp->MdlAddress;
      for( i = MdlAddress->Next; i; i = i->Next )
        MdlAddress = i;
      MdlAddress->Next = result;
    }
    else
    {
      Irp->MdlAddress = result;
    }
  }
  return result;
}

Referenced by:

AlpcpInitializeCompletionList
BuildQueryDirectoryIrp
CcLockSystemCacheBuffer
CcMdlRead
CcPrepareMdlWrite
CcZeroDataInCache
EtwpBuildMdlForTraceBuffer
EtwpSavePersistedLogger
FsRtlKernelFsControlFile
HalBuildMdlFromScatterGatherListV2
HalBuildMdlFromScatterGatherListV3
HalGetAdapterV2
HalGetAdapterV3
HalpDmaCheckMdlAccessibility
HvlGetCoverageData
HvlpDynamicUpdateMicrocode
IopBuildAsynchronousFsdRequest
IopBuildDeviceIoControlRequest
IopLiveDumpAllocateMappingResources
IopSetEaOrQuotaInformationFile
IopSetFileObjectIosbRange
IopXxxControlFile
MiApplyImageHotPatch
MiCreateMdl
MiLockAndMapEntireDriver
MiMapHotPatchImageInSystemSpace
MiPrepareImagePagesForHotPatch
MiZeroPageWrite
MmAllocateMdlForIoSpace
NtFreeUserPhysicalPages
NtNotifyChangeDirectoryFileEx
NtPssCaptureVaSpaceBulk
NtQueryEaFile
NtQueryQuotaInformationFile
NtReadFile
NtReadFileScatter
NtSetEaFile
NtWriteFile
NtWriteFileGather
PnprInitializeMappingReserve
PopReadPagesFromHiberFile
VerifierIoAllocateMdl
VerifierPortIoAllocateMdl
VfBuildMdlFromScatterGatherList
ViAllocateMapRegisterFile
WbMakeUserDataPagesKernelWritable
WbMakeUserExecutablePagesKernelWritable