Feature: Support setting the client building flag
This commit is contained in:
Binary file not shown.
@@ -302,6 +302,28 @@ std::vector<DllInfo*> ReadAllDllFilesWindows(const std::string& dirPath) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetParentDir()
|
||||
{
|
||||
char exePath[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, exePath, MAX_PATH);
|
||||
|
||||
std::string path(exePath);
|
||||
|
||||
// 找到最后一个反斜杠,得到程序目录
|
||||
size_t pos = path.find_last_of("\\/");
|
||||
if (pos != std::string::npos) {
|
||||
path = path.substr(0, pos); // 程序目录
|
||||
}
|
||||
|
||||
// 再往上一级
|
||||
pos = path.find_last_of("\\/");
|
||||
if (pos != std::string::npos) {
|
||||
path = path.substr(0, pos);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::IDD, pParent)
|
||||
{
|
||||
auto s = GetMasterHash();
|
||||
@@ -342,6 +364,8 @@ CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogEx(CMy2015RemoteDlg::I
|
||||
GET_FILEPATH(path, "Plugins");
|
||||
m_DllList = ReadAllDllFilesWindows(path);
|
||||
m_tinyDLL = NULL;
|
||||
auto dlls = ReadAllDllFilesWindows(GetParentDir() + "\\Plugins");
|
||||
m_DllList.insert(m_DllList.end(), dlls.begin(), dlls.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -717,15 +741,16 @@ VOID CMy2015RemoteDlg::ShowMessage(CString strType, CString strMsg)
|
||||
|
||||
LRESULT CMy2015RemoteDlg::OnShowErrMessage(WPARAM wParam, LPARAM lParam) {
|
||||
CString* text = (CString*)wParam;
|
||||
CString err = *text;
|
||||
delete text;
|
||||
CString* title = (CString*)lParam;
|
||||
|
||||
CTime Timer = CTime::GetCurrentTime();
|
||||
CString strTime = Timer.Format("%H:%M:%S");
|
||||
|
||||
m_CList_Message.InsertItem(0, "操作错误");
|
||||
m_CList_Message.InsertItem(0, title ? *title : "操作错误");
|
||||
m_CList_Message.SetItemText(0, 1, strTime);
|
||||
m_CList_Message.SetItemText(0, 2, err);
|
||||
m_CList_Message.SetItemText(0, 2, text ? *text : "内部错误");
|
||||
delete title;
|
||||
delete text;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1043,6 +1068,7 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
||||
OnCancel();
|
||||
return FALSE;
|
||||
}
|
||||
THIS_CFG.SetStr("settings", "MainWnd", std::to_string((uint64_t)GetSafeHwnd()));
|
||||
|
||||
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
|
||||
}
|
||||
@@ -1919,6 +1945,10 @@ BOOL CALLBACK CMy2015RemoteDlg::NotifyProc(CONTEXT_OBJECT* ContextObject)
|
||||
}
|
||||
HANDLE handles[2] = { hEvent, g_2015RemoteDlg->m_hExit };
|
||||
DWORD result = WaitForMultipleObjects(2, handles, FALSE, INFINITE);
|
||||
if (result == WAIT_FAILED) {
|
||||
DWORD err = GetLastError();
|
||||
Mprintf("NotifyProc WaitForMultipleObjects failed, error=%lu\n", err);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1980,6 +2010,7 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
||||
if (isClosed) {
|
||||
return;
|
||||
}
|
||||
clock_t tick = clock();
|
||||
unsigned cmd = ContextObject->InDeCompressedBuffer.GetBYTE(0);
|
||||
unsigned len = ContextObject->InDeCompressedBuffer.GetBufferLen();
|
||||
// 【L】:主机上下线和授权
|
||||
@@ -2176,6 +2207,10 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
||||
Mprintf("Receive unknown command '%s' [%d]: Len=%d\n", ContextObject->PeerName.c_str(), cmd, len);
|
||||
}
|
||||
}
|
||||
auto duration = clock() - tick;
|
||||
if (duration > 200) {
|
||||
Mprintf("[%s] Command '%s' [%d] cost %d ms\n", __FUNCTION__, ContextObject->PeerName.c_str(), cmd, duration);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
|
||||
@@ -2840,7 +2875,7 @@ void CMy2015RemoteDlg::OnHelpFeedback()
|
||||
|
||||
void CMy2015RemoteDlg::OnDynamicSubMenu(UINT nID) {
|
||||
if (m_DllList.size() == 0) {
|
||||
MessageBoxA("请将64位的DLL放于 'Plugins' 目录,再来点击此项菜单。"
|
||||
MessageBoxA("请将64位的DLL放于主控程序的 'Plugins' 目录,再来点击此项菜单。"
|
||||
"\n执行未经测试的代码可能造成程序崩溃。", "提示", MB_ICONINFORMATION);
|
||||
char path[_MAX_PATH];
|
||||
GetModuleFileNameA(NULL, path, _MAX_PATH);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "BuildDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
#include <io.h>
|
||||
#include "InputDlg.h"
|
||||
|
||||
enum Index
|
||||
{
|
||||
@@ -58,6 +59,7 @@ CBuildDlg::CBuildDlg(CWnd* pParent)
|
||||
: CDialog(CBuildDlg::IDD, pParent)
|
||||
, m_strIP(_T(""))
|
||||
, m_strPort(_T(""))
|
||||
, m_strFindden(FLAG_FINDEN)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -85,6 +87,7 @@ BEGIN_MESSAGE_MAP(CBuildDlg, CDialog)
|
||||
ON_BN_CLICKED(IDOK, &CBuildDlg::OnBnClickedOk)
|
||||
ON_CBN_SELCHANGE(IDC_COMBO_EXE, &CBuildDlg::OnCbnSelchangeComboExe)
|
||||
ON_COMMAND(ID_HELP_PARAMETERS, &CBuildDlg::OnHelpParameters)
|
||||
ON_COMMAND(ID_HELP_FINDDEN, &CBuildDlg::OnHelpFindden)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
@@ -154,6 +157,8 @@ void CBuildDlg::OnBnClickedOk()
|
||||
}
|
||||
//////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ//////////////////////
|
||||
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "", typ, false, DLL_VERSION, 0, startup, HeaderEncV0 };
|
||||
if(m_strFindden.GetLength())
|
||||
memcpy(g_ConnectAddress.szFlag, m_strFindden.GetBuffer(), min(sizeof(g_ConnectAddress.szFlag), m_strFindden.GetLength()));
|
||||
g_ConnectAddress.SetAdminId(GetMasterHash().c_str());
|
||||
g_ConnectAddress.SetServer(m_strIP, atoi(m_strPort));
|
||||
g_ConnectAddress.runningType = m_ComboRunType.GetCurSel();
|
||||
@@ -355,3 +360,14 @@ void CBuildDlg::OnHelpParameters()
|
||||
CString url = _T("https://github.com/yuanyuanxiang/SimpleRemoter/wiki#<23><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>");
|
||||
ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
|
||||
void CBuildDlg::OnHelpFindden()
|
||||
{
|
||||
CInputDialog dlg(this);
|
||||
dlg.m_str = m_strFindden;
|
||||
dlg.Init("<EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>ʶ", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD>ʶ<EFBFBD><EFBFBD>Ϣ:");
|
||||
if (dlg.DoModal() == IDOK) {
|
||||
m_strFindden = dlg.m_str;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,4 +36,6 @@ public:
|
||||
CComboBox m_ComboEncrypt;
|
||||
afx_msg void OnHelpParameters();
|
||||
CComboBox m_ComboCompress;
|
||||
CString m_strFindden;
|
||||
afx_msg void OnHelpFindden();
|
||||
};
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user