mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-27 23:11:02 +00:00
Add macOS support
This commit is contained in:
@@ -154,7 +154,7 @@ uint64_t kusd_mmio::read(const uint64_t addr, const size_t size)
|
||||
}
|
||||
|
||||
const auto end = addr + size;
|
||||
const auto valid_end = std::min(end, KUSD_SIZE);
|
||||
const auto valid_end = std::min(end, static_cast<uint64_t>(KUSD_SIZE));
|
||||
const auto real_size = valid_end - addr;
|
||||
|
||||
if (real_size > sizeof(result))
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <inttypes.h>
|
||||
#include <cinttypes>
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
|
||||
@@ -126,13 +126,13 @@ void syscall_dispatcher::dispatch(windows_emulator& win_emu)
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
printf("Syscall threw an exception: %X (0x%zX) - %s\n", syscall_id, address, e.what());
|
||||
printf("Syscall threw an exception: %X (0x%" PRIx64 ") - %s\n", syscall_id, address, e.what());
|
||||
emu.reg<uint64_t>(x64_register::rax, STATUS_UNSUCCESSFUL);
|
||||
emu.stop();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
printf("Syscall threw an unknown exception: %X (0x%zX)\n", syscall_id, address);
|
||||
printf("Syscall threw an unknown exception: %X (0x%" PRIx64 ")\n", syscall_id, address);
|
||||
emu.reg<uint64_t>(x64_register::rax, STATUS_UNSUCCESSFUL);
|
||||
emu.stop();
|
||||
}
|
||||
|
||||
@@ -834,7 +834,7 @@ namespace
|
||||
const auto mod = c.proc.mod_manager.find_by_address(base_address);
|
||||
if (!mod)
|
||||
{
|
||||
printf("Bad address for memory image request: 0x%zX\n", base_address);
|
||||
printf("Bad address for memory image request: 0x%" PRIx64 "\n", base_address);
|
||||
return STATUS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
@@ -1487,7 +1487,7 @@ namespace
|
||||
|
||||
for (const auto& file : std::filesystem::directory_iterator(dir))
|
||||
{
|
||||
files.emplace_back(file.path().filename());
|
||||
files.emplace_back(file_entry{.file_path = file.path().filename(),});
|
||||
}
|
||||
|
||||
return files;
|
||||
@@ -2899,13 +2899,8 @@ namespace
|
||||
const auto filename = read_unicode_string(c.emu, emulator_object<UNICODE_STRING<EmulatorTraits<Emu64>>>{c.emu, attributes.ObjectName});
|
||||
const auto u8_filename = u16_to_u8(filename);
|
||||
|
||||
#ifdef OS_WINDOWS
|
||||
struct _stat64 file_stat{};
|
||||
if (_stat64(u8_filename.c_str(), &file_stat) != 0)
|
||||
#else
|
||||
struct stat64 file_stat{};
|
||||
if (stat64(u8_filename.c_str(), &file_stat) != 0)
|
||||
#endif
|
||||
{
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
@@ -3199,7 +3194,7 @@ namespace
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unsupported thread attribute type: %zX\n", type);
|
||||
printf("Unsupported thread attribute type: %" PRIx64 "\n", type);
|
||||
}
|
||||
}, i);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace
|
||||
|
||||
const auto total_length = allocator.get_next_address() - context.process_params.value();
|
||||
|
||||
proc_params.Length = static_cast<uint32_t>(std::max(sizeof(proc_params), total_length));
|
||||
proc_params.Length = static_cast<uint32_t>(std::max(static_cast<uint64_t>(sizeof(proc_params)), total_length));
|
||||
proc_params.MaximumLength = proc_params.Length;
|
||||
});
|
||||
|
||||
@@ -869,7 +869,7 @@ void windows_emulator::on_instruction_execution(uint64_t address)
|
||||
auto& emu = this->emu();
|
||||
|
||||
printf(
|
||||
"Inst: %16" PRIu64 " - RAX: %16" PRIu64 " - RBX: %16" PRIu64 " - RCX: %16" PRIu64 " - RDX: %16" PRIu64 " - R8: %16" PRIu64 " - R9: %16" PRIu64 " - RDI: %16" PRIu64 " - RSI: %16" PRIu64 " - %s\n",
|
||||
"Inst: %16" PRIx64 " - RAX: %16" PRIx64 " - RBX: %16" PRIx64 " - RCX: %16" PRIx64 " - RDX: %16" PRIx64 " - R8: %16" PRIx64 " - R9: %16" PRIx64 " - RDI: %16" PRIx64 " - RSI: %16" PRIx64 " - %s\n",
|
||||
address,
|
||||
emu.reg(x64_register::rax), emu.reg(x64_register::rbx),
|
||||
emu.reg(x64_register::rcx),
|
||||
@@ -907,7 +907,7 @@ void windows_emulator::setup_hooks()
|
||||
{
|
||||
const auto ip = this->emu().read_instruction_pointer();
|
||||
|
||||
this->log.print(color::gray, "Invalid instruction at: 0x%" PRIu64 "\n", ip);
|
||||
this->log.print(color::gray, "Invalid instruction at: 0x%" PRIx64 "\n", ip);
|
||||
|
||||
return instruction_hook_continuation::skip_instruction;
|
||||
});
|
||||
@@ -921,7 +921,7 @@ void windows_emulator::setup_hooks()
|
||||
}
|
||||
|
||||
const auto rip = this->emu().read_instruction_pointer();
|
||||
this->log.print(color::gray, "Interrupt: %i 0x%" PRIu64 "\n", interrupt, rip);
|
||||
this->log.print(color::gray, "Interrupt: %i 0x%" PRIx64 "\n", interrupt, rip);
|
||||
|
||||
if (this->fuzzing || true) // TODO: Fix
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user