Add override libcheckra1nhelper option

This commit is contained in:
Nick Chan committed 2023-12-26 16:41:01 +08:00
1 parent 65707046dd
commit 240185c07e
8 files changed
+48 -4

No files matched your search

+2
View File
@@ -24,3 +24,5 @@ src/*.dmg.c
src/stage2/
src/libcheckra1nhelper.dylib*
src/Pongo.bin
sysroot
compile.sh
+2
View File
@@ -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 <libusb-1.0/libusb.h>
+12
View File
@@ -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
+2
View File
@@ -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);
+8 -2
View File
@@ -23,6 +23,7 @@
#endif
extern char **environ;
extern char* gOverrideLibcheckra1nHelper;
#include <palerain.h>
#include <xxd-embedded.h>
@@ -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
+5
View File
@@ -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
+17
View File
@@ -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++)
-2
View File
@@ -5,8 +5,6 @@
<true/>
<key>com.apple.private.security.no-container</key>
<true/>
<key>com.apple.private.skip-library-validation</key>
<true/>
<key>com.apple.security.iokit-user-client-class</key>
<array>
<string>IOUserClient</string>