Skip to content

Commit

Permalink
refactor exl patching (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight authored Nov 24, 2024
1 parent 5a2ddc3 commit b7f0066
Show file tree
Hide file tree
Showing 36 changed files with 818 additions and 961 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Michael
Copyright (c) 2024 Michael

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

Megaton is a build tool and support library for embedding Rust in a NSO binary. [(name reference)](https://www.zeldadungeon.net/wiki/Rusty_Switch)

## LICENSE
libmegaton is GPLv2. Everything else is MIT.

## Install
TODO

Expand Down
2 changes: 1 addition & 1 deletion lib/build/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn build_ninja(cli: &Cli) -> Result<(), Error> {
let includes = [&inc_root, &env.libnx_include];

// let mut c_flags = flags::DEFAULT_C.to_vec();
let mut c_flags = vec!["-Wall", "-Werror", "-O3"];
let mut c_flags = vec!["-Wall", "-Werror", "-O3", "-fdiagnostics-color=always"];
c_flags.push("-DMEGATON_LIB");

let include_flag = includes
Expand Down
4 changes: 2 additions & 2 deletions lib/include/exl/hook/inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <megaton/prelude.h>
#include <megaton/module_layout.h>

#include <exl/hook/lib.hpp>
#include <exl/hook/macros.h>
Expand All @@ -17,7 +17,7 @@ template <typename Derived> struct InlineHook {
inline_always_ void InstallAtOffset(ptrdiff_t address) {
_HOOK_STATIC_CALLBACK_ASSERT();

hook::HookInline(util::modules::GetTargetStart() + address,
hook::HookInline(megaton::module::main_info().start() + address,
Derived::Callback);
}

Expand Down
8 changes: 0 additions & 8 deletions lib/include/exl/hook/lib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <exl/hook/nx64/impl.hpp>
#include <exl/hook/nx64/inline_impl.hpp>
#include <exl/hook/util/func_ptrs.hpp>
#include <exl/hook/util/modules.hpp>

namespace exl::hook {

Expand All @@ -17,13 +16,6 @@ namespace {
using Entrypoint = util::GenericFuncPtr<void, void*, void*>;
};

/* inline noreturn_ CallTargetEntrypoint(void* x0, void* x1) { */
/* auto entrypoint =
* reinterpret_cast<Entrypoint>(util::modules::GetTargetStart()); */
/* entrypoint(x0, x1); */
/* __builtin_unreachable(); */
/* } */

inline void Initialize() {
arch::Initialize();
arch::InitializeInline();
Expand Down
4 changes: 2 additions & 2 deletions lib/include/exl/hook/replace.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <megaton/prelude.h>
#include <megaton/module_layout.h>

#include <exl/hook/lib.hpp>
#include <exl/hook/macros.h>
Expand All @@ -18,7 +18,7 @@ template <typename Derived> struct ReplaceHook {
inline_always_ void InstallAtOffset(ptrdiff_t address) {
_HOOK_STATIC_CALLBACK_ASSERT();

hook::Hook(util::modules::GetTargetStart() + address,
hook::Hook(megaton::module::main_info().start() + address,
Derived::Callback);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/include/exl/hook/trampoline.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <megaton/module_layout.h>
#include <megaton/prelude.h>

#include <exl/hook/lib.hpp>
Expand Down Expand Up @@ -34,7 +35,7 @@ template <typename Derived> class TrampolineHook {
inline_always_ void InstallAtOffset(ptrdiff_t address) {
_HOOK_STATIC_CALLBACK_ASSERT();

OrigRef() = hook::Hook(util::modules::GetTargetStart() + address,
OrigRef() = hook::Hook(megaton::module::main_info().start() + address,
Derived::Callback, true);
}

Expand Down
36 changes: 0 additions & 36 deletions lib/include/exl/hook/util/jit.hpp

This file was deleted.

15 changes: 0 additions & 15 deletions lib/include/exl/hook/util/modules.hpp

This file was deleted.

26 changes: 0 additions & 26 deletions lib/include/exl/hook/util/setting.hpp

This file was deleted.

42 changes: 0 additions & 42 deletions lib/include/exl/patch/code_patcher.hpp

This file was deleted.

60 changes: 0 additions & 60 deletions lib/include/exl/patch/patcher_impl.hpp

This file was deleted.

67 changes: 0 additions & 67 deletions lib/include/exl/patch/random_access_patcher.hpp

This file was deleted.

Loading

0 comments on commit b7f0066

Please sign in to comment.