KiInsertTimer2WithCollectionLockHeld
UINT8 __stdcall KiInsertTimer2WithCollectionLockHeld(_KTIMER2 *Timer, UINT8 InsertLate, UINT8 *WasLate){
bool *v3;
bool *v4;
unsigned __int8 v6;
UINT8 v7;
UINT8 v8;
int v10;
int v11;
__int64 v12;
__int64 v13;
UINT64 v14;
UINT64 *v15;
BOOL v16;
int v17;
UINT64 v18;
UINT64 v19;
_KTIMER2 *v20;
unsigned __int8 v21;
UINT64 *v22;
__int64 v23;
UINT64 v24;
BOOL v25;
int v26;
UINT64 v27;
UINT64 v28;
_KTIMER2 *v29;
bool v31;
signed __int32 *SchedulerAssist;
signed __int32 v33;
signed __int32 v34;
int v35[8];
v4 = v3;
v6 = Timer->CollectionIndex[0];
v7 = InsertLate;
v8 = 1;
v10 = 0;
*WasLate = 0;
v11 = 0;
*v3 = 0;
if( v6 == 21 || (v6 & 0x20) != 0 && Timer->DueTime[0] == Timer->DueTime[1] )
{
Timer->CollectionIndex[0] = v6 | 0x10;
}
else
{
Timer->CollectionIndex[0] = v6 & 0xEF;
v12 = 3i64 * (v6 & 7);
v13 = KiTimer2Collections[v12 + 1];
v14 = KiTimer2Collections[v12];
v15 = &KiTimer2Collections[v12];
if( (v13 & 1) != 0 )
{
if( v14 )
v14 ^= (unsigned __int64)v15;
else
v14 = 0i64;
}
v16 = 0;
v17 = v13 & 1;
if( v14 )
{
while( 1 )
{
if( Timer->DueTime[0] < *(_QWORD *)(v14 + 48) )
{
v18 = *(_QWORD *)v14;
if( v17 )
{
if( !v18 )
break;
v18 ^= v14;
}
if( !v18 )
break;
}
else
{
v18 = *(_QWORD *)(v14 + 8);
if( v17 )
{
if( !v18 )
goto LABEL_20;
v18 ^= v14;
}
if( !v18 )
{
LABEL_20:
v16 = 1;
break;
}
}
v14 = v18;
}
}
RtlRbInsertNodeEx(v15, v14, v16, (UINT64)&Timer->gap0[24]);
v19 = v15[1];
if( (v19 & 1) != 0 )
{
if( v19 == 1 )
v20 = 0i64;
else
v20 = (_KTIMER2 *)(v19 ^ ((unsigned __int64)v15 | 1));
}
else
{
v20 = (_KTIMER2 *)v15[1];
}
if( v20 == (_KTIMER2 *)&Timer->gap0[24] )
{
v15[2] = Timer->DueTime[0];
v11 = 1;
}
else
{
v11 = 0;
}
}
v21 = Timer->CollectionIndex[1];
if( Timer->DueTime[1] == -1i64 )
{
Timer->CollectionIndex[1] = v21 | 0x10;
}
else
{
Timer->CollectionIndex[1] = v21 & 0xEF;
v22 = (UINT64 *)(0x140000000i64 + 24i64 * (v21 & 7) + 12786240);
v23 = *(_QWORD *)(0x140000008i64 + 24i64 * (v21 & 7) + 12786240);
v24 = *v22;
if( (v23 & 1) != 0 )
{
if( v24 )
v24 ^= (unsigned __int64)v22;
else
v24 = 0i64;
}
v25 = 0;
v26 = v23 & 1;
if( v24 )
{
while( 1 )
{
if( Timer->DueTime[1] < *(_QWORD *)(v24 + 32) )
{
v27 = *(_QWORD *)v24;
if( v26 )
{
if( !v27 )
goto LABEL_40;
v27 ^= v24;
}
if( !v27 )
{
LABEL_40:
v25 = 0;
break;
}
}
else
{
v27 = *(_QWORD *)(v24 + 8);
if( v26 )
{
if( !v27 )
goto LABEL_63;
v27 ^= v24;
}
if( !v27 )
{
LABEL_63:
v25 = 1;
break;
}
}
v24 = v27;
}
}
RtlRbInsertNodeEx(v22, v24, v25, (UINT64)&Timer->gap0[48]);
v28 = v22[1];
if( (v28 & 1) != 0 )
{
if( v28 == 1 )
v29 = 0i64;
else
v29 = (_KTIMER2 *)(v28 ^ ((unsigned __int64)v22 | 1));
}
else
{
v29 = (_KTIMER2 *)v22[1];
}
if( v29 == (_KTIMER2 *)&Timer->gap0[48] )
{
v10 = 1;
v22[2] = Timer->DueTime[1];
}
v7 = InsertLate;
v11 |= v10;
}
if( v11 )
{
if( KiNextTimer2DueTime > Timer->DueTime[0] )
{
KiNextTimer2DueTime = Timer->DueTime[0];
_InterlockedOr(v35, 0);
}
if( Timer->DueTime[0] <= *(_QWORD *)&KUSER_SHARED_DATA.InterruptTime.LowPart )
{
*WasLate = 1;
if( !v7 )
{
KiRemoveTimer2(Timer);
v8 = 0;
}
}
}
if( (Timer->TypeFlags & 4) != 0 && _InterlockedIncrement(&KiHrTimerActiveCount) == 1 )
{
v31 = 0;
SchedulerAssist = (signed __int32 *)(*(&KiProcessorBlock + (unsigned int)KiClockTimerOwner))->SchedulerAssist;
if( SchedulerAssist && (KiVelocityFlags & 0x40) != 0 )
{
_m_prefetchw(SchedulerAssist);
v33 = *SchedulerAssist;
do
{
v34 = v33;
v33 = _InterlockedCompareExchange(SchedulerAssist, v33 | 0x80000, v33);
}
while( v34 != v33 );
v31 = (v33 & 0x80000) == 0;
}
*v4 = v31;
}
return v8;
}Referenced by:
KeSetTimer2
KiInsertTimer2