SMKM_STORE::SmStTrimWsStore
__int64 __fastcall SMKM_STORE::SmStTrimWsStore(__int64 a1, __int64 a2){
unsigned int v4;
_QWORD *v5;
bool v6;
__int64 v7;
_ETHREAD *CurrentThread;
unsigned int v9;
INT64 *v10;
__int64 v11;
unsigned int v12;
unsigned int v13;
__int64 v14;
_DWORD *v15;
_DWORD *v16;
int v17;
int v18;
_DWORD *v19;
unsigned int i;
unsigned int v21;
__int64 v22;
__int64 v23;
__int64 v24;
unsigned int v25;
__int64 v26;
__int64 v27;
__int64 v28;
int v30;
__int64 j;
__int64 v33;
_QWORD *v34;
_KAPC_STATE ApcState;
int v36[8];
__int64 result[8];
memset(&ApcState, 0, sizeof(ApcState));
memset((INT64)result, 0i64);
KiStackAttachProcess(*(_KPROCESS **)(a1 + 6584), 0i64, &ApcState);
if( (*(_BYTE *)(a1 + 6021) & 8) != 0 )
{
v4 = 0;
goto LABEL_58;
}
v5 = (_QWORD *)_InterlockedExchange64((volatile __int64 *)(a1 + 6568), -1i64);
v34 = v5;
if( v5 == (_QWORD *)-1i64 )
{
v4 = -1073740682;
goto LABEL_58;
}
v4 = 0;
if( !v5 || !*v5 || (v6 = a2 == 0, v7 = (__int64)(v5 + 1), !v6) )
v7 = 0i64;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
v9 = 0;
v33 = v7;
--*((_WORD *)CurrentThread + 243);
v10 = (INT64 *)(a1 + 6024);
ExAcquirePushLockSharedEx(a1 + 6024, 0i64);
if( v7 )
{
v12 = 0;
while( 1 )
{
v13 = *(_DWORD *)v7;
if( *(_DWORD *)v7 <= v12 )
{
LABEL_41:
v5 = v34;
v10 = (INT64 *)(a1 + 6024);
break;
}
v14 = *(_QWORD *)(v7 + 8);
v11 = v12;
v15 = (_DWORD *)(v14 + 4 * ((unsigned __int64)(v13 - 1) >> 5));
v16 = (_DWORD *)(v14 + 4 * ((unsigned __int64)v12 >> 5));
if( v16 != v15 && (*v16 | *((_DWORD *)qword_140011CE0 + (v12 & 0x1F))) == -1 )
{
v11 = v12 - (v12 & 0x1F) + 32;
for( ++v16; v16 < v15 && *v16 == -1; ++v16 )
v11 = (unsigned int)(v11 + 32);
}
for( ; (unsigned int)v11 < v13; v11 = (unsigned int)(v11 + 1) )
{
if( !_bittest(*(const signed __int32 **)(v7 + 8), v11) )
break;
}
v17 = 0;
if( v16 != v15 )
{
v18 = v11 & 0x1F;
if( (*v16 & ~*((_DWORD *)qword_140011CE0 + (v11 & 0x1F))) == 0 )
{
v17 = 32 - v18;
if( v18 == 33 )
goto LABEL_32;
v19 = v16 + 1;
while( v19 < v15 && !*v19 )
{
++v19;
v17 += 32;
if( v17 == -1 )
goto LABEL_32;
}
}
}
for( i = v17 + v11; i < *(_DWORD *)v7; ++v17 )
{
if( _bittest(*(const signed __int32 **)(v7 + 8), i) )
break;
if( v17 == -1 )
break;
++i;
}
LABEL_32:
v12 = v11;
if( !v17 )
goto LABEL_41;
if( (unsigned int)v11 < v17 + (int)v11 )
{
v21 = v17 + v11;
v22 = 8i64 * (unsigned int)v11;
do
{
v23 = *(_QWORD *)(v22 + *(_QWORD *)(a1 + 6216));
if( (v23 & 0x7FFFFFFFFFFF0000i64) != 0 && v23 >= 0 )
{
v24 = v9;
v36[v9++] = v12;
result[v24] = SMKM_STORE::SmStMapVirtualRegion(a1, v12, 0, v11, 4u);
if( v9 == 8 )
{
SMKM_STORE::SmStTrimWsStoreBatch(a1, (unsigned int *)v36, (PVOID *)result, 8u, v30, 0i64);
v9 = 0;
}
}
++v12;
v22 += 8i64;
}
while( v12 < v21 );
v7 = v33;
}
}
}
v25 = 0;
v26 = a2;
for( j = a2; v25 < *(_DWORD *)(a1 + 6212); ++v25 )
{
v27 = *(_QWORD *)(*(_QWORD *)(a1 + 6216) + 8i64 * v25);
if( (v27 & 0x7FFFFFFFFFFF0000i64) != 0 && v27 >= 0 && (!v7 || _bittest64(*(const signed __int64 **)(v7 + 8), v25)) )
{
v28 = v9;
v36[v9++] = v25;
result[v28] = SMKM_STORE::SmStMapVirtualRegion(a1, v25, 0, v11, 4u);
v26 = a2;
if( v9 == 8 )
{
SMKM_STORE::SmStTrimWsStoreBatch(
a1,
(unsigned int *)v36,
(PVOID *)result,
8u,
v30,
(_QWORD *)((unsigned __int64)&j & -(__int64)(a2 != 0)));
v26 = a2;
v9 = 0;
if( a2 )
{
if( !j )
goto LABEL_55;
}
}
v7 = v33;
}
else
{
v26 = a2;
}
}
if( v9 )
SMKM_STORE::SmStTrimWsStoreBatch(
a1,
(unsigned int *)v36,
(PVOID *)result,
v9,
v30,
(_QWORD *)((unsigned __int64)&j & -(__int64)(v26 != 0)));
LABEL_55:
if( _InterlockedCompareExchange64(v10, 0i64, 17i64) != 17 )
ExfReleasePushLockShared(v10);
KeAbPostRelease(v10);
KiLeaveGuardedRegionUnsafe((__int64)KeGetCurrentThread());
_InterlockedExchange64((volatile __int64 *)(a1 + 6568), (__int64)v5);
LABEL_58:
KiUnstackDetachProcess(&ApcState, 0i64);
return v4;
}
Referenced by:
No references.