RtlpGenericMATSPlusWorker

UINT8 __stdcall RtlpGenericMATSPlusWorker(UINT64 Pattern, UINT64 Inverse, PVOID VirtualAddress){
  unsigned int v4; 
  _DWORD *v5; 
  unsigned int v6; 
  unsigned __int64 v7; 
  UINT8 v8; 
  struct _KPRCB *CurrentPrcb; 
  __int64 v10; 
  char *i; 
  UINT8 result; 
  unsigned __int64 v13; 
  int v14; 
  struct _KPRCB *v15; 
  __int64 v16; 
  char *j; 
  _DWORD *v18; 
  signed __int32 v19[10]; 
  v4 = Pattern;
  v5 = VirtualAddress;
  v6 = Inverse;
  v7 = 1024i64;
  if( ((unsigned __int8)VirtualAddress & 4) != 0 )
  {
    *v5 = Pattern;
    v7 = 1023i64;
    ++v5;
  }
  memset64(v5, (unsigned int)Pattern | ((unsigned __int64)(unsigned int)Pattern << 32), v7 >> 1);
  v8 = 1;
  if( (v7 & 1) != 0 )
    v5[v7 - 1] = Pattern;
  CurrentPrcb = KeGetCurrentPrcb();
  v10 = *((unsigned int *)CurrentPrcb + 58);
  if( *((_DWORD *)CurrentPrcb + 58) )
  {
    _InterlockedOr(v19, 0);
    for( i = (char *)((unsigned __int64)VirtualAddress & ~(v10 - 1)); i < (char *)VirtualAddress + 4096; i += v10 )
      _mm_clflush(i);
  }
  result = RtlpTestAndFillMemoryUp(v4, v6, VirtualAddress);
  if( result )
  {
    v15 = KeGetCurrentPrcb();
    v16 = *((unsigned int *)v15 + 58);
    if( *((_DWORD *)v15 + 58) )
    {
      _InterlockedOr(v19, 0);
      for( j = (char *)(v13 & ~(v16 - 1)); (unsigned __int64)j < v13 + 4096; j += v16 )
        _mm_clflush(j);
    }
    v18 = (_DWORD *)(v13 + 4096);
    while( *--v18 == v6 )
    {
      *v18 = v14;
      if( v18 == (_DWORD *)v13 )
        return v8;
    }
    return 0;
  }
  return result;
}

Referenced by:

RtlScrubMemory