From 3129e32f0ca2821d2924aae308138c446fe4311f Mon Sep 17 00:00:00 2001 From: Orange Date: Thu, 9 Oct 2025 20:01:34 +0300 Subject: [PATCH] Uses std::uint16_t for SubsystemId enum Ensures consistency by using `std::uint16_t` instead of `uint16_t` for the `SubsystemId` enum. Relates to feature/pe_scanner --- include/omath/system/pe/dos_header.hpp | 2 +- include/omath/system/pe/file_header.hpp | 2 +- include/omath/system/pe/image_nt_headers.hpp | 2 +- include/omath/system/pe/optional_header.hpp | 74 ++++++++++---------- include/omath/system/pe/section_header.hpp | 2 +- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/omath/system/pe/dos_header.hpp b/include/omath/system/pe/dos_header.hpp index b4f370d..d483b25 100644 --- a/include/omath/system/pe/dos_header.hpp +++ b/include/omath/system/pe/dos_header.hpp @@ -7,7 +7,7 @@ namespace omath::system::pe { - struct DosHeader + struct DosHeader final { std::uint16_t e_magic; std::uint16_t e_cblp; diff --git a/include/omath/system/pe/file_header.hpp b/include/omath/system/pe/file_header.hpp index f120fa6..84490f6 100644 --- a/include/omath/system/pe/file_header.hpp +++ b/include/omath/system/pe/file_header.hpp @@ -43,7 +43,7 @@ namespace omath::system::pe CEE = 0xC0EE, }; - struct FileHeader + struct FileHeader final { MachineId machine; uint16_t num_sections; diff --git a/include/omath/system/pe/image_nt_headers.hpp b/include/omath/system/pe/image_nt_headers.hpp index 35c6430..ef30448 100644 --- a/include/omath/system/pe/image_nt_headers.hpp +++ b/include/omath/system/pe/image_nt_headers.hpp @@ -14,7 +14,7 @@ namespace omath::system::pe x64_bit, }; template - struct ImageNtHeaders + struct ImageNtHeaders final { std::uint32_t signature; FileHeader file_header; diff --git a/include/omath/system/pe/optional_header.hpp b/include/omath/system/pe/optional_header.hpp index afe0b23..b27dd5e 100644 --- a/include/omath/system/pe/optional_header.hpp +++ b/include/omath/system/pe/optional_header.hpp @@ -8,71 +8,71 @@ namespace omath::system::pe { static constexpr std::uint16_t opt_hdr32_magic = 0x010B; static constexpr std::uint16_t opt_hdr64_magic = 0x020B; - enum class SubsystemId : uint16_t + enum class SubsystemId : std::uint16_t { - unknown = 0x0000, // Unknown subsystem. - native = 0x0001, // Image doesn't require a subsystem. - windows_gui = 0x0002, // Image runs in the Windows GUI subsystem. - windows_cui = 0x0003, // Image runs in the Windows character subsystem - os2_cui = 0x0005, // image runs in the OS/2 character subsystem. - posix_cui = 0x0007, // image runs in the Posix character subsystem. - native_windows = 0x0008, // image is a native Win9x driver. - windows_ce_gui = 0x0009, // Image runs in the Windows CE subsystem. - efi_application = 0x000A, // - efi_boot_service_driver = 0x000B, // - efi_runtime_driver = 0x000C, // + unknown = 0x0000, + native = 0x0001, + windows_gui = 0x0002, + windows_cui = 0x0003, + os2_cui = 0x0005, + posix_cui = 0x0007, + native_windows = 0x0008, + windows_ce_gui = 0x0009, + efi_application = 0x000A, + efi_boot_service_driver = 0x000B, + efi_runtime_driver = 0x000C, efi_rom = 0x000D, xbox = 0x000E, windows_boot_application = 0x0010, xbox_code_catalog = 0x0011, }; - struct DataDirectory + struct DataDirectory final { - uint32_t rva; - uint32_t size; + std::uint32_t rva; + std::uint32_t size; }; - struct OptionalHeaderX64 + struct OptionalHeaderX64 final { // Standard fields. - uint16_t magic; + std::uint16_t magic; std::uint16_t linker_version; - uint32_t size_code; - uint32_t size_init_data; - uint32_t size_uninit_data; + std::uint32_t size_code; + std::uint32_t size_init_data; + std::uint32_t size_uninit_data; - uint32_t entry_point; - uint32_t base_of_code; + std::uint32_t entry_point; + std::uint32_t base_of_code; // NT additional fields. - uint64_t image_base; - uint32_t section_alignment; - uint32_t file_alignment; + std::uint64_t image_base; + std::uint32_t section_alignment; + std::uint32_t file_alignment; std::uint32_t os_version; std::uint32_t img_version; std::uint32_t subsystem_version; - uint32_t win32_version_value; + std::uint32_t win32_version_value; - uint32_t size_image; - uint32_t size_headers; + std::uint32_t size_image; + std::uint32_t size_headers; - uint32_t checksum; + std::uint32_t checksum; SubsystemId subsystem; - SubsystemId characteristics; + std::uint16_t characteristics; - uint64_t size_stack_reserve; - uint64_t size_stack_commit; - uint64_t size_heap_reserve; - uint64_t size_heap_commit; + std::uint64_t size_stack_reserve; + std::uint64_t size_stack_commit; + std::uint64_t size_heap_reserve; + std::uint64_t size_heap_commit; - uint32_t ldr_flags; + std::uint32_t ldr_flags; - uint32_t num_data_directories; + std::uint32_t num_data_directories; DataDirectory data_directories[16]; }; - struct OptionalHeaderX86 + struct OptionalHeaderX86 final { // Standard fields. uint16_t magic; diff --git a/include/omath/system/pe/section_header.hpp b/include/omath/system/pe/section_header.hpp index 868eb24..8c5448f 100644 --- a/include/omath/system/pe/section_header.hpp +++ b/include/omath/system/pe/section_header.hpp @@ -9,7 +9,7 @@ // namespace omath::system::pe { - struct SectionHeader + struct SectionHeader final { char name[8]; union