allow not embedding resources

This commit is contained in:
Nick Chan committed 2023-02-10 22:34:29 +08:00
1 parent c2c3f527c6
commit 96cadc4105
4 files changed
+91 -5

No files matched your search

+25 -4
View File
@@ -1,9 +1,30 @@
all: palera1n
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o exec_checkra1n.o
OBJECTS += optparse.o override_file.o pongo_helper.o log.o
OBJECTS += xxd-checkra1n.o xxd-checkra1n-kpf-pongo.o xxd-ramdisk.dmg.o
OBJECTS += xxd-binpack.dmg.o lock_vars.o
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o
OBJECTS += optparse.o override_file.o log.o lock_vars.o
OBJECTS += fake_embedded.o exec_checkra1n.o pongo_helper.o
ifneq ($(NO_RAMDISK),1)
OBJECTS += xxd-ramdisk.dmg.o
else
CFLAGS += -DNO_RAMDISK
endif
ifneq ($(NO_KPF),1)
OBJECTS += xxd-checkra1n-kpf-pongo.o
else
CFLAGS += -DNO_KPF
endif
ifneq ($(NO_BINPACK),1)
OBJECTS += xxd-binpack.dmg.o
else
CFLAGS += -DNO_BINPACK
endif
ifneq ($(NO_CHECKRAIN),1)
OBJECTS += xxd-checkra1n.o
else
CFLAGS += -DNO_CHECKRAIN
endif
ifeq ($(DEV_BUILD),1)
OBJECTS += tui_screen_enter_recovery.o tui_screen_enter_dfu.o tui_main.o
OBJECTS += tui_screen_jailbreak.o tui_screen_main.o tui_screen_options.o
+21
View File
@@ -0,0 +1,21 @@
#include <stdlib.h>
#ifdef NO_KPF
unsigned char* checkra1n_kpf_pongo = NULL;
unsigned int checkra1n_kpf_pongo_len = 0;
#endif
#ifdef NO_RAMDISK
unsigned char* ramdisk_dmg = NULL;
unsigned int ramdisk_dmg_len = 0;
#endif
#ifdef NO_CHECKRAIN
unsigned char* checkra1n = NULL;
unsigned int checkra1n_len = 0;
#endif
#ifdef NO_BINPACK
unsigned char* binpack_dmg = NULL;
unsigned int binpack_dmg_len = 0;
#endif
+7 -1
View File
@@ -58,6 +58,7 @@ void thr_cleanup(void* ptr) {
int build_checks() {
#if defined(__APPLE__)
#ifndef NO_CHECKRAIN
struct mach_header_64* c1_header = (struct mach_header_64*)&checkra1n[0];
if (c1_header->magic != MH_MAGIC_64 && c1_header->magic != MH_CIGAM_64) {
LOG(LOG_FATAL, "Broken build: checkra1n is not a thin Mach-O");
@@ -68,17 +69,21 @@ int build_checks() {
return -1;
}
#endif
#endif
#ifndef NO_KPF
struct mach_header_64 *kpf_hdr = (struct mach_header_64 *)checkra1n_kpf_pongo;
if (kpf_hdr->magic != MH_MAGIC_64 && kpf_hdr->magic != MH_CIGAM_64) {
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: Not thin 64-bit Mach-O");
return -1;
} else if (kpf_hdr->filetype != MH_KEXT_BUNDLE) {
} else
if (kpf_hdr->filetype != MH_KEXT_BUNDLE) {
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: Not a kext bundle");
return -1;
} else if (kpf_hdr->cputype != CPU_TYPE_ARM64) {
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: CPU type is not arm64");
return -1;
}
#endif
return 0;
}
@@ -114,6 +119,7 @@ int palera1n(int argc, char *argv[]) {
device_has_booted)
goto normal_exit;
if (exec_checkra1n()) goto cleanup;
if (checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_demote))
goto normal_exit;
set_spin(1);
+38
View File
@@ -279,6 +279,44 @@ int optparse(int argc, char* argv[]) {
return -1;
}
}
if (!(
checkrain_option_enabled(host_flags, host_option_dfuhelper_only) ||
checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
checkrain_option_enabled(host_flags, host_option_reboot_device)))
{
#ifdef NO_CHECKRAIN
if (checkra1n_len == 0 && ext_checkra1n == NULL)
{
LOG(LOG_FATAL, "checkra1n omitted in build but no override specified");
return -1;
}
if (!(checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_pongo_exit)))
{
#ifdef NO_BINPACK
if (binpack_dmg_len == 0)
{
LOG(LOG_FATAL, "binpack omitted in build but no override specified");
return -1;
}
#endif
#ifdef NO_RAMDISK
if (ramdisk_dmg_len == 0)
{
LOG(LOG_FATAL, "ramdisk omitted in build but no override specified");
return -1;
}
#endif
#ifdef NO_KPF
if (checkra1n_kpf_pongo_len == 0)
{
LOG(LOG_FATAL, "kernel patchfinder omitted in build but no override specified");
return -1;
}
#endif
}
#endif
}
for (index = optind; index < argc; index++)
{