mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-21 09:47:01 +02:00
* add "build" into .gitignore for future out-of-source compilation * help me this is a break point not to be committed * help me this is a break point not to be committed again * Fix many major problems 1. Fix deps so that a script can download the deps instead of some special actions build.yml runner step 2. Fix CMakeLists.txt so that it (partially) works It is still **NOT** recommended to use cmake for the build as it is currently not functional 3. Add to gitignore so that git doesn't track a bunch of generated files * fix deps * change the dep_root population into git submodules. I succeeded in finding git repos for all. * fix all issues and fix ftp settings * change all to cmake * fix CMakeLists.txt so that it doesn't suck as much * switch from ftp to artifacts * fix more issues in src/CMakeLists.txt * fix more issues in src/CMakeLists.txt again * fix more issues in src/CMakeLists.txt again again * add passcode info for A11 * better description formatting * add the 3s wait * dfuhelper: lowercase steps except for first letter * i cant spell * made C99 compliant * turn into valid c99 * fix more issues in src/CMakeLists.txt again again again * Use xcode instead of makefiles * fix deps again * fix deps again again * fix deps again again again * add "build" into .gitignore for future out-of-source compilation * help me this is a break point not to be committed * help me this is a break point not to be committed again * Fix many major problems 1. Fix deps so that a script can download the deps instead of some special actions build.yml runner step 2. Fix CMakeLists.txt so that it (partially) works It is still **NOT** recommended to use cmake for the build as it is currently not functional 3. Add to gitignore so that git doesn't track a bunch of generated files * change the dep_root population into git submodules. I succeeded in finding git repos for all. * fix all issues and fix ftp settings * change all to cmake * fix CMakeLists.txt so that it doesn't suck as much * switch from ftp to artifacts * fix more issues in src/CMakeLists.txt * fix more issues in src/CMakeLists.txt again * fix more issues in src/CMakeLists.txt again again * made C99 compliant * turn into valid c99 * fix more issues in src/CMakeLists.txt again again again * Use xcode instead of makefiles * fix deps again again again * make more fixes * help me * Revert "help me" This reverts commit 866d3669d8aa90bcd7eda0412aea8cb05f42389c. * fix most issues with compiling hopefully * make more fixes again * make more fixes again * make more fixes again * make more fixes again * add gpm * fix gpm patches * go back to automake popt * help me * make popt hopefully listen * make popt hopefully listen * FUCK NEWT * idk * add CMAKE_BUILD_TYPE work * fix checkra1n xxd issues * fix binary locations * fix binary locations again * fix binary locations again * try ftp again * try to fix ftp bugs * try to fix ftp bugs again * Update build.yml * try to fix ftp bugs again * try to find where final executable is * fix all the issues (hopefully) * fix all the issues (hopefully) again * fix all the issues (hopefully) again again * finalize build.yml * finalize build.yml v2 * finalize build.yml v2 * finalize build.yml v4 * finalize build.yml v5 * finalize build.yml v6 * finalize build.yml v7 * finalize build.yml v8 * finalize build.yml v9 * finalize build.yml v10 * finalize build.yml v10 * finalize build.yml v12 * finalize build.yml v13 fuck off amfi * finalize build.yml v14 fuck off amfi * finalize build.yml v15 fuck you macos build times * finalize build.yml v16 fuck you macos build times * finalize build.yml v17 fuck you macos build times * finalize build.yml v17 fuck you macos build times * finalize build.yml v19 fuck you macos build times * finalize build.yml v20 fuck you macos build times FUCK AMFI * finalize build.yml v21 fuck you macos build times FUCK AMFI fix so that it downloads build time not configure time * finalize build.yml v23 fuck you macos build times FUCK AMFI fix so that libs aren't broken * finalize build.yml v23 fuck you macos build times FUCK AMFI fix so that libs aren't broken * finalize build.yml v25 fuck you macos build times FUCK AMFI fix so that libs aren't broken * finalize build.yml v25 well pagure just fucked up everything * finalize build.yml v26 find pls work * finalize build.yml v26 now, remove submodules because of pagure * finalize build.yml v27 HELPPPPPPPPP * finalize build.yml v27 fix linux * finalize build.yml v27 fix linux again * finalize build.yml v27 fix linux again again * finalize build.yml v27 fix mac again * finalize build.yml v27 fix mac again again * finalize build.yml v30 fix mac again again again * finalize build.yml v32 fix mac again again again again * finalize build.yml v32 fix mac again again again again again * finalize build.yml v32 fix mac again again again again again again * finalize build.yml v32 fix mac again again again again again again again * add lto * fix some library issues * fix more issues * fix more issues * add lto to deps * try dynamic code finding with cmake and find_library. * fix more issues ( make static build ) * fix more issues ( make static build ) * fix more issues ( make static build ) * fix more issues ( make static build ) * fuck libusb * fuck cmake add_executable only once * fuck version change * fuck version change * fuck version change * fuck version change * fix more stuff * rename usbmuxd to libusbmuxd * fix linking issues * remove static on MacOS * add binary artifacts on MacOS * Revert "add binary artifacts on MacOS" This reverts commit 43799af8134609cbce7bdd231db6c4e16fe019ee. * remove -D lines * move to C99 * remove submodules * various changes 1. remove submodules 2. fix build.yml 3. add trailing spaces 4. add TSAN --------- Co-authored-by: Nick Chan <[email protected]> Co-authored-by: Tom E <[email protected]> Co-authored-by: Nebula <[email protected]>
226 lines
6.2 KiB
C
226 lines
6.2 KiB
C
#ifndef PALERAIN_H
|
|
#define PALERAIN_H
|
|
|
|
#if defined(__APPLE__)
|
|
#define _DARWIN_C_SOURCE 1
|
|
#endif
|
|
|
|
#include "xxd-embedded.h"
|
|
#include "kerninfo.h"
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdarg.h>
|
|
#include <usbmuxd.h>
|
|
#include <libirecovery.h>
|
|
#include <libimobiledevice/libimobiledevice.h>
|
|
|
|
#define LOG(loglevel, ...) p1_log(loglevel, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
#define CLEAR() printf("\33[2K\r");
|
|
#define palerain_option_version 129
|
|
#define CMD_LEN_MAX 512
|
|
#define OVERRIDE_MAGIC 0xd803b376
|
|
#ifdef USE_LIBUSB
|
|
#include <libusb-1.0/libusb.h>
|
|
|
|
#define USB_RET_SUCCESS LIBUSB_SUCCESS
|
|
#define USB_RET_NOT_RESPONDING LIBUSB_ERROR_OTHER
|
|
#define USB_RET_IO LIBUSB_ERROR_IO
|
|
typedef int usb_ret_t;
|
|
typedef libusb_device_handle *usb_device_handle_t;
|
|
|
|
typedef struct stuff
|
|
{
|
|
pthread_t th;
|
|
libusb_device *dev;
|
|
usb_device_handle_t handle;
|
|
} stuff_t;
|
|
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len);
|
|
#else
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wpedantic"
|
|
#include <IOKit/IOKitLib.h>
|
|
#include <IOKit/usb/IOUSBLib.h>
|
|
#include <IOKit/IOCFPlugIn.h>
|
|
#pragma clang diagnostic pop
|
|
|
|
#define USB_RET_SUCCESS KERN_SUCCESS
|
|
#define USB_RET_NOT_RESPONDING kIOReturnNotResponding
|
|
#define USB_RET_IO kIOReturnNotResponding
|
|
|
|
typedef IOReturn usb_ret_t;
|
|
typedef IOUSBInterfaceInterface245 **usb_device_handle_t;
|
|
|
|
typedef struct
|
|
{
|
|
pthread_t th;
|
|
volatile uint64_t regID;
|
|
IOUSBDeviceInterface245 **dev;
|
|
usb_device_handle_t handle;
|
|
} stuff_t;
|
|
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, uint32_t len);
|
|
#endif
|
|
|
|
#ifndef PALERAIN_VERSION
|
|
#define PALERAIN_VERSION "2.0.0"
|
|
#endif
|
|
|
|
#if defined(__APPLE__)
|
|
#include <mach-o/loader.h>
|
|
#include <mach-o/ldsyms.h>
|
|
#else
|
|
#define MH_MAGIC_64 0xfeedfacf
|
|
#define MH_CIGAM_64 0xcffaedfe
|
|
#define MH_KEXT_BUNDLE 0xb
|
|
|
|
typedef int cpu_type_t;
|
|
typedef int cpu_subtype_t;
|
|
|
|
#define CPU_ARCH_ABI64 0x01000000
|
|
#define CPU_TYPE_ARM ((cpu_type_t) 12)
|
|
#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
|
|
|
|
struct mach_header_64
|
|
{
|
|
uint32_t magic; /* mach magic number identifier */
|
|
cpu_type_t cputype; /* cpu specifier */
|
|
cpu_subtype_t cpusubtype; /* machine specifier */
|
|
uint32_t filetype; /* type of file */
|
|
uint32_t ncmds; /* number of load commands */
|
|
uint32_t sizeofcmds; /* the size of all the load commands */
|
|
uint32_t flags; /* flags */
|
|
uint32_t reserved; /* reserved */
|
|
};
|
|
#endif
|
|
|
|
// Keep in sync with Pongo
|
|
#define PONGO_USB_VENDOR 0x05ac
|
|
#define PONGO_USB_PRODUCT 0x4141
|
|
#define CMD_LEN_MAX 512
|
|
#define UPLOADSZ_MAX (1024 * 1024 * 128)
|
|
|
|
typedef enum {
|
|
LOG_FATAL = 0,
|
|
LOG_ERROR = 1,
|
|
LOG_WARNING = 2,
|
|
LOG_INFO = 3,
|
|
LOG_VERBOSE = 4,
|
|
LOG_VERBOSE2 = 5,
|
|
LOG_VERBOSE3 = 6,
|
|
LOG_VERBOSE4 = 7,
|
|
LOG_VERBOSE5 = 8,
|
|
} log_level_t;
|
|
|
|
typedef struct {
|
|
uint64_t ecid;
|
|
char* productType;
|
|
char* productVersion;
|
|
char* buildVersion;
|
|
char* CPUArchitecture;
|
|
const char* displayName;
|
|
} devinfo_t;
|
|
|
|
typedef struct {
|
|
int mode;
|
|
unsigned int cpid;
|
|
char product_type[0x20];
|
|
char display_name[0x20];
|
|
char iboot_ver[0x20];
|
|
} recvinfo_t;
|
|
|
|
typedef struct {
|
|
uint32_t magic; /* 0xd803b376*/
|
|
unsigned char* ptr; /* pointer to the override file in memory */
|
|
unsigned int len; /* length of override file */
|
|
unsigned char* orig_ptr; /* pointer to the overriden file */
|
|
unsigned int orig_len; /* length of the overriden file */
|
|
int fd; /* file descriptor of the override file */
|
|
} override_file_t;
|
|
|
|
typedef unsigned char niarelap_file_t[];
|
|
|
|
extern unsigned int verbose;
|
|
extern int demote;
|
|
|
|
extern char* pongo_path;
|
|
|
|
extern bool dfuhelper_only, pongo_exit;
|
|
#ifdef DEV_BUILD
|
|
extern bool use_tui, tui_started;
|
|
#endif
|
|
|
|
extern pthread_t dfuhelper_thread, pongo_thread;
|
|
extern int pongo_thr_running, dfuhelper_thr_running;
|
|
|
|
extern niarelap_file_t *kpf_to_upload_1, *ramdisk_to_upload_1, *overlay_to_upload_1;
|
|
extern niarelap_file_t **kpf_to_upload, **ramdisk_to_upload, **overlay_to_upload;
|
|
extern override_file_t override_ramdisk, override_kpf, override_overlay;
|
|
|
|
extern uint32_t checkrain_flags, palerain_flags, kpf_flags;
|
|
extern pthread_mutex_t log_mutex;
|
|
|
|
extern pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
|
|
|
|
extern int enable_rootful, demote;
|
|
extern int pongo_thr_running, dfuhelper_thr_running;
|
|
extern bool ohio, pongo_full, device_has_booted;
|
|
extern char xargs_cmd[0x270];
|
|
extern char checkrain_flags_cmd[0x20];
|
|
extern char palerain_flags_cmd[0x20];
|
|
extern char kpf_flags_cmd[0x20];
|
|
extern char dtpatch_cmd[0x20];
|
|
extern char rootfs_cmd[512];
|
|
extern char* ext_checkra1n;
|
|
|
|
extern bool palerain_version;
|
|
|
|
void thr_cleanup(void* ptr);
|
|
void* dfuhelper(void* ptr);
|
|
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char* __restrict format, ...);
|
|
/* devhelper helpers */
|
|
void devinfo_free(devinfo_t *dev);
|
|
bool cpid_is_arm64(unsigned int cpid);
|
|
/* devhelper commands */
|
|
int subscribe_cmd(usbmuxd_event_cb_t device_event_cb, irecv_device_event_cb_t irecv_event_cb);
|
|
int unsubscribe_cmd();
|
|
int devinfo_cmd(devinfo_t *dev, const char *udid);
|
|
int enter_recovery_cmd(const char* udid);
|
|
int reboot_cmd(const char* udid);
|
|
int passstat_cmd(unsigned char* status, const char* udid);
|
|
int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid);
|
|
int autoboot_cmd(const uint64_t ecid);
|
|
int exitrecv_cmd(const uint64_t ecid);
|
|
|
|
int exec_checkra1n();
|
|
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename);
|
|
void* pongo_helper(void* ptr);
|
|
|
|
|
|
extern void* pongo_usb_callback(void* arg);
|
|
usb_ret_t USBControlTransfer(usb_device_handle_t handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t wLength, void *data, uint32_t *wLenDone);
|
|
const char *usb_strerror(usb_ret_t err);
|
|
int wait_for_pongo();
|
|
int issue_pongo_command();
|
|
int upload_pongo_file();
|
|
int tui();
|
|
int optparse(int argc, char* argv[]);
|
|
|
|
bool get_spin();
|
|
bool set_spin(bool val);
|
|
bool get_found_pongo();
|
|
void* pongo_helper(void* _);
|
|
bool set_found_pongo(bool val);
|
|
uint64_t get_ecid_wait_for_dfu();
|
|
uint64_t set_ecid_wait_for_dfu(uint64_t ecid);
|
|
|
|
void write_stdout(char *buf, uint32_t len);
|
|
void io_start(stuff_t *stuff);
|
|
void io_stop(stuff_t *stuff);
|
|
|
|
#ifdef DEV_BUILD
|
|
#include <newt.h>
|
|
newtComponent get_tui_log();
|
|
newtComponent set_tui_log(newtComponent co);
|
|
#endif
|
|
#endif
|