fix: #71 Development of a simple Linux Client

This commit is contained in:
yuanyuanxiang
2025-04-06 19:35:20 +08:00
parent 9475e59887
commit 7a6b57917a
31 changed files with 629 additions and 124 deletions

View File

@@ -1,5 +1,63 @@
#pragma once
#include <vector>
#include <string>
#include <iosfwd>
#include <iostream>
#include <sstream>
#include <string.h>
#include <map>
#include <numeric>
#include <ctime>
#include <chrono>
#ifdef _WIN32
#include <concrt.h>
#include <corecrt_io.h>
#define MVirtualFree(a1, a2, a3) VirtualFree(a1, a2, a3)
#define MVirtualAlloc(a1, a2, a3, a4) VirtualAlloc(a1, a2, a3, a4)
#else // ʹ<>ø<EFBFBD>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> LINUX <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
#include <thread>
#define strcat_s strcat
#define sprintf_s sprintf
#define strcpy_s strcpy
#define __stdcall
#define WINAPI
#define TRUE 1
#define FALSE 0
#define skCrypt(p)
#define Mprintf printf
#define ASSERT(p)
#define AUTO_TICK_C(p)
#define AUTO_TICK(p)
#define OutputDebugStringA(p) printf(p)
#include <unistd.h>
#define Sleep(n) ((n) >= 1000 ? sleep((n) / 1000) : usleep((n) * 1000))
typedef int64_t __int64;
typedef uint32_t DWORD;
typedef int BOOL, SOCKET;
typedef unsigned int ULONG;
typedef unsigned int UINT;
typedef void VOID;
typedef unsigned char BYTE;
typedef BYTE* PBYTE, * LPBYTE;
typedef void* LPVOID, * HANDLE;
#define GET_PROCESS(a1, a2)
#define MVirtualFree(a1, a2, a3) delete[]a1
#define MVirtualAlloc(a1, a2, a3, a4) new BYTE[a2]
#define CopyMemory memcpy
#define MoveMemory memmove
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define closesocket close
#define CloseHandle(p)
#define CancelIo(p) close(reinterpret_cast<intptr_t>(p))
#endif
#include <string>
#include <vector>
#include <time.h>
@@ -193,18 +251,23 @@ typedef struct LOGIN_INFOR
{
unsigned char bToken; // 1.<2E><>½<EFBFBD><C2BD>Ϣ
char OsVerInfoEx[156]; // 2.<2E><EFBFBD><E6B1BE>Ϣ
unsigned long dwCPUMHz; // 3.CPU<50><55>Ƶ
unsigned int dwCPUMHz; // 3.CPU<50><55>Ƶ
char moduleVersion[24]; // 4.DLLģ<4C><C4A3><EFBFBD>
char szPCName[_MAX_PATH]; // 5.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int bWebCamIsExist; // 6.<2E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
unsigned long dwSpeed; // 7.<2E><><EFBFBD><EFBFBD>
unsigned int dwSpeed; // 7.<2E><><EFBFBD><EFBFBD>
char szStartTime[20]; // 8.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
char szReserved[512]; // 9.<2E><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
LOGIN_INFOR(){
memset(this, 0, sizeof(LOGIN_INFOR));
bToken = TOKEN_LOGIN;
strcpy_s(moduleVersion, DLL_VERSION);
}
LOGIN_INFOR& Speed(unsigned long speed) {
dwSpeed = speed;
return *this;
}
}LOGIN_INFOR;
inline void xor_encrypt_decrypt(unsigned char *data, int len, const std::vector<char>& keys) {
@@ -215,12 +278,54 @@ inline void xor_encrypt_decrypt(unsigned char *data, int len, const std::vector<
}
}
inline std::tm ToPekingTime(const time_t* t) {
// <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><EFBFBD><E4A3A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>Ϊ<EFBFBD>գ<EFBFBD>
std::time_t now = (t == nullptr) ? std::time(nullptr) : *t;
// <20>̰߳<DFB3>ȫ<EFBFBD><C8AB>ת<EFBFBD><D7AA>Ϊ UTC ʱ<><CAB1>
std::tm utc_time{};
#ifdef _WIN32 // Windows ʹ<><CAB9> gmtime_s
if (gmtime_s(&utc_time, &now) != 0) {
return { 0, 0, 0, 1, 0, 100 }; // ʧ<><CAA7>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> 2000-01-01 00:00:00
}
#else // Linux / macOS ʹ<><CAB9> gmtime_r
if (gmtime_r(&now, &utc_time) == nullptr) {
return { 0, 0, 0, 1, 0, 100 };
}
#endif
// ת<><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD>䣨UTC+8<><38>
utc_time.tm_hour += 8;
// <20><EFBFBD><E6B7B6>ʱ<EFBFBD><EFBFBD><E4A3A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::mktime(&utc_time);
return utc_time;
}
inline std::string ToPekingTimeAsString(const time_t* t) {
auto pekingTime = ToPekingTime(t);
char buffer[20];
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &pekingTime);
return buffer;
}
#ifdef _DEBUG
// Ϊ<>˽<EFBFBD><CBBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ꣬<C4BA><EAA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<CAB1>ã<EFBFBD><C3A3><EFBFBD>ʽ<EFBFBD>汾û<E6B1BE><C3BB>
#define SCREENYSPY_IMPROVE 0
#define SCREENSPY_WRITE 0
#endif
#ifdef _WIN32
#ifdef _WINDOWS
#include <afxwin.h>
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
// <20><><EFBFBD>ڴ<EFBFBD><DAB4>е<EFBFBD>λͼд<CDBC><D0B4><EFBFBD>ļ<EFBFBD>
inline bool WriteBitmap(LPBITMAPINFO bmpInfo, const void* bmpData, const std::string& filePrefix, int index = -1) {
char path[_MAX_PATH];
@@ -246,13 +351,6 @@ inline bool WriteBitmap(LPBITMAPINFO bmpInfo, const void* bmpData, const std::st
return false;
}
#ifdef _WIN32
#ifdef _WINDOWS
#include <afxwin.h>
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
class MSG32 { // <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ(32λ)
public:
uint32_t hwnd;