diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-15 02:03:28 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-15 02:47:11 +0300 |
commit | f2aaa85cca144827af29f0f32df9b1b67cc4aad4 (patch) | |
tree | 952b047cbf50475072fc6f247f644a20944f58e1 | |
parent | mingw builds: work around missing SymTagEnum (diff) | |
download | winapi-debug-f2aaa85cca144827af29f0f32df9b1b67cc4aad4.tar.gz winapi-debug-f2aaa85cca144827af29f0f32df9b1b67cc4aad4.zip |
mingw builds: workaround incorrect SymLoadModule64
-rw-r--r-- | src/dbghelp.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/dbghelp.cpp b/src/dbghelp.cpp index eba887e..94fa7ab 100644 --- a/src/dbghelp.cpp +++ b/src/dbghelp.cpp @@ -14,6 +14,7 @@ #include <cstring> #include <stdexcept> #include <string> +#include <vector> namespace pdb { namespace { @@ -73,11 +74,18 @@ void DbgHelp::close() { ModuleInfo DbgHelp::load_pdb(const std::string& path) const { DWORD size = 0; + if (!SafeCast(file::get_size(path), size)) throw std::range_error{"PDB file is too large"}; + // MinGW-w64 (as of version 7.0) requires PSTR as the third argument. + std::vector<char> _path; + _path.reserve(path.length() + 1); + _path.assign(path.cbegin(), path.cend()); + _path.emplace_back('\0'); + const auto offline_base = - SymLoadModule64(id, NULL, path.c_str(), NULL, gen_next_offline_base(size), size); + SymLoadModule64(id, NULL, _path.data(), NULL, gen_next_offline_base(size), size); if (!offline_base) throw error::windows(GetLastError()); |