File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change 1
1
#include < Geode/platform/cplatform.h>
2
2
#ifdef GEODE_IS_MACOS
3
- #include < Geode/loader/Mod .hpp>
3
+ #include < Geode/utils/ObjcHook .hpp>
4
4
#include < objc/runtime.h>
5
5
6
6
using namespace geode ::prelude;
@@ -17,17 +17,8 @@ void shutdownGameHook(void* self, SEL sel) {
17
17
}
18
18
19
19
$execute {
20
- auto appController = objc_getClass (" AppController" );
21
- if (!appController) return ;
22
-
23
- auto shutdownGame = class_getInstanceMethod (appController, sel_registerName (" shutdownGame" ));
24
- if (!shutdownGame) return ;
25
-
26
- s_originalShutdownGame = reinterpret_cast <decltype (s_originalShutdownGame)>(method_getImplementation (shutdownGame));
27
- if (s_originalShutdownGame) (void )Mod::get ()->hook (
28
- reinterpret_cast <void *>(s_originalShutdownGame),
29
- &shutdownGameHook,
30
- " AppController::shutdownGame"
31
- );
20
+ if (auto original = hook::replaceObjcMethod (" AppController" , " shutdownGame" , reinterpret_cast <void *>(&shutdownGameHook))) {
21
+ s_originalShutdownGame = reinterpret_cast <decltype (s_originalShutdownGame)>(original.unwrap ());
22
+ }
32
23
};
33
24
#endif
You can’t perform that action at this time.
0 commit comments