mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
Revert "replace macos entry with objc hook"
This commit is contained in:
parent
409815acb3
commit
794dded30f
1 changed files with 22 additions and 11 deletions
|
@ -14,7 +14,6 @@
|
||||||
#include "../../loader/LoaderImpl.hpp"
|
#include "../../loader/LoaderImpl.hpp"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <objc/runtime.h>
|
|
||||||
|
|
||||||
using namespace geode::prelude;
|
using namespace geode::prelude;
|
||||||
|
|
||||||
|
@ -112,26 +111,38 @@ void updateGeode() {
|
||||||
|
|
||||||
extern "C" void fake() {}
|
extern "C" void fake() {}
|
||||||
|
|
||||||
static IMP s_applicationDidFinishLaunching;
|
void applicationDidFinishLaunchingHook(void* self, SEL sel, NSNotification* notification) {
|
||||||
void applicationDidFinishLaunching(id self, SEL sel, NSNotification* notification) {
|
|
||||||
updateGeode();
|
updateGeode();
|
||||||
|
|
||||||
|
std::array<uint8_t, 6> patchBytes = {
|
||||||
|
0x55,
|
||||||
|
0x48, 0x89, 0xe5,
|
||||||
|
0x41, 0x57
|
||||||
|
};
|
||||||
|
|
||||||
|
auto res = tulip::hook::writeMemory((void*)(base::get() + 0x69a0), patchBytes.data(), 6);
|
||||||
|
if (!res)
|
||||||
|
return;
|
||||||
|
|
||||||
int exitCode = geodeEntry(nullptr);
|
int exitCode = geodeEntry(nullptr);
|
||||||
if (exitCode != 0)
|
if (exitCode != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using Type = decltype(&applicationDidFinishLaunching);
|
return reinterpret_cast<void(*)(void*, SEL, NSNotification*)>(geode::base::get() + 0x69a0)(self, sel, notification);
|
||||||
return reinterpret_cast<Type>(s_applicationDidFinishLaunching)(self, sel, notification);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool loadGeode() {
|
bool loadGeode() {
|
||||||
Class class_ = objc_getClass("AppController");
|
auto detourAddr = reinterpret_cast<uintptr_t>(&applicationDidFinishLaunchingHook) - geode::base::get() - 0x69a5;
|
||||||
SEL selector = @selector(applicationDidFinishLaunching:);
|
auto detourAddrPtr = reinterpret_cast<uint8_t*>(&detourAddr);
|
||||||
IMP function = (IMP)applicationDidFinishLaunching;
|
|
||||||
using Type = decltype(&applicationDidFinishLaunching);
|
|
||||||
|
|
||||||
s_applicationDidFinishLaunching = class_replaceMethod(class_, selector, function, @encode(Type));
|
std::array<uint8_t, 5> patchBytes = {
|
||||||
|
0xe9, detourAddrPtr[0], detourAddrPtr[1], detourAddrPtr[2], detourAddrPtr[3]
|
||||||
|
};
|
||||||
|
|
||||||
|
auto res = tulip::hook::writeMemory((void*)(base::get() + 0x69a0), patchBytes.data(), 5);
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue