MiAllocateCombineProto
INT64 *__fastcall MiAllocateCombineProto(INT64 a1, UINT64 a2, UINT64 a3, _QWORD *a4, INT64 a5){
unsigned int v6;
unsigned __int64 inserted;
UINT64 v10;
volatile LONG *v11;
unsigned __int64 v12;
INT64 v13;
int v14;
unsigned int v16;
signed __int64 v17;
signed __int64 v18;
__int64 *v19;
_QWORD *v20;
__int64 v21;
int v22;
__int64 v23;
void *v24;
struct _KLOCK_QUEUE_HANDLE LockHandle;
UINT64 v26;
unsigned int v27;
int v28;
_QWORD *v29;
v6 = a3;
memset(&LockHandle, 0, sizeof(LockHandle));
if( !a2 )
return 0i64;
inserted = 0i64;
v10 = a2 & 0xF;
v11 = (volatile LONG *)(16 * v10 + a1 + 104);
v12 = ExAcquireSpinLockShared(v11);
v28 = 0;
v26 = a2;
v27 = v6;
v29 = a4;
v13 = *(_QWORD *)(a1 + 16 * (v10 + 6));
if( !v13 )
{
LABEL_8:
v14 = a5;
goto LABEL_9;
}
while( 1 )
{
if( a2 > *(_QWORD *)(v13 + 24) )
{
LABEL_6:
v13 = *(_QWORD *)(v13 + 8);
goto LABEL_7;
}
if( a2 >= *(_QWORD *)(v13 + 24) )
{
v16 = *(_DWORD *)(v13 + 40) & 0x1F;
if( v6 >= v16 )
{
if( v6 > v16 )
goto LABEL_6;
if( !a4 )
break;
if( *a4 > *(_QWORD *)(v13 + 64) )
goto LABEL_6;
if( *a4 >= *(_QWORD *)(v13 + 64) )
break;
}
}
v13 = *(_QWORD *)v13;
LABEL_7:
if( !v13 )
goto LABEL_8;
}
v17 = *(_QWORD *)(v13 + 32);
if( !v17 )
{
LABEL_30:
v14 = 0;
LABEL_9:
_InterlockedAnd(v11, 0xBFFFFFFF);
_InterlockedDecrement(v11);
__writecr8(v12);
if( !v14 )
return 0i64;
KeAcquireInStackQueuedSpinLock((UINT64 *)(a1 + 88), &LockHandle);
v19 = *(__int64 **)(a1 + 72);
v20 = (_QWORD *)(a1 + 72);
if( v19 != (__int64 *)(a1 + 72) )
{
inserted = *(_QWORD *)(a1 + 72);
v21 = *v19;
if( *(_QWORD **)(inserted + 8) != v20 || *(_QWORD *)(v21 + 8) != inserted )
__fastfail(3u);
*v20 = v21;
*(_QWORD *)(v21 + 8) = v20;
++*(_DWORD *)((inserted & 0xFFFFFFFFFFFFF000ui64) + 8);
}
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
__writecr8(LockHandle.OldIrql);
if( !inserted )
{
LODWORD(v23) = MiAllocatePool((struct _SLIST_ENTRY *)0x112);
v24 = (void *)v23;
if( !v23 )
return 0i64;
*(_DWORD *)(v23 + 8) = 1;
*(_QWORD *)(v23 + 16) = a1;
inserted = (unsigned __int64)MiInsertNewCombineBlocks(a1, v23 + 72);
if( !inserted )
{
ExFreePoolWithTag(v24, 0);
return 0i64;
}
}
_InterlockedExchangeAdd((volatile signed __int32 *)(a1 + 388), 1u);
v22 = (*(_DWORD *)(inserted + 40) ^ v6) & 0x1F;
*(_QWORD *)(inserted + 32) = 1i64;
*(_DWORD *)(inserted + 40) ^= v22;
*(_QWORD *)(inserted + 64) = *a4;
_InterlockedExchangeAdd((volatile signed __int32 *)(a1 + 392), 1u);
return(INT64 *)inserted;
}
while( 1 )
{
v18 = v17;
v17 = _InterlockedCompareExchange64((volatile signed __int64 *)(v13 + 32), v17 + 1, v17);
if( v18 == v17 )
break;
if( !v17 )
goto LABEL_30;
}
ExReleaseSpinLockSharedFromDpcLevel(v11);
__writecr8(v12);
_InterlockedExchangeAdd((volatile signed __int32 *)(a1 + 392), 1u);
return(INT64 *)v13;
}Referenced by:
MiProcessCrcList
MiSharePages