-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change geode loading order, auto updating not implemented yet
- Loading branch information
Showing
9 changed files
with
83 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,4 @@ | ||
#include <ghc/filesystem.hpp> | ||
#include <mach-o/dyld.h> | ||
#include <unistd.h> | ||
#include <dlfcn.h> | ||
#include <array> | ||
#include <iostream> | ||
#include <CoreFoundation/CoreFoundation.h> | ||
|
||
void displayError(std::string alertMessage) { | ||
CFStringRef cfTitle = CFStringCreateWithCString(NULL, "Geode Bootstrapper", kCFStringEncodingUTF8); | ||
CFStringRef cfMessage = CFStringCreateWithCString(NULL, alertMessage.c_str(), kCFStringEncodingUTF8); | ||
|
||
CFUserNotificationDisplayNotice(0, kCFUserNotificationCautionAlertLevel, NULL, NULL, NULL, cfTitle, cfMessage, NULL); | ||
} | ||
|
||
void loadGeode() { | ||
auto dylib = dlopen("Geode.dylib", RTLD_NOW); | ||
if (!dylib) { | ||
displayError(std::string("Couldn't load Geode: ") + dlerror()); | ||
return; | ||
} | ||
auto trigger = dlsym(dylib, "dynamicTrigger"); | ||
if (!trigger) { | ||
displayError(std::string("Couldn't start Geode: ") + dlerror()); | ||
return; | ||
} | ||
reinterpret_cast<void(*)()>(trigger)(); | ||
return; | ||
} | ||
|
||
extern "C" void fake(); | ||
__attribute__((constructor)) void _entry() { | ||
std::array<char, PATH_MAX> gddir; | ||
|
||
uint32_t out = PATH_MAX; | ||
_NSGetExecutablePath(gddir.data(), &out); | ||
|
||
ghc::filesystem::path gdpath = gddir.data(); | ||
auto workingDir = gdpath.parent_path().parent_path(); | ||
|
||
auto updatesDir = workingDir / "geode" / "update"; | ||
auto libDir = workingDir / "Frameworks"; | ||
auto resourcesDir = workingDir / "geode" / "resources"; | ||
|
||
auto error = std::error_code(); | ||
|
||
if (ghc::filesystem::exists(updatesDir / "Geode.dylib", error) && !error) { | ||
ghc::filesystem::rename( | ||
updatesDir / "Geode.dylib", | ||
libDir / "Geode.dylib", error | ||
); | ||
if (error) { | ||
displayError(std::string("Couldn't update Geode: ") + error.message()); | ||
return loadGeode(); | ||
} | ||
} | ||
|
||
if (ghc::filesystem::exists(updatesDir / "resources", error) && !error) { | ||
ghc::filesystem::remove_all(resourcesDir / "geode.loader", error); | ||
|
||
if (error) { | ||
displayError(std::string("Couldn't update Geode resources: ") + error.message()); | ||
return loadGeode(); | ||
} | ||
|
||
ghc::filesystem::rename( | ||
updatesDir / "resources", | ||
resourcesDir / "geode.loader", error | ||
); | ||
|
||
if (error) { | ||
displayError(std::string("Couldn't update Geode resources: ") + error.message()); | ||
return loadGeode(); | ||
} | ||
} | ||
|
||
return loadGeode(); | ||
fake(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extern "C" void fake() {} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <Geode/DefaultInclude.hpp> | ||
|
||
#if defined(GEODE_IS_MACOS) | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#include "../load.hpp" | ||
#include <dlfcn.h> | ||
#include <mach-o/dyld.h> | ||
#include <unistd.h> | ||
#include <tulip/TulipHook.hpp> | ||
#include <iostream> | ||
|
||
#include <thread> | ||
|
||
using namespace geode::prelude; | ||
|
||
std::length_error::~length_error() _NOEXCEPT {} // do not ask... | ||
|
||
// camila has an old ass macos and this function turned | ||
// from dynamic to static thats why she needs to define it | ||
// this is what old versions does to a silly girl | ||
|
||
extern "C" void fake() {} | ||
|
||
void applicationDidFinishLaunchingHook(void* self, SEL sel, NSNotification* notification) { | ||
// 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); | ||
if (exitCode != 0) | ||
return; | ||
|
||
return reinterpret_cast<void(*)(void*, SEL, NSNotification*)>(geode::base::get() + 0x69a0)(self, sel, notification); | ||
} | ||
|
||
|
||
bool loadGeode() { | ||
auto detourAddr = reinterpret_cast<uintptr_t>(&applicationDidFinishLaunchingHook) - geode::base::get() - 0x69a5; | ||
auto detourAddrPtr = reinterpret_cast<uint8_t*>(&detourAddr); | ||
|
||
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; | ||
} | ||
|
||
__attribute__((constructor)) void _entry() { | ||
if (!loadGeode()) | ||
return; | ||
} | ||
|
||
#endif |