-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsymbol_enum.h
79 lines (68 loc) · 2.08 KB
/
symbol_enum.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
class SymbolEnum {
public:
enum class UndecorateMode {
Default = 0,
OldVersionCompatible,
None,
};
struct Callbacks {
std::function<bool()> queryCancel;
std::function<void(int)> notifyProgress;
std::function<void(PCSTR)> notifyLog;
};
SymbolEnum(HMODULE moduleBase,
PCWSTR enginePath,
PCWSTR symbolsPath,
PCWSTR symbolServer,
UndecorateMode undecorateMode,
Callbacks callbacks = {});
SymbolEnum(PCWSTR modulePath,
HMODULE moduleBase,
PCWSTR enginePath,
PCWSTR symbolsPath,
PCWSTR symbolServer,
UndecorateMode undecorateMode,
Callbacks callbacks = {});
struct Symbol {
void* address;
PCWSTR name;
PCWSTR nameUndecoratedPrefix1;
PCWSTR nameUndecoratedPrefix2;
PCWSTR nameUndecorated;
};
std::optional<Symbol> GetNextSymbol();
// https://ntdoc.m417z.com/image_chpe_range_entry
typedef struct _IMAGE_CHPE_RANGE_ENTRY {
union {
ULONG StartOffset;
struct {
ULONG NativeCode : 1;
ULONG AddressBits : 31;
} DUMMYSTRUCTNAME;
} DUMMYUNIONNAME;
ULONG Length;
} IMAGE_CHPE_RANGE_ENTRY, *PIMAGE_CHPE_RANGE_ENTRY;
private:
void InitModuleInfo(PCWSTR modulePath);
wil::com_ptr<IDiaDataSource> LoadMsdia();
static constexpr enum SymTagEnum kSymTags[] = {
SymTagPublicSymbol,
SymTagFunction,
SymTagData,
};
struct ModuleInfo {
WORD magic;
bool isHybrid;
std::vector<IMAGE_CHPE_RANGE_ENTRY> chpeRanges;
};
HMODULE m_moduleBase;
UndecorateMode m_undecorateMode;
ModuleInfo m_moduleInfo;
wil::unique_hmodule m_msdiaModule;
wil::com_ptr<IDiaSymbol> m_diaGlobal;
wil::com_ptr<IDiaEnumSymbols> m_diaSymbols;
size_t m_symTagIndex = 0;
wil::unique_bstr m_currentSymbolName;
wil::unique_bstr m_currentSymbolNameUndecorated;
};