ViHasBufferBeenTouched

UINT64 *__stdcall ViHasBufferBeenTouched(VOID *Address, UINT64 Length, UINT8 ExpectedFillChar){
  __int64 v3; 
  unsigned int i; 
  char v6; 

  v3 = 15i64;
  for( i = 1; i < 8; i *= 2 )
  {
    v6 = 8 * i;
    v3 |= v3 << v6;
  }
  while( ((unsigned __int8)Address & 7) != 0 && Length )
  {
    if( *(_BYTE *)Address != 15 )
      return(UINT64 *)Address;
    Address = (char *)Address + 1;
    --Length;
  }
  while( Length >= 8 )
  {
    if( *(_QWORD *)Address != v3 )
      return(UINT64 *)Address;
    Address = (char *)Address + 8;
    Length -= 8i64;
  }
  if( Length )
  {
    while( *(_BYTE *)Address == 15 )
    {
      Address = (char *)Address + 1;
      if( !--Length )
        return 0i64;
    }
    return(UINT64 *)Address;
  }
  return 0i64;
}

Referenced by:

ViCheckPadding