summaryrefslogtreecommitdiffstats
path: root/src/normal.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-05 04:02:05 +0800
committerGravatar rcg4u2010-06-09 17:17:28 +0800
commitce999c67996515b278f49ea88f4e306dc0308ff3 (patch)
tree418ddb485d8ad259b207cdb4cdc79b66dc328349 /src/normal.c
parentf37ceaa046ac9114789a9334cfff04fba3805601 (diff)
downloadidevicerestore-ce999c67996515b278f49ea88f4e306dc0308ff3.tar.gz
idevicerestore-ce999c67996515b278f49ea88f4e306dc0308ff3.tar.bz2
Refactoring continued, lots of bug fixes, probably about half way through
Diffstat (limited to 'src/normal.c')
-rw-r--r--src/normal.c30
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;
}