Feature: add client log dialog with auto-refresh, icon and menu bitmap
- CClientLogManager: push thread sends incremental logs every 3s; join() instead of detach() prevents use-after-free on shutdown - CClientLog::OnReceiveComplete: handles TOKEN_REPORT_LOG on IOCP thread via PostMessage, fixing incremental packets being silently dropped - Dialog icon (ClientLog.ico) and menu bitmap (ClientLog.bmp) added; OnInitDialog loads icon; IDR_MENU_LIST_ONLINE "运行日志" item gets the bitmap Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -181,6 +181,7 @@
|
|||||||
<ClCompile Include="CaptureVideo.cpp" />
|
<ClCompile Include="CaptureVideo.cpp" />
|
||||||
<ClCompile Include="clang_rt_compat.c" />
|
<ClCompile Include="clang_rt_compat.c" />
|
||||||
<ClCompile Include="ClientDll.cpp" />
|
<ClCompile Include="ClientDll.cpp" />
|
||||||
|
<ClCompile Include="ClientLogManager.cpp" />
|
||||||
<ClCompile Include="Common.cpp" />
|
<ClCompile Include="Common.cpp" />
|
||||||
<ClCompile Include="ConPTYManager.cpp" />
|
<ClCompile Include="ConPTYManager.cpp" />
|
||||||
<ClCompile Include="FileManager.cpp" />
|
<ClCompile Include="FileManager.cpp" />
|
||||||
@@ -228,6 +229,7 @@
|
|||||||
<ClInclude Include="Buffer.h" />
|
<ClInclude Include="Buffer.h" />
|
||||||
<ClInclude Include="CaptureVideo.h" />
|
<ClInclude Include="CaptureVideo.h" />
|
||||||
<ClInclude Include="clip.h" />
|
<ClInclude Include="clip.h" />
|
||||||
|
<ClInclude Include="ClientLogManager.h" />
|
||||||
<ClInclude Include="Common.h" />
|
<ClInclude Include="Common.h" />
|
||||||
<ClInclude Include="ConPTYManager.h" />
|
<ClInclude Include="ConPTYManager.h" />
|
||||||
<ClInclude Include="CursorInfo.h" />
|
<ClInclude Include="CursorInfo.h" />
|
||||||
|
|||||||
44
client/ClientLogManager.cpp
Normal file
44
client/ClientLogManager.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
#include "ClientLogManager.h"
|
||||||
|
#include "../common/commands.h"
|
||||||
|
#include "../common/logger.h"
|
||||||
|
|
||||||
|
CClientLogManager::CClientLogManager(IOCPClient* ClientObject, int n, void* p)
|
||||||
|
: CManager(ClientObject, n, p)
|
||||||
|
, m_sentIdx(0)
|
||||||
|
, m_running(true)
|
||||||
|
{
|
||||||
|
SendLogDump();
|
||||||
|
m_pushThread = std::thread([this]() {
|
||||||
|
while (m_running && m_ClientObject->IsConnected()) {
|
||||||
|
for (int i = 0; i < 30 && m_running; ++i)
|
||||||
|
Sleep(100);
|
||||||
|
if (m_running && m_ClientObject->IsConnected())
|
||||||
|
SendLogDump();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CClientLogManager::~CClientLogManager()
|
||||||
|
{
|
||||||
|
m_running = false;
|
||||||
|
if (m_pushThread.joinable())
|
||||||
|
m_pushThread.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CClientLogManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
if (ulLength >= 1 && szBuffer[0] == COMMAND_QUERY_LOG)
|
||||||
|
SendLogDump();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientLogManager::SendLogDump()
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_sendMutex);
|
||||||
|
std::string logs = Logger::getInstance().DumpMemoryLogFrom(m_sentIdx);
|
||||||
|
std::vector<BYTE> pkt(1 + logs.size());
|
||||||
|
pkt[0] = TOKEN_REPORT_LOG;
|
||||||
|
if (!logs.empty())
|
||||||
|
memcpy(pkt.data() + 1, logs.data(), logs.size());
|
||||||
|
Send(pkt.data(), (UINT)pkt.size());
|
||||||
|
}
|
||||||
21
client/ClientLogManager.h
Normal file
21
client/ClientLogManager.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Manager.h"
|
||||||
|
#include <atomic>
|
||||||
|
#include <mutex>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
class CClientLogManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CClientLogManager(IOCPClient* ClientObject, int n = 0, void* p = nullptr);
|
||||||
|
~CClientLogManager();
|
||||||
|
virtual VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SendLogDump();
|
||||||
|
|
||||||
|
size_t m_sentIdx;
|
||||||
|
std::mutex m_sendMutex;
|
||||||
|
std::atomic<bool> m_running;
|
||||||
|
std::thread m_pushThread;
|
||||||
|
};
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "VideoManager.h"
|
#include "VideoManager.h"
|
||||||
#include "KeyboardManager.h"
|
#include "KeyboardManager.h"
|
||||||
#include "ProxyManager.h"
|
#include "ProxyManager.h"
|
||||||
|
#include "ClientLogManager.h"
|
||||||
|
|
||||||
#include "KernelManager.h"
|
#include "KernelManager.h"
|
||||||
#include <iniFile.h>
|
#include <iniFile.h>
|
||||||
@@ -152,3 +153,8 @@ DWORD WINAPI LoopProxyManager(LPVOID lParam)
|
|||||||
{
|
{
|
||||||
return LoopManager<CProxyManager, 0>(lParam);
|
return LoopManager<CProxyManager, 0>(lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopClientLogManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CClientLogManager, COMMAND_QUERY_LOG>(lParam);
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,3 +36,4 @@ DWORD WINAPI LoopRegisterManager(LPVOID lParam);
|
|||||||
DWORD WINAPI LoopServicesManager(LPVOID lParam);
|
DWORD WINAPI LoopServicesManager(LPVOID lParam);
|
||||||
DWORD WINAPI LoopKeyboardManager(LPVOID lParam);
|
DWORD WINAPI LoopKeyboardManager(LPVOID lParam);
|
||||||
DWORD WINAPI LoopProxyManager(LPVOID lParam);
|
DWORD WINAPI LoopProxyManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopClientLogManager(LPVOID lParam);
|
||||||
|
|||||||
@@ -811,6 +811,13 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
std::string publicIP = m_ClientObject->GetClientIP();
|
std::string publicIP = m_ClientObject->GetClientIP();
|
||||||
|
|
||||||
switch (szBuffer[0]) {
|
switch (szBuffer[0]) {
|
||||||
|
case COMMAND_QUERY_LOG: {
|
||||||
|
auto* sub = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn, publicIP);
|
||||||
|
sub->EnableSubConnAuth();
|
||||||
|
m_hThread[m_ulThreadCount].p = sub;
|
||||||
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL, 0, LoopClientLogManager, &m_hThread[m_ulThreadCount], 0, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CMD_SET_GROUP: {
|
case CMD_SET_GROUP: {
|
||||||
std::string group = std::string((char*)szBuffer + 1);
|
std::string group = std::string((char*)szBuffer + 1);
|
||||||
m_cfg->SetStr("settings", "group_name", group);
|
m_cfg->SetStr("settings", "group_name", group);
|
||||||
|
|||||||
@@ -201,6 +201,7 @@
|
|||||||
<ClCompile Include="keylogger.cpp" />
|
<ClCompile Include="keylogger.cpp" />
|
||||||
<ClCompile Include="Loader.cpp" />
|
<ClCompile Include="Loader.cpp" />
|
||||||
<ClCompile Include="LoginServer.cpp" />
|
<ClCompile Include="LoginServer.cpp" />
|
||||||
|
<ClCompile Include="ClientLogManager.cpp" />
|
||||||
<ClCompile Include="Manager.cpp" />
|
<ClCompile Include="Manager.cpp" />
|
||||||
<ClCompile Include="MemoryModule.c" />
|
<ClCompile Include="MemoryModule.c" />
|
||||||
<ClCompile Include="proxy\ProxyManager.cpp" />
|
<ClCompile Include="proxy\ProxyManager.cpp" />
|
||||||
@@ -252,6 +253,7 @@
|
|||||||
<ClInclude Include="keylogger.h" />
|
<ClInclude Include="keylogger.h" />
|
||||||
<ClInclude Include="LoginServer.h" />
|
<ClInclude Include="LoginServer.h" />
|
||||||
<ClInclude Include="Manager.h" />
|
<ClInclude Include="Manager.h" />
|
||||||
|
<ClInclude Include="ClientLogManager.h" />
|
||||||
<ClInclude Include="MemoryModule.h" />
|
<ClInclude Include="MemoryModule.h" />
|
||||||
<ClInclude Include="my_clip.h" />
|
<ClInclude Include="my_clip.h" />
|
||||||
<ClInclude Include="proxy\ProxyManager.h" />
|
<ClInclude Include="proxy\ProxyManager.h" />
|
||||||
|
|||||||
@@ -313,7 +313,9 @@ enum {
|
|||||||
COMMAND_SCREEN_ROI = 152, // 屏幕区域
|
COMMAND_SCREEN_ROI = 152, // 屏幕区域
|
||||||
COMMAND_SCREEN_WINDOW = 153, // 窗口捕获(标题字符串,空串=恢复全屏)
|
COMMAND_SCREEN_WINDOW = 153, // 窗口捕获(标题字符串,空串=恢复全屏)
|
||||||
COMMAND_SCREEN_SIGNATURE = 154,
|
COMMAND_SCREEN_SIGNATURE = 154,
|
||||||
|
COMMAND_QUERY_LOG = 155,
|
||||||
|
TOKEN_REPORT_LOG = 156,
|
||||||
|
|
||||||
TOKEN_DECRYPT = 199,
|
TOKEN_DECRYPT = 199,
|
||||||
TOKEN_REGEDIT = 200, // 注册表
|
TOKEN_REGEDIT = 200, // 注册表
|
||||||
COMMAND_REG_FIND, // 注册表 管理标识
|
COMMAND_REG_FIND, // 注册表 管理标识
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
|
||||||
inline bool stringToBool(const std::string& str)
|
inline bool stringToBool(const std::string& str)
|
||||||
@@ -150,6 +151,16 @@ public:
|
|||||||
std::string logEntry = file && line ?
|
std::string logEntry = file && line ?
|
||||||
id + "[" + timestamp + "] [" + file + ":" + std::to_string(line) + "] " + message:
|
id + "[" + timestamp + "] [" + file + ":" + std::to_string(line) + "] " + message:
|
||||||
id + "[" + timestamp + "] " + message;
|
id + "[" + timestamp + "] " + message;
|
||||||
|
|
||||||
|
// Always record to in-memory ring buffer regardless of enable flag.
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_memMutex);
|
||||||
|
m_memLog.push_back(logEntry);
|
||||||
|
m_totalCount++;
|
||||||
|
if (m_memLog.size() > kMemLogMax)
|
||||||
|
m_memLog.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
if (running) {
|
if (running) {
|
||||||
std::lock_guard<std::mutex> lock(queueMutex);
|
std::lock_guard<std::mutex> lock(queueMutex);
|
||||||
@@ -168,6 +179,32 @@ public:
|
|||||||
cv.notify_one(); // 通知写线程
|
cv.notify_one(); // 通知写线程
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 返回内存 ring buffer 中的全部日志(供 TCP 查询使用)
|
||||||
|
std::string DumpMemoryLog() const
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_memMutex);
|
||||||
|
std::string result;
|
||||||
|
result.reserve(m_memLog.size() * 128);
|
||||||
|
for (const auto& entry : m_memLog)
|
||||||
|
result += entry;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 增量版本:只返回 fromAbs 之后的新条目,并将 fromAbs 更新到当前末尾。
|
||||||
|
// fromAbs 是调用方维护的绝对计数器(首次传 0 即得全量)。
|
||||||
|
std::string DumpMemoryLogFrom(size_t& fromAbs) const
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_memMutex);
|
||||||
|
// ring buffer 内最旧条目的绝对序号
|
||||||
|
size_t oldest = (m_totalCount >= m_memLog.size()) ? m_totalCount - m_memLog.size() : 0;
|
||||||
|
size_t startIdx = (fromAbs <= oldest) ? 0 : (fromAbs - oldest);
|
||||||
|
std::string result;
|
||||||
|
for (size_t i = startIdx; i < m_memLog.size(); ++i)
|
||||||
|
result += m_memLog[i];
|
||||||
|
fromAbs = m_totalCount;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// 停止日志系统
|
// 停止日志系统
|
||||||
void stop()
|
void stop()
|
||||||
{
|
{
|
||||||
@@ -220,6 +257,11 @@ private:
|
|||||||
std::mutex fileMutex; // 文件写入锁
|
std::mutex fileMutex; // 文件写入锁
|
||||||
std::string pid; // 进程ID
|
std::string pid; // 进程ID
|
||||||
|
|
||||||
|
static constexpr size_t kMemLogMax = 1000;
|
||||||
|
std::deque<std::string> m_memLog;
|
||||||
|
size_t m_totalCount = 0;
|
||||||
|
mutable std::mutex m_memMutex;
|
||||||
|
|
||||||
Logger() : enable(false), threadRun(false), running(true), workerThread(&Logger::processLogs, this) {}
|
Logger() : enable(false), threadRun(false), running(true), workerThread(&Logger::processLogs, this) {}
|
||||||
|
|
||||||
~Logger()
|
~Logger()
|
||||||
|
|||||||
Binary file not shown.
@@ -14,6 +14,7 @@
|
|||||||
#include "ShellDlg.h"
|
#include "ShellDlg.h"
|
||||||
#include "TerminalDlg.h"
|
#include "TerminalDlg.h"
|
||||||
#include "SystemDlg.h"
|
#include "SystemDlg.h"
|
||||||
|
#include "CClientLog.h"
|
||||||
#include "BuildDlg.h"
|
#include "BuildDlg.h"
|
||||||
#include "AudioDlg.h"
|
#include "AudioDlg.h"
|
||||||
#include "RegisterDlg.h"
|
#include "RegisterDlg.h"
|
||||||
@@ -644,6 +645,7 @@ CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogLangEx(CMy2015RemoteDl
|
|||||||
m_bmOnline[58].LoadBitmap(IDB_BITMAP_COPY);
|
m_bmOnline[58].LoadBitmap(IDB_BITMAP_COPY);
|
||||||
m_bmOnline[59].LoadBitmap(IDB_BITMAP_ACTIVE_WND);
|
m_bmOnline[59].LoadBitmap(IDB_BITMAP_ACTIVE_WND);
|
||||||
m_bmOnline[60].LoadBitmap(IDB_BITMAP_DEBUG);
|
m_bmOnline[60].LoadBitmap(IDB_BITMAP_DEBUG);
|
||||||
|
m_bmOnline[61].LoadBitmap(IDB_BITMAP_CLIENTLOG);
|
||||||
for (int i = 0; i < PAYLOAD_MAXTYPE; i++) {
|
for (int i = 0; i < PAYLOAD_MAXTYPE; i++) {
|
||||||
m_ServerDLL[i] = nullptr;
|
m_ServerDLL[i] = nullptr;
|
||||||
m_ServerBin[i] = nullptr;
|
m_ServerBin[i] = nullptr;
|
||||||
@@ -894,6 +896,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
|||||||
ON_MESSAGE(WM_INJECT_SHELLCODE, InjectShellcode)
|
ON_MESSAGE(WM_INJECT_SHELLCODE, InjectShellcode)
|
||||||
ON_MESSAGE(WM_ANTI_BLACKSCREEN, AntiBlackScreen)
|
ON_MESSAGE(WM_ANTI_BLACKSCREEN, AntiBlackScreen)
|
||||||
ON_MESSAGE(WM_OPEN_WINDOW_SCREEN, OpenWindowScreen)
|
ON_MESSAGE(WM_OPEN_WINDOW_SCREEN, OpenWindowScreen)
|
||||||
|
ON_MESSAGE(WM_OPENCLIENTLOGDIALOG, OnOpenClientLogDialog)
|
||||||
ON_MESSAGE(WM_SHARE_CLIENT, ShareClient)
|
ON_MESSAGE(WM_SHARE_CLIENT, ShareClient)
|
||||||
ON_MESSAGE(WM_ASSIGN_CLIENT, AssignClient)
|
ON_MESSAGE(WM_ASSIGN_CLIENT, AssignClient)
|
||||||
ON_MESSAGE(WM_ASSIGN_ALLCLIENT, AssignAllClient)
|
ON_MESSAGE(WM_ASSIGN_ALLCLIENT, AssignAllClient)
|
||||||
@@ -999,6 +1002,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
|||||||
ON_COMMAND(ID_ONLINE_ACTIVE_WND, &CMy2015RemoteDlg::OnOnlineActiveWnd)
|
ON_COMMAND(ID_ONLINE_ACTIVE_WND, &CMy2015RemoteDlg::OnOnlineActiveWnd)
|
||||||
ON_COMMAND(ID_ONLINE_VIEW_WND, &CMy2015RemoteDlg::OnOnlineWindowManager)
|
ON_COMMAND(ID_ONLINE_VIEW_WND, &CMy2015RemoteDlg::OnOnlineWindowManager)
|
||||||
ON_COMMAND(ID_ENABLE_DEV_DEBUG, &CMy2015RemoteDlg::OnEnableDevDebug)
|
ON_COMMAND(ID_ENABLE_DEV_DEBUG, &CMy2015RemoteDlg::OnEnableDevDebug)
|
||||||
|
ON_COMMAND(ID_ONLINE_CLIENT_LOG, &CMy2015RemoteDlg::OnOnlineClientLog)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
@@ -4049,6 +4053,7 @@ void CMy2015RemoteDlg::OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult)
|
|||||||
Menu.SetMenuItemBitmaps(ID_CANCEL_SHARE, MF_BYCOMMAND, &m_bmOnline[50], &m_bmOnline[50]);
|
Menu.SetMenuItemBitmaps(ID_CANCEL_SHARE, MF_BYCOMMAND, &m_bmOnline[50], &m_bmOnline[50]);
|
||||||
Menu.SetMenuItemBitmaps(ID_COPY_CLIENT_INFO, MF_BYCOMMAND, &m_bmOnline[58], &m_bmOnline[58]);
|
Menu.SetMenuItemBitmaps(ID_COPY_CLIENT_INFO, MF_BYCOMMAND, &m_bmOnline[58], &m_bmOnline[58]);
|
||||||
Menu.SetMenuItemBitmaps(ID_ONLINE_ACTIVE_WND, MF_BYCOMMAND, &m_bmOnline[59], &m_bmOnline[59]);
|
Menu.SetMenuItemBitmaps(ID_ONLINE_ACTIVE_WND, MF_BYCOMMAND, &m_bmOnline[59], &m_bmOnline[59]);
|
||||||
|
Menu.SetMenuItemBitmaps(ID_ONLINE_CLIENT_LOG, MF_BYCOMMAND, &m_bmOnline[61], &m_bmOnline[61]);
|
||||||
|
|
||||||
Menu.ModifyMenuL(ID_ONLINE_AUTHORIZE, MF_BYCOMMAND | MF_STRING, ID_ONLINE_AUTHORIZE, _T("发送授权"));
|
Menu.ModifyMenuL(ID_ONLINE_AUTHORIZE, MF_BYCOMMAND | MF_STRING, ID_ONLINE_AUTHORIZE, _T("发送授权"));
|
||||||
|
|
||||||
@@ -5234,6 +5239,20 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
|||||||
// 【L】:主机上下线和授权
|
// 【L】:主机上下线和授权
|
||||||
// 【x】:对话框相关功能
|
// 【x】:对话框相关功能
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
case TOKEN_REPORT_LOG: {
|
||||||
|
std::string logText((char*)(szBuffer + 1), len > 1 ? len - 1 : 0);
|
||||||
|
if (!ContextObject->hDlg) {
|
||||||
|
// 对话框尚未打开:用 SendMessage 同步打开并显示初始全量日志
|
||||||
|
SendMessage(WM_OPENCLIENTLOGDIALOG,
|
||||||
|
(WPARAM)new std::string(logText),
|
||||||
|
(LPARAM)ContextObject);
|
||||||
|
} else {
|
||||||
|
// 对话框已在:PostMessage 追加增量日志
|
||||||
|
static_cast<CClientLog*>(ContextObject->hDlg)->PostMessage(
|
||||||
|
WM_REPORT_CLIENT_LOG, 0, (LPARAM)new std::string(logText));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TOKEN_CLIENT_MSG: {
|
case TOKEN_CLIENT_MSG: {
|
||||||
ClientMsg *msg =(ClientMsg*)ContextObject->InDeCompressedBuffer.GetBuffer(0);
|
ClientMsg *msg =(ClientMsg*)ContextObject->InDeCompressedBuffer.GetBuffer(0);
|
||||||
PostMessageA(WM_SHOWERRORMSG, (WPARAM)new CString(_L(msg->text)), (LPARAM)new CString(_L(msg->title)));
|
PostMessageA(WM_SHOWERRORMSG, (WPARAM)new CString(_L(msg->text)), (LPARAM)new CString(_L(msg->title)));
|
||||||
@@ -11533,3 +11552,24 @@ void CMy2015RemoteDlg::OnEnableDevDebug()
|
|||||||
"YAMA_DBG=" + CString(debug), _L("提示"), MB_ICONINFORMATION);
|
"YAMA_DBG=" + CString(debug), _L("提示"), MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMy2015RemoteDlg::OnOnlineClientLog()
|
||||||
|
{
|
||||||
|
BYTE cmd = COMMAND_QUERY_LOG;
|
||||||
|
SendSelectedCommand(&cmd, sizeof(BYTE));
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CMy2015RemoteDlg::OnOpenClientLogDialog(WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
std::string* pInitLog = reinterpret_cast<std::string*>(wParam);
|
||||||
|
std::string initLog = pInitLog ? *pInitLog : "";
|
||||||
|
delete pInitLog;
|
||||||
|
|
||||||
|
OpenDialog<CClientLog, IDD_DIALOG_CLIENT_LOG>(0, lParam);
|
||||||
|
|
||||||
|
CONTEXT_OBJECT* ctx = reinterpret_cast<CONTEXT_OBJECT*>(lParam);
|
||||||
|
if (ctx && ctx->hDlg && !initLog.empty())
|
||||||
|
static_cast<CClientLog*>(ctx->hDlg)->AppendLog(initLog);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ public:
|
|||||||
bool IsDllRequestLimited(const std::string& ip);
|
bool IsDllRequestLimited(const std::string& ip);
|
||||||
void RecordDllRequest(const std::string& ip);
|
void RecordDllRequest(const std::string& ip);
|
||||||
CMenu m_MainMenu;
|
CMenu m_MainMenu;
|
||||||
CBitmap m_bmOnline[61];
|
CBitmap m_bmOnline[62];
|
||||||
uint64_t m_superID;
|
uint64_t m_superID;
|
||||||
std::map<HWND, CDialogBase *> m_RemoteWnds;
|
std::map<HWND, CDialogBase *> m_RemoteWnds;
|
||||||
FileTransformCmd m_CmdList;
|
FileTransformCmd m_CmdList;
|
||||||
@@ -637,4 +637,6 @@ public:
|
|||||||
afx_msg void OnCopyClientInfo();
|
afx_msg void OnCopyClientInfo();
|
||||||
afx_msg void OnOnlineActiveWnd();
|
afx_msg void OnOnlineActiveWnd();
|
||||||
afx_msg void OnEnableDevDebug();
|
afx_msg void OnEnableDevDebug();
|
||||||
|
afx_msg void OnOnlineClientLog();
|
||||||
|
afx_msg LRESULT OnOpenClientLogDialog(WPARAM wParam, LPARAM lParam);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -290,6 +290,7 @@
|
|||||||
<ClInclude Include="Buffer.h" />
|
<ClInclude Include="Buffer.h" />
|
||||||
<ClInclude Include="BuildDlg.h" />
|
<ClInclude Include="BuildDlg.h" />
|
||||||
<ClInclude Include="CClientListDlg.h" />
|
<ClInclude Include="CClientListDlg.h" />
|
||||||
|
<ClInclude Include="CClientLog.h" />
|
||||||
<ClInclude Include="CDlgFileSend.h" />
|
<ClInclude Include="CDlgFileSend.h" />
|
||||||
<ClInclude Include="CDrawingBoard.h" />
|
<ClInclude Include="CDrawingBoard.h" />
|
||||||
<ClInclude Include="CGridDialog.h" />
|
<ClInclude Include="CGridDialog.h" />
|
||||||
@@ -371,6 +372,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\client\Audio.cpp" />
|
<ClCompile Include="..\..\client\Audio.cpp" />
|
||||||
|
<ClCompile Include="CClientLog.cpp" />
|
||||||
<ClCompile Include="msvc_compat.c">
|
<ClCompile Include="msvc_compat.c">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||||
@@ -507,6 +509,7 @@
|
|||||||
<Image Include="res\Bitmap\authorize.bmp" />
|
<Image Include="res\Bitmap\authorize.bmp" />
|
||||||
<Image Include="res\Bitmap\Backup.bmp" />
|
<Image Include="res\Bitmap\Backup.bmp" />
|
||||||
<Image Include="res\Bitmap\CancelShare.bmp" />
|
<Image Include="res\Bitmap\CancelShare.bmp" />
|
||||||
|
<Image Include="res\Bitmap\ClientLog.bmp" />
|
||||||
<Image Include="res\bitmap\compress.bmp" />
|
<Image Include="res\bitmap\compress.bmp" />
|
||||||
<Image Include="res\Bitmap\Copy.bmp" />
|
<Image Include="res\Bitmap\Copy.bmp" />
|
||||||
<Image Include="res\Bitmap\Debug.bmp" />
|
<Image Include="res\Bitmap\Debug.bmp" />
|
||||||
@@ -561,6 +564,7 @@
|
|||||||
<Image Include="res\Bitmap\Wallet.bmp" />
|
<Image Include="res\Bitmap\Wallet.bmp" />
|
||||||
<Image Include="res\Bitmap\WebDesktop.bmp" />
|
<Image Include="res\Bitmap\WebDesktop.bmp" />
|
||||||
<Image Include="res\chat.ico" />
|
<Image Include="res\chat.ico" />
|
||||||
|
<Image Include="res\ClientLog.ico" />
|
||||||
<Image Include="res\cmdshell.ico" />
|
<Image Include="res\cmdshell.ico" />
|
||||||
<Image Include="res\decrypt.ico" />
|
<Image Include="res\decrypt.ico" />
|
||||||
<Image Include="res\DrawingBoard.ico" />
|
<Image Include="res\DrawingBoard.ico" />
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
<ClCompile Include="PluginSettingsDlg.cpp" />
|
<ClCompile Include="PluginSettingsDlg.cpp" />
|
||||||
<ClCompile Include="PreviewTipWnd.cpp" />
|
<ClCompile Include="PreviewTipWnd.cpp" />
|
||||||
<ClCompile Include="TriggerSettingsDlg.cpp" />
|
<ClCompile Include="TriggerSettingsDlg.cpp" />
|
||||||
|
<ClCompile Include="CClientLog.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\client\Audio.h" />
|
<ClInclude Include="..\..\client\Audio.h" />
|
||||||
@@ -188,6 +189,7 @@
|
|||||||
<ClInclude Include="PluginSettingsDlg.h" />
|
<ClInclude Include="PluginSettingsDlg.h" />
|
||||||
<ClInclude Include="PreviewTipWnd.h" />
|
<ClInclude Include="PreviewTipWnd.h" />
|
||||||
<ClInclude Include="TriggerSettingsDlg.h" />
|
<ClInclude Include="TriggerSettingsDlg.h" />
|
||||||
|
<ClInclude Include="CClientLog.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="2015Remote.rc" />
|
<ResourceCompile Include="2015Remote.rc" />
|
||||||
@@ -328,5 +330,7 @@
|
|||||||
<Image Include="res\Bitmap\Copy.bmp" />
|
<Image Include="res\Bitmap\Copy.bmp" />
|
||||||
<Image Include="res\bitmap\ActiveWnd.bmp" />
|
<Image Include="res\bitmap\ActiveWnd.bmp" />
|
||||||
<Image Include="res\Bitmap\Debug.bmp" />
|
<Image Include="res\Bitmap\Debug.bmp" />
|
||||||
|
<Image Include="res\ClientLog.ico" />
|
||||||
|
<Image Include="res\Bitmap\ClientLog.bmp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
106
server/2015Remote/CClientLog.cpp
Normal file
106
server/2015Remote/CClientLog.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
// CClientLog.cpp: 实现文件
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
#include "CClientLog.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include "../../common/commands.h"
|
||||||
|
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CClientLog, CDialogEx)
|
||||||
|
|
||||||
|
CClientLog::CClientLog(CWnd* pParent, Server* pServer, CONTEXT_OBJECT* pContext)
|
||||||
|
: CDialogBase(IDD_DIALOG_CLIENT_LOG, pParent, pServer, pContext, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CClientLog::~CClientLog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientLog::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialogBase::DoDataExchange(pDX);
|
||||||
|
DDX_Control(pDX, IDC_EDIT_LOG, m_editLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CClientLog, CDialogBase)
|
||||||
|
ON_WM_DESTROY()
|
||||||
|
ON_WM_SIZE()
|
||||||
|
ON_MESSAGE(WM_REPORT_CLIENT_LOG, OnReportLog)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
BOOL CClientLog::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialogBase::OnInitDialog();
|
||||||
|
SetWindowText(_TR("客户端日志") + " - " + m_IPAddress);
|
||||||
|
HICON hIcon = AfxGetApp()->LoadIcon(IDI_CLIENTLOG);
|
||||||
|
SetIcon(hIcon, TRUE);
|
||||||
|
SetIcon(hIcon, FALSE);
|
||||||
|
CFont* pFont = new CFont();
|
||||||
|
pFont->CreatePointFont(85, _T("Consolas"));
|
||||||
|
m_editLog.SetFont(pFont);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientLog::OnSize(UINT nType, int cx, int cy)
|
||||||
|
{
|
||||||
|
CDialogBase::OnSize(nType, cx, cy);
|
||||||
|
if (m_editLog.GetSafeHwnd() && cx > 0 && cy > 0)
|
||||||
|
m_editLog.MoveWindow(7, 7, cx - 14, cy - 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientLog::OnDestroy()
|
||||||
|
{
|
||||||
|
if (m_ContextObject && m_bConnected) {
|
||||||
|
BYTE cmd = COMMAND_BYE;
|
||||||
|
m_ContextObject->Send2Client(&cmd, 1);
|
||||||
|
}
|
||||||
|
CDialogBase::OnDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientLog::AppendLog(const std::string& text)
|
||||||
|
{
|
||||||
|
if (text.empty()) return;
|
||||||
|
// \n → \r\n,Windows 编辑框换行需要 \r\n
|
||||||
|
std::string norm;
|
||||||
|
norm.reserve(text.size() + 64);
|
||||||
|
for (size_t i = 0; i < text.size(); ++i) {
|
||||||
|
if (text[i] == '\n' && (i == 0 || text[i - 1] != '\r'))
|
||||||
|
norm += '\r';
|
||||||
|
norm += text[i];
|
||||||
|
}
|
||||||
|
// 超过 512KB 时截断旧内容
|
||||||
|
int existing = m_editLog.GetWindowTextLength();
|
||||||
|
if (existing > 512 * 1024) {
|
||||||
|
CString cur;
|
||||||
|
m_editLog.GetWindowText(cur);
|
||||||
|
m_editLog.SetWindowText(cur.Mid(cur.GetLength() - 256 * 1024));
|
||||||
|
}
|
||||||
|
// 追加到末尾并滚动
|
||||||
|
CString add = CA2T(norm.c_str(), CP_UTF8);
|
||||||
|
m_editLog.SetSel(-1, -1);
|
||||||
|
m_editLog.ReplaceSel(add);
|
||||||
|
m_editLog.SendMessage(EM_SCROLLCARET);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientLog::OnReceiveComplete()
|
||||||
|
{
|
||||||
|
auto& buf = m_ContextObject->InDeCompressedBuffer;
|
||||||
|
if (buf.GetBYTE(0) != TOKEN_REPORT_LOG)
|
||||||
|
return;
|
||||||
|
unsigned len = buf.GetBufferLen();
|
||||||
|
auto* pText = new std::string((char*)(buf.GetBuffer() + 1), len > 1 ? len - 1 : 0);
|
||||||
|
if (!PostMessage(WM_REPORT_CLIENT_LOG, 0, (LPARAM)pText))
|
||||||
|
delete pText;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CClientLog::OnReportLog(WPARAM /*wParam*/, LPARAM lParam)
|
||||||
|
{
|
||||||
|
std::string* pText = reinterpret_cast<std::string*>(lParam);
|
||||||
|
if (pText) {
|
||||||
|
AppendLog(*pText);
|
||||||
|
delete pText;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
31
server/2015Remote/CClientLog.h
Normal file
31
server/2015Remote/CClientLog.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "afxcmn.h"
|
||||||
|
#include "IOCPServer.h"
|
||||||
|
|
||||||
|
class CClientLog : public CDialogBase
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CClientLog)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CClientLog(CWnd* pParent, Server* pServer, CONTEXT_OBJECT* pContext);
|
||||||
|
virtual ~CClientLog();
|
||||||
|
|
||||||
|
virtual void OnReceiveComplete();
|
||||||
|
void AppendLog(const std::string& text);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX);
|
||||||
|
afx_msg void OnDestroy();
|
||||||
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||||
|
afx_msg LRESULT OnReportLog(WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEdit m_editLog;
|
||||||
|
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = IDD_DIALOG_CLIENT_LOG };
|
||||||
|
#endif
|
||||||
|
};
|
||||||
@@ -1954,3 +1954,5 @@ FRPC Զ
|
|||||||
设置环境变量=Set YAMA_DBG
|
设置环境变量=Set YAMA_DBG
|
||||||
设置成功! 请重启程序和调试器。=Successful! Please restart program and debugger.
|
设置成功! 请重启程序和调试器。=Successful! Please restart program and debugger.
|
||||||
设置失败! 通常是权限不足, 请手动在系统环境变量设置。=Failed! You have to set it via system environment center.
|
设置失败! 通常是权限不足, 请手动在系统环境变量设置。=Failed! You have to set it via system environment center.
|
||||||
|
运行日志=Client Log
|
||||||
|
客户端日志=Client Log
|
||||||
|
|||||||
@@ -1945,3 +1945,5 @@ FRPC Զ
|
|||||||
设置环境变量=设置环境变量
|
设置环境变量=设置环境变量
|
||||||
设置成功! 请重启程序和调试器。=设置成功! 请重启程序和调试器。
|
设置成功! 请重启程序和调试器。=设置成功! 请重启程序和调试器。
|
||||||
设置失败! 通常是权限不足, 请手动在系统环境变量设置。=设置失败! 通常是权限不足, 请手动在系统环境变量设置。
|
设置失败! 通常是权限不足, 请手动在系统环境变量设置。=设置失败! 通常是权限不足, 请手动在系统环境变量设置。
|
||||||
|
运行日志=运行日志
|
||||||
|
客户端日志=客户端日志
|
||||||
|
|||||||
BIN
server/2015Remote/res/Bitmap/ClientLog.bmp
Normal file
BIN
server/2015Remote/res/Bitmap/ClientLog.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
server/2015Remote/res/ClientLog.ico
Normal file
BIN
server/2015Remote/res/ClientLog.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -271,8 +271,11 @@
|
|||||||
#define IDB_BITMAP_ACTIVE_WND 390
|
#define IDB_BITMAP_ACTIVE_WND 390
|
||||||
#define IDR_BINARY8 391
|
#define IDR_BINARY8 391
|
||||||
#define IDR_ANDROID_GHOST 391
|
#define IDR_ANDROID_GHOST 391
|
||||||
#define IDB_BITMAP11 392
|
|
||||||
#define IDB_BITMAP_DEBUG 392
|
#define IDB_BITMAP_DEBUG 392
|
||||||
|
#define IDD_DIALOG8 393
|
||||||
|
#define IDD_DIALOG_CLIENT_LOG 393
|
||||||
|
#define IDB_BITMAP_CLIENTLOG 395
|
||||||
|
#define IDI_CLIENTLOG 396
|
||||||
#define IDC_MESSAGE 1000
|
#define IDC_MESSAGE 1000
|
||||||
#define IDC_ONLINE 1001
|
#define IDC_ONLINE 1001
|
||||||
#define IDC_STATIC_TIPS 1002
|
#define IDC_STATIC_TIPS 1002
|
||||||
@@ -756,6 +759,7 @@
|
|||||||
#define IDC_LIST_TRIGGERS 2543
|
#define IDC_LIST_TRIGGERS 2543
|
||||||
#define IDC_STATIC_TRIGGER_TYPE 2544
|
#define IDC_STATIC_TRIGGER_TYPE 2544
|
||||||
#define IDC_STATIC_TRIGGER_ACTION 2545
|
#define IDC_STATIC_TRIGGER_ACTION 2545
|
||||||
|
#define IDC_EDIT_LOG 2546
|
||||||
#define ID_ONLINE_UPDATE 32772
|
#define ID_ONLINE_UPDATE 32772
|
||||||
#define ID_ONLINE_MESSAGE 32773
|
#define ID_ONLINE_MESSAGE 32773
|
||||||
#define ID_ONLINE_DELETE 32775
|
#define ID_ONLINE_DELETE 32775
|
||||||
@@ -1015,14 +1019,16 @@
|
|||||||
#define ID_ONLINE_VIEW_WND 33070
|
#define ID_ONLINE_VIEW_WND 33070
|
||||||
#define ID_33071 33071
|
#define ID_33071 33071
|
||||||
#define ID_ENABLE_DEV_DEBUG 33072
|
#define ID_ENABLE_DEV_DEBUG 33072
|
||||||
|
#define ID_ONLINE_33073 33073
|
||||||
|
#define ID_ONLINE_CLIENT_LOG 33074
|
||||||
#define ID_EXIT_FULLSCREEN 40001
|
#define ID_EXIT_FULLSCREEN 40001
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
//
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 393
|
#define _APS_NEXT_RESOURCE_VALUE 397
|
||||||
#define _APS_NEXT_COMMAND_VALUE 33073
|
#define _APS_NEXT_COMMAND_VALUE 33075
|
||||||
#define _APS_NEXT_CONTROL_VALUE 2542
|
#define _APS_NEXT_CONTROL_VALUE 2542
|
||||||
#define _APS_NEXT_SYMED_VALUE 105
|
#define _APS_NEXT_SYMED_VALUE 105
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -110,6 +110,8 @@
|
|||||||
#define WM_SPLITTER_MOVED WM_USER+3040
|
#define WM_SPLITTER_MOVED WM_USER+3040
|
||||||
#define WM_SPLITTER_RELEASED WM_USER+3041
|
#define WM_SPLITTER_RELEASED WM_USER+3041
|
||||||
#define WM_OPEN_WINDOW_SCREEN WM_USER+3042 // 窗口管理→打开指定窗口远程画面
|
#define WM_OPEN_WINDOW_SCREEN WM_USER+3042 // 窗口管理→打开指定窗口远程画面
|
||||||
|
#define WM_OPENCLIENTLOGDIALOG WM_USER+3043 // 打开客户端日志对话框
|
||||||
|
#define WM_REPORT_CLIENT_LOG WM_USER+3044 // 追加日志到已打开的对话框
|
||||||
|
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
#if defined _M_IX86
|
#if defined _M_IX86
|
||||||
|
|||||||
Reference in New Issue
Block a user