HalpMmAllocCtxFree

VOID __stdcall HalpMmAllocCtxFree(_HALP_ALLOC_CONTEXT *Context, VOID *Memory){
  unsigned __int64 v3; 
  __int64 *i; 
  UINT32 v5; 
  __int64 v6; 
  unsigned int *v7; 
  __int64 *v8; 
  __int64 **v9; 
  unsigned int v10; 
  int *v11; 
  int v12; 
  int *v13; 
  bool j; 
  __int64 v15; 
  __int64 v16; 

  v3 = (unsigned __int8)KeAcquireSpinLockRaiseToDpc(qword_140C4B790);
  if( ((unsigned __int16)Memory & 0xFFF) == 0 )
  {
    for( i = (__int64 *)qword_140C4B780; i != &qword_140C4B780; i = (__int64 *)*i )
    {
      if( Memory == (VOID *)i[2] )
      {
        v5 = *((_DWORD *)i + 7);
        LODWORD(v6) = 0;
        *((_DWORD *)i + 7) = 0;
        goto LABEL_3;
      }
    }
  }
  i = (__int64 *)*((_QWORD *)Memory - 2);
  v5 = *((_DWORD *)Memory - 2);
  v6 = ((__int64)Memory - i[2] - 16) / 16;
LABEL_3:
  v7 = (unsigned int *)(i + 4);
  RtlClearBits((PRTL_BITMAP)i + 2, v6, v5);
  *((_DWORD *)i + 6) = v6;
  v8 = (__int64 *)*i;
  v9 = (__int64 **)i[1];
  if( *(__int64 **)(*i + 8) != i || *v9 != i )
    goto LABEL_28;
  *v9 = v8;
  v8[1] = (__int64)v9;
  v10 = *v7;
  if( !*v7 )
  {
LABEL_13:
    v15 = qword_140C4B780;
    if( *(_QWORD **)(qword_140C4B780 + 8i64) == &qword_140C4B780 )
    {
      *i = qword_140C4B780;
      i[1] = (__int64)&qword_140C4B780;
      *(_QWORD *)(v15 + 8) = i;
      qword_140C4B780 = i;
      i = 0i64;
      goto LABEL_15;
    }
LABEL_28:
    __fastfail(3u);
  }
  if( v10 <= 1 )
  {
    if( _bittest((const signed __int32 *)i[5], 0) )
      goto LABEL_13;
  }
  else
  {
    v11 = (int *)i[5];
    v12 = *v11;
    v13 = &v11[(unsigned __int64)(v10 - 1) >> 5];
    if( v11 == v13 )
    {
      if( (v12 & (0xFFFFFFFF >> (32 - v10))) != 0 )
        goto LABEL_13;
    }
    else
    {
      for( j = v12 == 0; ; j = *v11 == 0 )
      {
        if( !j )
          goto LABEL_13;
        if( ++v11 == v13 )
          break;
      }
      if( ((0xFFFFFFFF >> ~(v10 - 1)) & *v11) != 0 )
        goto LABEL_13;
    }
  }
LABEL_15:
  KxReleaseSpinLock(qword_140C4B790);
  __writecr8(v3);
  if( i )
    HalpMmAllocCtxBufferCleanup(v16, i);
}

Referenced by:

Amd64AddProfileSource
Amd64RemoveProfileSource
EmonAddProfileSource
EmonAllocateResources
EmonReleaseProfileResources
EmonRemoveProfileSource
ExtEnvFreeMemory
ExtEnvFreePhysicalMemory
HalAllocateCommonBufferVector
HalFreeCommonBufferVector
HalpAcpiPopulateTableCacheWork
HalpAllocatePmcCounterSet
HalpBuildResumeStructures
HalpDmaAllocateEmergencyResources
HalpDmaAllocateLocalContiguousPool
HalpDmaAllocateLocalScatterPool
HalpDmaAllocateMapRegisters
HalpDmaAllocateMappingResources
HalpDmaAllocateNewTranslationBuffer
HalpDmaAllocateReservedMapping
HalpDmaAllocateReservedMappingArray
HalpDmaAllocateTranslationBuffer
HalpDmaDereferenceDomainObject
HalpDmaFreeChildAdapter
HalpDmaFreeTranslationBuffer
HalpDmaInitializeMasterAdapter
HalpFreeNvsBuffers
HalpFreePmcCounterSet
HalpFreeResumeStructures
HalpIommuAllocateDmaDomain
HalpIommuBlockDevice
HalpIommuCleanupPageTable
HalpIommuCloneDeviceId
HalpIommuCreateDevice
HalpIommuCreateDmarPageTable
HalpIommuCreateIncreaseAliasTrack
HalpIommuDeleteDevice
HalpIommuDereferenceHardwareDomain
HalpIommuFreeDeviceId
HalpIommuFreeDmaDomain
HalpIommuGetHardwareDomain
HalpLaDeleteBlt
HalpLaFreeState
HalpLaInitializeState
HalpLapDeleteSubtree
HalpLapSplitNode
HalpMapCR3Ex
HalpMceInitializeErrorPacket
HalpMmFreeTiledMemoryMap
HalpNumaAddRangeProximity
IommuDisableDevicePasid
IommuDomainDetachDevice
IommuEnableDevicePasid
IommuGetLibraryContext
IommuMapDevice
IommuUnmapDevice
IommupGetSystemContext