Skip to content

Instantly share code, notes, and snippets.

@stek29
Last active December 9, 2021 02:10
Show Gist options
  • Save stek29/ccbe7a122c2f8f13fe1b713a8776708b to your computer and use it in GitHub Desktop.
Save stek29/ccbe7a122c2f8f13fe1b713a8776708b to your computer and use it in GitHub Desktop.
#include <objc/runtime.h>
extern void *SubGetImageByName(const char *filename) __asm__("SubGetImageByName");;
void *MSGetImageByName(const char *filename) {
return SubGetImageByName(filename);
}
extern void *SubFindSymbol(void *image, const char *name) __asm__("SubFindSymbol");
void *MSFindSymbol(void *image, const char *name) {
return SubFindSymbol(image, name);
}
extern void SubHookFunction(void *symbol, void *replace, void **result) __asm__("SubHookFunction");
void MSHookFunction(void *symbol, void *replace, void **result) {
SubHookFunction(symbol, replace, result);
}
extern void SubHookMessageEx(Class _class, SEL sel, IMP imp, IMP *result) __asm__("SubHookMessageEx");
void MSHookMessageEx(Class _class, SEL sel, IMP imp, IMP *result) {
SubHookMessageEx(_class, sel, imp, result);
}
@stek29
Copy link
Author

stek29 commented Jan 14, 2018

to build shim:

  1. unarchive substitute.0.dylib from tweaksupport.tar, save as substitute.dylib
  2. Get this file
  3. xcrun -sdk iphoneos cc -dynamiclib -arch arm64 substrate-shim.c -L$PWD -lsubstitute -install_name /Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate -o CydiaSubstrate
  4. jtool --sign --inplace CydiaSubstrate or ldid or ldid2 or whatever
  5. on device: mkdir -p /Library/Frameworks/CydiaSubstrate.framework
  6. copy CydiaSubstrate you've built to /Library/Frameworks/CydiaSubstrate.framework
  7. Tweaks depending on CydiaSubstrate would likely work -- when you move their files from /Library/MobileSubstrate/DynamicLibraries to /bootstrap/Library/SBInject ofc (no need to mess with install_name_tool though)
    You can just make a symlink from /Library/MobileSubstrate/DynamicLibraries to /bootstrap/Library/SBInject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment