Skip to content

Commit

Permalink
Range overload for find_pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroMemes committed Oct 14, 2024
1 parent 89dee45 commit 3587353
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/libhat/Concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <concepts>
#include <cstddef>
#include <iterator>
#include <ranges>
#include <type_traits>

namespace hat::detail {
Expand All @@ -27,6 +28,12 @@ namespace hat::detail {
&& std::contiguous_iterator<T>
&& std::same_as<std::iter_value_t<T>, std::byte>;

template<typename T>
concept byte_input_range = std::ranges::input_range<T>
&& std::ranges::contiguous_range<T>
&& std::ranges::sized_range<T>
&& std::same_as<std::ranges::range_value_t<T>, std::byte>;

template<typename T>
concept char_iterator = std::is_same_v<std::iter_value_t<T>, char>;
}
11 changes: 11 additions & 0 deletions include/libhat/Scanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,17 @@ namespace hat {
: nullptr;
}

/// Range overload of find_pattern
template<detail::byte_input_range Range>
[[nodiscard]] constexpr auto find_pattern(
Range&& range,
const signature_view signature,
const scan_alignment alignment = scan_alignment::X1,
const scan_hint hints = scan_hint::none
) noexcept -> detail::result_type_for<std::ranges::iterator_t<Range>> {
return find_pattern(std::ranges::begin(range), std::ranges::end(range), signature, alignment, hints);
}

/// Perform a signature scan on a specific section of the process module or a specified module
[[nodiscard]] inline scan_result find_pattern(
const signature_view signature,
Expand Down

0 comments on commit 3587353

Please sign in to comment.