aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.clang-format6
-rw-r--r--CMakeLists.txt1
-rw-r--r--include/pdb/symbol.hpp6
-rw-r--r--src/dbghelp.cpp6
-rw-r--r--src/module.cpp6
-rw-r--r--src/utils/file.cpp5
6 files changed, 17 insertions, 13 deletions
diff --git a/.clang-format b/.clang-format
index 070e7af..79d4ce0 100644
--- a/.clang-format
+++ b/.clang-format
@@ -14,8 +14,10 @@ IncludeCategories:
Priority: 1
- Regex: '^<boost/'
Priority: 2
- - Regex: '^<.*\.h>$'
+ - Regex: '^<SafeInt.hpp>$'
Priority: 3
- - Regex: '.*'
+ - Regex: '^<.*\.h>$'
Priority: 4
+ - Regex: '.*'
+ Priority: 5
...
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5063a67..306f183 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,7 @@ file(GLOB_RECURSE pdb_repo_src "src/*.cpp")
add_library(pdb_repo ${pdb_repo_include} ${pdb_repo_src})
target_compile_definitions(pdb_repo PUBLIC _NO_CVCONST_H)
target_include_directories(pdb_repo PUBLIC include/)
+target_include_directories(pdb_repo SYSTEM PUBLIC 3rdparty/microsoft/SafeInt)
target_link_libraries(pdb_repo PUBLIC Boost::boost)
target_link_libraries(pdb_repo PRIVATE DbgHelp)
diff --git a/include/pdb/symbol.hpp b/include/pdb/symbol.hpp
index d9f3f0c..e7ca523 100644
--- a/include/pdb/symbol.hpp
+++ b/include/pdb/symbol.hpp
@@ -8,8 +8,9 @@
#include "address.hpp"
#include "module.hpp"
+#include <SafeInt.hpp>
+
#include <Windows.h>
-#include <safeint.h>
#pragma warning(push, 0)
#include <DbgHelp.h>
#pragma warning(pop)
@@ -70,7 +71,6 @@ private:
static constexpr std::size_t max_buffer_size = sizeof(Raw) + MAX_SYM_NAME - 1;
static std::size_t calc_size(const Raw& raw) {
- using namespace msl::utilities;
try {
return SafeInt<std::size_t>{raw.SizeOfStruct} + raw.NameLen - 1;
} catch (const SafeIntException&) {
@@ -110,7 +110,7 @@ private:
static unsigned long cast_line_number(DWORD raw) {
unsigned long dest = 0;
- if (!msl::utilities::SafeCast(raw, dest))
+ if (!SafeCast(raw, dest))
throw std::runtime_error{"invalid line number"};
return dest;
diff --git a/src/dbghelp.cpp b/src/dbghelp.cpp
index 40c2ba5..af8d64d 100644
--- a/src/dbghelp.cpp
+++ b/src/dbghelp.cpp
@@ -5,8 +5,9 @@
#include "pdb/all.hpp"
+#include <SafeInt.hpp>
+
#include <Windows.h>
-#include <safeint.h>
#pragma warning(push, 0)
#include <DbgHelp.h>
#pragma warning(pop, 0)
@@ -39,7 +40,6 @@ Address next_offline_base = 0x10000000;
Address gen_next_offline_base(std::size_t pdb_size) {
const auto base = next_offline_base;
- using msl::utilities::SafeAdd;
if (!SafeAdd(next_offline_base, pdb_size, next_offline_base))
throw std::runtime_error{
"no more PDB files can be added, the internal address space is exhausted"};
@@ -75,7 +75,7 @@ void DbgHelp::close() {
ModuleInfo DbgHelp::load_pdb(const std::string& path) const {
DWORD size = 0;
- if (!msl::utilities::SafeCast(file::get_size(path), size))
+ if (!SafeCast(file::get_size(path), size))
throw std::range_error{"PDB file is too large"};
const auto offline_base =
diff --git a/src/module.cpp b/src/module.cpp
index 0bf9329..9f12599 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -5,7 +5,7 @@
#include "pdb/all.hpp"
-#include <safeint.h>
+#include <SafeInt.hpp>
#include <cstring>
#include <sstream>
@@ -33,7 +33,7 @@ Address Module::translate_offline_address(Address offline) const {
throw std::range_error{invalid_offline_address(offline)};
const auto offset = offline - get_offline_base();
auto online = offset;
- if (!msl::utilities::SafeAdd(online, get_online_base(), online))
+ if (!SafeAdd(online, get_online_base(), online))
throw std::range_error{invalid_offline_address(offline)};
return online;
}
@@ -43,7 +43,7 @@ Address Module::translate_online_address(Address online) const {
throw std::range_error{invalid_online_address(online)};
const auto offset = online - get_online_base();
auto offline = offset;
- if (!msl::utilities::SafeAdd(offline, get_offline_base(), offline))
+ if (!SafeAdd(offline, get_offline_base(), offline))
throw std::range_error{invalid_online_address(offline)};
return offline;
}
diff --git a/src/utils/file.cpp b/src/utils/file.cpp
index c25307a..85af444 100644
--- a/src/utils/file.cpp
+++ b/src/utils/file.cpp
@@ -5,8 +5,9 @@
#include "pdb/all.hpp"
+#include <SafeInt.hpp>
+
#include <Windows.h>
-#include <safeint.h>
#include <cstddef>
#include <stdexcept>
@@ -34,7 +35,7 @@ std::size_t get_size(const std::string& path) {
std::size_t result = 0;
- if (!msl::utilities::SafeCast(size.QuadPart, result))
+ if (!SafeCast(size.QuadPart, result))
throw std::runtime_error{"invalid file size"};
return result;