HalpMmAllocateMemoryInternal

PSTR __stdcall HalpMmAllocateMemoryInternal(UINT64 Size, _MEMORY_CACHING_TYPE CacheType){
  unsigned int v3; 
  PSTR result; 
  unsigned int v5; 
  UINT64 v6; 
  char *v7; 
  UINT64 Protection; 

  if( !LoaderBlock || KeGetPcr()->Prcb.Number )
    KeBugCheckEx(0x5Cu, (PVOID)0x8000, (PVOID)0x8675309, 0i64, 0i64);
  if( (unsigned int)CacheType > MmCached )
    return 0i64;
  v3 = (Size + 7) & 0xFFFFFFF8;
  if( dword_140C50680 >= v3 )
  {
    result = (PSTR)qword_140C50678;
    qword_140C50678 += v3;
    dword_140C50680 -= v3;
    return result;
  }
  v5 = (v3 + 4095) >> 12;
  v6 = HalpAllocPhysicalMemory(LoaderBlock, 0i64, v5, 0i64);
  if( !v6 )
    return 0i64;
  LODWORD(Protection) = 4;
  v7 = (char *)HalpMap(
                 (_LARGE_INTEGER)v6,
                 (_MEMORY_CACHING_TYPE)v5,
                 (_MEMORY_CACHING_TYPE)(CacheType == MmCached),
                 0,
                 Protection);
  if( v7 )
  {
    qword_140C50678 = (__int64)&v7[v3];
    dword_140C50680 = (v5 << 12) - v3;
  }
  return v7;
}

Referenced by:

ExtEnvAllocateMemory
ExtEnvRegisterIommu
HalRegisterPermanentAddressUsage
HalSocRequestApi
HalpBlkAllocateShadowData
HalpCopyDebugDescriptor
HalpExtInitExtensions
HalpExtRegisterResourceDescriptor
HalpInitializeInterrupts
HalpInterruptInitializeIpis
HalpInterruptMapParkedPage
HalpInterruptParseMadt
HalpInterruptRegisterController
HalpInterruptRegisterLine
HalpIommuCreateDmarPageTable
HalpIommuPopulateExceptionList
HalpIommuProcessReservationsInternal
HalpMmAllocateMemory
HalpMmAllocatePerProcessorMemory
HalpPowerInitNvsRegionData
HalpRegisterDmaController
HalpSetupAcpiPhase0
HalpTimerCreateReferencePage
HalpTimerRegister