summaryrefslogtreecommitdiffstats
path: root/src/recovery.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/recovery.c')
-rw-r--r--src/recovery.c66
1 files changed, 24 insertions, 42 deletions
diff --git a/src/recovery.c b/src/recovery.c
index 415a5d1..6048382 100644
--- a/src/recovery.c
+++ b/src/recovery.c
@@ -35,14 +35,16 @@
#include "restore.h"
#include "recovery.h"
-static int recovery_progress_callback(irecv_client_t client, const irecv_event_t* event) {
+static int recovery_progress_callback(irecv_client_t client, const irecv_event_t* event)
+{
if (event->type == IRECV_PROGRESS) {
//print_progress_bar(event->progress);
}
return 0;
}
-void recovery_client_free(struct idevicerestore_client_t* client) {
+void recovery_client_free(struct idevicerestore_client_t* client)
+{
if(client) {
if (client->recovery) {
if(client->recovery->client) {
@@ -55,7 +57,8 @@ void recovery_client_free(struct idevicerestore_client_t* client) {
}
}
-int recovery_client_new(struct idevicerestore_client_t* client) {
+int recovery_client_new(struct idevicerestore_client_t* client)
+{
int i = 0;
int attempts = 20;
irecv_client_t recovery = NULL;
@@ -98,37 +101,8 @@ int recovery_client_new(struct idevicerestore_client_t* client) {
return 0;
}
-int recovery_check_mode(struct idevicerestore_client_t* client) {
- irecv_client_t recovery = NULL;
- irecv_error_t recovery_error = IRECV_E_SUCCESS;
- int mode = 0;
-
- if (client->udid && client->ecid == 0) {
- /* if we have a UDID but no ECID we can't make sure this is the correct device */
- return -1;
- }
-
- irecv_init();
- recovery_error=irecv_open_with_ecid(&recovery, client->ecid);
-
- if (recovery_error != IRECV_E_SUCCESS) {
- return -1;
- }
-
- irecv_get_mode(recovery, &mode);
-
- if ((mode == IRECV_K_DFU_MODE) || (mode == IRECV_K_WTF_MODE)) {
- irecv_close(recovery);
- return -1;
- }
-
- irecv_close(recovery);
- recovery = NULL;
-
- return 0;
-}
-
-int recovery_set_autoboot(struct idevicerestore_client_t* client, int enable) {
+int recovery_set_autoboot(struct idevicerestore_client_t* client, int enable)
+{
irecv_error_t recovery_error = IRECV_E_SUCCESS;
recovery_error = irecv_send_command(client->recovery->client, (enable) ? "setenv auto-boot true" : "setenv auto-boot false");
@@ -146,7 +120,8 @@ int recovery_set_autoboot(struct idevicerestore_client_t* client, int enable) {
return 0;
}
-int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build_identity) {
+int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build_identity)
+{
if (client->build_major >= 8) {
client->restore_boot_args = strdup("rd=md0 nand-enable-reformat=1 -progress");
} else if (client->build_major >= 20) {
@@ -353,7 +328,8 @@ int recovery_send_component_and_command(struct idevicerestore_client_t* client,
return 0;
}
-int recovery_send_ibec(struct idevicerestore_client_t* client, plist_t build_identity) {
+int recovery_send_ibec(struct idevicerestore_client_t* client, plist_t build_identity)
+{
const char* component = "iBEC";
irecv_error_t recovery_error = IRECV_E_SUCCESS;
@@ -378,7 +354,8 @@ int recovery_send_ibec(struct idevicerestore_client_t* client, plist_t build_ide
return 0;
}
-int recovery_send_applelogo(struct idevicerestore_client_t* client, plist_t build_identity) {
+int recovery_send_applelogo(struct idevicerestore_client_t* client, plist_t build_identity)
+{
const char* component = "RestoreLogo";
irecv_error_t recovery_error = IRECV_E_SUCCESS;
@@ -461,7 +438,8 @@ int recovery_send_loaded_by_iboot(struct idevicerestore_client_t* client, plist_
return (err) ? -1 : 0;
}
-int recovery_send_ramdisk(struct idevicerestore_client_t* client, plist_t build_identity) {
+int recovery_send_ramdisk(struct idevicerestore_client_t* client, plist_t build_identity)
+{
const char *component = "RestoreRamDisk";
irecv_error_t recovery_error = IRECV_E_SUCCESS;
@@ -495,7 +473,8 @@ int recovery_send_ramdisk(struct idevicerestore_client_t* client, plist_t build_
return 0;
}
-int recovery_send_kernelcache(struct idevicerestore_client_t* client, plist_t build_identity) {
+int recovery_send_kernelcache(struct idevicerestore_client_t* client, plist_t build_identity)
+{
const char* component = "RestoreKernelCache";
irecv_error_t recovery_error = IRECV_E_SUCCESS;
@@ -528,7 +507,8 @@ int recovery_send_kernelcache(struct idevicerestore_client_t* client, plist_t bu
return 0;
}
-int recovery_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) {
+int recovery_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid)
+{
if(client->recovery == NULL) {
if (recovery_client_new(client) < 0) {
return -1;
@@ -561,7 +541,8 @@ int recovery_is_image4_supported(struct idevicerestore_client_t* client)
return (device_info->ibfl & IBOOT_FLAG_IMAGE4_AWARE);
}
-int recovery_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size) {
+int recovery_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size)
+{
if(client->recovery == NULL) {
if (recovery_client_new(client) < 0) {
return -1;
@@ -585,7 +566,8 @@ int recovery_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char*
return 0;
}
-int recovery_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size) {
+int recovery_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size)
+{
if(client->recovery == NULL) {
if (recovery_client_new(client) < 0) {
return -1;