Phase 0 makes implementations that already existed reachable. macOS now declares TERMINAL, SCREEN_CLIPBOARD, PROCESS and C2C_RECV_ACK; PROCESS is a new bit and Linux declares it too. SystemManager was dead code -- its constructor took a second argument and it did not derive IOCPManager, so the sub-connection skeleton could never instantiate it -- and now matches the createHandler/OnReceive contract, so COMMAND_SYSTEM really spawns a sub-connection (proc_listpids, SIGKILL). DataProcess always gets a NULL user, so main.mm keeps a g_pMainClient handle and the V2 C2C receiver finally answers TOKEN_C2C_RECV_RESULT. The server asks for SupportsTerminal() on MAC for exec_command / terminal_* and for SupportsProcess() for kill_process, so an old build gets "client is too old" instead of a command nobody answers; kToolPlatforms and mcp/tools.json follow. http_probe stays win/lnx: the terminal works on macOS, but the probe uses GNU-only base64 -w. Phase 1 is POSIX parity. ScreenPreview captures through CGDisplayCreateImage, scales and ships BGRX for the server to encode, and the capability is only declared when preflight or a real capture says the display is readable. ActivityHistory samples the frontmost layer-0 window once a second and prints the same records as Windows and Linux. COMMAND_SCREEN_KEYFRAME_REQ is now consumed by Linux (x264 IDR) and macOS (VideoToolbox force keyframe): the receive thread raises a flag, the capture thread -- which owns the encoder -- consumes it and puts it back if the frame never went out. The macOS quality level persists in NSUserDefaults because main.mm rewrites config.conf. Linux client and Debug x64 server rebuild green; check_platform_table PASS. Not built or run on a Mac. Co-Authored-By: deepseek-flash
48 lines
1.9 KiB
C++
48 lines
1.9 KiB
C++
#pragma once
|
||
|
||
#include <cstdint>
|
||
#include <string>
|
||
#include <vector>
|
||
#include <sys/types.h>
|
||
|
||
// IOCPManager / IOCPClient / PBYTE / ULONG 来自这里;本类必须派生 IOCPManager,
|
||
// 见下方注释。Mprintf 由 common/logger.h 提供(本类的日志要进「运行日志」的 ring)。
|
||
#include "../client/IOCPClient.h"
|
||
#include "../common/logger.h"
|
||
|
||
// ============== macOS 进程管理 ==============
|
||
// 与 Linux 端(linux/SystemManager.h)同一套 wire 格式:主连接收到 COMMAND_SYSTEM 后,
|
||
// 客户端另起一条「系统子连接」,本类只在这条子连接上收发:
|
||
// COMMAND_PSLIST → TOKEN_PSLIST
|
||
// COMMAND_KILLPROCESS → kill(2) 后补发一次 TOKEN_PSLIST
|
||
// COMMAND_WSLIST → TOKEN_WSLIST
|
||
//
|
||
// 两个约束都是子连接骨架(common/sub_conn_thread.h)定死的:
|
||
// 1. 必须派生 IOCPManager —— 骨架装的回调是 IOCPManager::DataProcess,它把 user
|
||
// 强转成 IOCPManager* 再调虚函数 OnReceive;普通类装上去会直接崩。
|
||
// 2. 构造函数必须只收 IOCPClient* —— 骨架的 createHandler 契约是
|
||
// std::unique_ptr<T>(IOCPClient*)。
|
||
// 这也解释了它以前为什么是死代码:签名对不上骨架,一直没被实例化,
|
||
// main.mm 的 COMMAND_SYSTEM 只打了一行日志。
|
||
class SystemManager : public IOCPManager
|
||
{
|
||
public:
|
||
explicit SystemManager(IOCPClient* client);
|
||
~SystemManager() override {}
|
||
|
||
virtual VOID OnReceive(PBYTE szBuffer, ULONG ulLength) override;
|
||
|
||
private:
|
||
// 发送完整进程列表(构造时立即发一次,服务端据此判定子连接就绪)
|
||
void sendProcessList();
|
||
|
||
// 终止进程:载荷是若干个 4 字节 PID(与 Windows/Linux 一致)
|
||
void killProcesses(const uint8_t* data, size_t size);
|
||
|
||
// 窗口列表:macOS 只能给「有可见窗口的应用」的伪句柄(PID)+ 应用名
|
||
void sendWindowsList();
|
||
|
||
private:
|
||
IOCPClient* m_client;
|
||
};
|