Skip to content

Instantly share code, notes, and snippets.

@opa334
Last active May 14, 2025 06:19
Show Gist options
  • Save opa334/b14fa4a593bbb79f025cda6113e8b81b to your computer and use it in GitHub Desktop.
Save opa334/b14fa4a593bbb79f025cda6113e8b81b to your computer and use it in GitHub Desktop.
Macros to support rootless jailbreaks in your packages (OUTDATED / DEPRECATED)
#import <Foundation/Foundation.h>
#include <unistd.h>
// Use for NSString literals or variables
#define ROOT_PATH_NS(path)([[NSFileManager defaultManager] fileExistsAtPath:path] ? path : [@"/var/jb" stringByAppendingPathComponent:path])
// Use for C string literals
#define ROOT_PATH_C(cPath) (access(cPath, F_OK) == 0) ? cPath : "/var/jb" cPath
// Use for C string variables
// The string returned by this will get freed when your function exits
// If you want to keep it, use strdup
#define ROOT_PATH_C_VAR(cPath)(ROOT_PATH_NS([NSString stringWithUTF8String:cPath]).fileSystemRepresentation)
@opa334
Copy link
Author

opa334 commented Dec 1, 2024

DO NOT USE THESE MACROS ANYMORE, THEY ARE NOT ONLY THE IMPROPER WAY OF DOING ROOTLESS SUPPORT, THEY CAN ALSO BE COMPLETELY BROKEN IN SOME RARE EDGE CASES.

Use libroot! For this update theos, #include <libroot.h>, then use the JBROOT_PATH macro for all paths (NSString *, char *)!!!

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