MiFindPagesForMdl

VOID __fastcall 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 Signature; 
  __int64 v12; 
  _MDL *WorkerRoutine; 
  int *v14; 
  int *v15; 
  unsigned int v16; 
  UINT64 v17; 
  int Blink; 
  int v19[4]; 

  v9 = 0i64;
  Signature = Partition->Core.Signature;
  v12 = *(_QWORD *)&Partition->Core.PartitionId;
  WorkerRoutine = (_MDL *)Partition->Core.PfnUnmapWorkItem.WorkerRoutine;
  if( (unsigned __int16)KeNumberNodes <= 1u )
  {
    Signature &= ~2u;
    v19[0] = 0;
LABEL_3:
    v14 = v19;
    goto LABEL_4;
  }
  Blink = (int)Partition->Core.PfnUnmapWorkItem.List.Blink;
  if( (Signature & 2) != 0 )
  {
    v19[0] = Blink;
    goto LABEL_3;
  }
  v14 = (int *)(*(&stru_140C4DB30 + 21) + 4i64 * (unsigned int)(unsigned __int16)KeNumberNodes * Blink);
  v9 = &v14[(unsigned __int16)KeNumberNodes];
LABEL_4:
  v15 = v14 + 1;
  if( v14 != v19 )
    v15 = v9;
  v16 = Signature | 0x4000000;
  if( (Signature & 0x100) == 0 )
    v16 = Signature;
  if( (v16 & 0x10052) == 0x10000 )
  {
    if( MiAllocateMdlPagesByLists(
           (PVOID *)v12,
           WorkerRoutine,
           v16,
           SHIDWORD(Partition->Core.PfnUnmapWorkItem.List.Blink),
           (UINT64)Partition->Core.PageRoot.Root,
           Partition->Core.MemoryBlockReferences - ((unsigned __int64)WorkerRoutine->ByteCount >> 12),
           (UINT16)Partition->Core.PfnUnmapWorkItem.List.Blink) == 1 )
      return;
    v16 &= ~0x10000u;
  }
  do
  {
    v17 = (unsigned int)*v14;
    if( *(_QWORD *)(4544 * v17 + *(_QWORD *)(v12 + 16) + 4176) || !(_DWORD)InitializationPhase )
    {
      if( (v16 & 0x40) != 0 )
      {
        MiAllocateFastLargePagesForMdl((UINT64)Partition, v17, v16);
      }
      else if( (v16 & 0x20) != 0 )
      {
        MiAllocateSkipPagesForMdl((__int64)Partition, v17, v16);
      }
      else
      {
        MiAllocateMostlyContiguousPagesForMdl((INT64)Partition, v17, v16);
      }
    }
    if( (unsigned __int64)WorkerRoutine->ByteCount >> 12 == Partition->Core.MemoryBlockReferences )
      break;
    if( (v16 & 2) != 0 )
      break;
    ++v14;
  }
  while( v14 < v15 );
}

Referenced by:

MiAllocatePagesForMdl