From e2bb1c4d48ddd82c2319c91af2249941c4144985 Mon Sep 17 00:00:00 2001 From: brian Date: Tue, 30 Dec 2025 19:13:47 +0800 Subject: [PATCH] Fix registry unicode and enhance syscall exception logging --- src/windows-emulator/registry/hive_parser.hpp | 3 ++- src/windows-emulator/syscall_dispatcher.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/windows-emulator/registry/hive_parser.hpp b/src/windows-emulator/registry/hive_parser.hpp index 6fa98440..80557a41 100644 --- a/src/windows-emulator/registry/hive_parser.hpp +++ b/src/windows-emulator/registry/hive_parser.hpp @@ -5,6 +5,7 @@ #include #include +#include struct hive_value { @@ -111,7 +112,7 @@ class hive_parser return nullptr; } - current_key = current_key->get_sub_key(this->file_, key_part.string()); + current_key = current_key->get_sub_key(this->file_, u16_to_u8(key_part.u16string())); } return current_key; diff --git a/src/windows-emulator/syscall_dispatcher.cpp b/src/windows-emulator/syscall_dispatcher.cpp index 370da9af..87f0b0b1 100644 --- a/src/windows-emulator/syscall_dispatcher.cpp +++ b/src/windows-emulator/syscall_dispatcher.cpp @@ -68,6 +68,9 @@ void syscall_dispatcher::dispatch(windows_emulator& win_emu) const auto raw_syscall_id = emu.reg(x86_register::eax); const auto syscall_id = raw_syscall_id & 0xFFFF; // Only take low bits for WOW64 compatibility + const auto entry = this->handlers_.find(syscall_id); + const auto* syscall_name = (entry != this->handlers_.end()) ? entry->second.name.c_str() : ""; + const syscall_context c{ .win_emu = win_emu, .emu = emu, @@ -77,7 +80,6 @@ void syscall_dispatcher::dispatch(windows_emulator& win_emu) try { - const auto entry = this->handlers_.find(syscall_id); if (entry == this->handlers_.end()) { win_emu.log.error("Unknown syscall: 0x%X (raw: 0x%X)\n", syscall_id, raw_syscall_id); @@ -104,13 +106,15 @@ void syscall_dispatcher::dispatch(windows_emulator& win_emu) } catch (std::exception& e) { - win_emu.log.error("Syscall threw an exception: %X (raw: %X) (0x%" PRIx64 ") - %s\n", syscall_id, raw_syscall_id, address, e.what()); + win_emu.log.error("Syscall %s threw an exception: 0x%X (raw: 0x%X) (0x%" PRIx64 ") - %s\n", syscall_name, syscall_id, + raw_syscall_id, address, e.what()); emu.reg(x86_register::rax, STATUS_UNSUCCESSFUL); emu.stop(); } catch (...) { - win_emu.log.error("Syscall threw an unknown exception: %X (raw: %X) (0x%" PRIx64 ")\n", syscall_id, raw_syscall_id, address); + win_emu.log.error("Syscall %s threw an unknown exception: 0x%X (raw: 0x%X) (0x%" PRIx64 ")\n", syscall_name, syscall_id, + raw_syscall_id, address); emu.reg(x86_register::rax, STATUS_UNSUCCESSFUL); emu.stop(); }