KiInsertTimerTable
UINT8 __stdcall KiInsertTimerTable(_KPRCB *CurrentPrcb, _KTIMER *Timer, _KDPC *Dpc, UINT64 Hand, UINT8 *Late){
unsigned int v5;
__int64 v6;
unsigned int v9;
unsigned __int64 v10;
unsigned __int64 v11;
char *v12;
char *v13;
char *v14;
unsigned __int64 v15;
char **v16;
_KTIMER_TABLE *v17;
unsigned int v18;
__int64 v19;
UINT8 v20;
int v21;
struct _KPRCB *v22;
int Number;
char **v25;
char *v26;
__int64 v27;
char v28;
unsigned __int64 v29;
int v30[8];
UINT64 SpinCount;
volatile signed __int64 *v32;
_KTIMER_TABLE *TimerTable;
INT64 v34;
char v35;
v5 = 0;
v6 = (unsigned int)Hand;
v32 = 0i64;
v35 = 0;
if( !*((_DWORD *)Timer + 15) )
*((_DWORD *)Timer + 1) = 0;
v9 = 0;
if( !KiSerializeTimerExpiration )
{
if( Dpc && (Number = Dpc->Number, (unsigned __int16)Number >= 0x500u) )
{
v9 = Number - 1280;
}
else
{
v9 = *((_DWORD *)CurrentPrcb + 9);
if( (*((_BYTE *)CurrentPrcb + 35) & 2) != 0 )
{
v27 = *(_QWORD *)(*((_QWORD *)CurrentPrcb + 24) + 80i64) & *(_QWORD *)(*((_QWORD *)CurrentPrcb + 24) + 136i64);
if( v27 )
{
v28 = *((_BYTE *)CurrentPrcb + 209);
_BitScanForward64(&v29, __ROR8__(v27, v28));
v9 = KiProcessorNumberToIndexMappingTable[64 * *((unsigned __int8 *)CurrentPrcb + 208)
+ (((unsigned __int8)v29 + v28) & 0x3F)];
}
}
}
}
v10 = *((_QWORD *)Timer + 3);
*((_WORD *)Timer + 28) = v9;
v34 = (INT64)KeGetCurrentPrcb();
v11 = (unsigned __int64)*((unsigned __int16 *)Timer + 29) << 8;
TimerTable = (_KTIMER_TABLE *)((char *)*(&KiProcessorBlock + v9) + 14656);
v12 = (char *)TimerTable + 32 * v11 + 32 * (unsigned int)Hand + 512;
LODWORD(SpinCount) = 0;
v13 = v12 + 8;
while( _interlockedbittestandset64((volatile signed __int32 *)v12, 0i64) )
{
do
KeYieldProcessorEx(&SpinCount);
while( *(_QWORD *)v12 );
}
v14 = (char *)*((_QWORD *)v12 + 1);
v32 = (volatile signed __int64 *)v12;
if( v14 == v12 + 8 )
{
v5 = 6;
}
else
{
v15 = *((_QWORD *)v14 - 1);
if( v10 > v15 )
{
v25 = (char **)(v12 + 16);
if( v10 - v15 <= (unsigned __int64)KeMaximumIncrement >> 2 )
{
v13 = v14;
if( v14 != *v25 )
{
do
{
v26 = *(char **)v13;
if( v10 <= *(_QWORD *)(*(_QWORD *)v13 - 8i64) )
break;
v13 = *(char **)v13;
}
while( v26 != *v25 );
}
}
else
{
v13 = *v25;
do
{
if( v10 >= *((_QWORD *)v13 - 1) )
break;
v13 = (char *)*((_QWORD *)v13 + 1);
}
while( v13 != v12 + 8 );
}
}
else
{
v5 = v10 < v15 ? 2 : 0;
}
v14 = *(char **)v13;
}
v16 = (char **)((char *)Timer + 32);
if( *((char **)v14 + 1) != v13 )
__fastfail(3u);
*((_QWORD *)Timer + 5) = v13;
*v16 = v14;
*((_QWORD *)v14 + 1) = v16;
*(_QWORD *)v13 = v16;
if( (v5 & 2) != 0 )
{
*((_QWORD *)v12 + 3) = v10;
_InterlockedOr(v30, 0);
v17 = TimerTable;
if( v5 >= 4 )
{
if( KiSerializeTimerExpiration )
{
v18 = v6 & 0x3F;
v19 = 8i64 * ((unsigned int)v6 >> 6);
}
else
{
v18 = *((unsigned __int8 *)TimerTable - 14447);
v19 = v6 << 6;
}
_interlockedbittestandset64(
(volatile signed __int32 *)(qword_140CFC7A8[2 * *((unsigned __int8 *)TimerTable - 14448)] + v19),
v18);
}
if( v10 <= *(_QWORD *)&KUSER_SHARED_DATA.InterruptTime.LowPart )
{
if( Late )
{
v20 = 1;
v35 = 1;
goto LABEL_18;
}
LOBYTE(v5) = 1;
KiRemoveEntryTimer(v17, Timer, (unsigned int)v6);
}
}
v20 = 0;
LABEL_18:
v21 = (int)v32;
_InterlockedAnd64(v32, 0i64);
v22 = KeGetCurrentPrcb();
if( *((_QWORD *)v22 + 4247) && *((_BYTE *)v22 + 32) <= 1u && !v21 )
v20 = v35;
if( Late )
*Late = v20;
return(v5 & 1) == 0;
}Referenced by:
ExpSetTimerObject
KeSetTimerEx
KiAdjustTimerDueTimes
KiCommitThreadWait
KiResumeThread
KiSetTimerEx
KiTimerWaitTest