MiFindPagesForMdl

UINT64 __stdcall MiFindPagesForMdl(
        _MI_PARTITION *Partition,
        _MDL *MemoryDescriptorList,
        UINT64 Flags,
        _MI_PFN_CACHE_ATTRIBUTE CacheAttribute,
        UINT64 SizeInPages,
        UINT64 LowPage,
        UINT64 HighPage,
        UINT64 SkipPages,
        UINT16 IdealNode){
  int *v9; 
  unsigned int v10; 
  __int64 v12; 
  _MDL *v13; 
  int *v14; 
  int *v15; 
  unsigned int v16; 
  UINT64 result; 
  UINT64 v18; 
  int v19; 
  INT64 v20; 
  int v21[4]; 
  v9 = 0i64;
  v10 = *((_DWORD *)Partition + 2);
  v12 = *(_QWORD *)Partition;
  v13 = (_MDL *)*((_QWORD *)Partition + 8);
  if( (unsigned __int16)KeNumberNodes <= 1u )
  {
    v10 &= ~2u;
    v21[0] = 0;
LABEL_3:
    v14 = v21;
    goto LABEL_4;
  }
  v19 = *((_DWORD *)Partition + 14);
  if( (v10 & 2) != 0 )
  {
    v21[0] = v19;
    goto LABEL_3;
  }
  v14 = (int *)(qword_140C4DBD8 + 4i64 * (unsigned int)(unsigned __int16)KeNumberNodes * v19);
  v9 = &v14[(unsigned __int16)KeNumberNodes];
LABEL_4:
  v15 = v14 + 1;
  if( v14 != v21 )
    v15 = v9;
  v16 = v10 | 0x4000000;
  if( (v10 & 0x100) == 0 )
    v16 = v10;
  if( (v16 & 0x10052) == 0x10000 )
  {
    LODWORD(v20) = *((_DWORD *)Partition + 14);
    result = MiAllocateMdlPagesByLists(
               (_MI_PARTITION *)v12,
               v13,
               v16,
               (_MI_PFN_CACHE_ATTRIBUTE)*((_DWORD *)Partition + 15),
               *((_QWORD *)Partition + 3),
               *((_QWORD *)Partition + 5) - ((unsigned __int64)v13->ByteCount >> 12),
               v20);
    if( (_DWORD)result == 1 )
      return result;
    v16 &= ~0x10000u;
  }
  do
  {
    v18 = (unsigned int)*v14;
    if( *(_QWORD *)(4544 * v18 + *(_QWORD *)(v12 + 16) + 4176) || !*(_DWORD *)InitializationPhase )
    {
      if( (v16 & 0x40) != 0 )
      {
        MiAllocateFastLargePagesForMdl((UINT64)Partition, v18, v16);
      }
      else if( (v16 & 0x20) != 0 )
      {
        MiAllocateSkipPagesForMdl((INT64)Partition, v18, v16);
      }
      else
      {
        MiAllocateMostlyContiguousPagesForMdl((INT64)Partition, v18, v16);
      }
    }
    result = (unsigned __int64)v13->ByteCount >> 12;
    if( result == *((_QWORD *)Partition + 5) )
      break;
    if( (v16 & 2) != 0 )
      break;
    ++v14;
  }
  while( v14 < v15 );
  return result;
}

Referenced by:

MiAllocatePagesForMdl