RtlpGenericRandomPatternWorker
UINT8 __stdcall RtlpGenericRandomPatternWorker(PVOID VirtualAddress){
unsigned int v1;
char *v2;
__int64 **v4;
__int64 *v5;
unsigned __int64 v6;
unsigned __int64 v7;
unsigned int v8;
UINT64 v9;
unsigned __int64 v10;
struct _KPRCB *CurrentPrcb;
__int64 v12;
char *i;
char *v14;
unsigned __int64 v15;
struct _KPRCB *v16;
UINT64 v17;
char *j;
unsigned __int64 *v19;
unsigned __int64 v20;
unsigned __int64 v21;
unsigned __int64 v22;
struct _KPRCB *v23;
UINT64 v24;
char *k;
struct _KPRCB *v26;
UINT64 v27;
char *m;
_QWORD *v29;
unsigned __int64 v30;
struct _KPRCB *v31;
__int64 v32;
char *n;
_QWORD *v34;
unsigned __int64 v35;
struct _KPRCB *v36;
__int64 v37;
char *ii;
_DWORD *v39;
signed __int32 v41[14];
v1 = 0;
v2 = (char *)VirtualAddress + 4096;
v4 = &GlfsrXorLookupTables;
LABEL_2:
v5 = *v4;
v6 = *(_QWORD *)RtlpSeedGlfsr;
v7 = __rdtsc();
v8 = 0;
v9 = (unsigned int)v7;
do
{
v10 = ((unsigned int)v9 & (unsigned __int64)(1i64 << v8)) << v8;
++v8;
v6 ^= v10;
}
while( v8 < 0x20 );
RtlpFillMemoryRandomUp(VirtualAddress, v9, (UINT64 *)v6);
CurrentPrcb = KeGetCurrentPrcb();
v12 = *((unsigned int *)CurrentPrcb + 58);
if( *((_DWORD *)CurrentPrcb + 58) )
{
_InterlockedOr(v41, 0);
for( i = (char *)((unsigned __int64)VirtualAddress & ~(v12 - 1)); i < v2; i += v12 )
_mm_clflush(i);
}
v14 = (char *)VirtualAddress;
v15 = v6;
if( VirtualAddress >= v2 )
{
LABEL_12:
v16 = KeGetCurrentPrcb();
v17 = *((unsigned int *)v16 + 58);
if( *((_DWORD *)v16 + 58) )
{
_InterlockedOr(v41, 0);
for( j = (char *)((unsigned __int64)VirtualAddress & ~(v17 - 1)); j < v2; j += v17 )
_mm_clflush(j);
}
if( RtlpTestMemoryRandomUp(VirtualAddress, v17, (UINT64 *)v6) )
{
v19 = (unsigned __int64 *)VirtualAddress;
v20 = v6;
v21 = 0i64;
v22 = (unsigned __int64)(v2 - (_BYTE *)VirtualAddress + 7) >> 3;
if( VirtualAddress > v2 )
v22 = 0i64;
if( v22 )
{
do
{
++v21;
*v19++ = ~v20;
v20 = (v20 >> 4) ^ v5[v20 & 0xF];
}
while( v21 < v22 );
}
v23 = KeGetCurrentPrcb();
v24 = *((unsigned int *)v23 + 58);
if( *((_DWORD *)v23 + 58) )
{
_InterlockedOr(v41, 0);
for( k = (char *)((unsigned __int64)VirtualAddress & ~(v24 - 1)); k < v2; k += v24 )
_mm_clflush(k);
}
RtlpFillMemoryRandomUp(VirtualAddress, v24, (UINT64 *)v6);
v26 = KeGetCurrentPrcb();
v27 = *((unsigned int *)v26 + 58);
if( *((_DWORD *)v26 + 58) )
{
_InterlockedOr(v41, 0);
for( m = (char *)((unsigned __int64)VirtualAddress & ~(v27 - 1)); m < v2; m += v27 )
_mm_clflush(m);
}
if( RtlpTestMemoryRandomUp(VirtualAddress, v27, (UINT64 *)v6) )
{
v29 = v2;
v30 = v6;
do
{
*--v29 = ~v30;
v30 = (v30 >> 4) ^ v5[v30 & 0xF];
}
while( v29 != VirtualAddress );
v31 = KeGetCurrentPrcb();
v32 = *((unsigned int *)v31 + 58);
if( *((_DWORD *)v31 + 58) )
{
_InterlockedOr(v41, 0);
for( n = (char *)((unsigned __int64)VirtualAddress & ~(v32 - 1)); n < v2; n += v32 )
_mm_clflush(n);
}
v34 = v2;
v35 = v6;
do
{
*--v34 = v35;
v35 = (v35 >> 4) ^ v5[v35 & 0xF];
}
while( v34 != VirtualAddress );
v36 = KeGetCurrentPrcb();
v37 = *((unsigned int *)v36 + 58);
if( *((_DWORD *)v36 + 58) )
{
_InterlockedOr(v41, 0);
for( ii = (char *)((unsigned __int64)VirtualAddress & ~(v37 - 1)); ii < v2; ii += v37 )
_mm_clflush(ii);
}
v39 = v2;
while( *(v39 - 1) == HIDWORD(v6) )
{
v39 -= 2;
if( *v39 != (_DWORD)v6 )
break;
v6 = (v6 >> 4) ^ v5[v6 & 0xF];
if( v39 == VirtualAddress )
{
++v1;
++v4;
if( v1 < 5 )
goto LABEL_2;
return 1;
}
}
}
}
}
else
{
while( *(_DWORD *)v14 == (_DWORD)v15 )
{
*(_DWORD *)v14 = v15;
if( *((_DWORD *)v14 + 1) != HIDWORD(v15) )
break;
*((_DWORD *)v14 + 1) = HIDWORD(v15);
v14 += 8;
v15 = (v15 >> 4) ^ v5[v15 & 0xF];
if( v14 >= v2 )
goto LABEL_12;
}
}
return 0;
}Referenced by:
RtlScrubMemory