Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(macos): Add support for macos and ARM64 patching #62

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion librecomp/src/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ void protect(void* target_func, uint64_t old_flags) {

class recomp::mods::DynamicLibrary {
public:
#if defined(__APPLE__)
static constexpr std::string_view PlatformExtension = ".dylib";
#else
static constexpr std::string_view PlatformExtension = ".so";
#endif
DynamicLibrary() = default;
DynamicLibrary(const std::filesystem::path& path) {
native_handle = dlopen(path.c_str(), RTLD_NOW | RTLD_LOCAL);
Expand Down Expand Up @@ -399,7 +403,13 @@ void patch_func(recomp_func_t* target_func, recomp::mods::GenericFunction replac
}
}, replacement_func);
#elif defined(IS_ARM64)
ultramodern::error_handling::message_box("Mod loading not currently implemented on ARM CPUs!\n");
static const uint8_t ldr_x2_8__br_x2[] = {0x42, 0x00, 0x00, 0x58, 0x40, 0x00, 0x1F, 0xD6};
std::visit(overloaded {
[&write_bytes](recomp_func_t* native_func) {
write_bytes(ldr_x2_8__br_x2, sizeof(ldr_x2_8__br_x2));
write_bytes(&native_func, sizeof(&native_func));
}
}, replacement_func);
#else
# error "Unsupported architecture"
#endif
Expand Down