int recovery_restore(string *args, struct shell_state *sh) { mach_error_t ret; if (args[1] == "") { ifNotQuiet cout << "args[1] must be RestoreBundlePath" << endl; return SHELL_CONTINUE; } D("Building CFMutableDictionary"); CFMutableDictionaryRef opts; D("Getting AMRestoreCreateDefaultOptions"); opts = AMRestoreCreateDefaultOptions(kCFAllocatorDefault); CFStringRef value = CFStringCreateWithCString(kCFAllocatorDefault, args[1].c_str(), kCFStringEncodingMacRoman); CFDictionarySetValue(opts, CFSTR("RestoreBundlePath"), value ); // describe255(opts); g_recoveryDevice = sh->recovery_dev; ret = AMRestorePerformRecoveryModeRestore( sh->recovery_dev, opts, (void *)recovery_progress_callback, NULL ); CFRelease(value); ifVerbose cout << "AMRestorePerformRecoveryModeRestore: " << ret << endl; return SHELL_CONTINUE; }
void DoDFU(am_recovery_device *rdev, const char* restoreBundle) { CFMutableDictionaryRef opts; opts = AMRestoreCreateDefaultOptions(NULL); CFStringRef value = CFStringCreateWithCString(NULL, restoreBundle, kCFStringEncodingASCII); CFDictionarySetValue(opts, CFSTR("RestoreBundlePath"), value); int ret = AMRestorePerformDFURestore( rdev, opts, (void*)dfu_progress_callback, NULL ); if(ret != 0) { fprintf(stdout, "I'm sorry, but something seems to have gone wrong during the download. Please try connecting your iPhone/iPod to another USB port (NOT through a hub) and trying again.\n"); fflush(stdout); cleanup_and_exit(); } XLOG(3, "AMRestorePerformDFURestore: %d", ret); CFRelease(value); }