incremented version + improved naming

This commit is contained in:
2026-06-10 14:29:18 +03:00
parent ad2523dc3a
commit a2c9084e5f
5 changed files with 19 additions and 18 deletions
+1 -1
View File
@@ -1 +1 @@
5.2.0 5.3.0
+4 -4
View File
@@ -19,7 +19,7 @@ namespace omath
scan_for_pattern_in_loaded_module(const void* module_base_address, const std::string_view& pattern, scan_for_pattern_in_loaded_module(const void* module_base_address, const std::string_view& pattern,
const std::string_view& target_section_name = ".text"); const std::string_view& target_section_name = ".text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<std::uintptr_t> static std::optional<std::uintptr_t>
scan_for_pattern_in_loaded_module(const void* module_base_address, scan_for_pattern_in_loaded_module(const void* module_base_address,
@@ -34,7 +34,7 @@ namespace omath
scan_for_pattern_in_file(const std::filesystem::path& path_to_file, const std::string_view& pattern, scan_for_pattern_in_file(const std::filesystem::path& path_to_file, const std::string_view& pattern,
const std::string_view& target_section_name = ".text"); const std::string_view& target_section_name = ".text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<SectionScanResult> static std::optional<SectionScanResult>
scan_for_pattern_in_file(const std::filesystem::path& path_to_file, scan_for_pattern_in_file(const std::filesystem::path& path_to_file,
@@ -49,7 +49,7 @@ namespace omath
scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, const std::string_view& pattern, scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, const std::string_view& pattern,
const std::string_view& target_section_name = ".text"); const std::string_view& target_section_name = ".text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<SectionScanResult> static std::optional<SectionScanResult>
scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, scan_for_pattern_in_memory_file(std::span<const std::byte> file_data,
@@ -62,7 +62,7 @@ namespace omath
private: private:
using SectionScanFunction = std::optional<std::ptrdiff_t> (*)(std::span<const std::byte>); using SectionScanFunction = std::optional<std::ptrdiff_t> (*)(std::span<const std::byte>);
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<std::ptrdiff_t> scan_section_for_pattern(const std::span<const std::byte> section_data) static std::optional<std::ptrdiff_t> scan_section_for_pattern(const std::span<const std::byte> section_data)
{ {
+4 -4
View File
@@ -19,7 +19,7 @@ namespace omath
scan_for_pattern_in_loaded_module(const void* module_base_address, const std::string_view& pattern, scan_for_pattern_in_loaded_module(const void* module_base_address, const std::string_view& pattern,
const std::string_view& target_section_name = "__text"); const std::string_view& target_section_name = "__text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<std::uintptr_t> static std::optional<std::uintptr_t>
scan_for_pattern_in_loaded_module(const void* module_base_address, scan_for_pattern_in_loaded_module(const void* module_base_address,
@@ -34,7 +34,7 @@ namespace omath
scan_for_pattern_in_file(const std::filesystem::path& path_to_file, const std::string_view& pattern, scan_for_pattern_in_file(const std::filesystem::path& path_to_file, const std::string_view& pattern,
const std::string_view& target_section_name = "__text"); const std::string_view& target_section_name = "__text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<SectionScanResult> static std::optional<SectionScanResult>
scan_for_pattern_in_file(const std::filesystem::path& path_to_file, scan_for_pattern_in_file(const std::filesystem::path& path_to_file,
@@ -49,7 +49,7 @@ namespace omath
scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, const std::string_view& pattern, scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, const std::string_view& pattern,
const std::string_view& target_section_name = "__text"); const std::string_view& target_section_name = "__text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<SectionScanResult> static std::optional<SectionScanResult>
scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, scan_for_pattern_in_memory_file(std::span<const std::byte> file_data,
@@ -62,7 +62,7 @@ namespace omath
private: private:
using SectionScanFunction = std::optional<std::ptrdiff_t> (*)(std::span<const std::byte>); using SectionScanFunction = std::optional<std::ptrdiff_t> (*)(std::span<const std::byte>);
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<std::ptrdiff_t> scan_section_for_pattern(const std::span<const std::byte> section_data) static std::optional<std::ptrdiff_t> scan_section_for_pattern(const std::span<const std::byte> section_data)
{ {
+6 -5
View File
@@ -39,11 +39,12 @@ namespace omath
public: public:
template<std::size_t N> template<std::size_t N>
struct fixed_string final struct ConstevalPattern final
{ {
char value[N]{}; char value[N]{};
constexpr fixed_string(const char (&text)[N]) // ReSharper disable once CppNonExplicitConvertingConstructor
constexpr ConstevalPattern(const char (&text)[N]) // NOLINT(*-explicit-constructor)
{ {
std::ranges::copy(text, value); std::ranges::copy(text, value);
} }
@@ -69,7 +70,7 @@ namespace omath
return scan_for_parsed_pattern(begin, end, parsed_pattern.value()); return scan_for_parsed_pattern(begin, end, parsed_pattern.value());
} }
template<fixed_string Pattern, class IteratorType> template<ConstevalPattern Pattern, class IteratorType>
requires std::input_or_output_iterator<std::remove_cvref_t<IteratorType>> requires std::input_or_output_iterator<std::remove_cvref_t<IteratorType>>
static IteratorType scan_for_pattern(const IteratorType& begin, const IteratorType& end) static IteratorType scan_for_pattern(const IteratorType& begin, const IteratorType& end)
{ {
@@ -129,7 +130,7 @@ namespace omath
return c - 'a' + 10; return c - 'a' + 10;
return -1; return -1;
} }
template<fixed_string Pattern> template<ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static consteval std::size_t signature_size() static consteval std::size_t signature_size()
{ {
@@ -152,7 +153,7 @@ namespace omath
return count; return count;
} }
template<fixed_string Pattern> template<ConstevalPattern Pattern>
static consteval std::array<std::optional<std::byte>, signature_size<Pattern>()> parse_pattern() static consteval std::array<std::optional<std::byte>, signature_size<Pattern>()> parse_pattern()
{ {
std::array<std::optional<std::byte>, signature_size<Pattern>()> result{}; std::array<std::optional<std::byte>, signature_size<Pattern>()> result{};
+4 -4
View File
@@ -21,7 +21,7 @@ namespace omath
scan_for_pattern_in_loaded_module(const void* module_base_address, const std::string_view& pattern, scan_for_pattern_in_loaded_module(const void* module_base_address, const std::string_view& pattern,
const std::string_view& target_section_name = ".text"); const std::string_view& target_section_name = ".text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<std::uintptr_t> static std::optional<std::uintptr_t>
scan_for_pattern_in_loaded_module(const void* module_base_address, scan_for_pattern_in_loaded_module(const void* module_base_address,
@@ -36,7 +36,7 @@ namespace omath
scan_for_pattern_in_file(const std::filesystem::path& path_to_file, const std::string_view& pattern, scan_for_pattern_in_file(const std::filesystem::path& path_to_file, const std::string_view& pattern,
const std::string_view& target_section_name = ".text"); const std::string_view& target_section_name = ".text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<SectionScanResult> static std::optional<SectionScanResult>
scan_for_pattern_in_file(const std::filesystem::path& path_to_file, scan_for_pattern_in_file(const std::filesystem::path& path_to_file,
@@ -51,7 +51,7 @@ namespace omath
scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, const std::string_view& pattern, scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, const std::string_view& pattern,
const std::string_view& target_section_name = ".text"); const std::string_view& target_section_name = ".text");
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<SectionScanResult> static std::optional<SectionScanResult>
scan_for_pattern_in_memory_file(std::span<const std::byte> file_data, scan_for_pattern_in_memory_file(std::span<const std::byte> file_data,
@@ -64,7 +64,7 @@ namespace omath
private: private:
using SectionScanFunction = std::optional<std::ptrdiff_t> (*)(std::span<const std::byte>); using SectionScanFunction = std::optional<std::ptrdiff_t> (*)(std::span<const std::byte>);
template<PatternScanner::fixed_string Pattern> template<PatternScanner::ConstevalPattern Pattern>
[[nodiscard]] [[nodiscard]]
static std::optional<std::ptrdiff_t> scan_section_for_pattern(const std::span<const std::byte> section_data) static std::optional<std::ptrdiff_t> scan_section_for_pattern(const std::span<const std::byte> section_data)
{ {