Adds PE section extraction and pattern scanning

Adds functionality to extract a specific section from a PE file and scan for a given pattern within that section.

Introduces `extract_section_from_pe_file` to isolate a section, enabling more targeted pattern searches.
Overhauls `scan_for_pattern_in_file` to utilize extracted section data and improve accuracy.
This commit is contained in:
2025-10-07 10:04:08 +03:00
parent 710f91999f
commit d64c7ad756
2 changed files with 68 additions and 3 deletions

View File

@@ -4,9 +4,9 @@
#pragma once
#include <cstdint>
#include <filesystem>
#include <optional>
#include <string_view>
#include <filesystem>
namespace omath
{
class PePatternScanner final
@@ -17,6 +17,11 @@ namespace omath
const std::string_view& pattern);
[[nodiscard]]
static std::optional<std::uintptr_t> scan_for_pattern_in_file(const std::filesystem::path& path_to_file);
static std::optional<std::uintptr_t> scan_for_pattern_in_file(const std::filesystem::path& path_to_file,
const std::string_view& pattern);
[[nodiscard]]
static std::optional<std::vector<std::byte>>
extract_section_from_pe_file(const std::filesystem::path& path_to_file, const std::string_view& section_name);
};
} // namespace omath