-
Notifications
You must be signed in to change notification settings - Fork 269
Fix SymLoadModuleEx failing to find PDB files #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,6 +51,7 @@ pdbparser::pdbparser(pe64* pe) { | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| SymSetSearchPath(GetCurrentProcess(), std::filesystem::path(pdb_path).parent_path().string().c_str()); | ||||||||||||||||||||||||
| this->module_base = | ||||||||||||||||||||||||
|
Comment on lines
+54
to
55
|
||||||||||||||||||||||||
| SymSetSearchPath(GetCurrentProcess(), std::filesystem::path(pdb_path).parent_path().string().c_str()); | |
| this->module_base = | |
| std::filesystem::path parent_path = std::filesystem::path(pdb_path).parent_path(); | |
| if (!parent_path.empty()) { | |
| std::string parent_path_str = parent_path.string(); | |
| if (!SymSetSearchPath(GetCurrentProcess(), parent_path_str.c_str())) { | |
| DWORD err = GetLastError(); | |
| throw std::runtime_error("SymSetSearchPath failed with error " + std::to_string(err)); | |
| } | |
| } | |
| this->module_base = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SymSetSearchPathreplaces the entire symbol search path for the process. Setting it to only the PDB’s parent directory can unintentionally drop existing paths (e.g.,_NT_SYMBOL_PATH/ symbol server settings) and break symbol resolution elsewhere. Consider reading the existing path (e.g., viaSymGetSearchPath) and prepending/appending the target directory instead of overwriting it.