def QueryValueEx(key, value_name):
  """This calls the Windows QueryValueEx function in a Unicode safe way."""
  size = 256
  data_type = ctypes.wintypes.DWORD()
  while True:
    tmp_size = ctypes.wintypes.DWORD(size)
    buf = ctypes.create_string_buffer(size)
    rc = RegQueryValueEx(key.handle, value_name, LPDWORD(),
                         ctypes.byref(data_type),
                         ctypes.cast(buf, LPBYTE), ctypes.byref(tmp_size))
    if rc != ERROR_MORE_DATA:
      break

    # We limit the size here to ~10 MB so the response doesn't get too big.
    if 10 * 1024 * 1024 > size:
      raise exceptions.WindowsError("Value too big to be read by GRR.")

    size *= 2

  if rc != ERROR_SUCCESS:
    raise ctypes.WinError(2)

  return (Reg2Py(buf, tmp_size.value, data_type.value), data_type.value)
dataset/ETHPy150Open google/grr/grr/client/vfs_handlers/registry.py/QueryValueEx/swapped operands of `>`