EmonOverflowHandler
VOID __stdcall EmonOverflowHandler(KTRAP_FRAME *TrFrame){
unsigned int v1;
_KTRAP_FRAME *v2;
__int64 v3;
__int64 v4;
unsigned int v5;
unsigned int v6;
unsigned __int64 v7;
unsigned int v8;
unsigned int v9;
unsigned __int64 v10;
unsigned __int64 v11;
__int64 v12;
__int64 v13;
__int64 v14;
unsigned int v15;
int v16;
unsigned int v17;
UINT64 v18;
unsigned __int64 v19;
int v20;
LARGE_INTEGER v21;
__int64 v22;
LARGE_INTEGER v23;
unsigned __int64 v24;
unsigned __int64 v25;
__int64 v26;
unsigned int v27;
unsigned int v28;
int v29;
__int64 v30;
__int64 v31;
unsigned __int64 v32;
unsigned __int64 v33;
__int64 *v34;
__int64 v35;
unsigned __int64 v36;
void(__fastcall *v37)(unsigned __int64, __int64 *, _KTRAP_FRAME *);
bool v38;
__int64 v39;
unsigned __int64 v40;
__int64 v41;
unsigned int v42;
unsigned int v43;
unsigned __int64 v44;
__int64 v45;
__int64 v46;
__int64 v47;
unsigned int v48;
int v49;
unsigned int v50;
UINT64 v51;
unsigned __int64 v52;
int v53;
LARGE_INTEGER v54;
__int64 v55;
LARGE_INTEGER v56;
unsigned __int64 v57;
unsigned __int64 v58;
__int64 v59;
unsigned int v60;
unsigned int v61;
int v62;
__int64 v63;
__int64 v64;
unsigned __int64 v65;
int v66;
UINT64 TotalTransitions;
UINT64 v68;
union _LARGE_INTEGER PerformanceFrequency;
__int64 v70;
union _LARGE_INTEGER v71;
unsigned __int64 v72;
unsigned int v74;
int v75;
unsigned int v76;
unsigned int v77;
unsigned int v78;
unsigned int v79;
v1 = *((_DWORD *)KeGetPcr() + 105);
v2 = TrFrame;
v74 = 0;
v3 = EmonCounterStatus + 16i64 * v1 * EmonNumberCounters;
if( (unsigned int)EmonVersion >= 2 )
{
v32 = EmonOverflowMask & __readmsr(0x38Eu);
v72 = v32;
if( (v32 & 0x4000000000000000i64) != 0 )
EmonPebsOverflowHandler();
v33 = v32 & 0xBFFFFFFFFFFFFFFFui64;
v34 = (__int64 *)EmonReservedResourcesList;
if( (v32 & 0x4000000000000000i64) == 0 )
v33 = v32;
if( (__int64 *)EmonReservedResourcesList != &EmonReservedResourcesList )
{
v35 = v1;
do
{
v36 = v33 & v34[v35 + 4];
if( v36 )
{
v37 = (void(__fastcall *)(unsigned __int64, __int64 *, _KTRAP_FRAME *))v34[2];
if( v37 )
v37(v33 & v34[v35 + 4], v34, v2);
}
v34 = (__int64 *)*v34;
v33 &= ~v36;
}
while( v34 != &EmonReservedResourcesList );
}
v38 = !_BitScanForward64((unsigned __int64 *)&v39, v33);
v75 = v39;
if( v38 )
{
LABEL_102:
__writemsr(0x390u, v32);
return;
}
v40 = 4289724415i64;
while( 1 )
{
v33 &= ~(1i64 << v39);
if( (unsigned int)v39 >= EmonNumberArchCounters )
{
LODWORD(v39) = EmonNumberArchCounters + v39 - 32;
v75 = v39;
}
v41 = 2i64 * (unsigned int)v39;
if( *(_DWORD *)(v3 + 16i64 * (unsigned int)v39) )
goto LABEL_100;
v70 = 0i64;
v42 = v39 - EmonNumberArchCounters + 32;
v77 = v42;
if( (unsigned int)v39 >= EmonNumberArchCounters )
{
v40 = __readmsr(0x38Fu);
_bittestandreset64((__int64 *)&v40, v42);
v43 = 911;
v70 = v40;
v44 = v40;
}
else
{
v43 = v39 + 390;
v44 = *(_DWORD *)(v3 + 16i64 * (unsigned int)v39 + 12) & 0xFFAFFFFF;
}
__writemsr(v43, v44);
v45 = *(unsigned int *)(v3 + 16i64 * (unsigned int)v39 + 4);
if( (_DWORD)v45 )
{
KeProfileInterruptWithSource(TrFrame, (_KPROFILE_SOURCE)v45);
LODWORD(v52) = *(_DWORD *)(v3 + 16i64 * (unsigned int)v39 + 8);
goto LABEL_90;
}
v68 = 0i64;
v71.QuadPart = 0i64;
if( HalpTimerProfilingCallback )
HalpTimerProfilingCallback(TrFrame, v45, v40);
else
KeProfileInterruptWithSource(TrFrame, ProfileTime);
v46 = HalpProfileData;
v47 = 32i64 * *((unsigned int *)KeGetPcr() + 105);
v48 = *(_DWORD *)(v47 + HalpProfileData + 24);
if( !v48 )
{
LODWORD(v52) = 0;
goto LABEL_87;
}
TotalTransitions = *(unsigned int *)(v47 + HalpProfileData + 16);
v49 = *(_DWORD *)(v47 + HalpProfileData + 20);
if( v49 )
{
v53 = v49 - 1;
*(_DWORD *)(v47 + HalpProfileData + 20) = v53;
if( v53 )
goto LABEL_76;
v79 = 0x2710 / v48;
*(_DWORD *)(v47 + v46 + 20) = 0x2710 / v48;
if( !(0x2710 / v48) )
{
*(_DWORD *)(v47 + v46 + 20) = 1;
v79 = 1;
}
PoGetProcessorIdleAccounting(&v68);
v51 = v68;
if( v68 == *(_QWORD *)(v47 + v46 + 8) )
{
v54 = KeQueryPerformanceCounter(&v71);
v55 = HalpProfileData;
v56 = v54;
v57 = v54.QuadPart - *(_QWORD *)(v47 + HalpProfileData);
if( v54.QuadPart != *(_QWORD *)(v47 + HalpProfileData) )
{
v58 = (unsigned int)TotalTransitions * v79 * (unsigned __int64)*(unsigned int *)(v47 + HalpProfileData + 24);
*(LARGE_INTEGER *)(v47 + HalpProfileData) = v56;
v52 = v71.QuadPart * (v58 / v57) / 0x989680;
if( v52 < 0x1000 )
v52 = 4096i64;
if( v52 > 0x7FFFFFFF )
LODWORD(v52) = 0x7FFFFFFF;
*(_DWORD *)(v47 + v55 + 16) = v52;
goto LABEL_87;
}
goto LABEL_76;
}
}
else
{
v50 = 0x2710 / v48;
if( !(0x2710 / v48) )
v50 = 1;
*(_DWORD *)(v47 + HalpProfileData + 20) = v50;
PoGetProcessorIdleAccounting(&v68);
v51 = v68;
}
*(_QWORD *)(v47 + v46 + 8) = v51;
*(LARGE_INTEGER *)(v47 + HalpProfileData) = KeQueryPerformanceCounter(0i64);
LABEL_76:
LODWORD(v52) = TotalTransitions;
LABEL_87:
LODWORD(v39) = v75;
v42 = v77;
LABEL_90:
if( (unsigned int)v39 >= EmonNumberArchCounters )
{
if( (unsigned int)EmonFixedCounterResolution < 0x40 )
v63 = (1i64 << EmonFixedCounterResolution) - 1;
else
v63 = -1i64;
__writemsr(v39 - EmonNumberArchCounters + 777, v63 & -(__int64)(unsigned int)v52);
v64 = v70;
_bittestandset64(&v64, v42);
v61 = HIDWORD(v64);
v62 = v64;
v60 = 911;
}
else
{
if( (unsigned int)EmonCounterResolution < 0x40 )
v59 = (1i64 << EmonCounterResolution) - 1;
else
v59 = -1i64;
__writemsr(v39 + 193, v59 & -(__int64)(unsigned int)v52);
v60 = v39 + 390;
v61 = 0;
v62 = *(_DWORD *)(v3 + 8 * v41 + 12) | 0x500000;
}
v40 = 4289724415i64;
__writemsr(v60, __PAIR64__(v61, v62));
LABEL_100:
v38 = !_BitScanForward64(&v65, v33);
LODWORD(v39) = v65;
v75 = v65;
if( v38 )
{
v32 = v72;
goto LABEL_102;
}
}
}
if( (unsigned int)EmonCounterResolution < 0x40 )
v4 = (1i64 << EmonCounterResolution) - 1;
else
v4 = -1i64;
if( EmonNumberCounters )
{
v5 = 0;
while( 1 )
{
if( !*(_DWORD *)(v3 + 16i64 * v5) )
{
v6 = v5 + 193;
v7 = __readmsr(v5 + 193);
if( ((((unsigned __int64)HIDWORD(v7) << 32) | (unsigned int)v7) & v4) < (v4 & 0xFFFFFFFF80000001ui64) )
break;
}
LABEL_46:
v5 = ++v74;
if( v74 >= EmonNumberCounters )
return;
}
v70 = 0i64;
v8 = v5 - EmonNumberArchCounters + 32;
v76 = v8;
if( v5 >= EmonNumberArchCounters )
{
v11 = __readmsr(0x38Fu);
_bittestandreset64((__int64 *)&v11, v8);
v9 = 911;
v70 = v11;
v10 = v11;
v2 = TrFrame;
}
else
{
v9 = v5 + 390;
v10 = *(_DWORD *)(v3 + 16i64 * v5 + 12) & 0xFFAFFFFF;
}
__writemsr(v9, v10);
v12 = *(unsigned int *)(v3 + 16i64 * v5 + 4);
if( (_DWORD)v12 )
{
KeProfileInterruptWithSource(v2, (_KPROFILE_SOURCE)v12);
LODWORD(v19) = *(_DWORD *)(v3 + 16i64 * v5 + 8);
goto LABEL_36;
}
TotalTransitions = 0i64;
PerformanceFrequency.QuadPart = 0i64;
if( HalpTimerProfilingCallback )
HalpTimerProfilingCallback(v2, v12, v2);
else
KeProfileInterruptWithSource(v2, ProfileTime);
v13 = HalpProfileData;
v14 = 32i64 * *((unsigned int *)KeGetPcr() + 105);
v15 = *(_DWORD *)(v14 + HalpProfileData + 24);
if( !v15 )
{
LODWORD(v19) = 0;
goto LABEL_33;
}
v66 = *(_DWORD *)(v14 + HalpProfileData + 16);
v16 = *(_DWORD *)(v14 + HalpProfileData + 20);
if( v16 )
{
v20 = v16 - 1;
*(_DWORD *)(v14 + HalpProfileData + 20) = v20;
if( v20 )
goto LABEL_22;
v78 = 0x2710 / v15;
*(_DWORD *)(v14 + v13 + 20) = 0x2710 / v15;
if( !(0x2710 / v15) )
{
*(_DWORD *)(v14 + v13 + 20) = 1;
v78 = 1;
}
PoGetProcessorIdleAccounting(&TotalTransitions);
v18 = TotalTransitions;
if( TotalTransitions == *(_QWORD *)(v14 + v13 + 8) )
{
v21 = KeQueryPerformanceCounter(&PerformanceFrequency);
v22 = HalpProfileData;
v23 = v21;
v24 = v21.QuadPart - *(_QWORD *)(v14 + HalpProfileData);
if( v21.QuadPart != *(_QWORD *)(v14 + HalpProfileData) )
{
v25 = v66 * v78 * (unsigned __int64)*(unsigned int *)(v14 + HalpProfileData + 24);
*(LARGE_INTEGER *)(v14 + HalpProfileData) = v23;
v19 = PerformanceFrequency.QuadPart * (v25 / v24) / 0x989680;
if( v19 < 0x1000 )
v19 = 4096i64;
if( v19 > 0x7FFFFFFF )
LODWORD(v19) = 0x7FFFFFFF;
*(_DWORD *)(v14 + v22 + 16) = v19;
goto LABEL_33;
}
goto LABEL_22;
}
}
else
{
v17 = 0x2710 / v15;
if( !(0x2710 / v15) )
v17 = 1;
*(_DWORD *)(v14 + HalpProfileData + 20) = v17;
PoGetProcessorIdleAccounting(&TotalTransitions);
v18 = TotalTransitions;
}
*(_QWORD *)(v14 + v13 + 8) = v18;
*(LARGE_INTEGER *)(v14 + HalpProfileData) = KeQueryPerformanceCounter(0i64);
LABEL_22:
LODWORD(v19) = v66;
LABEL_33:
v8 = v76;
v6 = v5 + 193;
LABEL_36:
if( v5 >= EmonNumberArchCounters )
{
if( (unsigned int)EmonFixedCounterResolution < 0x40 )
v30 = (1i64 << EmonFixedCounterResolution) - 1;
else
v30 = -1i64;
__writemsr(v5 - EmonNumberArchCounters + 777, v30 & -(__int64)(unsigned int)v19);
v31 = v70;
_bittestandset64(&v31, v8);
v28 = HIDWORD(v31);
v29 = v31;
v27 = 911;
}
else
{
if( (unsigned int)EmonCounterResolution < 0x40 )
v26 = (1i64 << EmonCounterResolution) - 1;
else
v26 = -1i64;
__writemsr(v6, v26 & -(__int64)(unsigned int)v19);
v27 = v5 + 390;
v28 = 0;
v29 = *(_DWORD *)(v3 + 16i64 * v5 + 12) | 0x500000;
}
v2 = TrFrame;
__writemsr(v27, __PAIR64__(v28, v29));
goto LABEL_46;
}
}Referenced by:
No references.