PopFxRegisterPluginEx
NTSTATUS __stdcall PopFxRegisterPluginEx(
_PEP_INFORMATION *PepInformation,
UINT64 Attributes,
_PEP_KERNEL_INFORMATION_STRUCT_V3 *KernelInformation){
__int16 v3;
int v7;
bool v8;
__int16 v10;
VOID **PoolWithTag;
VOID **v12;
_ETHREAD *CurrentThread;
VOID ***v14;
_QWORD *v15;
_ETHREAD *v16;
unsigned int SessionId;
unsigned __int8 v18;
int v19;
bool v20;
__int64 v21;
_KLOCK_ENTRY *v22;
int v23;
unsigned int v24;
__int64 v25;
UINT64 a3;
v3 = *(_WORD *)KernelInformation;
if( *(_WORD *)KernelInformation > 3u )
return -1073700860;
switch( v3 )
{
case 3:
v8 = *((_WORD *)KernelInformation + 1) < 0x60u;
break;
case 2:
v8 = *((_WORD *)KernelInformation + 1) < 0x58u;
break;
case 0:
return -1073741811;
default:
goto LABEL_11;
}
if( v8 )
return -1073741811;
LABEL_11:
if( *((_WORD *)KernelInformation + 1) < 0x38u )
return -1073741811;
v10 = *(_WORD *)PepInformation;
if( *(_WORD *)PepInformation > 3u )
return -1073700859;
if( v10 == 3 )
{
if( *((_WORD *)PepInformation + 1) < 0x20u || !*((_QWORD *)PepInformation + 1) && !*((_QWORD *)PepInformation + 3) )
return -1073741811;
}
else if( v10 != 2 || *((_WORD *)PepInformation + 1) < 0x18u || !*((_QWORD *)PepInformation + 1) )
{
return -1073741811;
}
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0x1A8ui64, 1297630800i64);
v12 = PoolWithTag;
if( !PoolWithTag )
return -1073741670;
memset(PoolWithTag, 0i64, 0x1A8u);
v7 = PopFxInitializeWorkPool(v12 + 15, (INT64)v12);
if( v7 >= 0 )
{
*((_DWORD *)v12 + 4) = *(unsigned __int16 *)PepInformation;
v12[3] = (VOID *)Attributes;
v12[12] = (VOID *)*((_QWORD *)PepInformation + 1);
v12[13] = (VOID *)*((_QWORD *)PepInformation + 2);
if( *(_WORD *)PepInformation >= 3u )
v12[14] = (VOID *)*((_QWORD *)PepInformation + 3);
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--CurrentThread->Tcb.KernelApcDisable;
ExAcquirePushLockExclusiveEx((_EX_PUSH_LOCK *)&stru_140C23628 + 497, 0i64);
v14 = (VOID ***)*(&stru_140C23628 + 488);
v15 = (_QWORD *)**(&stru_140C23628 + 488);
if( *(_QWORD *)(**(&stru_140C23628 + 488) + 8i64) != *(&stru_140C23628 + 488) )
__fastfail(3u);
v12[1] = (VOID *)*(&stru_140C23628 + 488);
*v12 = v15;
v15[1] = v12;
*v14 = v12;
if( (Attributes & 0x80000000) != 0 )
*(&stru_140C23628 + 488) = v12;
if( (_InterlockedExchangeAdd64((_QWORD *)&stru_140C23628 + 497, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock((_EX_PUSH_LOCK *)&stru_140C23628 + 497);
LODWORD(a3) = 0;
v16 = (_ETHREAD *)KeGetCurrentThread();
if( MiGetSystemRegionType((UINT64)&stru_140C23628 + 3976) == 1 )
SessionId = MmGetSessionIdEx(v16->Tcb.ApcState.Process);
else
SessionId = -1;
--v16->Tcb.SpecialApcDisable;
v18 = ++v16->Tcb.AbAllocationRegionCount;
v19 = ((char)v16->Tcb.AbEntrySummary | (char)v16->Tcb.AbOrphanedEntrySummary) ^ 0x3F;
while( 1 )
{
v20 = !_BitScanReverse((unsigned int *)&v21, v19);
if( v20 )
break;
v22 = &v16->Tcb.LockEntries[v21];
v19 &= ~(1 << v21);
if( (v22->AcquiredByte & 1) != 0
&& (v22->LockState.$E8276A2CF8B819ED32D1B6FEB35D730A::_bf_0 & 1) == 0
&& (v22->LockState.$E8276A2CF8B819ED32D1B6FEB35D730A::_bf_0 & 0x7FFFFFFFFFFFFFFCi64) == (((unsigned __int64)&stru_140C23628
+ 3976) & 0x7FFFFFFFFFFFFFFCi64)
&& v22->LockState.SessionId == SessionId )
{
v22->AcquiredByte &= ~1u;
if( v22->LockState.$E8276A2CF8B819ED32D1B6FEB35D730A::_bf_0 )
{
if( v22 )
{
v22->CrossThreadReleasableAndBusyByte |= 2u;
if( v22->LockState.$E8276A2CF8B819ED32D1B6FEB35D730A::_bf_0 < 0 )
KiAbEntryRemoveFromTree(v22);
v23 = v22->BoostBitmap.AllFields & 0x1FFFF;
v24 = v22->BoostBitmap.AllFields & 0xFFFE0000;
v22->ThreadLocalFlags &= ~1u;
LODWORD(a3) = v23;
v22->BoostBitmap.AllFields = v24;
v22->LockState.$E8276A2CF8B819ED32D1B6FEB35D730A::_bf_0 = 0i64;
v25 = v22 - v16->Tcb.LockEntries;
if( v18 == 1 )
v16->Tcb.AbEntrySummary |= 1 << v25;
else
_InterlockedOr8((volatile signed __int8 *)&v16->Tcb.AbOrphanedEntrySummary, 1 << v25);
goto LABEL_50;
}
break;
}
}
}
if( (*(&v16->Tcb.MiscFlags + 1) & 0x10000) == 0 )
KeBugCheckEx(0x162u, v16, (char *)&stru_140C23628 + 3976, (PVOID)SessionId, 0i64);
LABEL_50:
--v16->Tcb.AbAllocationRegionCount;
KiAbThreadRemoveBoosts(&v16->Tcb, (char *)&stru_140C23628 + 3976, &a3);
v20 = v16->Tcb.SpecialApcDisable++ == -1;
if( v20 && ($F25F8C4BA33AF922A5F1AF68CD89DDDF *)v16->Tcb.ApcState.ApcListHead[0].Flink != &v16->Tcb.152 )
KiCheckForKernelApcDelivery();
KeLeaveCriticalRegionThread(KeGetCurrentThread());
PopDiagTraceFxPluginRegistration(v12, Attributes, 0);
*((_QWORD *)KernelInformation + 4) = 0i64;
*((_QWORD *)KernelInformation + 5) = 0i64;
*((_QWORD *)KernelInformation + 3) = 0i64;
v8 = *(_WORD *)KernelInformation < 2u;
*((_QWORD *)KernelInformation + 2) = PopFxRequestWorker;
*((_QWORD *)KernelInformation + 6) = PopFxTransitionCriticalResource;
*((_QWORD *)KernelInformation + 1) = v12;
if( !v8 )
{
*((_QWORD *)KernelInformation + 7) = PopFxProcessorIdleVeto;
*((_QWORD *)KernelInformation + 8) = PopFxPlatformIdleVeto;
*((_QWORD *)KernelInformation + 9) = PopFxUpdateProcessorIdleState;
*((_QWORD *)KernelInformation + 10) = PopFxUpdatePlatformIdleState;
}
if( *(_WORD *)PepInformation >= 3u )
{
*((_QWORD *)KernelInformation + 11) = PopFxRequestCommon;
if( *(_WORD *)PepInformation == 3 )
{
if( *((_QWORD *)PepInformation + 3) )
PopFxAcpiPepRegistered = 1;
}
}
return 0;
}
else
{
ExFreePoolWithTag(v12, 0x4D584650u);
}
return v7;
}Referenced by:
PoFxRegisterPlugin
PoFxRegisterPluginEx