mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 19:23:56 +00:00
Add macOS support
This commit is contained in:
34
.github/workflows/build.yml
vendored
34
.github/workflows/build.yml
vendored
@@ -132,3 +132,37 @@ jobs:
|
||||
name: Linux Clang ${{matrix.configuration}} Artifacts
|
||||
path: |
|
||||
build/${{matrix.preset}}/artifacts/*
|
||||
|
||||
build-mac:
|
||||
name: Build macOS
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
include:
|
||||
- configuration: Debug
|
||||
preset: debug
|
||||
- configuration: Release
|
||||
preset: release
|
||||
steps:
|
||||
- name: Checkout Source
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
brew install ninja
|
||||
|
||||
- name: CMake Build
|
||||
run: cmake --workflow --preset=${{matrix.preset}}
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macOS ${{matrix.configuration}} Artifacts
|
||||
path: |
|
||||
build/${{matrix.preset}}/artifacts/*
|
||||
|
||||
@@ -30,12 +30,20 @@
|
||||
#define NO_INLINE __attribute__((noinline))
|
||||
|
||||
#define DECLSPEC_ALIGN(n) alignas(n)
|
||||
#define _fseeki64 fseeko64
|
||||
#define _ftelli64 ftello64
|
||||
#define fopen_s fopen
|
||||
|
||||
#define RESTRICTED_POINTER __restrict
|
||||
// TODO: warning stdcall problem
|
||||
#define WINAPI
|
||||
|
||||
#ifdef OS_MAC
|
||||
#define _fseeki64 fseeko
|
||||
#define _ftelli64 ftello
|
||||
#define _stat64 stat
|
||||
#else
|
||||
#define _fseeki64 fseeko64
|
||||
#define _ftelli64 ftello64
|
||||
#define _stat64 stat64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -28,12 +28,12 @@ namespace utils::io
|
||||
io::create_directory(file.parent_path());
|
||||
}
|
||||
|
||||
std::basic_ofstream<uint8_t> stream(
|
||||
std::ofstream stream(
|
||||
file, std::ios::binary | std::ofstream::out | (append ? std::ofstream::app : std::ofstream::out));
|
||||
|
||||
if (stream.is_open())
|
||||
{
|
||||
stream.write(data.data(), static_cast<std::streamsize>(data.size()));
|
||||
stream.write(reinterpret_cast<const char*>(data.data()), static_cast<std::streamsize>(data.size()));
|
||||
stream.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ bool memory_manager::allocate_memory(const uint64_t address, const size_t size,
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto entry = this->reserved_regions_.try_emplace(address, size).first;
|
||||
const auto entry = this->reserved_regions_.try_emplace(address, reserved_region{.length = size,}).first;
|
||||
|
||||
if (!reserve_only)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "fuzzer.hpp"
|
||||
#include <cinttypes>
|
||||
|
||||
#include "input_generator.hpp"
|
||||
|
||||
namespace fuzzer
|
||||
@@ -123,7 +125,7 @@ namespace fuzzer
|
||||
const auto executions = context.executions.exchange(0);
|
||||
const auto highest_scorer = context.generator.get_highest_scorer();
|
||||
const auto avg_score = context.generator.get_average_score();
|
||||
printf("Executions/s: %zd - Score: %zX - Avg: %.3f\n", executions, highest_scorer.score, avg_score);
|
||||
printf("Executions/s: %" PRIu64 " - Score: %" PRIx64 " - Avg: %.3f\n", executions, highest_scorer.score, avg_score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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