int dfu_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); ret = AMRestorePerformDFURestore( sh->dfu_dev, opts, (void*)dfu_progress_callback, NULL ); CFRelease(value); ifVerbose cout << "AMRestorePerformDFURestore: " << ret << endl; return SHELL_CONTINUE; }
void dfuConnect(AMRecoveryModeDevice device, void* ctx) { PITMD_CONTEXT c = (PITMD_CONTEXT)ctx; if (s_device == NULL) { s_device = device; } invokeCallback(c, EventDfuEnter, device); if (c->restoreOptions && c->dfuAttempts > 0) { --c->dfuAttempts; AMRestorePerformDFURestore(device, c->restoreOptions, restoreProgressCallback, ctx); } }
MUX_API void itmd_restoreBundle(const char* bundlePath) { #ifdef WIN32 AMRestoreEnableFileLogging("c:\\temp\\md.log"); ///FIXME: hardcoded path #else AMRestoreEnableFileLogging("/tmp/md.log"); #endif s_restoreContext->dfuAttempts = 5; s_restoreContext->recoveryAttempts = 1; s_restoreContext->restoreOptions = RestoreOptionsDictWithBundlePath(bundlePath); if (s_device != NULL) { --s_restoreContext->dfuAttempts; AMRestorePerformDFURestore(s_device, s_restoreContext->restoreOptions, restoreProgressCallback, s_restoreContext); } }
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); }