Skip to content

Conversation

@orange-cpp
Copy link
Owner

This commit updates the PE header structure for x64, including the PE headers file to omath directory. It is done to improve code quality and maintainability. This ensures that the code is correctly structured to efficiently process x64 PE files.
Fixes #123

@orange-cpp orange-cpp self-assigned this Oct 7, 2025
@orange-cpp orange-cpp added the enhancement New feature or request label Oct 7, 2025
Introduces a structure for representing the DOS header
within a PE (Portable Executable) file for x64 architectures.
This definition enables easier parsing and manipulation of PE header information.
Organizes the project by relocating the PE headers file to the omath directory structure.
This improves code organization and maintainability.
Rephrases the explanation regarding build presets for clarity in the INSTALL.md file.
The text now more explicitly advises users on selecting appropriate presets.
Introduces a method to scan for patterns within specified PE files.
This facilitates searching for patterns outside of loaded modules.
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.
Defines `DosHeader` and `FileHeader` structures to represent PE file header information.
Includes definitions for `MachineId` enum and `FileCharacteristics` union.
These definitions are prerequisite for PE file parsing and analysis.
Initializes infrastructure for PE file scanning.

Adds data structures for PE headers (DOS, optional, section),
including user-defined types for section characteristics.

Refactors existing pattern scanning code to utilize new PE data structures.

Adds basic parsing of PE headers.
Updates the PE scanner implementation to support both 32-bit and 64-bit architectures.
Leverages `std::variant` and a generic `ImageNtHeaders` to abstract architecture-specific details.
Simplifies the logic for retrieving section data, generalizing the process for improved maintainability.
Eliminates the PE scanner test code from the unit tests.

This removes a test that appears to be broken or no longer relevant, since the test directly references a file path.
Ensures consistency by using `std::uint16_t` instead of `uint16_t` for the `SubsystemId` enum.

Relates to feature/pe_scanner
Simplifies pattern scanner logic by removing conditional compilation for non-Windows platforms.

The error handling previously thrown on non-Windows platforms was unnecessary as this functionality is not intended for those systems. This change streamlines the code and removes a misleading error message.
Adjusts the virtual method calling convention based on the compiler (_MSC_VER).
This ensures compatibility and correct behavior on different platforms.
Simplifies PE header reading and validation logic, extracting common functionality into helper functions.

Introduces `get_nt_header_from_file` to handle both x86 and x64 PE headers.

Adds validation checks for both DOS and NT headers to ensure file integrity.

Improves code readability and maintainability by reducing redundancy in header parsing.

Relates to feature/pe_scanner
Simplifies `extract_section_from_pe_file` by removing the unused path parameter.
This clarifies the function's purpose and improves readability.
Enables users to specify the target section name when scanning a PE file for a pattern.
This provides more flexibility in locating patterns within a PE file, as it's not limited to the ".text" section.
@orange-cpp orange-cpp merged commit 086eda4 into main Oct 9, 2025
3 checks passed
@orange-cpp orange-cpp deleted the feature/pe_scanner branch October 13, 2025 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants