Skip to content

Commit 5184959

Browse files
Add symbol server configuration.
1 parent 000fb0b commit 5184959

12 files changed

+124
-10
lines changed

WinArk/ConfigServerDlg.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "stdafx.h"
2+
#include "ConfigServerDlg.h"
3+
#include "Helpers.h"
4+
5+
LRESULT CConfigServerDbg::OnInitDialog(UINT uMsg, WPARAM wParam,
6+
LPARAM lParam, BOOL& bHandled) {
7+
m_Check1.Attach(GetDlgItem(IDC_SZDYG));
8+
m_Check2.Attach(GetDlgItem(IDC_MICROSOFT));
9+
m_Edit.Attach(GetDlgItem(IDC_SERVER_URL));
10+
return TRUE;
11+
}
12+
13+
LRESULT CConfigServerDbg::OnCloseCmd(WORD, WORD wID, HWND, BOOL&) {
14+
if (wID == IDOK) {
15+
if (m_Check1.GetCheck() == BST_CHECKED) {
16+
m_Server = "https://msdl.szdyg.cn/download/symbols";
17+
}
18+
if (m_Check2.GetCheck() == BST_CHECKED) {
19+
m_Server = "https://msdl.microsoft.com/download/symbols";
20+
}
21+
CString url;
22+
m_Edit.GetWindowText(url);
23+
if (!url.IsEmpty()) {
24+
std::wstring wurl(url);
25+
m_Server = Helpers::WstringToString(wurl);
26+
}
27+
28+
}
29+
EndDialog(wID);
30+
return 0;
31+
}
32+
33+
std::string CConfigServerDbg::GetServer() const {
34+
return m_Server;
35+
}

WinArk/ConfigServerDlg.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
#include "resource.h"
3+
4+
5+
class CConfigServerDbg
6+
: public CDialogImpl<CConfigServerDbg> {
7+
public:
8+
enum { IDD = IDD_CONFIG_SERVER };
9+
10+
BEGIN_MSG_MAP(CConfigServerDbg)
11+
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
12+
COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
13+
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
14+
END_MSG_MAP()
15+
16+
17+
LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
18+
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
19+
20+
std::string GetServer() const;
21+
private:
22+
CButton m_Check1, m_Check2, m_Check3;
23+
CEdit m_Edit;
24+
std::string m_Server;
25+
};

WinArk/SymbolFileInfo.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <curlcpp/curl_easy.h>
77
#include <curlcpp/curl_exception.h>
88
#include <curlcpp/curl_ios.h>
9+
#include "ConfigServerDlg.h"
910

1011
using curl::curl_easy;
1112
using curl::curl_ios;
@@ -21,7 +22,7 @@ bool SymbolFileInfo::SymDownloadSymbol(std::wstring localPath) {
2122
std::wstring path = localPath + L"\\" + _path.GetString();
2223
std::filesystem::create_directories(path);
2324

24-
std::string url = "https://msdl.microsoft.com/download/symbols";
25+
std::string url = _server;
2526

2627
if (url.back() != '/')
2728
url += '/';
@@ -138,6 +139,12 @@ downslib_error SymbolFileInfo::Download(std::string url, std::wstring fileName,
138139
}
139140

140141
SymbolFileInfo::SymbolFileInfo() {
142+
std::string url = "https://msdl.microsoft.com/download/symbols";
143+
CConfigServerDbg dlg;
144+
if (dlg.DoModal() == IDOK) {
145+
url = dlg.GetServer();
146+
}
147+
_server = url;
141148
}
142149

143150
SymbolFileInfo::~SymbolFileInfo() {

WinArk/SymbolFileInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ struct SymbolFileInfo {
5151
CString _pdbFile;
5252
PdbValidationData _pdbValidation;
5353
CString _path;
54+
std::string _server = "https://msdl.microsoft.com/download/symbols";
5455
};

WinArk/SymbolHelper.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ bool SymbolHelper::GetPdbFile(std::wstring fileName, std::string& pdbDir,
1414
PEParser parser(path);
1515
auto dir = parser.GetDataDirectory(IMAGE_DIRECTORY_ENTRY_DEBUG);
1616
if (dir != nullptr) {
17-
SymbolFileInfo info;
1817
auto entry = static_cast<PIMAGE_DEBUG_DIRECTORY>(parser.GetAddress(dir->VirtualAddress));
1918
ULONG_PTR VA = reinterpret_cast<ULONG_PTR>(parser.GetBaseAddress());
20-
info.GetPdbSignature(VA, entry);
19+
g_SymbolHelper.GetPdbSignature(VA, entry);
2120
::GetCurrentDirectory(MAX_PATH, path);
2221
wcscat_s(path, L"\\Symbols");
2322
std::wstring curDir = path;
24-
std::wstring dir = curDir + L"\\" + info._path.GetString();
25-
std::wstring name = info._pdbFile.GetString();
23+
std::wstring dir = curDir + L"\\" + g_SymbolHelper._path.GetString();
24+
std::wstring name = g_SymbolHelper._pdbFile.GetString();
2625
pdbDir = Helpers::WstringToString(dir);
2726
pdbName = Helpers::WstringToString(name);
2827
return true;

WinArk/WinArk.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,24 @@ AppSettings _Settings;
2222

2323
bool g_hasSymbol = true;
2424
HANDLE g_hSingleInstMutex{ nullptr };
25+
SymbolFileInfo g_SymbolHelper;
2526

2627
void InitSymbols(std::wstring fileName) {
2728
WCHAR path[MAX_PATH];
2829
::GetSystemDirectory(path, MAX_PATH);
2930
wcscat_s(path, L"\\");
3031
wcscat_s(path, fileName.c_str());
3132
PEParser parser(path);
33+
3234
auto dir = parser.GetDataDirectory(IMAGE_DIRECTORY_ENTRY_DEBUG);
3335
if (dir != nullptr) {
34-
SymbolFileInfo info;
36+
3537
auto entry = static_cast<PIMAGE_DEBUG_DIRECTORY>(parser.GetAddress(dir->VirtualAddress));
3638
ULONG_PTR VA = reinterpret_cast<ULONG_PTR>(parser.GetBaseAddress());
37-
info.GetPdbSignature(VA, entry);
39+
g_SymbolHelper.GetPdbSignature(VA, entry);
3840
::GetCurrentDirectory(MAX_PATH, path);
3941
wcscat_s(path, L"\\Symbols");
40-
bool success = info.SymDownloadSymbol(path);
42+
bool success = g_SymbolHelper.SymDownloadSymbol(path);
4143
if (!success)
4244
g_hasSymbol = false;
4345
}

WinArk/WinArk.rc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,22 @@ BEGIN
362362
CONTROL "",IDC_DLL_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,399,181
363363
END
364364

365+
IDD_CONFIG_SERVER DIALOGEX 0, 0, 309, 176
366+
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
367+
CAPTION "Configure Symbols"
368+
FONT 8, "MS Shell Dlg", 400, 0, 0x1
369+
BEGIN
370+
DEFPUSHBUTTON "OK",IDOK,198,155,50,14
371+
PUSHBUTTON "Cancel",IDCANCEL,252,155,50,14
372+
LTEXT "Public Symbol Server:",IDC_STATIC,19,19,70,8
373+
CONTROL "https://msdl.szdyg.cn/download/symbols",IDC_SZDYG,
374+
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,34,155,23
375+
CONTROL "https://msdl.microsoft.com/download/symbols",IDC_MICROSOFT,
376+
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,52,197,23
377+
EDITTEXT IDC_SERVER_URL,25,97,258,14,ES_AUTOHSCROLL
378+
LTEXT "Other public symbol server:",IDC_STATIC,18,82,89,8
379+
END
380+
365381

366382
/////////////////////////////////////////////////////////////////////////////
367383
//
@@ -496,6 +512,14 @@ BEGIN
496512
TOPMARGIN, 7
497513
BOTTOMMARGIN, 206
498514
END
515+
516+
IDD_CONFIG_SERVER, DIALOG
517+
BEGIN
518+
LEFTMARGIN, 7
519+
RIGHTMARGIN, 302
520+
TOPMARGIN, 7
521+
BOTTOMMARGIN, 169
522+
END
499523
END
500524
#endif // APSTUDIO_INVOKED
501525

@@ -615,6 +639,11 @@ BEGIN
615639
0
616640
END
617641

642+
IDD_CONFIG_SERVER AFX_DIALOG_LAYOUT
643+
BEGIN
644+
0
645+
END
646+
618647

619648
/////////////////////////////////////////////////////////////////////////////
620649
//

WinArk/WinArk.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@
255255
<ClCompile Include="BinaryValueDlg.cpp" />
256256
<ClCompile Include="BypassDlg.cpp" />
257257
<ClCompile Include="CallStackDlg.cpp" />
258+
<ClCompile Include="ConfigServerDlg.cpp" />
258259
<ClCompile Include="DisasmDlg.cpp" />
259260
<ClCompile Include="ExplorerView.cpp" />
260261
<ClCompile Include="ExtensionTable.cpp" />
@@ -430,6 +431,7 @@
430431
<ClInclude Include="BypassDlg.h" />
431432
<ClInclude Include="CallStackDlg.h" />
432433
<ClInclude Include="ComHelper.h" />
434+
<ClInclude Include="ConfigServerDlg.h" />
433435
<ClInclude Include="CustomListView.h" />
434436
<ClInclude Include="CustomSplitterWindow.h" />
435437
<ClInclude Include="DisasmDlg.h" />

WinArk/WinArk.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@
543543
<ClCompile Include="TreeImportExport.cpp">
544544
<Filter>Scylla</Filter>
545545
</ClCompile>
546+
<ClCompile Include="ConfigServerDlg.cpp">
547+
<Filter>Dialogs</Filter>
548+
</ClCompile>
546549
</ItemGroup>
547550
<ItemGroup>
548551
<ClInclude Include="stdafx.h">
@@ -1094,6 +1097,9 @@
10941097
<ClInclude Include="TreeImportExport.h">
10951098
<Filter>Scylla</Filter>
10961099
</ClInclude>
1100+
<ClInclude Include="ConfigServerDlg.h">
1101+
<Filter>Dialogs</Filter>
1102+
</ClInclude>
10971103
</ItemGroup>
10981104
<ItemGroup>
10991105
<ResourceCompile Include="WinArk.rc">

WinArk/resource.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
#define IDD_DISASSEMBLER 313
118118
#define IDR_DISASM 315
119119
#define IDD_PICK_DLL 316
120+
#define IDD_CONFIG_SERVER 318
120121
#define IDC_CONFIG_LIST 1000
121122
#define IDC_VALUE 1001
122123
#define IDC_APPICON 1002
@@ -261,6 +262,10 @@
261262
#define IDC_DISASM_FORWARD 1130
262263
#define IDC_DISASM 1131
263264
#define IDC_DLL_LIST 1132
265+
#define IDC_SZDYG 1135
266+
#define IDC_EDIT1 1136
267+
#define IDC_SERVER_URL 1136
268+
#define IDC_MICROSOFT 1137
264269
#define ID_PROCESS_THREADS 32775
265270
#define ID_PROCESS_MODULES 32776
266271
#define ID_PROCESS_KILL 32777
@@ -539,9 +544,9 @@
539544
//
540545
#ifdef APSTUDIO_INVOKED
541546
#ifndef APSTUDIO_READONLY_SYMBOLS
542-
#define _APS_NEXT_RESOURCE_VALUE 318
547+
#define _APS_NEXT_RESOURCE_VALUE 320
543548
#define _APS_NEXT_COMMAND_VALUE 33078
544-
#define _APS_NEXT_CONTROL_VALUE 1133
549+
#define _APS_NEXT_CONTROL_VALUE 1137
545550
#define _APS_NEXT_SYMED_VALUE 101
546551
#endif
547552
#endif

0 commit comments

Comments
 (0)