int copyAcrossVolumes(Volume* volume1, Volume* volume2, char* path1, char* path2) { void* buffer; size_t bufferSize; AbstractFile* tmpFile; int ret; buffer = malloc(1); bufferSize = 0; tmpFile = createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize); if(!silence) { printf("retrieving... "); fflush(stdout); } get_hfs(volume1, path1, tmpFile); tmpFile->seek(tmpFile, 0); if(!silence) { printf("writing (%ld)... ", (long) tmpFile->getLength(tmpFile)); fflush(stdout); } ret = add_hfs(volume2, tmpFile, path2); if(!silence) { printf("done\n"); } free(buffer); return ret; }
void fixupBootNeuterArgs(Volume* volume, char unlockBaseband, char selfDestruct, char use39, char use46) { const char bootNeuterPlist[] = "/System/Library/LaunchDaemons/com.devteam.bootneuter.auto.plist"; AbstractFile* plistFile; char* plist; Dictionary* info; size_t bufferSize; ArrayValue* arguments; XLOG(0, "fixing up BootNeuter arguments...\n"); plist = malloc(1); bufferSize = 0; plistFile = createAbstractFileFromMemoryFile((void**)&plist, &bufferSize); get_hfs(volume, bootNeuterPlist, plistFile); plistFile->close(plistFile); info = createRoot(plist); free(plist); arguments = (ArrayValue*) getValueByKey(info, "ProgramArguments"); addStringToArray(arguments, "-autoMode"); addStringToArray(arguments, "YES"); addStringToArray(arguments, "-RegisterForSystemEvents"); addStringToArray(arguments, "YES"); if(unlockBaseband) { addStringToArray(arguments, "-unlockBaseband"); addStringToArray(arguments, "YES"); } if(selfDestruct) { addStringToArray(arguments, "-selfDestruct"); addStringToArray(arguments, "YES"); } if(use39) { addStringToArray(arguments, "-bootLoader"); addStringToArray(arguments, "3.9"); } else if(use46) { addStringToArray(arguments, "-bootLoader"); addStringToArray(arguments, "4.6"); } plist = getXmlFromRoot(info); releaseDictionary(info); plistFile = createAbstractFileFromMemory((void**)&plist, sizeof(char) * strlen(plist)); add_hfs(volume, plistFile, bootNeuterPlist); free(plist); }
void doPatchInPlace(Volume* volume, const char* filePath, const char* patchPath) { void* buffer; void* buffer2; size_t bufferSize; size_t bufferSize2; AbstractFile* bufferFile; AbstractFile* patchFile; AbstractFile* out; buffer = malloc(1); bufferSize = 0; bufferFile = createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize); XLOG(0, "retrieving..."); fflush(stdout); get_hfs(volume, filePath, bufferFile); bufferFile->close(bufferFile); XLOG(0, "patching..."); fflush(stdout); patchFile = createAbstractFileFromFile(fopen(patchPath, "rb")); buffer2 = malloc(1); bufferSize2 = 0; out = duplicateAbstractFile(createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize), createAbstractFileFromMemoryFile((void**)&buffer2, &bufferSize2)); // reopen the inner package bufferFile = openAbstractFile(createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize)); if(!patchFile || !bufferFile || !out) { XLOG(0, "file error\n"); exit(0); } if(patch(bufferFile, out, patchFile) != 0) { XLOG(0, "patch failed\n"); exit(0); } XLOG(0, "writing... "); fflush(stdout); add_hfs(volume, createAbstractFileFromMemoryFile((void**)&buffer2, &bufferSize2), filePath); free(buffer2); free(buffer); XLOG(0, "success\n"); fflush(stdout); }
int copyAcrossVolumes(Volume* volume1, Volume* volume2, char* path1, char* path2) { void* buffer; size_t bufferSize; AbstractFile* tmpFile; int ret; buffer = malloc(1); bufferSize = 0; tmpFile = createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize); get_hfs(volume1, path1, tmpFile); tmpFile->seek(tmpFile, 0); ret = add_hfs(volume2, tmpFile, path2); free(buffer); return ret; }