PopPepRegisterDevice
char __fastcall PopPepRegisterDevice(__int64 a1, __int64 a2, __int64 a3, int a4, _QWORD *a5){
char v5;
unsigned int v9;
unsigned int v10;
__int64 v11;
unsigned int v12;
int v13;
unsigned int v14;
__int64 v15;
__int64 v16;
VOID *PoolWithTag;
INT64 v18;
INT64 v19;
INT64 *v20;
_QWORD *v21;
char *v22;
unsigned __int64 v23;
unsigned int v24;
__int64 *v25;
INT64 v26;
__int64 v27;
char *v28;
unsigned __int64 v29;
INT64 *v30;
INT64 v31;
_QWORD *v32;
int v33;
int v34;
_DWORD *v35;
unsigned int v36;
unsigned int v37;
__int64 v38;
UINT64 v39;
int LatencyIdleState;
UINT64 v41;
INT64 v42;
__int64 v43;
int v44;
_QWORD *v46;
__int64 v47;
UINT64 Size;
v5 = 0;
*a5 = 0i64;
v9 = *(_DWORD *)(a3 + 8);
if( v9 )
{
v10 = 0;
v11 = a3 + 16;
v12 = 0;
while( 1 )
{
v13 = *(_DWORD *)(*(_QWORD *)v11 + 28i64);
if( !v13 )
break;
if( v13 < 0 )
break;
v14 = v13 + v10;
if( v13 + v10 < v10 )
break;
++v12;
v11 += 8i64;
v10 += v13;
if( v12 >= v9 )
{
v15 = 0i64;
v16 = (int)(200 * v9 + 184);
if( v14 )
{
v15 = (int)(200 * v9 + 184);
v16 += 24i64 * v14;
}
Size = v16 + 60i64 * (v9 + 1);
PoolWithTag = ExAllocatePoolWithTag(NonPagedPoolNx, Size, 0x54706550ui64);
v18 = (INT64)PoolWithTag;
if( PoolWithTag )
{
DbgPrintEx(0x92u, 3u, "PopPep: register device(0x%p, %wZ)\n", PoolWithTag, a1);
memset(v18, 0i64);
*(_QWORD *)(v18 + 32) = a2;
v46 = (_QWORD *)(v15 + v18);
v19 = v18 + v16;
*(_QWORD *)(v18 + 24) = *(_QWORD *)a3;
KeInitializeEvent((_KEVENT *)(v18 + 40), NotificationEvent, 0);
v20 = (INT64 *)(v18 + 72);
*(_DWORD *)(v18 + 180) = v9;
v21 = (_QWORD *)(v18 + 72);
*(_DWORD *)(v18 + 140) = v9;
*(_BYTE *)(v18 + 136) = 1;
v22 = ActivityAttributes;
v23 = 0i64;
do
{
if( v23 <= 5 && *v22 == 1 )
{
*v21 = v19;
v19 += 20i64;
}
++v23;
++v21;
v22 += 136;
}
while( (__int64)v22 < (__int64)&EmptyUnicodeString );
*(_QWORD *)(v18 + 16) |= 1ui64;
v24 = 0;
v25 = (__int64 *)(a3 + 16);
v47 = a3 + 16;
v26 = v18 + 216;
while( 1 )
{
v27 = *v25;
*(_DWORD *)(v26 - 24) = v24;
v28 = ActivityAttributes;
*(_DWORD *)(v26 - 28) = 3;
v29 = 0i64;
v30 = v20;
do
{
v31 = v19;
if( v29 <= 5 && *v28 == 1 )
v31 = *v30;
else
v19 += 20i64;
*(INT64 *)((char *)v30 + -48 - v18 + v26) = v31;
++v29;
++v30;
v28 += 136;
}
while( (__int64)v28 < (__int64)&EmptyUnicodeString );
KeInitializeEvent((_KEVENT *)v26, NotificationEvent, 0);
v32 = v46;
*(_QWORD *)(v26 - 16) = *(_QWORD *)(v27 + 16);
v33 = *(_DWORD *)(v27 + 28);
*(_DWORD *)(v26 + 156) = v33;
v34 = v33 - 1;
if( (unsigned int)(v33 - 1) >= *(_DWORD *)(v27 + 24) )
v34 = *(_DWORD *)(v27 + 24);
*(_DWORD *)(v27 + 24) = v34;
*(_QWORD *)(v26 + 80) = -1i64;
*(_QWORD *)(v26 + 88) = 0i64;
v35 = *(_DWORD **)(v26 + 48);
*(_DWORD *)(v26 + 116) = v34;
*(_QWORD *)(v26 + 160) = v46;
*(_QWORD *)(v26 + 96) = 0i64;
*v35 |= 4u;
v36 = *(_DWORD *)(v27 + 28);
if( v36 > 1 )
{
*(_QWORD *)(v18 + 16) &= ~1ui64;
v36 = *(_DWORD *)(v27 + 28);
}
v37 = 0;
if( v36 )
break;
LABEL_28:
v39 = *(_QWORD *)(v26 + 80);
*(_DWORD *)(v26 + 120) = 0;
LatencyIdleState = PopPepComponentGetLatencyIdleState(v26 - 32, v39);
v41 = *(_QWORD *)(v26 + 88);
*(_DWORD *)(v26 + 124) = LatencyIdleState;
*(_DWORD *)(v26 + 128) = PopPepComponentGetResidencyIdleState(v42, v41);
++v24;
v44 = *(_DWORD *)(v26 + 156) - 1;
*(_DWORD *)(v26 + 132) = v44;
*(_DWORD *)(v26 + 136) = v44;
*(_DWORD *)(v26 + 140) = v44;
v26 += 200i64;
v25 = (__int64 *)(v47 + 8);
v47 += 8i64;
if( v24 >= v9 )
{
v5 = 1;
*a5 = v18;
if( a4 == 2 )
*(_BYTE *)(v18 + 124) = 1;
*(_DWORD *)(v18 + 168) = 1;
PopPepInsertDevice(v43, v18);
return v5;
}
v20 = (INT64 *)(v18 + 72);
}
while( (unsigned __int64)v32 - v18 <= Size - 24 )
{
v38 = v37++;
*v32 = *(_QWORD *)(*(_QWORD *)(v27 + 32) + 24 * v38);
v32[1] = *(_QWORD *)(*(_QWORD *)(v27 + 32) + 24 * v38 + 8);
v32 += 3;
v46 = v32;
if( v37 >= *(_DWORD *)(v27 + 28) )
goto LABEL_28;
}
ExFreePoolWithTag((PVOID)v18, 0x54706550u);
}
return v5;
}
}
}
return v5;
}Referenced by:
PopFxRegisterDeviceWithPep