HalSocRequestApi

INT64 __fastcall HalSocRequestApi(INT64 a1, INT64 a2, INT64 a3, UINT64 a4, VOID *dst){
  unsigned int v5; 
  unsigned int v6; 
  __int64 *v8; 
  char v9; 
  int v10; 
  int v11; 
  int v12; 
  int v13; 
  int v14; 
  __int64(__fastcall **p_Src)(); 
  unsigned int v16; 
  _QWORD *i; 
  int v19; 
  PSTR MemoryInternal; 
  UINT64(__fastcall *v21)(INT64, UINT64); 
  __int128 v22; 
  __int128 Src; 
  __int128 v24; 
  v5 = 0;
  v21 = 0i64;
  v6 = a4;
  v8 = 0i64;
  v9 = 0;
  Src = 0i64;
  v22 = 0i64;
  v10 = a3 - 1;
  if( !v10 )
  {
    p_Src = HalpTimerCmosApi;
    goto LABEL_8;
  }
  v11 = v10 - 1;
  if( !v11 )
  {
    p_Src = &HalpTimerPcCpuApi;
    goto LABEL_8;
  }
  v12 = v11 - 1;
  if( !v12 )
  {
    if( HalpIsMicrosoftCompatibleHvLoaded() )
    {
      v24 = 0i64;
      LODWORD(v24) = EAX(__cpuid(1073741827, 0));
      if( (v24 & 2) != 0 )
      {
        p_Src = (__int64(__fastcall **)())&HalpTimerHypervisorReferenceTime;
        HalpTimerHypervisorReferenceTime = (__int64)qword_140C4A148;
        v8 = &HalpTimerHvReferenceCallbackList;
        v16 = 8;
        v9 = 1;
        goto LABEL_9;
      }
    }
    return(unsigned int)-1073741637;
  }
  v13 = v12 - 1;
  if( !v13 )
  {
    v16 = 8;
    v21 = HalpSocApiAllocatePhysicalMemory;
    p_Src = (__int64(__fastcall **)())&v21;
    goto LABEL_9;
  }
  v14 = v13 - 1;
  if( v14 )
  {
    v19 = v14 - 1;
    if( v19 )
    {
      if( v19 != 1 )
      {
        HalpTimerLastProblem = 27;
        return(unsigned int)-1073741811;
      }
      p_Src = HalpTimerSkipApi;
      goto LABEL_8;
    }
    if( HalpHvIsFrequencyAvailable() )
    {
      *(_QWORD *)&v22 = HalpHvGetTscFrequency;
      p_Src = (__int64(__fastcall **)())&v22;
      *((_QWORD *)&v22 + 1) = HalpHvGetApicFrequency;
      goto LABEL_8;
    }
    return(unsigned int)-1073741637;
  }
  p_Src = (__int64(__fastcall **)())&Src;
  Src = xmmword_140C4A128;
  v8 = &HalpTimerHvApicCallbackList;
  v9 = 1;
LABEL_8:
  v16 = 16;
LABEL_9:
  if( !dst || v6 > v16 )
  {
    HalpTimerLastProblem = 28;
    return(unsigned int)-1073741811;
  }
  if( v6 < v16 )
  {
    v5 = -1073741789;
    HalpTimerLastProblem = 28;
    return v5;
  }
  if( !v9 )
    goto LABEL_13;
  if( !a2 )
    return(unsigned int)-1073741811;
  for( i = (_QWORD *)*v8; i; i = (_QWORD *)*i )
  {
    if( i[1] == a2 )
      goto LABEL_13;
  }
  MemoryInternal = HalpMmAllocateMemoryInternal(0x10ui64, MmCached);
  if( !MemoryInternal )
    return(unsigned int)-1073741801;
  *((_QWORD *)MemoryInternal + 1) = a2;
  *(_QWORD *)MemoryInternal = *v8;
  *v8 = (__int64)MemoryInternal;
LABEL_13:
  memmove((UINT8 *)dst, (UINT8 *)p_Src, v16);
  return v5;
}

Referenced by:

HalpApicGetCpuInfo
HalpApicSetupRegisterAccess
HalpApicTimerDiscover
HalpApicTimerIsInvariant
HalpArtAvailable
HalpHvCounterUpdateCallback
HalpHvDiscover
HalpHvTimerInitialize
HalpIvtProcessDrhdEntry
HalpRtcDiscover
HalpTscDiscover
HalpTscGetAttributes
HalpVpptTimerRegister
HsaInitializeIommu
IvtInitializeIommu