Files
SimpleRemoter/macos
yuanyuanxianganddeepseek-flash 2cbed0dcdf Fix: Report process uptime and harden the login reserved list
The "启动信息" elapsed time was computed by subtracting a client-formatted
wall-clock string from the master's own local time. Windows clients send their
local time, Linux/Android/macOS send Beijing time, so a host whose clock runs
ahead of the master (UTC+8 clients on a UTC+1 master, a fast CMOS clock) gave a
negative difference that was clamped to 0s — permanently, for that host.

Add RES_UPTIME to the login reserved list: the client reports its process
uptime in seconds, a difference between two readings of the same clock, so
timezone and clock skew cancel out. The master adds the connection's alive
time to get the current value, and keeps the old string path as the fallback
for clients that do not send the field. That fallback now also treats MAC as
Beijing time, which was simply missed.

AddReserved() now goes through one bounds-checked append. The separator used
to be written without any length check (an overflow aborts the client, which
installs no invalid parameter handler), and an over-long value now leaves an
empty slot instead of dropping its separator, so positional lookups cannot
shift.

Verified with an ASan/UBSan test over the encoding boundaries and Debug builds
of the client and the master. The Linux/Android/macOS clients only append the
same field at the end of the list; they were not compiled here.

Co-Authored-By: deepseek-flash
2026-11-08 21:49:20 +01:00
..

macOS Remote Desktop Client
===========================

Prerequisites:
  1. Xcode Command Line Tools: xcode-select --install
  2. CMake: brew install cmake

Build:
  chmod +x build.sh
  ./build.sh

Or manually:
  mkdir build && cd build
  cmake ..
  make

Run:
  ./build/bin/ghost

Configuration:
  Server address is configured in main.mm (g_SETTINGS variable).
  Modify before building if needed.

Permissions Required:
  1. Screen Recording - System Settings > Privacy & Security > Screen Recording
  2. Accessibility - System Settings > Privacy & Security > Accessibility

Features:
  [x] Screen capture (CGDisplayCreateImage)
  [x] H264 video encoding (VideoToolbox)
  [x] Mouse control (move, click, drag, scroll)
  [x] Keyboard control (full VK code mapping)
  [x] Retina display support (coordinate scaling)
  [x] Network connection (IOCPClient)
  [x] LOGIN_INFOR (system info reporting)
  [x] Heartbeat with RTT estimation
  [x] Active window tracking
  [x] Quality level adjustment (FPS/algorithm)

Files:
  CMakeLists.txt      - Build configuration
  Permissions.h/mm    - macOS permission handling
  ScreenHandler.h/mm  - Screen capture and H264 encoding
  InputHandler.h/mm   - Mouse/keyboard simulation
  H264Encoder.h/mm    - VideoToolbox H264 encoder
  SystemManager.h/mm  - Process management
  main.mm             - Entry point, LOGIN_INFOR, heartbeat

Quality Levels:
  Level 0: 5 FPS,  Grayscale (emergency low bandwidth)
  Level 1: 10 FPS, RGB565
  Level 2: 15 FPS, H264 (default, office work)
  Level 3: 20 FPS, H264
  Level 4: 25 FPS, H264
  Level 5: 30 FPS, H264 (smooth)

Notes:
  - First frame is always raw bitmap (TOKEN_FIRSTSCREEN)
  - Subsequent frames use H264 encoding (TOKEN_NEXTSCREEN)
  - Coordinates are scaled for Retina displays automatically
  - Windows VK codes are mapped to macOS key codes