HalpDmaAllocateScatterMemory

_MDL *__stdcall HalpDmaAllocateScatterMemory(_LARGE_INTEGER *Adapter, VOID **VirtualAddressOut, VOID **a3){
  _LARGE_INTEGER v3; 
  char v4; 
  UINT64 v6; 
  _LARGE_INTEGER v7; 
  _MDL *PagesForMdl; 
  _MDL *v9; 
  VOID *MappedSystemVa; 
  UINT64 v12; 
  UINT64 Priority; 

  v3 = Adapter[17];
  v4 = 0;
  v6 = (unsigned __int64)(unsigned int)VirtualAddressOut << 12;
  while( 1 )
  {
    v7.QuadPart = 0i64;
    if( !v4 && v3.anonymous_0.LowPart == -1 )
      v7.QuadPart = 0x1000000i64;
    PagesForMdl = MmAllocatePagesForMdl(v7, v3, 0i64, v6);
    v9 = PagesForMdl;
    if( PagesForMdl )
      break;
    if( v4 || !v7.QuadPart )
      return 0i64;
    v4 = 1;
  }
  if( (PagesForMdl->MdlFlags & 5) != 0 )
  {
    MappedSystemVa = PagesForMdl->MappedSystemVa;
  }
  else
  {
    LODWORD(Priority) = 1073741856;
    LODWORD(v12) = 0;
    MappedSystemVa = MmMapLockedPagesSpecifyCache(PagesForMdl, 0, MmCached, 0i64, v12, Priority);
  }
  *a3 = MappedSystemVa;
  return v9;
}

Referenced by:

HalpDmaAllocateLocalScatterPool
HalpDmaGrowScatterMapBuffers