mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-21 09:47:01 +02:00
refactor(build): de-dup definitions & manifest changes
This commit is contained in:
1 parent
7f57325f7d
commit
443bacdc8d
9 files changed
+61
-51
No files matched your search
+8
-8
@@ -102,7 +102,7 @@ if(APPLE AND WITH_GUI)
|
|||||||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist
|
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist
|
||||||
MACOSX_BUNDLE_ICON_FILE palera1n.icns
|
MACOSX_BUNDLE_ICON_FILE palera1n.icns
|
||||||
)
|
)
|
||||||
elseif(MINGW OR MSYS AND WITH_GUI)
|
elseif(MINGW AND WITH_GUI)
|
||||||
set(APP_MANIFEST_RC ${CMAKE_SOURCE_DIR}/resources/app.rc)
|
set(APP_MANIFEST_RC ${CMAKE_SOURCE_DIR}/resources/app.rc)
|
||||||
add_executable(palera1n WIN32 ${SOURCES} ${APP_MANIFEST_RC})
|
add_executable(palera1n WIN32 ${SOURCES} ${APP_MANIFEST_RC})
|
||||||
else()
|
else()
|
||||||
@@ -164,7 +164,7 @@ if(WITH_STATIC)
|
|||||||
mbedtls_LIBS=-lmbedtls\ -lmbedx509\ -lmbedcrypto
|
mbedtls_LIBS=-lmbedtls\ -lmbedx509\ -lmbedcrypto
|
||||||
)
|
)
|
||||||
|
|
||||||
if(MINGW OR MSYS)
|
if(MINGW)
|
||||||
set(IMD_AUTOTOOLS_ARGS
|
set(IMD_AUTOTOOLS_ARGS
|
||||||
--disable-static
|
--disable-static
|
||||||
--enable-shared
|
--enable-shared
|
||||||
@@ -179,7 +179,7 @@ if(WITH_STATIC)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MINGW AND NOT MSYS)
|
if(NOT MINGW)
|
||||||
# =========================
|
# =========================
|
||||||
# mbedTLS
|
# mbedTLS
|
||||||
# =========================
|
# =========================
|
||||||
@@ -200,7 +200,7 @@ if(WITH_STATIC)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LINUX OR MINGW OR MSYS)
|
if(LINUX OR MINGW)
|
||||||
# =========================
|
# =========================
|
||||||
# libusb
|
# libusb
|
||||||
# =========================
|
# =========================
|
||||||
@@ -318,11 +318,11 @@ if(WITH_STATIC)
|
|||||||
limd_glue_ep
|
limd_glue_ep
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT MINGW AND NOT MSYS)
|
if(NOT MINGW)
|
||||||
list(APPEND LIBIMOBILEDEVICE_DEPS mbedtls_ep)
|
list(APPEND LIBIMOBILEDEVICE_DEPS mbedtls_ep)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LINUX OR MINGW OR MSYS)
|
if(LINUX OR MINGW)
|
||||||
list(APPEND LIBIMOBILEDEVICE_DEPS libusb_ep)
|
list(APPEND LIBIMOBILEDEVICE_DEPS libusb_ep)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ if(WITH_STATIC)
|
|||||||
libirecovery_ep
|
libirecovery_ep
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT MINGW AND NOT MSYS)
|
if(NOT MINGW)
|
||||||
add_dependencies(palera1n mbedtls_ep)
|
add_dependencies(palera1n mbedtls_ep)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -428,7 +428,7 @@ if(WITH_STATIC)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MINGW OR MSYS)
|
if(MINGW)
|
||||||
target_link_libraries(palera1n PRIVATE
|
target_link_libraries(palera1n PRIVATE
|
||||||
imobiledevice-1.0
|
imobiledevice-1.0
|
||||||
irecovery-1.0
|
irecovery-1.0
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
<assemblyIdentity
|
<assemblyIdentity
|
||||||
version="1.0.0.0"
|
version="1.0.0.0"
|
||||||
processorArchitecture="*"
|
processorArchitecture="*"
|
||||||
name="app"
|
name="app"
|
||||||
type="win32"
|
type="win32"
|
||||||
/>
|
/>
|
||||||
<dependency>
|
<dependency>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity
|
<assemblyIdentity
|
||||||
type="win32"
|
type="win32"
|
||||||
name="Microsoft.Windows.Common-Controls"
|
name="Microsoft.Windows.Common-Controls"
|
||||||
@@ -16,6 +16,16 @@
|
|||||||
publicKeyToken="6595b64144ccf1df"
|
publicKeyToken="6595b64144ccf1df"
|
||||||
language="*"
|
language="*"
|
||||||
/>
|
/>
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges>
|
||||||
|
<requestedExecutionLevel
|
||||||
|
level="requireAdministrator"
|
||||||
|
uiAccess="false"
|
||||||
|
/>
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
</assembly>
|
</assembly>
|
||||||
+2
-2
@@ -157,7 +157,7 @@ void recovery_device_event_cb(
|
|||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
VERBOSE("Opened client after %d attempts", attempts);
|
LOG_VERBOSE("Opened client after %d attempts", attempts);
|
||||||
|
|
||||||
irecv_device_t device = nullptr;
|
irecv_device_t device = nullptr;
|
||||||
if (irecv_devices_get_device_by_client(client, &device) == IRECV_E_SUCCESS && device)
|
if (irecv_devices_get_device_by_client(client, &device) == IRECV_E_SUCCESS && device)
|
||||||
@@ -170,7 +170,7 @@ void recovery_device_event_cb(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR("Failed to open irecv client after retries");
|
LOG_ERROR("Failed to open irecv client after retries");
|
||||||
}
|
}
|
||||||
|
|
||||||
state.isSupported = SequenceIsSupported(state.productType);
|
state.isSupported = SequenceIsSupported(state.productType);
|
||||||
|
|||||||
+6
-6
@@ -165,28 +165,28 @@ bool checkm8_stage_patch(const usb_handle_t *handle, struct DeviceConfiguration
|
|||||||
create_pongo_payload_for_device(deviceConfig->cpid, &payload, &data_sz);
|
create_pongo_payload_for_device(deviceConfig->cpid, &payload, &data_sz);
|
||||||
|
|
||||||
if (payload == NULL || data_sz == 0) {
|
if (payload == NULL || data_sz == 0) {
|
||||||
ERROR("unsupported cpid 0x%X", (unsigned)deviceConfig->cpid);
|
LOG_ERROR("unsupported cpid 0x%X", (unsigned)deviceConfig->cpid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERBOSE("setting up stage 2 for CPID 0x%X", (unsigned)deviceConfig->cpid);
|
LOG_VERBOSE("setting up stage 2 for CPID 0x%X", (unsigned)deviceConfig->cpid);
|
||||||
|
|
||||||
data = calloc(1, data_sz);
|
data = calloc(1, data_sz);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
ERROR("failed to allocate payload buffer");
|
LOG_ERROR("failed to allocate payload buffer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(data, payload, data_sz);
|
memcpy(data, payload, data_sz);
|
||||||
|
|
||||||
if(checkm8_usb_request_stall(handle) && checkm8_usb_request_leak(handle)) {
|
if(checkm8_usb_request_stall(handle) && checkm8_usb_request_leak(handle)) {
|
||||||
VERBOSE("successfully leaked data");
|
LOG_VERBOSE("successfully leaked data");
|
||||||
} else {
|
} else {
|
||||||
ERROR("failed to leak data");
|
LOG_ERROR("failed to leak data");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(i = 0; i < 2; i++) {
|
for(i = 0; i < 2; i++) {
|
||||||
VERBOSE("i = %zu", i);
|
LOG_VERBOSE("i = %zu", i);
|
||||||
send_usb_control_request_no_data(handle, 2, 3, 0, 0x80, 0, NULL);
|
send_usb_control_request_no_data(handle, 2, 3, 0, 0x80, 0, NULL);
|
||||||
}
|
}
|
||||||
if(p != NULL && send_usb_control_request(handle, 0x00, 0, 0, 0x00, p, 0x30, &transfer_ret) && transfer_ret.ret == USB_TRANSFER_STALL) {
|
if(p != NULL && send_usb_control_request(handle, 0x00, 0, 0, 0x00, p, 0x30, &transfer_ret) && transfer_ret.ret == USB_TRANSFER_STALL) {
|
||||||
|
|||||||
+3
-3
@@ -56,7 +56,7 @@ bool checkm8_find_device_configuration_for_cpid(
|
|||||||
config->config_hole = 0;
|
config->config_hole = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR("CPID 0x%x is not supported!", cpid);
|
LOG_ERROR("CPID 0x%x is not supported!", cpid);
|
||||||
foundMatchingConfiguration = false;
|
foundMatchingConfiguration = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ bool checkm8_find_payload_configuration_for_cpid(
|
|||||||
config->usb_serial_number_string_descriptor = 0x18008062A;
|
config->usb_serial_number_string_descriptor = 0x18008062A;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR("CPID 0x%x is not supported!", cpid);
|
LOG_ERROR("CPID 0x%x is not supported!", cpid);
|
||||||
foundMatchingConfiguration = false;
|
foundMatchingConfiguration = false;
|
||||||
}
|
}
|
||||||
return foundMatchingConfiguration;
|
return foundMatchingConfiguration;
|
||||||
@@ -237,7 +237,7 @@ void create_pongo_payload_for_device(
|
|||||||
uint8_t **payload,
|
uint8_t **payload,
|
||||||
size_t *payloadSize)
|
size_t *payloadSize)
|
||||||
{
|
{
|
||||||
VERBOSE("Preparing YoloDFU payload for CPID 0x%x.", cpid);
|
LOG_VERBOSE("Preparing YoloDFU payload for CPID 0x%x.", cpid);
|
||||||
|
|
||||||
*payload = NULL;
|
*payload = NULL;
|
||||||
*payloadSize = 0;
|
*payloadSize = 0;
|
||||||
|
|||||||
+1
-1
@@ -140,7 +140,7 @@ static void *pongo_thread(void *arg)
|
|||||||
if (!seen) {
|
if (!seen) {
|
||||||
seen = true;
|
seen = true;
|
||||||
|
|
||||||
SUCCESS("Pongo device detected!");
|
LOG_SUCCESS("Pongo device detected!");
|
||||||
|
|
||||||
char paleinfo[64];
|
char paleinfo[64];
|
||||||
snprintf(paleinfo, sizeof(paleinfo), "palera1n_flags 0x%" PRIx64, palerain_flags);
|
snprintf(paleinfo, sizeof(paleinfo), "palera1n_flags 0x%" PRIx64, palerain_flags);
|
||||||
|
|||||||
+2
-2
@@ -139,7 +139,7 @@ void parse_arguments(int argc, char* argv[]) {
|
|||||||
palerain_flags |= palerain_option_verbose_boot;
|
palerain_flags |= palerain_option_verbose_boot;
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
ERROR("Unknown option");
|
LOG_ERROR("Unknown option");
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
default: break;
|
default: break;
|
||||||
@@ -148,7 +148,7 @@ void parse_arguments(int argc, char* argv[]) {
|
|||||||
|
|
||||||
if (!(palerain_flags & palerain_option_gui)) {
|
if (!(palerain_flags & palerain_option_gui)) {
|
||||||
if (!(palerain_flags & palerain_option_rootful) && !(palerain_flags & palerain_option_rootless)) {
|
if (!(palerain_flags & palerain_option_rootful) && !(palerain_flags & palerain_option_rootless)) {
|
||||||
ERROR("You must specify either -l, --rootless or -f, --rootful.\n");
|
LOG_ERROR("You must specify either -l, --rootless or -f, --rootful.\n");
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-15
@@ -21,15 +21,15 @@ void compress_pongo(void *out, size_t *out_len) {
|
|||||||
|
|
||||||
void checkm8_boot_pongo(usb_handle_t *handle) {
|
void checkm8_boot_pongo(usb_handle_t *handle) {
|
||||||
transfer_ret_t transfer_ret;
|
transfer_ret_t transfer_ret;
|
||||||
VERBOSE("Booting pongoOS");
|
LOG_VERBOSE("Booting pongoOS");
|
||||||
VERBOSE("Compressing pongoOS");
|
LOG_VERBOSE("Compressing pongoOS");
|
||||||
VERBOSE("Appending shellcode to the top of pongoOS (512 bytes)");
|
LOG_VERBOSE("Appending shellcode to the top of pongoOS (512 bytes)");
|
||||||
void *shellcode = malloc(512);
|
void *shellcode = malloc(512);
|
||||||
memcpy(shellcode, payloads_lz4dec_bin, payloads_lz4dec_bin_len);
|
memcpy(shellcode, payloads_lz4dec_bin, payloads_lz4dec_bin_len);
|
||||||
size_t out_len = payloads_Pongo_bin_len;
|
size_t out_len = payloads_Pongo_bin_len;
|
||||||
void *out = malloc(out_len);
|
void *out = malloc(out_len);
|
||||||
compress_pongo(out, &out_len);
|
compress_pongo(out, &out_len);
|
||||||
VERBOSE("Compressed pongoOS from %u to %zu bytes", payloads_Pongo_bin_len, out_len);
|
LOG_VERBOSE("Compressed pongoOS from %u to %zu bytes", payloads_Pongo_bin_len, out_len);
|
||||||
void *tmp = malloc(out_len + 512);
|
void *tmp = malloc(out_len + 512);
|
||||||
memcpy(tmp, shellcode, 512);
|
memcpy(tmp, shellcode, 512);
|
||||||
memcpy(tmp + 512, out, out_len);
|
memcpy(tmp + 512, out, out_len);
|
||||||
@@ -37,12 +37,12 @@ void checkm8_boot_pongo(usb_handle_t *handle) {
|
|||||||
out = tmp;
|
out = tmp;
|
||||||
out_len += 512;
|
out_len += 512;
|
||||||
free(shellcode);
|
free(shellcode);
|
||||||
VERBOSE("Setting the compressed size into the shellcode");
|
LOG_VERBOSE("Setting the compressed size into the shellcode");
|
||||||
uint32_t* size = (uint32_t*)(out + 0x1fc);
|
uint32_t* size = (uint32_t*)(out + 0x1fc);
|
||||||
*size = out_len - 512;
|
*size = out_len - 512;
|
||||||
VERBOSE("Reconnecting to device");
|
LOG_VERBOSE("Reconnecting to device");
|
||||||
init_usb_handle(handle, 0x5AC, 0x1227);
|
init_usb_handle(handle, 0x5AC, 0x1227);
|
||||||
VERBOSE("Waiting for device to be ready");
|
LOG_VERBOSE("Waiting for device to be ready");
|
||||||
wait_usb_handle(handle);
|
wait_usb_handle(handle);
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
@@ -54,16 +54,16 @@ void checkm8_boot_pongo(usb_handle_t *handle) {
|
|||||||
send_usb_control_request(handle, 0x21, DFU_DNLOAD, 0, 0, (unsigned char*)&out[len], size, &transfer_ret);
|
send_usb_control_request(handle, 0x21, DFU_DNLOAD, 0, 0, (unsigned char*)&out[len], size, &transfer_ret);
|
||||||
if(transfer_ret.sz != size || transfer_ret.ret != USB_TRANSFER_OK)
|
if(transfer_ret.sz != size || transfer_ret.ret != USB_TRANSFER_OK)
|
||||||
{
|
{
|
||||||
VERBOSE("retrying at len = %zu", len);
|
LOG_VERBOSE("retrying at len = %zu", len);
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
len += size;
|
len += size;
|
||||||
VERBOSE("len = %zu", len);
|
LOG_VERBOSE("len = %zu", len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
send_usb_control_request_no_data(handle, 0x21, 4, 0, 0, 0, NULL);
|
send_usb_control_request_no_data(handle, 0x21, 4, 0, 0, 0, NULL);
|
||||||
VERBOSE("pongoOS sent, should be booting");
|
LOG_VERBOSE("pongoOS sent, should be booting");
|
||||||
}
|
}
|
||||||
|
|
||||||
int issue_pongo_command(const usb_handle_t *handle, const char *command) {
|
int issue_pongo_command(const usb_handle_t *handle, const char *command) {
|
||||||
@@ -81,11 +81,11 @@ int issue_pongo_command(const usb_handle_t *handle, const char *command) {
|
|||||||
size_t len = strlen(command);
|
size_t len = strlen(command);
|
||||||
|
|
||||||
if (len > 510) {
|
if (len > 510) {
|
||||||
ERROR("Pongo command too long: %s", command);
|
LOG_ERROR("Pongo command too long: %s", command);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERBOSE("Executing PongoOS command: '%s'", command);
|
LOG_VERBOSE("Executing PongoOS command: '%s'", command);
|
||||||
|
|
||||||
snprintf(command_buf, sizeof(command_buf), "%s\n", command);
|
snprintf(command_buf, sizeof(command_buf), "%s\n", command);
|
||||||
len = strlen(command_buf);
|
len = strlen(command_buf);
|
||||||
@@ -115,7 +115,7 @@ int issue_pongo_command(const usb_handle_t *handle, const char *command) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR("Pongo USB error: %d", tx_status.ret);
|
LOG_ERROR("Pongo USB error: %d", tx_status.ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,11 +124,11 @@ int issue_pongo_command(const usb_handle_t *handle, const char *command) {
|
|||||||
|
|
||||||
bool upload_buffer_to_pongo(usb_handle_t *handle, const void *data, size_t length) {
|
bool upload_buffer_to_pongo(usb_handle_t *handle, const void *data, size_t length) {
|
||||||
if (data == NULL || length == 0) {
|
if (data == NULL || length == 0) {
|
||||||
ERROR("Invalid data buffer or length.");
|
LOG_ERROR("Invalid data buffer or length.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERBOSE("Uploading %zu bytes to PongoOS...", length);
|
LOG_VERBOSE("Uploading %zu bytes to PongoOS...", length);
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
transfer_ret_t tx_status = {0};
|
transfer_ret_t tx_status = {0};
|
||||||
|
|||||||
+4
-4
@@ -26,10 +26,10 @@ typedef enum {
|
|||||||
} log_level_t;
|
} log_level_t;
|
||||||
|
|
||||||
#define LOG(fmt, ...) log_write(LOG_INFO, fmt, ##__VA_ARGS__)
|
#define LOG(fmt, ...) log_write(LOG_INFO, fmt, ##__VA_ARGS__)
|
||||||
#define SUCCESS(fmt, ...) log_write(LOG_SUCCESS, fmt, ##__VA_ARGS__)
|
#define LOG_SUCCESS(fmt, ...) log_write(LOG_SUCCESS, fmt, ##__VA_ARGS__)
|
||||||
#define WARN(fmt, ...) log_write(LOG_WARN, fmt, ##__VA_ARGS__)
|
#define LOG_WARN(fmt, ...) log_write(LOG_WARN, fmt, ##__VA_ARGS__)
|
||||||
#define ERROR(fmt, ...) log_write(LOG_ERROR, fmt, ##__VA_ARGS__)
|
#define LOG_ERROR(fmt, ...) log_write(LOG_ERROR, fmt, ##__VA_ARGS__)
|
||||||
#define VERBOSE(fmt, ...) log_write(LOG_VERBOSE, fmt, ##__VA_ARGS__)
|
#define LOG_VERBOSE(fmt, ...) log_write(LOG_VERBOSE, fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
Reference in new issue
Block a user