From d74792025020f50d485db7d7a5e287453ae929ec Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Sun, 21 Jul 2024 23:47:34 +0800 Subject: [PATCH] fixed ios 18 trollstore --- include/universalhooks/hooks.h | 1 + plooshInit.xcodeproj/project.pbxproj | 4 ++++ src/systemhook/main.c | 6 ++++++ src/universalhooks/main.c | 21 +++++++++++++++++++++ src/universalhooks/trollstorehelper.c | 12 ++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 src/universalhooks/trollstorehelper.c diff --git a/include/universalhooks/hooks.h b/include/universalhooks/hooks.h index 822acd1..58da856 100644 --- a/include/universalhooks/hooks.h +++ b/include/universalhooks/hooks.h @@ -15,5 +15,6 @@ void cfprefsdInit(void); void pineboardInit(void); void lsdUniversalInit(void); void headboardInit(void); +void trollstorehelperInit(char* executablePath); #endif diff --git a/plooshInit.xcodeproj/project.pbxproj b/plooshInit.xcodeproj/project.pbxproj index d0d75fb..f69a0f6 100644 --- a/plooshInit.xcodeproj/project.pbxproj +++ b/plooshInit.xcodeproj/project.pbxproj @@ -149,6 +149,7 @@ 01F2C6172C4C4118007E932C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01F2C6162C4C4118007E932C /* CoreGraphics.framework */; }; 01F2C6192C4C411B007E932C /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01F2C6182C4C411B007E932C /* ImageIO.framework */; }; 01F2C61A2C4C4126007E932C /* IOMobileFramebuffer.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 01D3D5EE2B5C80DA007845B6 /* IOMobileFramebuffer.tbd */; }; + 01F2C6262C4D6091007E932C /* trollstorehelper.c in Sources */ = {isa = PBXBuildFile; fileRef = 01F2C6252C4D6091007E932C /* trollstorehelper.c */; }; 01FE46A92C1AD335005E6E9D /* runcmd.c in Sources */ = {isa = PBXBuildFile; fileRef = 01FE46A82C1AD335005E6E9D /* runcmd.c */; }; /* End PBXBuildFile section */ @@ -560,6 +561,7 @@ 01E427D32BA1F29F008BC989 /* patch_dyld-test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "patch_dyld-test"; sourceTree = BUILT_PRODUCTS_DIR; }; 01F2C6162C4C4118007E932C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; 01F2C6182C4C411B007E932C /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; }; + 01F2C6252C4D6091007E932C /* trollstorehelper.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = trollstorehelper.c; sourceTree = ""; }; 01FE46A82C1AD335005E6E9D /* runcmd.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = runcmd.c; sourceTree = ""; }; /* End PBXFileReference section */ @@ -802,6 +804,7 @@ 017796CB2BAEDA1A00BCC2C3 /* cfprefsd.c */, 017796D22BAEF0AA00BCC2C3 /* pineboard.m */, 01D6C6112C1B3C3D00D02A79 /* headboard.c */, + 01F2C6252C4D6091007E932C /* trollstorehelper.c */, ); path = universalhooks; sourceTree = ""; @@ -1973,6 +1976,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 01F2C6262C4D6091007E932C /* trollstorehelper.c in Sources */, 017796CC2BAEDA1A00BCC2C3 /* cfprefsd.c in Sources */, 01E427C12BA1EF2B008BC989 /* securityd.c in Sources */, 017796CA2BAED7ED00BCC2C3 /* springboard.m in Sources */, diff --git a/src/systemhook/main.c b/src/systemhook/main.c index 8b9e330..ac5b03b 100644 --- a/src/systemhook/main.c +++ b/src/systemhook/main.c @@ -467,6 +467,12 @@ __attribute__((constructor)) static void initializer(void) dlopen_hook("/cores/binpack/usr/lib/universalhooks.dylib", RTLD_NOW); } } + if (release >= 24) { + if (stringEndsWith(gExecutablePath, "/TrollStore.app/trollstorehelper")) { + if (getuid() == 0) + dlopen_hook("/cores/binpack/usr/lib/universalhooks.dylib", RTLD_NOW); + } + } } //fprintf(stderr, "shouldEnableTweaks(): %d\n", shouldEnableTweaks()); diff --git a/src/universalhooks/main.c b/src/universalhooks/main.c index d7d47fc..0651e59 100644 --- a/src/universalhooks/main.c +++ b/src/universalhooks/main.c @@ -5,6 +5,7 @@ #include #include #include +#include struct hook_info { const char* executablePath; @@ -24,6 +25,22 @@ struct hook_info info[] = { { "/Applications/HeadBoard.app/HeadBoard", NULL, NULL, headboardInit }, }; +bool stringEndsWith(const char* str, const char* suffix) +{ + if (!str || !suffix) { + return false; + } + + size_t str_len = strlen(str); + size_t suffix_len = strlen(suffix); + + if (str_len < suffix_len) { + return false; + } + + return !strcmp(str + str_len - suffix_len, suffix); +} + uint64_t pflags; bool rootful; __attribute__((constructor))void universalhooks_main(void) { @@ -43,4 +60,8 @@ __attribute__((constructor))void universalhooks_main(void) { if (info[i].universalInit) info[i].universalInit(); } + + if (stringEndsWith(path, "/TrollStore.app/trollstorehelper")) { + trollstorehelperInit(path); + } } diff --git a/src/universalhooks/trollstorehelper.c b/src/universalhooks/trollstorehelper.c new file mode 100644 index 0000000..2b393ff --- /dev/null +++ b/src/universalhooks/trollstorehelper.c @@ -0,0 +1,12 @@ +#include +int apply_coretrust_bypass_hook(__unused char* binaryPath) { + return 0; +} + +void trollstorehelperInit(char* executablePath) { + MSImageRef trollstorehelper = MSGetImageByName(executablePath); + void* apply_coretrust_bypass = MSFindSymbol(trollstorehelper, "_apply_coretrust_bypass"); + if (apply_coretrust_bypass) { + MSHookFunction(apply_coretrust_bypass, apply_coretrust_bypass_hook, NULL); + } +}