From 3237f6ade484671e74d2cd473bfd33f66443916c Mon Sep 17 00:00:00 2001 From: Quentin Date: Thu, 21 Dec 2023 09:51:23 +0100 Subject: [PATCH] Fix debug build (#2625) --- CMakeSettings.json | 13 ++++++++++++- src/memory/pattern.cpp | 36 ++++++++---------------------------- src/memory/pattern.hpp | 1 - 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index 330798fd..f3d24fbd 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,6 +1,17 @@ -{ +{ "configurations": [ { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "" + }, + { "name": "x64-Release", "generator": "Ninja", "configurationType": "RelWithDebInfo", diff --git a/src/memory/pattern.cpp b/src/memory/pattern.cpp index 0ba55089..8add0551 100644 --- a/src/memory/pattern.cpp +++ b/src/memory/pattern.cpp @@ -36,46 +36,26 @@ namespace memory pattern::pattern(std::string_view ida_sig) { - const auto size = ida_sig.size(); - for (std::size_t i{}; i != size; ++i) + const auto size_minus_one = ida_sig.size() - 1; + m_bytes.reserve(size_minus_one / 2); + for (size_t i = 0; i != size_minus_one; ++i) { if (ida_sig[i] == ' ') continue; - bool last = (i == ida_sig.size() - 1); + if (ida_sig[i] != '?') { - if (!last) + auto c1 = to_hex(ida_sig[i]); + auto c2 = to_hex(ida_sig[i + 1]); + if (c1 && c2) { - auto c1 = to_hex(ida_sig[i]); - auto c2 = to_hex(ida_sig[i + 1]); - if (c1 && c2) - { - m_bytes.emplace_back(static_cast((*c1 * 0x10) + *c2)); - } + m_bytes.emplace_back(static_cast((*c1 * 0x10) + *c2)); } } else { m_bytes.push_back({}); - - // add support for double question mark sigs - if (ida_sig[i + 1] == '?') - { - ++i; - } } } } - - pattern::pattern(const void* bytes, std::string_view mask) - { - const auto size = mask.size(); - for (std::size_t i{}; i != size; ++i) - { - if (mask[i] != '?') - m_bytes.emplace_back(static_cast(bytes)[i]); - else - m_bytes.push_back(std::nullopt); - } - } } diff --git a/src/memory/pattern.hpp b/src/memory/pattern.hpp index d35a904c..5c293784 100644 --- a/src/memory/pattern.hpp +++ b/src/memory/pattern.hpp @@ -16,7 +16,6 @@ namespace memory public: pattern(std::string_view ida_sig); - explicit pattern(const void* bytes, std::string_view mask); inline pattern(const char* ida_sig) : pattern(std::string_view(ida_sig))