diff options
author | Joshua Hill | 2010-06-04 16:02:05 -0400 |
---|---|---|
committer | Joshua Hill | 2010-06-04 16:02:05 -0400 |
commit | 26e7635460c7369be07455a7bcc7621cf53cdd2d (patch) | |
tree | 418ddb485d8ad259b207cdb4cdc79b66dc328349 /src/normal.c | |
parent | 95d83e38a95c9cf28ffa59611149fbba242449c4 (diff) | |
download | idevicerestore-26e7635460c7369be07455a7bcc7621cf53cdd2d.tar.gz idevicerestore-26e7635460c7369be07455a7bcc7621cf53cdd2d.tar.bz2 |
Refactoring continued, lots of bug fixes, probably about half way through
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/normal.c b/src/normal.c index 0420a82..3c2bf5c 100644 --- a/src/normal.c +++ b/src/normal.c @@ -21,10 +21,12 @@ #include <stdio.h> #include <stdint.h> +#include <libirecovery.h> #include <libimobiledevice/lockdown.h> #include <libimobiledevice/libimobiledevice.h> #include "normal.h" +#include "recovery.h" #include "idevicerestore.h" int normal_check_mode(const char* uuid) { @@ -112,9 +114,11 @@ int normal_get_device(const char* uuid) { int normal_enter_recovery(const char* uuid) { idevice_t device = NULL; + irecv_client_t recovery = NULL; lockdownd_client_t lockdown = NULL; + irecv_error_t recovery_error = IRECV_E_SUCCESS; idevice_error_t device_error = IDEVICE_E_SUCCESS; - lockdownd_error_t lockdown_error = IDEVICE_E_SUCCESS; + lockdownd_error_t lockdown_error = LOCKDOWN_E_SUCCESS; device_error = idevice_new(&device, uuid); if (device_error != IDEVICE_E_SUCCESS) { @@ -141,6 +145,29 @@ int normal_enter_recovery(const char* uuid) { idevice_free(device); lockdown = NULL; device = NULL; + + if(recovery_open_with_timeout(&recovery) < 0) { + error("ERROR: Unable to enter recovery mode\n"); + return -1; + } + + recovery_error = irecv_send_command(recovery, "setenv auto-boot true"); + if (recovery_error != IRECV_E_SUCCESS) { + error("ERROR: Unable to reset auto-boot variable\n"); + irecv_close(recovery); + return -1; + } + + recovery_error = irecv_send_command(recovery, "saveenv"); + if (recovery_error != IRECV_E_SUCCESS) { + error("ERROR: Unable to save auto-boot variable\n"); + irecv_close(recovery); + return -1; + } + + idevicerestore_mode = RECOVERY_MODE; + irecv_close(recovery); + recovery = NULL; return 0; } @@ -192,4 +219,5 @@ int normal_get_ecid(const char* uuid, uint64_t* ecid) { idevice_free(device); lockdown = NULL; device = NULL; + return 0; } |