MiConvertInitialMemoryBlock

PHYSICAL_MEMORY_DESCRIPTOR *__stdcall MiConvertInitialMemoryBlock(
        _MI_PARTITION *Partition,
        PHYSICAL_MEMORY_DESCRIPTOR *Memory){
  int v2; 
  PHYSICAL_MEMORY_DESCRIPTOR *v5; 
  _PHYSICAL_MEMORY_RUN *Run; 
  __int64 v7; 
  int v8; 
  unsigned __int64 v9; 
  bool v10; 
  PHYSICAL_MEMORY_DESCRIPTOR *result; 
  _PHYSICAL_MEMORY_RUN *v12; 
  unsigned int v13; 
  unsigned int v14; 
  __int64 v15; 
  __int64 v16; 
  __int64 v17; 

  v2 = 1;
  if( Memory->NumberOfRuns > 1 )
  {
    v5 = Memory + 1;
    Run = Memory->Run;
    v7 = Memory->NumberOfRuns - 1;
    do
    {
      v8 = v2 + 1;
      v9 = Run->BasePage + Run->PageCount;
      ++Run;
      v10 = *(_QWORD *)&v5->NumberOfRuns == v9;
      v5 = (PHYSICAL_MEMORY_DESCRIPTOR *)((char *)v5 + 16);
      if( v10 )
        v8 = v2;
      v2 = v8;
      --v7;
    }
    while( v7 );
  }
  result = (PHYSICAL_MEMORY_DESCRIPTOR *)MiAllocatePool(64i64, 16 * ((unsigned int)(v2 - 1) + 3i64), 0x6C4D6D4Dui64);
  if( result )
  {
    v12 = result->Run;
    result->NumberOfPages = 1i64;
    LODWORD(result->Run[0].BasePage) = v2;
    v13 = 0;
    *(_QWORD *)&result->NumberOfRuns = Partition;
    v14 = 0;
    for( result->Run[0].PageCount = Memory->NumberOfPages; v14 < Memory->NumberOfRuns; ++v14 )
    {
      if( v14 )
      {
        v15 = v14;
        if( Memory->Run[v14].BasePage == *((_QWORD *)&Memory->NumberOfRuns + 2 * v14) + Memory->Run[v14 - 1].PageCount )
        {
          v12[v13].PageCount += Memory->Run[v14].PageCount;
          continue;
        }
      }
      else
      {
        v15 = 0i64;
      }
      v16 = v15;
      v17 = v13++;
      v12[v17 + 1].BasePage = Memory->Run[v16].BasePage;
      v12[v17 + 1].PageCount = Memory->Run[v16].PageCount;
    }
    return(PHYSICAL_MEMORY_DESCRIPTOR *)((char *)result + 16);
  }
  return result;
}

Referenced by:

MiInitNucleus
MiMakePartitionMemoryBlock