Skip to content

Feature/compile time patten parsing#197

Merged
orange-cpp merged 3 commits into
mainfrom
feature/compile_time_patten_parsing
Jun 10, 2026
Merged

Feature/compile time patten parsing#197
orange-cpp merged 3 commits into
mainfrom
feature/compile_time_patten_parsing

Conversation

@orange-cpp

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_string and a consteval pattern 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, and scan_for_pattern_in_memory_file for 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)};
@orange-cpp orange-cpp merged commit ad2523d into main Jun 10, 2026
20 checks passed
@orange-cpp orange-cpp deleted the feature/compile_time_patten_parsing branch June 10, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants