mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-23 21:51:02 +00:00
Comprehensive WOW64 subsystem implementation
This commit is contained in:
@@ -65,7 +65,8 @@ void syscall_dispatcher::dispatch(windows_emulator& win_emu)
|
||||
auto& context = win_emu.process;
|
||||
|
||||
const auto address = emu.read_instruction_pointer();
|
||||
const auto syscall_id = emu.reg<uint32_t>(x86_register::eax);
|
||||
const auto raw_syscall_id = emu.reg<uint32_t>(x86_register::eax);
|
||||
const auto syscall_id = raw_syscall_id & 0xFFFF; // Only take low bits for WOW64 compatibility
|
||||
|
||||
const syscall_context c{
|
||||
.win_emu = win_emu,
|
||||
@@ -79,7 +80,7 @@ void syscall_dispatcher::dispatch(windows_emulator& win_emu)
|
||||
const auto entry = this->handlers_.find(syscall_id);
|
||||
if (entry == this->handlers_.end())
|
||||
{
|
||||
win_emu.log.error("Unknown syscall: 0x%X\n", syscall_id);
|
||||
win_emu.log.error("Unknown syscall: 0x%X (raw: 0x%X)\n", syscall_id, raw_syscall_id);
|
||||
c.emu.reg<uint64_t>(x86_register::rax, STATUS_NOT_SUPPORTED);
|
||||
c.emu.stop();
|
||||
return;
|
||||
@@ -93,23 +94,30 @@ void syscall_dispatcher::dispatch(windows_emulator& win_emu)
|
||||
|
||||
if (!entry->second.handler)
|
||||
{
|
||||
win_emu.log.error("Unimplemented syscall: %s - 0x%X\n", entry->second.name.c_str(), syscall_id);
|
||||
win_emu.log.error("Unimplemented syscall: %s - 0x%X (raw: 0x%X)\n", entry->second.name.c_str(), syscall_id, raw_syscall_id);
|
||||
c.emu.reg<uint64_t>(x86_register::rax, STATUS_NOT_SUPPORTED);
|
||||
c.emu.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
entry->second.handler(c);
|
||||
|
||||
if (c.write_status && !c.retrigger_syscall)
|
||||
{
|
||||
const auto status = static_cast<uint32_t>(emu.reg<uint64_t>(x86_register::rax));
|
||||
win_emu.log.print(color::dark_gray, "Syscall return: %s (0x%X, raw: 0x%X) -> 0x%08X\n", entry->second.name.c_str(), syscall_id,
|
||||
raw_syscall_id, status);
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
win_emu.log.error("Syscall threw an exception: %X (0x%" PRIx64 ") - %s\n", syscall_id, address, e.what());
|
||||
win_emu.log.error("Syscall threw an exception: %X (raw: %X) (0x%" PRIx64 ") - %s\n", syscall_id, raw_syscall_id, address, e.what());
|
||||
emu.reg<uint64_t>(x86_register::rax, STATUS_UNSUCCESSFUL);
|
||||
emu.stop();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
win_emu.log.error("Syscall threw an unknown exception: %X (0x%" PRIx64 ")\n", syscall_id, address);
|
||||
win_emu.log.error("Syscall threw an unknown exception: %X (raw: %X) (0x%" PRIx64 ")\n", syscall_id, raw_syscall_id, address);
|
||||
emu.reg<uint64_t>(x86_register::rax, STATUS_UNSUCCESSFUL);
|
||||
emu.stop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user