diff --git a/.gitignore b/.gitignore index 9e6e726..052b4c2 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ src/*.dmg.c src/stage2/ src/libcheckra1nhelper.dylib* src/Pongo.bin +sysroot +compile.sh diff --git a/include/palerain.h b/include/palerain.h index 781683f..e64c613 100644 --- a/include/palerain.h +++ b/include/palerain.h @@ -24,6 +24,8 @@ #define palerain_option_case_version palerain_option_case(0) #define palerain_option_case_force_revert palerain_option_case(1) +#define palerain_option_case_libcheckra1nhelper_path palerain_option_case(2) + #ifdef USE_LIBUSB #include diff --git a/src/Makefile b/src/Makefile index 83a11b2..a7a68b6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,12 +9,24 @@ OBJS = $(patsubst %,$(OBJDIR)/%,$(C_SRC:.c=.c.o)) ifeq (,$(findstring macosx, $(CFLAGS))) ifneq (,$(findstring version-min=, $(CFLAGS))) +ifneq ($(NO_EMBED_HELPER),1) C_SRC += $(GENDIR)/gen-libcheckra1nhelper.dylib.c endif endif +endif + +ifeq ($(NO_EMBED_HELPER),1) +CFLAGS += -DNO_EMBED_HELPER +endif + +ifeq ($(DFUHELPER_AUTO_ONLY),1) +CFLAGS += -DDFUHELPER_AUTO_ONLY +endif ifeq ($(FORCE_HELPER),1) +ifneq ($(NO_EMBED_HELPER),1) C_SRC += $(GENDIR)/gen-libcheckra1nhelper.dylib.c +endif CFLAGS += -DFORCE_HELPER BUILD_OPTIONS += FORCE_HELPER endif diff --git a/src/dfuhelper.c b/src/dfuhelper.c index 1ecb234..e9c67b8 100644 --- a/src/dfuhelper.c +++ b/src/dfuhelper.c @@ -137,8 +137,10 @@ void* connected_recovery_mode(struct irecv_device_info* info) { LOG(LOG_ERROR, "Cannot set auto-boot back to true"); return NULL; } +#if !defined(DFUHELPER_AUTO_ONLY) LOG(LOG_INFO, "Press Enter when ready for DFU mode"); getchar(); +#endif step(3, 0, "Get ready", NULL, 0); if (NOHOME) step(4, 2, "Hold volume down + side button", NULL, 0); diff --git a/src/exec_checkra1n.c b/src/exec_checkra1n.c index 9cfe6d3..7e51b3e 100644 --- a/src/exec_checkra1n.c +++ b/src/exec_checkra1n.c @@ -23,6 +23,7 @@ #endif extern char **environ; +extern char* gOverrideLibcheckra1nHelper; #include #include @@ -106,6 +107,10 @@ int exec_checkra1n(void) { #if !defined(FORCE_HELPER) if (darwinMajor < 20) { #endif + if (gOverrideLibcheckra1nHelper) { + libcheckra1nhelper_dylib_path = gOverrideLibcheckra1nHelper; + goto setenv_ra1n; + } libcheckra1nhelper_dylib_path = malloc(strlen(tmpdir) + 40); if (libcheckra1nhelper_dylib_path == NULL) { LOG(LOG_FATAL, "memory allocation failed\n"); @@ -131,6 +136,7 @@ int exec_checkra1n(void) { unlink(libcheckra1nhelper_dylib_path); return -1; } +setenv_ra1n: setenv("DYLD_INSERT_LIBRARIES", libcheckra1nhelper_dylib_path, 1); #if !defined(FORCE_HELPER) } @@ -185,10 +191,10 @@ checkra1n_exec: {}; pongo_path = NULL; #if defined(__APPLE__) && defined(__arm64__) && (TARGET_OS_IPHONE || defined(FORCE_HELPER)) if (libcheckra1nhelper_dylib_path != NULL) { - unlink(libcheckra1nhelper_dylib_path); + if (!gOverrideLibcheckra1nHelper) unlink(libcheckra1nhelper_dylib_path); unsetenv("DYLD_INSERT_LIBRARIES"); unsetenv("DYLD_FORCE_FLAT_NAMESPACE"); - free(libcheckra1nhelper_dylib_path); + if (!gOverrideLibcheckra1nHelper) free(libcheckra1nhelper_dylib_path); libcheckra1nhelper_dylib_path = NULL; } #endif diff --git a/src/fake_embedded.c b/src/fake_embedded.c index 5a6715d..48d3ce1 100644 --- a/src/fake_embedded.c +++ b/src/fake_embedded.c @@ -24,3 +24,8 @@ unsigned int binpack_dmg_len = 0; unsigned char* Pongo_bin = NULL; unsigned int Pongo_bin_len = 0; #endif + +#ifdef NO_EMBED_HELPER +unsigned char* libcheckra1nhelper_dylib = NULL; +unsigned int libcheckra1nhelper_dylib_len = 0; +#endif diff --git a/src/optparse.c b/src/optparse.c index 4993906..af1a039 100644 --- a/src/optparse.c +++ b/src/optparse.c @@ -17,6 +17,7 @@ uint64_t* palerain_flags_p = &palerain_flags; static bool force_use_verbose_boot = false; +char* gOverrideLibcheckra1nHelper = NULL; static struct option longopts[] = { {"setup-partial-fakefs", no_argument, NULL, 'B'}, @@ -36,6 +37,7 @@ static struct option longopts[] = { {"no-colors", no_argument, NULL, 'S'}, {"safe-mode", no_argument, NULL, 's'}, {"version", no_argument, NULL, palerain_option_case_version}, + {"override-libcheckra1nhelper", required_argument, NULL, palerain_option_case_libcheckra1nhelper_path}, {"override-pongo", required_argument, NULL, 'k'}, {"override-overlay", required_argument, NULL, 'o'}, {"override-ramdisk", required_argument, NULL, 'r'}, @@ -301,6 +303,14 @@ int optparse(int argc, char* argv[]) { case palerain_option_case_version: palerain_flags |= palerain_option_palerain_version; break; + case palerain_option_case_libcheckra1nhelper_path: + printf("meow\n"); + gOverrideLibcheckra1nHelper = calloc(1, strlen(optarg) + 1); + if (!gOverrideLibcheckra1nHelper) { + return -1; + } + snprintf(gOverrideLibcheckra1nHelper, strlen(optarg) + 1, "%s", optarg); + break; default: usage(1, argv[0]); break; @@ -377,6 +387,13 @@ int optparse(int argc, char* argv[]) { #endif } #endif + +#ifdef NO_EMBED_HELPER + if (libcheckra1nhelper_dylib_len == 0 && gOverrideLibcheckra1nHelper == NULL) { + LOG(LOG_FATAL, "checkra1n helper omitted in build but no override specified"); + return -1; + } +#endif } for (index = optind; index < argc; index++) diff --git a/src/usb.xml b/src/usb.xml index 936018d..24e1c53 100644 --- a/src/usb.xml +++ b/src/usb.xml @@ -5,8 +5,6 @@ com.apple.private.security.no-container - com.apple.private.skip-library-validation - com.apple.security.iokit-user-client-class IOUserClient