HalpTimerMeasureFrequencies
NTSTATUS __fastcall HalpTimerMeasureFrequencies(_KDPC *Dpc, VOID *a2, VOID *a3, VOID *a4){
unsigned __int64 v4;
INT64 *v5;
int v6;
INT64 v8;
void *v9;
void *v10;
void *v11;
INT64 *v12;
INT64 *v13;
void *v14;
void *v15;
void *v16;
INT64 *v17;
INT64 *v18;
__int64 v19;
void *v20;
void *v21;
VOID *v22;
UINT64 v23;
void *v24;
void *v25;
void *v26;
INT64 *v27;
INT64 *v28;
__int64 v29;
INT64 *v30;
INT64 *v31;
int v32;
unsigned __int64 v33;
unsigned __int64 v34;
void *v35;
char *v36;
unsigned int v37;
void *v38;
__int64 v39;
__int64(__fastcall *v40)(__int64);
__int64 v41;
__int64 v42;
__int64 v43;
__int64 v44;
__int64 v45;
__int64 v46;
__int64 v47;
void *retaddr;
v4 = (unsigned __int64)&retaddr;
v5 = (INT64 *)HalpRegisteredTimers;
v6 = (__int64)Dpc[3].DeferredContext & 2;
LOBYTE(a2) = 0;
if( (INT64 *)HalpRegisteredTimers != &HalpRegisteredTimers )
{
do
{
v8 = (INT64)v5;
v5 = (INT64 *)*v5;
if( *(_QWORD *)(v8 + 192) )
{
LODWORD(v4) = *(_DWORD *)(v8 + 184);
if( (v4 & 8) == 0 )
continue;
}
LODWORD(v4) = *(_DWORD *)(v8 + 224);
if( (v4 & 2) != 0 )
{
LODWORD(v4) = HalpTimerInitialize(v8, a2, a3, a4);
LOBYTE(a2) = 1;
}
}
while( v5 != &HalpRegisteredTimers );
if( (_BYTE)a2 )
{
KeStallExecutionProcessor(0x5DCu);
v12 = (INT64 *)HalpRegisteredTimers;
while( v12 != &HalpRegisteredTimers )
{
v13 = v12;
v12 = (INT64 *)*v12;
if( (!v13[24] || (v13[23] & 8) != 0) && (v13[28] & 2) != 0 && (v13[23] & 2) != 0 )
{
if( v6 )
{
*((_DWORD *)v13 + 12) = HalpTimerDetermineValidTimerPairReadLatency((_KDPC *)v13, Dpc);
}
else
{
HalpTimerGetInternalData((_KDPC *)v13, v9, v10, v11);
v13[2] = ((__int64(__fastcall *)(__int64))v13[14])(v41);
}
}
}
HalpProcessorFence();
if( ((__int64)Dpc[3].DeferredContext & 2) == 0 )
{
HalpTimerGetInternalData(Dpc, v14, v15, v16);
((void(__fastcall *)(__int64, _QWORD))Dpc[2].SystemArgument2)(v42, 0i64);
}
v17 = (INT64 *)HalpRegisteredTimers;
while( v17 != &HalpRegisteredTimers )
{
v18 = v17;
v19 = (__int64)v17;
v17 = (INT64 *)*v17;
if( (!v18[24] || (v18[23] & 8) != 0) && (*(_DWORD *)(v19 + 224) & 2) != 0 && (*(_DWORD *)(v19 + 184) & 2) != 0 )
{
if( v6 )
{
HalpTimerReadTimerPairWithLatencyLimit(
*(_DWORD *)(v19 + 48),
v19,
(__int64)Dpc,
(UINT64 *)v18 + 2,
(UINT64 *)(v19 + 24));
}
else
{
HalpTimerGetInternalData((_KDPC *)v19, v14, v15, v16);
v18[2] = (*(__int64(__fastcall **)(__int64))(v43 + 112))(v44);
}
}
}
HalpProcessorFence();
if( ((__int64)Dpc[3].DeferredContext & 2) != 0 )
{
v23 = 1250000i64;
HalpTimerStallExecutionProcessor(Dpc, (VOID *)0x1312D0, 0i64, v22);
}
else
{
HalpTimerGetInternalData(Dpc, v20, v21, v22);
v23 = ((__int64(__fastcall *)(__int64, __int64))Dpc[2].SystemArgument2)(v45, 1250000i64);
}
LODWORD(v4) = HalpProcessorFence();
v27 = (INT64 *)HalpRegisteredTimers;
while( v27 != &HalpRegisteredTimers )
{
v28 = v27;
v29 = (__int64)v27;
v27 = (INT64 *)*v27;
if( v28[24] )
{
LODWORD(v4) = *((_DWORD *)v28 + 46);
if( (v4 & 8) == 0 )
continue;
}
LODWORD(v4) = *(_DWORD *)(v29 + 224);
if( (v4 & 2) != 0 )
{
LODWORD(v4) = *(_DWORD *)(v29 + 184);
if( (v4 & 2) != 0 )
{
if( v6 )
{
LODWORD(v4) = HalpTimerReadTimerPairWithLatencyLimit(
*(_DWORD *)(v29 + 48),
v29,
(__int64)Dpc,
(UINT64 *)v28 + 4,
(UINT64 *)(v29 + 40));
}
else
{
HalpTimerGetInternalData((_KDPC *)v29, v24, v25, v26);
v4 = (*(__int64(__fastcall **)(__int64))(v46 + 112))(v47);
v28[4] = v4;
}
}
}
}
v30 = (INT64 *)HalpRegisteredTimers;
while( v30 != &HalpRegisteredTimers )
{
v31 = v30;
v30 = (INT64 *)*v30;
if( v31[24] )
{
LODWORD(v4) = *((_DWORD *)v31 + 46);
if( (v4 & 8) == 0 )
continue;
}
LODWORD(v4) = *((_DWORD *)v31 + 56);
if( (v4 & 2) != 0 )
{
v32 = *((_DWORD *)v31 + 46);
if( (v32 & 2) != 0 )
{
v33 = v31[2];
v34 = v31[4] - v33;
v35 = (void *)v31[3];
v36 = (char *)(v31[5] - (_QWORD)v35);
if( v31[4] < v33 )
v34 += 1i64 << *((_DWORD *)v31 + 55);
if( v31[5] < (unsigned __int64)v35 )
v36 += 1i64 << HIDWORD(Dpc[3].DeferredRoutine);
if( v6 )
v23 = HalpTimerScaleCounter((UINT64)v36, *(_QWORD *)&Dpc[3].TargetInfoAsUlong, 0x989680ui64);
v37 = v32 & 0xFFFFFFF7;
v4 = 10000000 * v34 / v23;
*((_DWORD *)v31 + 46) = v37;
v31[24] = v4;
if( v31 != (INT64 *)Dpc && (v37 & 4) == 0 )
{
v38 = (void *)v31[17];
if( v38 )
{
HalpTimerGetInternalData((_KDPC *)v31, v38, v35, v36);
LODWORD(v4) = v40(v39);
}
}
}
}
}
}
}
return v4;
}Referenced by:
HalpTimerSelectRoles