mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
Refactors PE scanner to eliminate redundant section extraction
Simplifies the PE pattern scanner by removing the redundant `extract_section_from_pe_file` function. The extracted data is now returned directly from a new `ExtractedSection` struct within the main scanning function, streamlining the code and reducing duplication. This improves readability and maintainability of the PE scanner.
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
namespace omath
|
||||
{
|
||||
struct PeSectionScanResult
|
||||
@@ -18,13 +17,6 @@ namespace omath
|
||||
};
|
||||
class PePatternScanner final
|
||||
{
|
||||
private:
|
||||
struct Section
|
||||
{
|
||||
std::uint64_t virtual_base_addr;
|
||||
std::uint64_t raw_base_addr;
|
||||
std::vector<std::byte> data;
|
||||
};
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
@@ -35,9 +27,5 @@ namespace omath
|
||||
static std::optional<PeSectionScanResult>
|
||||
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");
|
||||
|
||||
[[nodiscard]]
|
||||
static std::optional<Section> extract_section_from_pe_file(const std::filesystem::path& path_to_file,
|
||||
const std::string_view& section_name);
|
||||
};
|
||||
} // namespace omath
|
||||
Reference in New Issue
Block a user