Moved libxpwn prototypes from nor_files to includes/xpwn/libxpwn.h, also revamped logging functionality

This commit is contained in:
planetbeing 2008-07-23 17:27:35 +00:00
Родитель 52c18ceb04
Коммит e2ccbb9496
7 изменённых файлов: 139 добавлений и 70 удалений

30
includes/xpwn/libxpwn.h Normal file
Просмотреть файл

@ -0,0 +1,30 @@
#ifndef LIBXPWN_H
#define LIBXPWN_H
typedef void (*LogMessageCallback) (const char * Message);
extern LogMessageCallback logCallback;
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
#endif
#define XLOG(level, format, ...) Log(level, __FILE__, __LINE__, __func__, format, ## __VA_ARGS__)
#ifdef __cplusplus
extern "C" {
#endif
void init_libxpwn();
void libxpwn_log(LogMessageCallback callback);
void Log(int level, const char* file, unsigned int line, const char* function, const char* format, ...);
void TestByteOrder();
#ifdef __cplusplus
}
#endif
#endif

Просмотреть файл

@ -13,7 +13,6 @@ extern "C" {
AbstractFile* openAbstractFile2(AbstractFile* file, const unsigned int* key, const unsigned int* iv);
AbstractFile* duplicateAbstractFile(AbstractFile* file, AbstractFile* backing);
AbstractFile* duplicateAbstractFile2(AbstractFile* file, AbstractFile* backing, const unsigned int* key, const unsigned int* iv, AbstractFile* certificate);
void init_libxpwn();
#ifdef __cplusplus
}
#endif

Просмотреть файл

@ -3,6 +3,7 @@
#include <string.h>
#include "common.h"
#include "abstractfile.h"
#include <xpwn/libxpwn.h>
#include <xpwn/ibootim.h>
#include <xpwn/lzss.h>
#include <png.h>
@ -95,14 +96,14 @@ AbstractFile* createAbstractFileFromIBootIM(AbstractFile* file) {
flipIBootIMHeader(&(info->header));
if(strcmp(info->header.signature, IBOOTIM_SIGNATURE) != 0) {
free(info);
fprintf(stderr, "createAbstractFileFromIBootIM: signature does not match\n");
XLOG(1, "createAbstractFileFromIBootIM: signature does not match\n");
return NULL;
}
info->compLength = file->getLength(file) - sizeof(info->header);
if(info->header.compression_type != IBOOTIM_LZSS_TYPE) {
//free(info);
fprintf(stderr, "createAbstractFileFromIBootIM: (warning) unsupported compression type: %x\n", info->header.compression_type);
XLOG(1, "createAbstractFileFromIBootIM: (warning) unsupported compression type: %x\n", info->header.compression_type);
//return NULL;
}
@ -114,7 +115,7 @@ AbstractFile* createAbstractFileFromIBootIM(AbstractFile* file) {
info->length = 2 * info->header.width * info->header.height;
depth = 2;
} else {
fprintf(stderr, "createAbstractFileFromIBootIM: unsupported color type: %x\n", info->header.format);
XLOG(1, "createAbstractFileFromIBootIM: unsupported color type: %x\n", info->header.format);
free(info);
return NULL;
}
@ -125,12 +126,12 @@ AbstractFile* createAbstractFileFromIBootIM(AbstractFile* file) {
int length = decompress_lzss(info->buffer, compressed, info->compLength);
if(length > info->length) {
fprintf(stderr, "createAbstractFileFromIBootIM: decompression error\n");
XLOG(1, "createAbstractFileFromIBootIM: decompression error\n");
free(compressed);
free(info);
return NULL;
} else if(length < info->length) {
fprintf(stderr, "createAbstractFileFromIBootIM: (warning) uncompressed data shorter than expected: %d\n", length);
XLOG(1, "createAbstractFileFromIBootIM: (warning) uncompressed data shorter than expected: %d\n", length);
info->length = length;
}
@ -189,7 +190,7 @@ void pngRead(png_structp png_ptr, png_bytep data, png_size_t length) {
}
void pngError(png_structp png_ptr, png_const_charp error_msg) {
printf("error: %s\n", error_msg);
XLOG(0, "error: %s\n", error_msg);
exit(0);
}
@ -205,7 +206,7 @@ void* replaceBootImage(AbstractFile* imageWrapper, const unsigned int* key, cons
png->read(png, header, 8);
if(png_sig_cmp(header, 0, 8) != 0) {
printf("error: not a valid png file\n");
XLOG(0, "error: not a valid png file\n");
return NULL;
}
png->seek(png, 0);
@ -231,7 +232,7 @@ void* replaceBootImage(AbstractFile* imageWrapper, const unsigned int* key, cons
if (setjmp(png_jmpbuf(png_ptr)))
{
printf("error reading png\n");
XLOG(0, "error reading png\n");
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
free(buffer);
return NULL;
@ -242,15 +243,15 @@ void* replaceBootImage(AbstractFile* imageWrapper, const unsigned int* key, cons
png_read_info(png_ptr, info_ptr);
if(info_ptr->bit_depth > 8) {
printf("warning: bit depth per channel is greater than 8 (%d). Attempting to strip, but image quality will be degraded.\n", info_ptr->bit_depth);
XLOG(0, "warning: bit depth per channel is greater than 8 (%d). Attempting to strip, but image quality will be degraded.\n", info_ptr->bit_depth);
}
if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY || info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
printf("notice: attempting to add dummy transparency channel\n");
XLOG(0, "notice: attempting to add dummy transparency channel\n");
}
if(info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
printf("notice: attempting to expand palette into full rgb\n");
XLOG(0, "notice: attempting to expand palette into full rgb\n");
}
png_set_expand(png_ptr);
@ -263,24 +264,24 @@ void* replaceBootImage(AbstractFile* imageWrapper, const unsigned int* key, cons
if(info_ptr->width > 320 || info_ptr->height > 480) {
printf("error: dimensions out of range, must be within 320x480, not %lux%lu\n", info_ptr->width, info_ptr->height);
XLOG(0, "error: dimensions out of range, must be within 320x480, not %lux%lu\n", info_ptr->width, info_ptr->height);
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return NULL;
}
if(info_ptr->bit_depth != 8) {
printf("error: bit depth per channel must be 8 not %d!\n", info_ptr->bit_depth);
XLOG(0, "error: bit depth per channel must be 8 not %d!\n", info_ptr->bit_depth);
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return NULL;
}
if(info_ptr->color_type != PNG_COLOR_TYPE_GRAY_ALPHA && info_ptr->color_type != PNG_COLOR_TYPE_RGB_ALPHA) {
printf("error: incorrect color type, must be greyscale with alpha, or rgb with alpha\n");
XLOG(0, "error: incorrect color type, must be greyscale with alpha, or rgb with alpha\n");
if(info_ptr->color_type == PNG_COLOR_TYPE_GRAY || info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
printf("It appears you're missing an alpha channel. Add transparency to your image\n");
XLOG(0, "It appears you're missing an alpha channel. Add transparency to your image\n");
}
if(info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
printf("This PNG is saved with the palette color type rather than ARGB.\n");
XLOG(0, "This PNG is saved with the palette color type rather than ARGB.\n");
}
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);

Просмотреть файл

@ -1,6 +1,11 @@
#include "common.h"
#include <xpwn/libxpwn.h>
#include <stdarg.h>
#include <string.h>
LogMessageCallback logCallback;
char endianness;
int GlobalLogLevel;
void TestByteOrder()
{
@ -9,7 +14,45 @@ void TestByteOrder()
endianness = byte[0] ? IS_LITTLE_ENDIAN : IS_BIG_ENDIAN;
}
void init_libxpwn() {
TestByteOrder();
void defaultCallback(const char* Message) {
printf(Message);
}
void init_libxpwn() {
TestByteOrder();
GlobalLogLevel = 0xFF;
logCallback = defaultCallback;
}
void libxpwn_log(LogMessageCallback callback) {
logCallback = callback;
}
void libxpwn_loglevel(int logLevel) {
GlobalLogLevel = logLevel;
}
void Log(int level, const char* file, unsigned int line, const char* function, const char* format, ...) {
char mainBuffer[1024];
char buffer[1024];
if(level >= GlobalLogLevel) {
return;
}
va_list args;
va_start(args, format);
vsnprintf(buffer, sizeof(buffer), format, args);
va_end(args);
switch(level) {
case 0:
case 1:
strcpy(mainBuffer, buffer);
break;
default:
snprintf(mainBuffer, sizeof(mainBuffer), "%s:%s:%d: %s", file, function, line, buffer);
}
logCallback(mainBuffer);
}

Просмотреть файл

@ -2,6 +2,7 @@
#include <sys/types.h>
#include <string.h>
#include "common.h"
#include <xpwn/libxpwn.h>
#include <xpwn/nor_files.h>
#include <dmg/dmg.h>
#include <dmg/filevault.h>
@ -14,15 +15,8 @@
char endianness;
void TestByteOrder()
{
short int word = 0x0001;
char *byte = (char *) &word;
endianness = byte[0] ? IS_LITTLE_ENDIAN : IS_BIG_ENDIAN;
}
int main(int argc, char* argv[]) {
TestByteOrder();
init_libxpwn();
Dictionary* info;
Dictionary* firmwarePatches;
@ -86,7 +80,7 @@ int main(int argc, char* argv[]) {
unsigned int* pIV = NULL;
if(argc < 3) {
printf("usage %s <input.ipsw> <target.ipsw> [-b <bootimage.png>] [-r <recoveryimage.png>] [-nobbupdate] [-nowipe] [-e \"<action to exclude>\"] [[-unlock] [-use39] [-use46] [-cleanup] -3 <bootloader 3.9 file> -4 <bootloader 4.6 file>] <package1.tar> <package2.tar>...\n", argv[0]);
XLOG(0, "usage %s <input.ipsw> <target.ipsw> [-b <bootimage.png>] [-r <recoveryimage.png>] [-nobbupdate] [-nowipe] [-e \"<action to exclude>\"] [[-unlock] [-use39] [-use46] [-cleanup] -3 <bootloader 3.9 file> -4 <bootloader 4.6 file>] <package1.tar> <package2.tar>...\n", argv[0]);
return 0;
}
@ -94,7 +88,7 @@ int main(int argc, char* argv[]) {
info = parseIPSW(argv[1], bundleRoot, &bundlePath, &outputState);
if(info == NULL) {
printf("error: Could not load IPSW\n");
XLOG(0, "error: Could not load IPSW\n");
exit(1);
}
@ -130,7 +124,7 @@ int main(int argc, char* argv[]) {
if(strcmp(argv[i], "-use39") == 0) {
if(use46) {
printf("error: select only one of -use39 and -use46\n");
XLOG(0, "error: select only one of -use39 and -use46\n");
exit(1);
}
use39 = TRUE;
@ -139,7 +133,7 @@ int main(int argc, char* argv[]) {
if(strcmp(argv[i], "-use46") == 0) {
if(use39) {
printf("error: select only one of -use39 and -use46\n");
XLOG(0, "error: select only one of -use39 and -use46\n");
exit(1);
}
use46 = TRUE;
@ -149,7 +143,7 @@ int main(int argc, char* argv[]) {
if(strcmp(argv[i], "-b") == 0) {
applelogo = createAbstractFileFromFile(fopen(argv[i + 1], "rb"));
if(!applelogo) {
printf("cannot open %s\n", argv[i + 1]);
XLOG(0, "cannot open %s\n", argv[i + 1]);
exit(1);
}
i++;
@ -159,7 +153,7 @@ int main(int argc, char* argv[]) {
if(strcmp(argv[i], "-r") == 0) {
recoverymode = createAbstractFileFromFile(fopen(argv[i + 1], "rb"));
if(!recoverymode) {
printf("cannot open %s\n", argv[i + 1]);
XLOG(0, "cannot open %s\n", argv[i + 1]);
exit(1);
}
i++;
@ -169,7 +163,7 @@ int main(int argc, char* argv[]) {
if(strcmp(argv[i], "-3") == 0) {
bootloader39 = createAbstractFileFromFile(fopen(argv[i + 1], "rb"));
if(!bootloader39) {
printf("cannot open %s\n", argv[i + 1]);
XLOG(0, "cannot open %s\n", argv[i + 1]);
exit(1);
}
i++;
@ -179,7 +173,7 @@ int main(int argc, char* argv[]) {
if(strcmp(argv[i], "-4") == 0) {
bootloader46 = createAbstractFileFromFile(fopen(argv[i + 1], "rb"));
if(!bootloader46) {
printf("cannot open %s\n", argv[i + 1]);
XLOG(0, "cannot open %s\n", argv[i + 1]);
exit(1);
}
i++;
@ -189,7 +183,7 @@ int main(int argc, char* argv[]) {
if(use39 || use46 || unlockBaseband || selfDestruct || bootloader39 || bootloader46) {
if(!(bootloader39) || !(bootloader46)) {
printf("error: you must specify both bootloader files.\n");
XLOG(0, "error: you must specify both bootloader files.\n");
exit(1);
} else {
doBootNeuter = TRUE;
@ -240,7 +234,7 @@ int main(int argc, char* argv[]) {
patchValue = (StringValue*) getValueByKey(patchDict, "Patch2");
if(patchValue) {
if(noWipe) {
printf("%s: ", patchDict->dValue.key); fflush(stdout);
XLOG(0, "%s: ", patchDict->dValue.key); fflush(stdout);
doPatch(patchValue, fileValue, bundlePath, &outputState, pKey, pIV);
patchDict = (Dictionary*) patchDict->dValue.next;
continue; /* skip over the normal Patch */
@ -249,18 +243,18 @@ int main(int argc, char* argv[]) {
patchValue = (StringValue*) getValueByKey(patchDict, "Patch");
if(patchValue) {
printf("%s: ", patchDict->dValue.key); fflush(stdout);
XLOG(0, "%s: ", patchDict->dValue.key); fflush(stdout);
doPatch(patchValue, fileValue, bundlePath, &outputState, pKey, pIV);
}
if(strcmp(patchDict->dValue.key, "AppleLogo") == 0 && applelogo) {
printf("replacing %s\n", fileValue->value); fflush(stdout);
XLOG(0, "replacing %s\n", fileValue->value); fflush(stdout);
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&outputState, fileValue->value), pKey, pIV, applelogo, &imageSize)) != NULL, "failed to use new image");
addToOutput(&outputState, fileValue->value, imageBuffer, imageSize);
}
if(strcmp(patchDict->dValue.key, "RecoveryMode") == 0 && recoverymode) {
printf("replacing %s\n", fileValue->value); fflush(stdout);
XLOG(0, "replacing %s\n", fileValue->value); fflush(stdout);
ASSERT((imageBuffer = replaceBootImage(getFileFromOutputState(&outputState, fileValue->value), pKey, pIV, recoverymode, &imageSize)) != NULL, "failed to use new image");
addToOutput(&outputState, fileValue->value, imageBuffer, imageSize);
}
@ -276,9 +270,9 @@ int main(int argc, char* argv[]) {
rootSize -= 47438 * 512;
buffer = malloc(rootSize);
printf("allocating rootfs: %p %s %s %d\n", buffer, rootFSPathInIPSW, ((StringValue*)getValueByKey(info, "RootFilesystemKey"))->value, rootSize); fflush(stdout);
XLOG(0, "allocating rootfs: %p %s %s %d\n", buffer, rootFSPathInIPSW, ((StringValue*)getValueByKey(info, "RootFilesystemKey"))->value, rootSize); fflush(stdout);
if(buffer == NULL) {
fprintf(stderr, "out of memory. please close some applications and try again.\n");
XLOG(0, "out of memory. please close some applications and try again.\n");
return 1;
}
@ -289,7 +283,7 @@ int main(int argc, char* argv[]) {
rootFS = IOFuncFromAbstractFile(createAbstractFileFromMemoryFile((void**)&buffer, &rootSize));
rootVolume = openVolume(rootFS);
printf("Growing root: %ld\n", (long) rootSize); fflush(stdout);
XLOG(0, "Growing root: %ld\n", (long) rootSize); fflush(stdout);
grow_hfs(rootVolume, rootSize);
firmwarePatches = (Dictionary*)getValueByKey(info, "FilesystemPatches");
@ -302,7 +296,7 @@ int main(int argc, char* argv[]) {
actionValue = (StringValue*) getValueByKey(patchDict, "Action");
if(strcmp(actionValue->value, "ReplaceKernel") == 0) {
pathValue = (StringValue*) getValueByKey(patchDict, "Path");
printf("replacing kernel... %s -> %s\n", fileValue->value, pathValue->value); fflush(stdout);
XLOG(0, "replacing kernel... %s -> %s\n", fileValue->value, pathValue->value); fflush(stdout);
add_hfs(rootVolume, getFileFromOutputState(&outputState, fileValue->value), pathValue->value);
} if(strcmp(actionValue->value, "Patch") == 0) {
patchValue = (StringValue*) getValueByKey(patchDict, "Patch");
@ -311,7 +305,7 @@ int main(int argc, char* argv[]) {
strcat(patchPath, "/");
strcat(patchPath, patchValue->value);
printf("patching %s (%s)... ", fileValue->value, patchPath);
XLOG(0, "patching %s (%s)... ", fileValue->value, patchPath);
doPatchInPlace(rootVolume, fileValue->value, patchPath);
free(patchPath);
}
@ -321,7 +315,7 @@ int main(int argc, char* argv[]) {
}
for(; mergePaths < argc; mergePaths++) {
printf("merging %s\n", argv[mergePaths]);
XLOG(0, "merging %s\n", argv[mergePaths]);
AbstractFile* tarFile = createAbstractFileFromFile(fopen(argv[mergePaths], "rb"));
hfs_untar(rootVolume, tarFile);
tarFile->close(tarFile);
@ -330,11 +324,11 @@ int main(int argc, char* argv[]) {
if(pRamdiskKey) {
ramdiskFS = IOFuncFromAbstractFile(openAbstractFile2(getFileFromOutputStateForOverwrite(&outputState, ramdiskFSPathInIPSW), pRamdiskKey, pRamdiskIV));
} else {
printf("unencrypted ramdisk\n");
XLOG(0, "unencrypted ramdisk\n");
ramdiskFS = IOFuncFromAbstractFile(openAbstractFile(getFileFromOutputStateForOverwrite(&outputState, ramdiskFSPathInIPSW)));
}
ramdiskVolume = openVolume(ramdiskFS);
printf("growing ramdisk: %d -> %d\n", ramdiskVolume->volumeHeader->totalBlocks * ramdiskVolume->volumeHeader->blockSize, (ramdiskVolume->volumeHeader->totalBlocks + 4) * ramdiskVolume->volumeHeader->blockSize);
XLOG(0, "growing ramdisk: %d -> %d\n", ramdiskVolume->volumeHeader->totalBlocks * ramdiskVolume->volumeHeader->blockSize, (ramdiskVolume->volumeHeader->totalBlocks + 4) * ramdiskVolume->volumeHeader->blockSize);
grow_hfs(ramdiskVolume, (ramdiskVolume->volumeHeader->totalBlocks + 4) * ramdiskVolume->volumeHeader->blockSize);
if(doBootNeuter) {
@ -346,7 +340,7 @@ int main(int argc, char* argv[]) {
fileValue = (StringValue*) getValueByKey(patchDict, "File");
if(fileValue) {
printf("copying %s -> %s... ", fileValue->value, pathValue->value); fflush(stdout);
XLOG(0, "copying %s -> %s... ", fileValue->value, pathValue->value); fflush(stdout);
if(copyAcrossVolumes(ramdiskVolume, rootVolume, fileValue->value, pathValue->value)) {
patchValue = (StringValue*) getValueByKey(patchDict, "Patch");
if(patchValue) {
@ -354,7 +348,7 @@ int main(int argc, char* argv[]) {
strcpy(patchPath, bundlePath);
strcat(patchPath, "/");
strcat(patchPath, patchValue->value);
printf("patching %s (%s)... ", pathValue->value, patchPath); fflush(stdout);
XLOG(0, "patching %s (%s)... ", pathValue->value, patchPath); fflush(stdout);
doPatchInPlace(rootVolume, pathValue->value, patchPath);
free(patchPath);
}

Просмотреть файл

@ -3,6 +3,7 @@
#include <string.h>
#include <dirent.h>
#include <openssl/sha.h>
#include <xpwn/libxpwn.h>
#include <xpwn/plist.h>
#include <xpwn/outputstate.h>
#include <xpwn/pwnutil.h>
@ -37,7 +38,7 @@ Dictionary* parseIPSW(const char* inputIPSW, const char* bundleRoot, char** bund
return NULL;
}
printf("Hashing IPSW...\n");
XLOG(0, "Hashing IPSW...\n");
SHA1_Init(&sha1_ctx);
while(!feof(inputIPSWFile)) {
@ -48,7 +49,7 @@ Dictionary* parseIPSW(const char* inputIPSW, const char* bundleRoot, char** bund
fclose(inputIPSWFile);
printf("Matching IPSW... (%02x%02x%02x%02x...)\n", (int) hash[0], (int) hash[1], (int) hash[2], (int) hash[3]);
XLOG(0, "Matching IPSW... (%02x%02x%02x%02x...)\n", (int) hash[0], (int) hash[1], (int) hash[2], (int) hash[3]);
dir = opendir(bundleRoot);
if(dir == NULL) {
@ -64,7 +65,7 @@ Dictionary* parseIPSW(const char* inputIPSW, const char* bundleRoot, char** bund
strcpy(infoPath, bundleRoot);
strcat(infoPath, ent->d_name);
strcat(infoPath, "/Info.plist");
printf("checking: %s\n", infoPath);
XLOG(0, "checking: %s\n", infoPath);
if((plistFile = createAbstractFileFromFile(fopen(infoPath, "rb"))) != NULL) {
plist = (char*) malloc(plistFile->getLength(plistFile));
@ -130,48 +131,48 @@ int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundleP
strcat(patchPath, "/");
strcat(patchPath, patchValue->value);
printf("%s (%s)... ", fileValue->value, patchPath); fflush(stdout);
XLOG(0, "%s (%s)... ", fileValue->value, patchPath); fflush(stdout);
patchFile = createAbstractFileFromFile(fopen(patchPath, "rb"));
bufferSize = 0;
if(key != NULL) {
printf("encrypted input... ");
XLOG(0, "encrypted input... ");
out = duplicateAbstractFile2(getFileFromOutputState(state, fileValue->value), createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize), key, iv, NULL);
} else {
out = duplicateAbstractFile(getFileFromOutputState(state, fileValue->value), createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize));
}
if(key != NULL) {
printf("encrypted output... ");
XLOG(0, "encrypted output... ");
file = openAbstractFile2(getFileFromOutputState(state, fileValue->value), key, iv);
} else {
file = openAbstractFile(getFileFromOutputState(state, fileValue->value));
}
if(!patchFile || !file || !out) {
printf("file error\n");
XLOG(0, "file error\n");
exit(0);
}
if(patch(file, out, patchFile) != 0) {
printf("patch failed\n");
XLOG(0, "patch failed\n");
exit(0);
}
if(strstr(fileValue->value, "WTF.s5l8900xall.RELEASE")) {
printf("Exploiting 8900 vulnerability... ;)\n");
XLOG(0, "Exploiting 8900 vulnerability... ;)\n");
AbstractFile* exploited = createAbstractFileFrom8900(createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize));
exploit8900(exploited);
exploited->close(exploited);
}
printf("writing... "); fflush(stdout);
XLOG(0, "writing... "); fflush(stdout);
addToOutput(state, fileValue->value, buffer, bufferSize);
printf("success\n"); fflush(stdout);
XLOG(0, "success\n"); fflush(stdout);
free(patchPath);
@ -192,11 +193,11 @@ void doPatchInPlace(Volume* volume, const char* filePath, const char* patchPath)
bufferSize = 0;
bufferFile = createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize);
printf("retrieving..."); fflush(stdout);
XLOG(0, "retrieving..."); fflush(stdout);
get_hfs(volume, filePath, bufferFile);
bufferFile->close(bufferFile);
printf("patching..."); fflush(stdout);
XLOG(0, "patching..."); fflush(stdout);
patchFile = createAbstractFileFromFile(fopen(patchPath, "rb"));
@ -208,21 +209,21 @@ void doPatchInPlace(Volume* volume, const char* filePath, const char* patchPath)
bufferFile = openAbstractFile(createAbstractFileFromMemoryFile((void**)&buffer, &bufferSize));
if(!patchFile || !bufferFile || !out) {
printf("file error\n");
XLOG(0, "file error\n");
exit(0);
}
if(patch(bufferFile, out, patchFile) != 0) {
printf("patch failed\n");
XLOG(0, "patch failed\n");
exit(0);
}
printf("writing... "); fflush(stdout);
XLOG(0, "writing... "); fflush(stdout);
add_hfs(volume, createAbstractFileFromMemoryFile((void**)&buffer2, &bufferSize2), filePath);
free(buffer2);
free(buffer);
printf("success\n"); fflush(stdout);
XLOG(0, "success\n"); fflush(stdout);
}
void createRestoreOptions(Volume* volume, int SystemPartitionSize, int UpdateBaseband) {
@ -231,7 +232,7 @@ void createRestoreOptions(Volume* volume, int SystemPartitionSize, int UpdateBas
Dictionary* info;
char* plist;
printf("start create restore options\n");
XLOG(0, "start create restore options\n");
info = createRoot("<dict></dict>");
addBoolToDictionary(info, "CreateFilesystemPartitions", TRUE);
@ -241,7 +242,7 @@ void createRestoreOptions(Volume* volume, int SystemPartitionSize, int UpdateBas
plist = getXmlFromRoot(info);
releaseDictionary(info);
printf("%s", plist);
XLOG(0, "%s", plist);
plistFile = createAbstractFileFromMemory((void**)&plist, sizeof(char) * strlen(plist));
@ -257,7 +258,7 @@ void fixupBootNeuterArgs(Volume* volume, char unlockBaseband, char selfDestruct,
size_t bufferSize;
ArrayValue* arguments;
printf("fixing up BootNeuter arguments...\n");
XLOG(0, "fixing up BootNeuter arguments...\n");
plist = malloc(1);
bufferSize = 0;

Просмотреть файл

@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <xpwn/libxpwn.h>
#include <xpwn/nor_files.h>
#define BUFFERSIZE (1024*1024)