Feature: run a test client inside the master from the Advanced menu

The Advanced menu now ends with Run Test Program. It copies the kernel
payload that was already read into memory, points its CONNECT_ADDRESS at
127.0.0.1:<listen port>, and loads it with MemoryLoadLibrary inside the
master process, so this machine comes online as a controlled host -- no
second machine is needed to try remote desktop or file transfer. A
worker thread waits for the client to exit, then frees the module and
re-enables the item. Only one instance runs at a time: the item is
grayed while it does, and stopping it means uninstalling the test host
from the online list.

The loaded copy carries LOCAL_TEST_CLIENT_MAGIC in szFuture. The client
uses that mark to refuse the commands that would otherwise hit the host
process or the whole machine: uninstall (no self_del), update, run as
admin, ban, share/assign, and shutdown/reboot/logoff. It also skips
auth-kernel detection, which GetModuleFileName(NULL) would misjudge
inside the master.

Renames szFututre to szFuture and documents that the first 16 bytes of
the reserved tail are now claimed, with a static_assert so it cannot
silently shrink below the magic.

Translations for en_US, zh_TW and de_DE, plus the HIDE_MENU_RUN_TEST
feature flag and its row in the limits dialog.

Verified on a Debug master: the item is last and has its icon, one click
brings the host online, a second click is refused, uninstall stops it in
about a second and the master survives, re-run works, and exiting the
master with a live test client takes 2.6s (3.0s baseline).

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-06 17:17:18 +01:00
1 parent cc9ce35c4d
commit f77b18aa68
18 files changed
+268 -11

No files matched your search

+10 -1
View File
@@ -302,6 +302,15 @@ public:
int GetScreenTuningFlags() const;
// 自适应质量是否启用吞吐判据(双判据),供 CScreenSpyDlg::EvaluateQuality 查询
bool IsAdaptiveDualCriteria() const { return m_bAdaptiveDualCriteria; }
// 高级→运行测试程序:把 m_ServerDLL 里的 DLL 在**本进程**内存加载,本机即上线一台
// 测试主机。同一时间只跑一份,跑完后工作线程释放模块并重新启用菜单项。
afx_msg void OnToolRunTest();
afx_msg LRESULT OnLocalTestFinished(WPARAM wParam, LPARAM lParam);
static DWORD WINAPI LocalTestThreadProc(LPVOID param);
void SetLocalTestMenuEnabled(BOOL enable);
HMEMORYMODULE m_hLocalTestDll = NULL; // 已加载的测试模块,NULL 表示未运行
HANDLE m_hLocalTestThread = NULL; // 等待测试客户端退出的工作线程
volatile LONG m_bLocalTestRunning = 0; // 0/1 原子闸门,保证同时只有一份
MasterSettings m_settings;
// 缓存上次检测到的上级 FRP 配置([settings] FrpConfig),由定时器检测外部模块写入的变更。
// 检出变更后会热切换 FRPC(首次=启动 / 覆盖=重启 / 撤销=停止),并在主对话框信息列表中给出友好提示。
@@ -499,7 +508,7 @@ public:
bool IsDllRequestLimited(const std::string& ip);
void RecordDllRequest(const std::string& ip);
CMenu m_MainMenu;
CBitmap m_bmOnline[76];
CBitmap m_bmOnline[77];
uint64_t m_superID;
std::map<HWND, CDialogBase *> m_RemoteWnds;
FileTransformCmd m_CmdList;