Feature: Add tool menu for changing exe file icon
This commit is contained in:
Binary file not shown.
@@ -41,6 +41,7 @@
|
|||||||
#include "CDrawingBoard.h"
|
#include "CDrawingBoard.h"
|
||||||
#include "CWalletDlg.h"
|
#include "CWalletDlg.h"
|
||||||
#include <wallet.h>
|
#include <wallet.h>
|
||||||
|
#include "CRcEditDlg.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
@@ -477,6 +478,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
|||||||
ON_NOTIFY(NM_CUSTOMDRAW, IDC_ONLINE, &CMy2015RemoteDlg::OnNMCustomdrawOnline)
|
ON_NOTIFY(NM_CUSTOMDRAW, IDC_ONLINE, &CMy2015RemoteDlg::OnNMCustomdrawOnline)
|
||||||
ON_COMMAND(ID_ONLINE_RUN_AS_ADMIN, &CMy2015RemoteDlg::OnOnlineRunAsAdmin)
|
ON_COMMAND(ID_ONLINE_RUN_AS_ADMIN, &CMy2015RemoteDlg::OnOnlineRunAsAdmin)
|
||||||
ON_COMMAND(ID_MAIN_WALLET, &CMy2015RemoteDlg::OnMainWallet)
|
ON_COMMAND(ID_MAIN_WALLET, &CMy2015RemoteDlg::OnMainWallet)
|
||||||
|
ON_COMMAND(ID_TOOL_RCEDIT, &CMy2015RemoteDlg::OnToolRcedit)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
@@ -2656,15 +2658,12 @@ BOOL WriteBinaryToFile(const char* path, const char* data, ULONGLONG size)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int run_upx(const std::string& upx, const std::string &file, bool isCompress) {
|
int run_cmd(std::string cmdLine) {
|
||||||
STARTUPINFOA si = { sizeof(si) };
|
STARTUPINFOA si = { sizeof(si) };
|
||||||
si.dwFlags |= STARTF_USESHOWWINDOW;
|
si.dwFlags |= STARTF_USESHOWWINDOW;
|
||||||
si.wShowWindow = SW_HIDE;
|
si.wShowWindow = SW_HIDE;
|
||||||
|
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi = { 0 };
|
||||||
std::string cmd = isCompress ? "\" --best \"" : "\" -d \"";
|
|
||||||
std::string cmdLine = "\"" + upx + cmd + file + "\"";
|
|
||||||
|
|
||||||
BOOL success = CreateProcessA(
|
BOOL success = CreateProcessA(
|
||||||
NULL,
|
NULL,
|
||||||
&cmdLine[0], // 注意必须是非 const char*
|
&cmdLine[0], // 注意必须是非 const char*
|
||||||
@@ -2688,20 +2687,14 @@ int run_upx(const std::string& upx, const std::string &file, bool isCompress) {
|
|||||||
return static_cast<int>(exitCode);
|
return static_cast<int>(exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int run_upx(const std::string& upx, const std::string &file, bool isCompress) {
|
||||||
|
std::string cmd = isCompress ? "\" --best \"" : "\" -d \"";
|
||||||
|
std::string cmdLine = "\"" + upx + cmd + file + "\"";
|
||||||
|
return run_cmd(cmdLine);
|
||||||
|
}
|
||||||
|
|
||||||
std::string ReleaseUPX() {
|
std::string ReleaseUPX() {
|
||||||
DWORD dwSize = 0;
|
return ReleaseEXE(IDR_BINARY_UPX, "upx.exe");
|
||||||
LPBYTE data = ReadResource(IDR_BINARY_UPX, dwSize);
|
|
||||||
if (!data)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
char path[MAX_PATH];
|
|
||||||
DWORD len = GetModuleFileNameA(NULL, path, MAX_PATH);
|
|
||||||
std::string curExe = path;
|
|
||||||
GET_FILEPATH(path, "upx.exe");
|
|
||||||
BOOL r = WriteBinaryToFile(path, (char*)data, dwSize);
|
|
||||||
SAFE_DELETE_ARRAY(data);
|
|
||||||
|
|
||||||
return r ? path : "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解压UPX对当前应用程序进行操作
|
// 解压UPX对当前应用程序进行操作
|
||||||
@@ -3305,3 +3298,10 @@ void CMy2015RemoteDlg::OnMainWallet()
|
|||||||
THIS_CFG.SetStr("settings", "wallet", m_settings.WalletAddress);
|
THIS_CFG.SetStr("settings", "wallet", m_settings.WalletAddress);
|
||||||
SendMasterSettings(nullptr);
|
SendMasterSettings(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMy2015RemoteDlg::OnToolRcedit()
|
||||||
|
{
|
||||||
|
CRcEditDlg dlg;
|
||||||
|
dlg.DoModal();
|
||||||
|
}
|
||||||
|
|||||||
@@ -305,4 +305,5 @@ public:
|
|||||||
afx_msg void OnOnlineRunAsAdmin();
|
afx_msg void OnOnlineRunAsAdmin();
|
||||||
afx_msg LRESULT OnShowErrMessage(WPARAM wParam, LPARAM lParam);
|
afx_msg LRESULT OnShowErrMessage(WPARAM wParam, LPARAM lParam);
|
||||||
afx_msg void OnMainWallet();
|
afx_msg void OnMainWallet();
|
||||||
|
afx_msg void OnToolRcedit();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -247,6 +247,7 @@
|
|||||||
<None Include="res\frpc.dll" />
|
<None Include="res\frpc.dll" />
|
||||||
<None Include="res\My2015Remote.rc2" />
|
<None Include="res\My2015Remote.rc2" />
|
||||||
<None Include="res\pc.ico" />
|
<None Include="res\pc.ico" />
|
||||||
|
<None Include="res\rcedit.exe" />
|
||||||
<None Include="res\string.ico" />
|
<None Include="res\string.ico" />
|
||||||
<None Include="res\upx.exe" />
|
<None Include="res\upx.exe" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -267,6 +268,7 @@
|
|||||||
<ClInclude Include="CGridDialog.h" />
|
<ClInclude Include="CGridDialog.h" />
|
||||||
<ClInclude Include="Chat.h" />
|
<ClInclude Include="Chat.h" />
|
||||||
<ClInclude Include="CPasswordDlg.h" />
|
<ClInclude Include="CPasswordDlg.h" />
|
||||||
|
<ClInclude Include="CRcEditDlg.h" />
|
||||||
<ClInclude Include="CTextDlg.h" />
|
<ClInclude Include="CTextDlg.h" />
|
||||||
<ClInclude Include="CWalletDlg.h" />
|
<ClInclude Include="CWalletDlg.h" />
|
||||||
<ClInclude Include="DateVerify.h" />
|
<ClInclude Include="DateVerify.h" />
|
||||||
@@ -339,6 +341,7 @@
|
|||||||
<ClCompile Include="CGridDialog.cpp" />
|
<ClCompile Include="CGridDialog.cpp" />
|
||||||
<ClCompile Include="Chat.cpp" />
|
<ClCompile Include="Chat.cpp" />
|
||||||
<ClCompile Include="CPasswordDlg.cpp" />
|
<ClCompile Include="CPasswordDlg.cpp" />
|
||||||
|
<ClCompile Include="CRcEditDlg.cpp" />
|
||||||
<ClCompile Include="CTextDlg.cpp" />
|
<ClCompile Include="CTextDlg.cpp" />
|
||||||
<ClCompile Include="CWalletDlg.cpp" />
|
<ClCompile Include="CWalletDlg.cpp" />
|
||||||
<ClCompile Include="DecryptDlg.cpp" />
|
<ClCompile Include="DecryptDlg.cpp" />
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
<ClCompile Include="..\..\common\ikcp.c" />
|
<ClCompile Include="..\..\common\ikcp.c" />
|
||||||
<ClCompile Include="CGridDialog.cpp" />
|
<ClCompile Include="CGridDialog.cpp" />
|
||||||
<ClCompile Include="CWalletDlg.cpp" />
|
<ClCompile Include="CWalletDlg.cpp" />
|
||||||
|
<ClCompile Include="CRcEditDlg.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\client\Audio.h" />
|
<ClInclude Include="..\..\client\Audio.h" />
|
||||||
@@ -120,6 +121,7 @@
|
|||||||
<ClInclude Include="..\..\common\ikcp.h" />
|
<ClInclude Include="..\..\common\ikcp.h" />
|
||||||
<ClInclude Include="CGridDialog.h" />
|
<ClInclude Include="CGridDialog.h" />
|
||||||
<ClInclude Include="CWalletDlg.h" />
|
<ClInclude Include="CWalletDlg.h" />
|
||||||
|
<ClInclude Include="CRcEditDlg.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="2015Remote.rc" />
|
<ResourceCompile Include="2015Remote.rc" />
|
||||||
@@ -195,6 +197,7 @@
|
|||||||
<None Include="res\frpc.dll" />
|
<None Include="res\frpc.dll" />
|
||||||
<None Include="..\..\Release\SCLoader.exe" />
|
<None Include="..\..\Release\SCLoader.exe" />
|
||||||
<None Include="..\..\x64\Release\SCLoader.exe" />
|
<None Include="..\..\x64\Release\SCLoader.exe" />
|
||||||
|
<None Include="res\rcedit.exe" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="..\..\ReadMe.md" />
|
<Text Include="..\..\ReadMe.md" />
|
||||||
|
|||||||
@@ -104,6 +104,22 @@ bool MakeShellcode(LPBYTE& compressedBuffer, int& ulTotalSize, LPBYTE originBuff
|
|||||||
|
|
||||||
BOOL WriteBinaryToFile(const char* path, const char* data, ULONGLONG size);
|
BOOL WriteBinaryToFile(const char* path, const char* data, ULONGLONG size);
|
||||||
|
|
||||||
|
std::string ReleaseEXE(int resID, const char* name) {
|
||||||
|
DWORD dwSize = 0;
|
||||||
|
LPBYTE data = ReadResource(resID, dwSize);
|
||||||
|
if (!data)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
char path[MAX_PATH];
|
||||||
|
DWORD len = GetModuleFileNameA(NULL, path, MAX_PATH);
|
||||||
|
std::string curExe = path;
|
||||||
|
GET_FILEPATH(path, name);
|
||||||
|
BOOL r = WriteBinaryToFile(path, (char*)data, dwSize);
|
||||||
|
SAFE_DELETE_ARRAY(data);
|
||||||
|
|
||||||
|
return r ? path : "";
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct SCInfo
|
typedef struct SCInfo
|
||||||
{
|
{
|
||||||
unsigned char aes_key[16];
|
unsigned char aes_key[16];
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
LPBYTE ReadResource(int resourceId, DWORD& dwSize);
|
LPBYTE ReadResource(int resourceId, DWORD& dwSize);
|
||||||
|
|
||||||
|
std::string ReleaseEXE(int resID, const char* name);
|
||||||
|
|
||||||
// CBuildDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
// CBuildDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
class CBuildDlg : public CDialog
|
class CBuildDlg : public CDialog
|
||||||
|
|||||||
127
server/2015Remote/CRcEditDlg.cpp
Normal file
127
server/2015Remote/CRcEditDlg.cpp
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
// CRcEditDlg.cpp: 实现文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "CRcEditDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
#include "Resource.h"
|
||||||
|
|
||||||
|
|
||||||
|
// CRcEditDlg 对话框
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CRcEditDlg, CDialogEx)
|
||||||
|
|
||||||
|
CRcEditDlg::CRcEditDlg(CWnd* pParent /*=nullptr*/)
|
||||||
|
: CDialogEx(IDD_DIALOG_RCEDIT, pParent)
|
||||||
|
, m_sExePath(_T(""))
|
||||||
|
, m_sIcoPath(_T(""))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CRcEditDlg::~CRcEditDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRcEditDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialogEx::DoDataExchange(pDX);
|
||||||
|
DDX_Control(pDX, IDC_EDIT_EXE_FILE, m_EditExe);
|
||||||
|
DDX_Control(pDX, IDC_EDIT_ICO_FILE, m_EditIco);
|
||||||
|
DDX_Text(pDX, IDC_EDIT_EXE_FILE, m_sExePath);
|
||||||
|
DDV_MaxChars(pDX, m_sExePath, 256);
|
||||||
|
DDX_Text(pDX, IDC_EDIT_ICO_FILE, m_sIcoPath);
|
||||||
|
DDV_MaxChars(pDX, m_sIcoPath, 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CRcEditDlg, CDialogEx)
|
||||||
|
ON_BN_CLICKED(IDC_BTN_SELECT_EXE, &CRcEditDlg::OnBnClickedBtnSelectExe)
|
||||||
|
ON_BN_CLICKED(IDC_BTN_SELECT_ICO, &CRcEditDlg::OnBnClickedBtnSelectIco)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CRcEditDlg 消息处理程序
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CRcEditDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialogEx::OnInitDialog();
|
||||||
|
|
||||||
|
// TODO: 在此添加额外的初始化
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// 异常: OCX 属性页应返回 FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CRcEditDlg::OnOK()
|
||||||
|
{
|
||||||
|
if (m_sExePath.IsEmpty()) {
|
||||||
|
MessageBox("请选择目标应用程序!", "提示", MB_ICONINFORMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_sIcoPath.IsEmpty()) {
|
||||||
|
MessageBox("请选择[*.ico]图标文件!", "提示", MB_ICONINFORMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string ReleaseEXE(int resID, const char* name);
|
||||||
|
int run_cmd(std::string cmdLine);
|
||||||
|
|
||||||
|
std::string rcedit = ReleaseEXE(IDR_BIN_RCEDIT, "rcedit.exe");
|
||||||
|
if (rcedit.empty()) {
|
||||||
|
MessageBox("解压程序失败,无法替换图标!", "提示", MB_ICONINFORMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string exe = m_sExePath.GetString();
|
||||||
|
std::string icon = m_sIcoPath.GetString();
|
||||||
|
std::string cmdLine = "\"" + rcedit + "\" " + "\"" + exe + "\" --set-icon \"" + icon + "\"";
|
||||||
|
int result = run_cmd(cmdLine);
|
||||||
|
if (result) {
|
||||||
|
MessageBox(CString("替换图标失败,错误代码: ") + std::to_string(result).c_str(),
|
||||||
|
"提示", MB_ICONINFORMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CDialogEx::OnOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CRcEditDlg::OnBnClickedBtnSelectExe()
|
||||||
|
{
|
||||||
|
CFileDialog fileDlg(TRUE, _T("exe"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||||
|
_T("EXE Files (*.exe)|*.exe|All Files (*.*)|*.*||"), AfxGetMainWnd());
|
||||||
|
int ret = 0;
|
||||||
|
try {
|
||||||
|
ret = fileDlg.DoModal();
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
MessageBox("文件对话框未成功打开! 请稍后再试。", "提示");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ret == IDOK)
|
||||||
|
{
|
||||||
|
m_sExePath = fileDlg.GetPathName();
|
||||||
|
m_EditExe.SetWindowTextA(m_sExePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CRcEditDlg::OnBnClickedBtnSelectIco()
|
||||||
|
{
|
||||||
|
CFileDialog fileDlg(TRUE, _T("ico"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||||
|
_T("EXE Files (*.ico)|*.ico|All Files (*.*)|*.*||"), AfxGetMainWnd());
|
||||||
|
int ret = 0;
|
||||||
|
try {
|
||||||
|
ret = fileDlg.DoModal();
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
MessageBox("文件对话框未成功打开! 请稍后再试。", "提示");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ret == IDOK)
|
||||||
|
{
|
||||||
|
m_sIcoPath = fileDlg.GetPathName();
|
||||||
|
m_EditIco.SetWindowTextA(m_sIcoPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
server/2015Remote/CRcEditDlg.h
Normal file
35
server/2015Remote/CRcEditDlg.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <afx.h>
|
||||||
|
#include <afxwin.h>
|
||||||
|
|
||||||
|
|
||||||
|
// CRcEditDlg 对话框
|
||||||
|
|
||||||
|
class CRcEditDlg : public CDialogEx
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CRcEditDlg)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CRcEditDlg(CWnd* pParent = nullptr); // 标准构造函数
|
||||||
|
virtual ~CRcEditDlg();
|
||||||
|
|
||||||
|
// 对话框数据
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = IDD_DIALOG_RCEDIT };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
CEdit m_EditExe;
|
||||||
|
CEdit m_EditIco;
|
||||||
|
CString m_sExePath;
|
||||||
|
CString m_sIcoPath;
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
virtual void OnOK();
|
||||||
|
afx_msg void OnBnClickedBtnSelectExe();
|
||||||
|
afx_msg void OnBnClickedBtnSelectIco();
|
||||||
|
};
|
||||||
BIN
server/2015Remote/res/rcedit.exe
Normal file
BIN
server/2015Remote/res/rcedit.exe
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user