示例#1
0
int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build_identity) {
	idevice_t device = NULL;
	restored_client_t restore = NULL;

	if (client->buildno >= 8) {
		client->restore_boot_args = strdup("rd=md0 nand-enable-reformat=1 -progress");
	}

	/* upload data to make device boot restore mode */

	if(client->recovery == NULL) {
		if (recovery_client_new(client) < 0) {
			return -1;
		}
	}

	if ((client->buildno > 8) && !(client->flags & FLAG_CUSTOM)) {
		/* send ApTicket */
		if (recovery_send_ticket(client) < 0) {
			error("ERROR: Unable to send APTicket\n");
			return -1;
		}
	}

	if (recovery_set_autoboot(client, 0) < 0) {
		return -1;
	}

	irecv_send_command(client->recovery->client, "getenv build-version");
	irecv_send_command(client->recovery->client, "getenv build-style");
	irecv_send_command(client->recovery->client, "getenv radio-error");

	/* send logo and show it */
	if (recovery_send_applelogo(client, build_identity) < 0) {
		error("ERROR: Unable to send AppleLogo\n");
		return -1;
	}

	/* send ramdisk and run it */
	if (recovery_send_ramdisk(client, build_identity) < 0) {
		error("ERROR: Unable to send Ramdisk\n");
		return -1;
	}

	/* send devicetree and load it */
	if (recovery_send_devicetree(client, build_identity) < 0) {
		error("ERROR: Unable to send DeviceTree\n");
		return -1;
	}

	if (recovery_send_kernelcache(client, build_identity) < 0) {
		error("ERROR: Unable to send KernelCache\n");
		return -1;
	}

	client->mode = &idevicerestore_modes[MODE_RESTORE];
	return 0;
}
示例#2
0
int recovery_enter_restore(const char* uuid, const char* ipsw, plist_t tss) {
	idevice_t device = NULL;
	restored_client_t restore = NULL;

	// upload data to make device boot restore mode
	if (recovery_send_ibec(ipsw, tss) < 0) {
		error("ERROR: Unable to send iBEC\n");
		return -1;
	}
	sleep(1);

	if (recovery_send_applelogo(ipsw, tss) < 0) {
		error("ERROR: Unable to send AppleLogo\n");
		return -1;
	}

	if (recovery_send_devicetree(ipsw, tss) < 0) {
		error("ERROR: Unable to send DeviceTree\n");
		return -1;
	}

	if (recovery_send_ramdisk(ipsw, tss) < 0) {
		error("ERROR: Unable to send Ramdisk\n");
		return -1;
	}

	// for some reason iboot requires a hard reset after ramdisk
	//  or things start getting wacky
	printf("Please unplug your device, then plug it back in\n");
	printf("Hit any key to continue...");
	getchar();

	if (recovery_send_kernelcache(ipsw, tss) < 0) {
		error("ERROR: Unable to send KernelCache\n");
		return -1;
	}

	info("Waiting for device to enter restore mode\n");
	if (restore_open_with_timeout(uuid, &device, &restore) < 0) {
		error("ERROR: Unable to connect to device in restore mode\n");
		return -1;
	}

	restore_close(device, restore);
	idevicerestore_mode = MODE_RESTORE;
	return 0;
}
示例#3
0
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");
	}

	/* upload data to make device boot restore mode */

	if(client->recovery == NULL) {
		if (recovery_client_new(client) < 0) {
			return -1;
		}
	}

	if ((client->build_major > 8) && !(client->flags & FLAG_CUSTOM)) {
		if (!client->image4supported) {
			/* send ApTicket */
			if (recovery_send_ticket(client) < 0) {
				error("ERROR: Unable to send APTicket\n");
				return -1;
			}
		}
	}

    //no need to set auto-boot false when we want to just boot the device
	if ((client->flags & FLAG_BOOT) == 0) if (recovery_set_autoboot(client, 0) < 0) return -1;

	info("Recovery Mode Environment:\n");
	char* value = NULL;
	irecv_getenv(client->recovery->client, "build-version", &value);
	info("iBoot build-version=%s\n", (value) ? value : "(unknown)");
	if (value) {
		free(value);
		value = NULL;
	}

	irecv_getenv(client->recovery->client, "build-style", &value);
	info("iBoot build-style=%s\n", (value) ? value : "(unknown)");
	if (value) {
		free(value);
		value = NULL;
	}

	unsigned long radio_error = 0;
	irecv_getenv(client->recovery->client, "radio-error", &value);
	if (value) {
		radio_error = strtoul(value, NULL, 0);
	}
	if (radio_error > 0) {
		info("radio-error=%s\n", value);
		free(value);
		value = NULL;
		irecv_getenv(client->recovery->client, "radio-error-string", &value);
		if (value) {
			info("radio-error-string=%s\n", value);
			free(value);
			value = NULL;
		}
	}

	/* send logo and show it */
	if (recovery_send_applelogo(client, build_identity) < 0) {
		error("ERROR: Unable to send AppleLogo\n");
		return -1;
	}
    if ((client->flags & FLAG_BOOT) == 0) {
        /* send ramdisk and run it */
        if (recovery_send_ramdisk(client, build_identity) < 0) {
            error("ERROR: Unable to send Ramdisk\n");
            return -1;
        }
    }
    
	/* send devicetree and load it */
	if (recovery_send_devicetree(client, build_identity) < 0) {
		error("ERROR: Unable to send DeviceTree\n");
		return -1;
	}
    
	if (recovery_send_kernelcache(client, build_identity) < 0) {
		error("ERROR: Unable to send KernelCache\n");
		return -1;
	}

	if ((client->flags & FLAG_BOOT) == 0 && (client->flags & FLAG_NOBOOTX) == 0) client->mode = &idevicerestore_modes[MODE_RESTORE];
	return 0;
}