PsBoostThreadIoEx
VOID __stdcall PsBoostThreadIoEx(_ETHREAD *Thread, UINT8 Unboost, UINT8 DoTracking, VOID *Context){
signed __int32 v4;
unsigned __int8 v5;
UINT8 v7;
_LIST_ENTRY *v10;
bool v11;
unsigned __int8 CurrentIrql;
struct _KPRCB *CurrentPrcb;
int v14;
VOID **PoolWithTag;
_LIST_ENTRY *p_BoostList;
_LIST_ENTRY *Flink;
_LIST_ENTRY *p_DeboostList;
_LIST_ENTRY *v19;
_LIST_ENTRY *v20;
_LIST_ENTRY *v21;
_LIST_ENTRY *v22;
_LIST_ENTRY *Blink;
v4 = 0;
v5 = 0;
v7 = DoTracking;
v10 = 0i64;
if( PspAlwaysTrackIoBoosting )
{
v7 = 1;
}
else if( !DoTracking )
{
goto LABEL_3;
}
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0x70ui64, 1936682818i64);
v10 = (_LIST_ENTRY *)PoolWithTag;
if( PoolWithTag )
{
memset(PoolWithTag, 0i64, 0x70u);
RtlCaptureStackBackTrace(1ui64, 0xAui64, (VOID **)&v10[1].Flink, 0i64);
v10[6].Flink = (_LIST_ENTRY *)KeGetCurrentThread();
v10[6].Blink = (_LIST_ENTRY *)Context;
}
v5 = KeAcquireSpinLockRaiseToDpc(&Thread->BoostListLock);
LABEL_3:
if( Unboost )
{
if( Thread->IoBoostCount )
{
v4 = _InterlockedDecrement((volatile signed __int32 *)&Thread->IoBoostCount);
if( !v7 )
goto LABEL_6;
if( !Thread->IoBoostCount )
{
if( v10 )
ExFreePoolWithTag(v10, 0x736F6F42u);
p_BoostList = &Thread->BoostList;
while( 1 )
{
Flink = p_BoostList->Flink;
if( p_BoostList->Flink == p_BoostList )
break;
v20 = Flink->Flink;
if( Flink->Blink != p_BoostList || v20->Blink != Flink )
goto LABEL_36;
p_BoostList->Flink = v20;
v20->Blink = p_BoostList;
ExFreePoolWithTag(Flink, 0x736F6F42u);
}
p_DeboostList = &Thread->DeboostList;
while( 1 )
{
v19 = p_DeboostList->Flink;
if( p_DeboostList->Flink == p_DeboostList )
goto LABEL_27;
v22 = v19->Flink;
if( v19->Blink != p_DeboostList || v22->Blink != v19 )
goto LABEL_36;
p_DeboostList->Flink = v22;
v22->Blink = p_DeboostList;
ExFreePoolWithTag(v19, 0x736F6F42u);
}
}
if( v10 )
{
Blink = Thread->DeboostList.Blink;
if( Blink->Flink == &Thread->DeboostList )
{
v10->Flink = &Thread->DeboostList;
v10->Blink = Blink;
Blink->Flink = v10;
Thread->DeboostList.Blink = v10;
goto LABEL_27;
}
LABEL_36:
__fastfail(3u);
}
}
}
else
{
v4 = _InterlockedIncrement((volatile signed __int32 *)&Thread->IoBoostCount);
if( !v7 )
goto LABEL_13;
if( !v10 )
goto LABEL_27;
v21 = Thread->BoostList.Blink;
if( v21->Flink != &Thread->BoostList )
goto LABEL_36;
v10->Flink = &Thread->BoostList;
v10->Blink = v21;
v21->Flink = v10;
Thread->BoostList.Blink = v10;
}
LABEL_27:
if( v7 )
{
KxReleaseSpinLock(&Thread->BoostListLock);
__writecr8(v5);
}
LABEL_6:
if( !Unboost )
{
LABEL_13:
v11 = v4 == 1;
goto LABEL_8;
}
v11 = v4 == 0;
LABEL_8:
if( v11 && !Unboost && Thread->Tcb.AbWaitEntryCount )
{
CurrentIrql = KeGetCurrentIrql();
__writecr8(2ui64);
CurrentPrcb = KeGetCurrentPrcb();
KiAbThreadInsertList(Thread, &CurrentPrcb->AbPropagateBoostsList, &Thread->Tcb.PropagateBoostsEntry);
if( v14 )
KiAbQueueAutoBoostDpc(CurrentPrcb);
__writecr8(CurrentIrql);
}
}Referenced by:
CcAcquireByteRangeForWrite
CcApplyLowIoPriorityToThread
CcBoostLowPriorityWorkerThread
ExDeleteResourceLite
ExEnterPriorityRegionAndAcquireResourceExclusive
ExEnterPriorityRegionAndAcquireResourceShared
ExReinitializeResourceLite
ExReleaseResourceAndLeavePriorityRegion
ExpAcquireResourceExclusiveLite
ExpAcquireResourceSharedLite
ExpApplyPriorityBoost
ExpBoostIoAfterAcquire
ExpFreeOwnerEntry
ExpReleaseResourceExclusiveForThreadLite
ExpReleaseResourceSharedForThreadLite
ExpSetResourceOwnerPointerEx
FsRtlReleaseEofLock
FsRtlpDoBoost
FsRtlpModifyThreadPriorities
IoBoostThreadIo
KiAbThreadBoostIoPriority
KiAbThreadUnboostIoPriority
PsBoostThreadIo
PsEnterPriorityRegion
PsLeavePriorityRegion