Improvement: #72 Input command is always at the end of Shelldlg
This commit is contained in:
Binary file not shown.
@@ -1041,6 +1041,13 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
||||
{
|
||||
switch (ContextObject->InDeCompressedBuffer.GetBYTE(0))
|
||||
{
|
||||
case SOCKET_DLLLOADER: {// <20><><EFBFBD><EFBFBD>DLL
|
||||
BYTE cmd[32] = { COMMAND_BYE };
|
||||
const char reason[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>!";
|
||||
memcpy(cmd + 1, reason, sizeof(reason));
|
||||
m_iocpServer->Send(ContextObject, cmd, sizeof(cmd));
|
||||
break;
|
||||
}
|
||||
case COMMAND_BYE:
|
||||
{
|
||||
CancelIo((HANDLE)ContextObject->sClientSocket);
|
||||
|
||||
@@ -6,6 +6,18 @@
|
||||
#include "ShellDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAutoEndEdit, CEdit)
|
||||
ON_WM_CHAR()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void CAutoEndEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) {
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>ı<EFBFBD>ĩβ
|
||||
int nLength = GetWindowTextLength();
|
||||
SetSel(nLength, nLength);
|
||||
|
||||
// <20><><EFBFBD>ø<EFBFBD><C3B8>ദ<EFBFBD><E0B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
||||
CEdit::OnChar(nChar, nRepCnt, nFlags);
|
||||
}
|
||||
|
||||
// CShellDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
@@ -34,6 +46,7 @@ void CShellDlg::DoDataExchange(CDataExchange* pDX)
|
||||
BEGIN_MESSAGE_MAP(CShellDlg, CDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_CTLCOLOR()
|
||||
ON_WM_SIZE()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
@@ -59,6 +72,12 @@ BOOL CShellDlg::OnInitDialog()
|
||||
BYTE bToken = COMMAND_NEXT;
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(BYTE));
|
||||
|
||||
m_Edit.SetWindowTextA(">>");
|
||||
m_nCurSel = m_Edit.GetWindowTextLengthA();
|
||||
m_nReceiveLength = m_nCurSel;
|
||||
m_Edit.SetSel((int)m_nCurSel, (int)m_nCurSel);
|
||||
m_Edit.PostMessage(EM_SETSEL, m_nCurSel, m_nCurSel);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||
}
|
||||
@@ -76,6 +95,12 @@ VOID CShellDlg::OnReceiveComplete()
|
||||
}
|
||||
|
||||
|
||||
#include <regex>
|
||||
std::string removeAnsiCodes(const std::string& input) {
|
||||
std::regex ansi_regex("\x1B\\[[0-9;]*[mK]");
|
||||
return std::regex_replace(input, ansi_regex, "");
|
||||
}
|
||||
|
||||
VOID CShellDlg::AddKeyBoardData(void)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0
|
||||
@@ -84,7 +109,8 @@ VOID CShellDlg::AddKeyBoardData(void)
|
||||
//Shit\0
|
||||
m_ContextObject->InDeCompressedBuffer.WriteBuffer((LPBYTE)"", 1); //<2F>ӱ<EFBFBD><D3B1><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>\0
|
||||
Buffer tmp = m_ContextObject->InDeCompressedBuffer.GetMyBuffer(0);
|
||||
CString strResult = tmp.c_str(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> \0
|
||||
bool firstRecv = tmp.c_str() == std::string(">");
|
||||
CString strResult = firstRecv ? "" : CString("\r\n") + removeAnsiCodes(tmp.c_str()).c_str(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> \0
|
||||
|
||||
//<2F>滻<EFBFBD><E6BBBB>ԭ<EFBFBD><D4AD><EFBFBD>Ļ<EFBFBD><C4BB>з<EFBFBD> <20><><EFBFBD><EFBFBD>cmd <20>Ļ<EFBFBD><C4BB><EFBFBD>ͬw32<33>µı༭<C4B1>ؼ<EFBFBD><D8BC>Ļ<EFBFBD><C4BB>з<EFBFBD><D0B7><EFBFBD>һ<EFBFBD><D2BB> <20><><EFBFBD>еĻس<C4BB><D8B3><EFBFBD><EFBFBD><EFBFBD>
|
||||
strResult.Replace("\n", "\r\n");
|
||||
@@ -146,15 +172,14 @@ BOOL CShellDlg::PreTranslateMessage(MSG* pMsg)
|
||||
//Ȼ<><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7>ͳ<EFBFBD>ȥ
|
||||
LPBYTE pSrc = (LPBYTE)str.GetBuffer(0) + m_nCurSel;
|
||||
#ifdef _DEBUG
|
||||
OutputDebugStringA("[Shell]=> ");
|
||||
OutputDebugStringA((char*)pSrc);
|
||||
TRACE("[Shell]=> %s", (char*)pSrc);
|
||||
#endif
|
||||
int length = str.GetLength() - m_nCurSel;
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, pSrc, length);
|
||||
m_nCurSel = m_Edit.GetWindowTextLength();
|
||||
if (0 == strcmp((char*)pSrc, "exit\r\n"))
|
||||
{
|
||||
ShowWindow(SW_HIDE);
|
||||
return PostMessage(WM_CLOSE);
|
||||
}
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>VK_BACK
|
||||
@@ -190,3 +215,19 @@ HBRUSH CShellDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||||
}
|
||||
return hbr;
|
||||
}
|
||||
|
||||
|
||||
void CShellDlg::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
|
||||
if (!m_Edit.GetSafeHwnd()) return; // ȷ<><C8B7><EFBFBD>ؼ<EFBFBD><D8BC>Ѵ<EFBFBD><D1B4><EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>úʹ<C3BA>С
|
||||
CRect rc;
|
||||
m_Edit.GetWindowRect(&rc);
|
||||
ScreenToClient(&rc);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD>С
|
||||
m_Edit.MoveWindow(0, 0, cx, cy, TRUE);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
#include "IOCPServer.h"
|
||||
#include "afxwin.h"
|
||||
|
||||
// <20><><EFBFBD>۹<EFBFBD><DBB9><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dz<EFBFBD><C7B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ĩβ
|
||||
class CAutoEndEdit : public CEdit {
|
||||
public:
|
||||
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
// CShellDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
class CShellDlg : public CDialog
|
||||
@@ -29,7 +37,8 @@ protected:
|
||||
public:
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnClose();
|
||||
CEdit m_Edit;
|
||||
CAutoEndEdit m_Edit;
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user