Improve Windows version detection and LdrSystemDllInitBlock initialization

- Add WINDOWS_VERSION enum and PS_SYSTEM_DLL_INIT_BLOCK sizes for WOW64 support across different Windows builds.
- Read system information (SystemRoot, BuildNumber, UpdateBuildRevision) from registry instead of hardcoded paths.
- Add build comparison helpers in process_context for precise build checks.
This commit is contained in:
brian
2026-01-09 00:38:03 +08:00
parent 9090e29e21
commit 456dc99fb6
6 changed files with 161 additions and 61 deletions

View File

@@ -7,6 +7,8 @@
#include "platform/win_pefile.hpp"
class logger;
class registry_manager;
struct process_context;
// Execution mode for the emulated process
enum class execution_mode
@@ -78,6 +80,13 @@ class pe_architecture_detector
static execution_mode determine_execution_mode(winpe::pe_arch executable_arch);
};
struct system_information
{
windows_path system_root{};
uint32_t build_number{0};
uint32_t update_build_revision{0};
};
class module_manager
{
public:
@@ -91,8 +100,7 @@ class module_manager
module_manager(memory_manager& memory, file_system& file_sys, callbacks& cb);
void map_main_modules(const windows_path& executable_path, const windows_path& system32_path, const windows_path& syswow64_path,
const logger& logger);
void map_main_modules(const windows_path& executable_path, registry_manager& registry, process_context& context, const logger& logger);
mapped_module* map_module(const windows_path& file, const logger& logger, bool is_static = false);
mapped_module* map_local_module(const std::filesystem::path& file, const logger& logger, bool is_static = false);
@@ -186,11 +194,13 @@ class module_manager
// Execution mode detection
execution_mode detect_execution_mode(const windows_path& executable_path, const logger& logger);
static void get_system_information_from_registry(registry_manager& registry, system_information& info, const logger& logger);
// Module loading helpers
void load_native_64bit_modules(const windows_path& executable_path, const windows_path& ntdll_path, const windows_path& win32u_path,
const logger& logger);
void load_wow64_modules(const windows_path& executable_path, const windows_path& ntdll_path, const windows_path& win32u_path,
const windows_path& ntdll32_path, const logger& logger);
const windows_path& ntdll32_path, process_context& context, const logger& logger);
void install_wow64_heaven_gate(const logger& logger);