HalpVpptUpdatePhysicalTimer

NTSTATUS __stdcall HalpVpptUpdatePhysicalTimer(){
  void *v0; 
  void *v1; 
  INT64 v2; 
  unsigned __int64 v3; 
  __int64 v4; 
  __int64 v5; 
  INT64 v6; 
  void *v7; 
  void *v8; 
  __int64 v9; 
  __int64 v10; 
  NTSTATUS v11; 
  INT64 v12; 
  unsigned __int64 v13; 
  INT64 v14; 
  unsigned __int64 v15; 
  unsigned __int64 v16; 
  NTSTATUS result; 
  INT64 v18; 
  INT64 CurrentQpc; 

  v2 = *(unsigned int *)(Arg2 + 16);
  v3 = *(_QWORD *)(Arg2 + 32);
  if( (_DWORD)dword_140C4A428 != (_DWORD)v2 )
  {
    HalpTimerGetInternalData((_KDPC *)qword_140C4A480, qword_140C4A480, v0, v1);
    (*(void(__fastcall **)(__int64))(v4 + 136))(v5);
    if( (*((_DWORD *)qword_140C4A480 + 56) & 0x200000) == 0 )
    {
      HalpTimerGetInternalData((_KDPC *)qword_140C4A480, qword_140C4A480, v7, v8);
      (*(void(__fastcall **)(__int64))(v9 + 104))(v10);
    }
    if( (_DWORD)dword_140C4A428 != (_DWORD)v2 )
    {
      v11 = ExtEnvSetVpptTarget(v6, (unsigned int)v2);
      if( v11 < 0 )
        ExtEnvCriticalFailure(v12, 276i64, (unsigned int)dword_140C4A428, v2, v11);
      LODWORD(dword_140C4A428) = v2;
    }
  }
  LODWORD(v13) = RtlGetInterruptTimePrecise(&CurrentQpc);
  if( v13 <= v3 )
    v15 = v3 - v13;
  else
    v15 = 0i64;
  v16 = 0x989680ui64 / *((_QWORD *)qword_140C4A480 + 24);
  if( *((_DWORD *)qword_140C4A480 + 57) == 2 )
  {
    if( v16 < 0x1312 )
      v16 = 4882i64;
  }
  else if( v16 < 0x1388 )
  {
    v16 = 5000i64;
  }
  if( v15 >= v16 )
    v16 = v15;
  result = HalpSetTimerAnyMode((_KDPC *)qword_140C4A480, v16, v14, (INT64)&CurrentQpc);
  if( result < 0 )
    ExtEnvCriticalFailure(v18, 277i64, (INT64)qword_140C4A480, v16, result);
  return result;
}

Referenced by:

HalpVpptAcknowledgeInterrupt
HalpVpptArmTimer
HalpVpptStop