Feature/compile time patten parsing#197
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces compile-time (template/consteval) pattern parsing and scanning APIs to the existing PatternScanner and the PE / Mach-O / ELF section scanners, and expands unit coverage to exercise the new compile-time entry points (including file-based scans).
Changes:
- Added
PatternScanner::fixed_stringand aconstevalpattern parser, plus template scan overloads that take the pattern as a non-type template parameter. - Added template convenience overloads for
scan_for_pattern_in_loaded_module,scan_for_pattern_in_file, andscan_for_pattern_in_memory_filefor PE/Mach-O/ELF scanners, implemented via a shared “scan section with callback” path. - Added/updated unit tests to cover compile-time parsing and compile-time pattern scanning for memory buffers, loaded-module null handling, and file scans via temporary files.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/general/unit_test_pe_memory_file_scan.cpp | Adds tests for new compile-time PE scan APIs (memory + file + nullptr module). |
| tests/general/unit_test_pattern_scan.cpp | Adds tests validating consteval pattern parsing (spacing/case and wildcard handling). |
| tests/general/unit_test_pattern_scan_extra.cpp | Adds iterator-based compile-time scan coverage. |
| tests/general/unit_test_macho_memory_file_scan.cpp | Adds tests for new compile-time Mach-O scan APIs (memory + file + nullptr module). |
| tests/general/unit_test_elf_scanner.cpp | Adds tests for new compile-time ELF scan APIs (memory + file + nullptr module). |
| source/utility/pe_pattern_scan.cpp | Adds callback-based scan overloads for memory/file/loaded-module paths. |
| source/utility/macho_pattern_scan.cpp | Refactors loaded-module scanning to accept a scan callback; adds callback-based file/memory overloads. |
| source/utility/elf_pattern_scan.cpp | Refactors loaded-module scanning to accept a scan callback; adds callback-based file/memory overloads. |
| include/omath/utility/pe_pattern_scan.hpp | Adds template convenience overloads for compile-time patterns via callback-based internals. |
| include/omath/utility/pattern_scan.hpp | Adds fixed_string, consteval pattern parsing, and template scan overloads. |
| include/omath/utility/macho_pattern_scan.hpp | Adds template convenience overloads for compile-time patterns via callback-based internals. |
| include/omath/utility/elf_pattern_scan.hpp | Adds template convenience overloads for compile-time patterns via callback-based internals. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+6
to
13
| #include <algorithm> | ||
| #include <array> | ||
| #include <expected> | ||
| #include <optional> | ||
| #include <span> | ||
| #include <stdexcept> | ||
| #include <string_view> | ||
| #include <vector> |
Comment on lines
+82
to
+86
| template<class IteratorType, class ParsedPattern> | ||
| requires std::input_or_output_iterator<std::remove_cvref_t<IteratorType>> | ||
| static IteratorType scan_for_parsed_pattern(const IteratorType& begin, const IteratorType& end, | ||
| const ParsedPattern& parsed_pattern) | ||
| { |
Comment on lines
+475
to
+479
| const auto* section = section_table + i; | ||
|
|
||
| if (std::string_view{section->name} != target_section_name || section->size_raw_data == 0) | ||
| continue; | ||
|
|
Comment on lines
+72
to
+74
| template<fixed_string Pattern, class IteratorType> | ||
| requires std::input_or_output_iterator<std::remove_cvref_t<IteratorType>> | ||
| static IteratorType scan_for_pattern(const IteratorType& begin, const IteratorType& end) |
Comment on lines
375
to
+379
| continue; | ||
| } | ||
| const auto* section_begin = base + static_cast<std::size_t>(section->addr); | ||
| const auto* section_end = section_begin + static_cast<std::size_t>(section->size); | ||
| const auto scan_range = | ||
| std::span<const std::byte>{section_begin, static_cast<std::size_t>(section->size)}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.