本文整理汇总了C++中AbstractFile类的典型用法代码示例。如果您正苦于以下问题:C++ AbstractFile类的具体用法?C++ AbstractFile怎么用?C++ AbstractFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeDriverDescriptorMap
void writeDriverDescriptorMap(AbstractFile* file, DriverDescriptorRecord* DDM, ChecksumFunc dataForkChecksum, void* dataForkToken,
ResourceKey **resources) {
AbstractFile* bufferFile;
BLKXTable* blkx;
ChecksumToken uncompressedToken;
DriverDescriptorRecord* buffer;
buffer = (DriverDescriptorRecord*) malloc(DDM_SIZE * SECTOR_SIZE);
memcpy(buffer, DDM, DDM_SIZE * SECTOR_SIZE);
memset(&uncompressedToken, 0, sizeof(uncompressedToken));
flipDriverDescriptorRecord(buffer, TRUE);
bufferFile = createAbstractFileFromMemory((void**)&buffer, DDM_SIZE * SECTOR_SIZE);
blkx = insertBLKX(file, bufferFile, DDM_OFFSET, DDM_SIZE, DDM_DESCRIPTOR, CHECKSUM_CRC32, &CRCProxy, &uncompressedToken,
dataForkChecksum, dataForkToken, NULL);
blkx->checksum.data[0] = uncompressedToken.crc;
*resources = insertData(*resources, "blkx", -1, "Driver Descriptor Map (DDM : 0)", (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL);
free(buffer);
bufferFile->close(bufferFile);
free(blkx);
}
示例2: readDriverDescriptorMap
void readDriverDescriptorMap(AbstractFile* file, ResourceKey* resources) {
BLKXTable* blkx;
unsigned char* buffer;
AbstractFile* bufferFile;
DriverDescriptorRecord* record;
int i;
blkx = (BLKXTable*) (getDataByID(getResourceByKey(resources, "blkx"), -1)->data);
buffer = (unsigned char*) malloc(512);
bufferFile = createAbstractFileFromMemory((void**)&(buffer), 512);
extractBLKX(file, bufferFile, blkx);
bufferFile->close(bufferFile);
record = (DriverDescriptorRecord*)buffer;
flipDriverDescriptorRecord(record, FALSE);
printf("sbSig:\t\t0x%x\n", record->sbSig);
printf("sbBlkSize:\t0x%x\n", record->sbBlkSize);
printf("sbBlkCount:\t0x%x\n", record->sbBlkCount);
printf("sbDevType:\t0x%x\n", record->sbDevType);
printf("sbDevId:\t0x%x\n", record->sbDevId);
printf("sbData:\t\t0x%x\n", record->sbData);
printf("sbDrvrCount:\t0x%x\n", record->sbDrvrCount);
printf("ddBlock:\t0x%x\n", record->ddBlock);
printf("ddSize:\t\t0x%x\n", record->ddSize);
printf("ddType:\t\t0x%x\n", record->ddType);
for(i = 0; i < (record->sbDrvrCount - 1); i++) {
printf("\tddBlock:\t0x%x\n", record->ddPad[i].ddBlock);
printf("\tddSize:\t\t0x%x\n", record->ddPad[i].ddSize);
printf("\tddType:\t\t0x%x\n", record->ddPad[i].ddType);
}
free(buffer);
}
示例3: copyAcrossVolumes
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;
}
示例4: writeDriverDescriptorMap
int writeDriverDescriptorMap(int pNum, AbstractFile* file, DriverDescriptorRecord* DDM, unsigned int BlockSize, ChecksumFunc dataForkChecksum, void* dataForkToken,
ResourceKey **resources) {
AbstractFile* bufferFile;
BLKXTable* blkx;
ChecksumToken uncompressedToken;
DriverDescriptorRecord* buffer;
buffer = (DriverDescriptorRecord*) malloc(DDM_SIZE * BlockSize);
memcpy(buffer, DDM, DDM_SIZE * BlockSize);
memset(&uncompressedToken, 0, sizeof(uncompressedToken));
flipDriverDescriptorRecord(buffer, TRUE);
bufferFile = createAbstractFileFromMemory((void**)&buffer, DDM_SIZE * BlockSize);
blkx = insertBLKX(file, bufferFile, DDM_OFFSET, DDM_SIZE, DDM_DESCRIPTOR, CHECKSUM_CRC32, &CRCProxy, &uncompressedToken,
dataForkChecksum, dataForkToken, NULL, 0);
blkx->checksum.data[0] = uncompressedToken.crc;
char pName[100];
sprintf(pName, "Driver Descriptor Map (DDM : %d)", pNum + 1);
*resources = insertData(*resources, "blkx", pNum, pName, (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL);
free(buffer);
bufferFile->close(bufferFile);
free(blkx);
pNum++;
if((DDM_SIZE * BlockSize / SECTOR_SIZE) - DDM_SIZE > 0)
pNum = writeFreePartition(pNum, file, DDM_SIZE, (DDM_SIZE * BlockSize / SECTOR_SIZE) - DDM_SIZE, resources);
return pNum;
}
示例5: cmd_extract
void cmd_extract(Volume* volume, int argc, const char *argv[]) {
HFSPlusCatalogRecord* record;
AbstractFile *outFile;
if(argc < 3) {
printf("Not enough arguments");
return;
}
outFile = createAbstractFileFromFile(fopen(argv[2], "wb"));
if(outFile == NULL) {
printf("cannot create file");
}
record = getRecordFromPath(argv[1], volume, NULL, NULL);
if(record != NULL) {
if(record->recordType == kHFSPlusFileRecord)
writeToFile((HFSPlusCatalogFile*)record, outFile, volume);
else
printf("Not a file\n");
} else {
printf("No such file or directory\n");
}
outFile->close(outFile);
free(record);
}
示例6: absFileWrite
int absFileWrite(io_func* io, off_t location, size_t size, void *buffer) {
AbstractFile* file;
file = (AbstractFile*) io->data;
file->seek(file, location);
if(file->write(file, buffer, size) == size) {
return TRUE;
} else {
return FALSE;
}
}
示例7: writeApplePartitionMap
int writeApplePartitionMap(int pNum, AbstractFile* file, Partition* partitions, unsigned int BlockSize, ChecksumFunc dataForkChecksum, void* dataForkToken, ResourceKey **resources, NSizResource** nsizIn) {
AbstractFile* bufferFile;
BLKXTable* blkx;
ChecksumToken uncompressedToken;
Partition* buffer;
NSizResource* nsiz;
CSumResource csum;
size_t realPartitionSize = (PARTITION_SIZE * SECTOR_SIZE) / BlockSize * BlockSize;
buffer = (Partition*) malloc(realPartitionSize);
memcpy(buffer, partitions, realPartitionSize);
memset(&uncompressedToken, 0, sizeof(uncompressedToken));
flipPartition(buffer, TRUE, BlockSize);
bufferFile = createAbstractFileFromMemory((void**)&buffer, realPartitionSize);
blkx = insertBLKX(file, bufferFile, PARTITION_OFFSET * BlockSize / SECTOR_SIZE, realPartitionSize / SECTOR_SIZE, pNum, CHECKSUM_CRC32,
&BlockCRC, &uncompressedToken, dataForkChecksum, dataForkToken, NULL, 0);
bufferFile->close(bufferFile);
*((uint32_t*)blkx->checksum.data) = uncompressedToken.crc;
csum.version = 1;
csum.type = CHECKSUM_MKBLOCK;
csum.checksum = uncompressedToken.block;
char pName[100];
sprintf(pName, "Apple (Apple_partition_map : %d)", pNum + 1);
*resources = insertData(*resources, "blkx", pNum, pName, (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL);
*resources = insertData(*resources, "cSum", 0, "", (const char*) (&csum), sizeof(csum), 0);
nsiz = (NSizResource*) malloc(sizeof(NSizResource));
memset(nsiz, 0, sizeof(NSizResource));
nsiz->isVolume = FALSE;
nsiz->blockChecksum2 = uncompressedToken.block;
nsiz->partitionNumber = 0;
nsiz->version = 6;
nsiz->next = NULL;
if((*nsizIn) == NULL) {
*nsizIn = nsiz;
} else {
nsiz->next = (*nsizIn)->next;
(*nsizIn)->next = nsiz;
}
free(buffer);
free(blkx);
return pNum + 1;
}
示例8: main
int main(int argc, char* argv[]) {
init_libxpwn();
if(argc < 4) {
print_usage();
return 0;
}
AbstractFile* png;
AbstractFile* img;
AbstractFile* dst;
void* imageBuffer;
size_t imageSize;
unsigned int key[16];
unsigned int iv[16];
unsigned int* pKey = NULL;
unsigned int* pIV = NULL;
if(strcmp(argv[1], "e") == 0) {
img = createAbstractFileFromFile(fopen(argv[2], "rb"));
if(argc >= 6) {
sscanf(argv[4], "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
&iv[0], &iv[1], &iv[2], &iv[3], &iv[4], &iv[5], &iv[6], &iv[7], &iv[8],
&iv[9], &iv[10], &iv[11], &iv[12], &iv[13], &iv[14], &iv[15]);
sscanf(argv[5], "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
&key[0], &key[1], &key[2], &key[3], &key[4], &key[5], &key[6], &key[7], &key[8],
&key[9], &key[10], &key[11], &key[12], &key[13], &key[14], &key[15]);
pKey = key;
pIV = iv;
}
AbstractFile2* img3 = (AbstractFile2*) createAbstractFileFromImg3(img);
img3->setKey(img3, key, iv);
AbstractFile * out = createAbstractFileFromFile(fopen(argv[3], "wb"));
size_t inDataSize = (size_t) ((AbstractFile *)img3)->getLength((AbstractFile *)img3);
char *inData = (char*) malloc(inDataSize);
((AbstractFile *)img3)->read((AbstractFile *)img3, inData, inDataSize);
out->write(out, inData, inDataSize);
}
return 0;
}
示例9: hfslib_untar
BOOL hfslib_untar(HfsContext* ctx, char* tarFile) {
AbstractFile *inFile = createAbstractFileFromFile(fopen(tarFile, "rb"));
BOOL result = FALSE;
if(inFile == NULL) {
printf("file to untar not found");
} else {
result = hfs_untar(ctx->volume, inFile);
}
if (inFile != NULL) {
inFile->close(inFile);
}
return result;
}
示例10: fixupBootNeuterArgs
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);
}
示例11: extractAllInFolder
void extractAllInFolder(HFSCatalogNodeID folderID, Volume* volume) {
CatalogRecordList* list;
CatalogRecordList* theList;
char cwd[1024];
char* name;
HFSPlusCatalogFolder* folder;
HFSPlusCatalogFile* file;
AbstractFile* outFile;
struct stat status;
ASSERT(getcwd(cwd, 1024) != NULL, "cannot get current working directory");
theList = list = getFolderContents(folderID, volume);
while(list != NULL) {
name = unicodeToAscii(&list->name);
if(strncmp(name, ".HFS+ Private Directory Data", sizeof(".HFS+ Private Directory Data") - 1) == 0 || name[0] == '\0') {
free(name);
list = list->next;
continue;
}
if(list->record->recordType == kHFSPlusFolderRecord) {
folder = (HFSPlusCatalogFolder*)list->record;
printf("folder: %s\n", name);
if(stat(name, &status) != 0) {
ASSERT(mkdir(name, 0755) == 0, "mkdir");
}
ASSERT(chdir(name) == 0, "chdir");
extractAllInFolder(folder->folderID, volume);
ASSERT(chdir(cwd) == 0, "chdir");
} else if(list->record->recordType == kHFSPlusFileRecord) {
printf("file: %s\n", name);
file = (HFSPlusCatalogFile*)list->record;
outFile = createAbstractFileFromFile(fopen(name, "wb"));
if(outFile != NULL) {
writeToFile(file, outFile, volume);
outFile->close(outFile);
} else {
printf("WARNING: cannot fopen %s\n", name);
}
}
free(name);
list = list->next;
}
releaseCatalogRecordList(theList);
}
示例12: writeATAPI
void writeATAPI(AbstractFile* file, ChecksumFunc dataForkChecksum, void* dataForkToken, ResourceKey **resources, NSizResource** nsizIn) {
AbstractFile* bufferFile;
BLKXTable* blkx;
ChecksumToken uncompressedToken;
NSizResource* nsiz;
CSumResource csum;
char* atapi;
memset(&uncompressedToken, 0, sizeof(uncompressedToken));
atapi = (char*) malloc(ATAPI_SIZE * SECTOR_SIZE);
printf("malloc: %p %d\n", atapi, ATAPI_SIZE * SECTOR_SIZE); fflush(stdout);
memcpy(atapi, atapi_data, ATAPI_SIZE * SECTOR_SIZE);
bufferFile = createAbstractFileFromMemory((void**)&atapi, ATAPI_SIZE * SECTOR_SIZE);
blkx = insertBLKX(file, bufferFile, ATAPI_OFFSET, ATAPI_SIZE, 1, CHECKSUM_CRC32,
&BlockCRC, &uncompressedToken, dataForkChecksum, dataForkToken, NULL);
bufferFile->close(bufferFile);
free(atapi);
blkx->checksum.data[0] = uncompressedToken.crc;
csum.version = 1;
csum.type = CHECKSUM_MKBLOCK;
csum.checksum = uncompressedToken.block;
*resources = insertData(*resources, "blkx", 1, "Macintosh (Apple_Driver_ATAPI : 2)", (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL);
*resources = insertData(*resources, "cSum", 1, "", (const char*) (&csum), sizeof(csum), 0);
nsiz = (NSizResource*) malloc(sizeof(NSizResource));
memset(nsiz, 0, sizeof(NSizResource));
nsiz->isVolume = FALSE;
nsiz->blockChecksum2 = uncompressedToken.block;
nsiz->partitionNumber = 1;
nsiz->version = 6;
nsiz->next = NULL;
if((*nsizIn) == NULL) {
*nsizIn = nsiz;
} else {
nsiz->next = (*nsizIn)->next;
(*nsizIn)->next = nsiz;
}
free(blkx);
}
示例13: createRestoreOptions
void createRestoreOptions(Volume* volume, const char *optionsPlist, int SystemPartitionSize, int UpdateBaseband) {
AbstractFile* plistFile;
Dictionary* info;
char* plist;
HFSPlusCatalogRecord* record;
info = NULL;
record = getRecordFromPath(optionsPlist, volume, NULL, NULL);
if(record != NULL && record->recordType == kHFSPlusFileRecord) {
HFSPlusCatalogFile* file = (HFSPlusCatalogFile*)record;
size_t bufferSize = 512;
plist = malloc(bufferSize);
plistFile = createAbstractFileFromMemory((void**)&plist, bufferSize);
if (plistFile) {
char zero = 0;
writeToFile(file, plistFile, volume);
plistFile->write(plistFile, &zero, sizeof(zero));
plistFile->close(plistFile);
info = createRoot(plist);
removeKey(info, "CreateFilesystemPartitions");
removeKey(info, "SystemPartitionSize");
removeKey(info, "UpdateBaseband");
removeKey(info, "MinimumSystemPartition");
addIntegerToDictionary(info, "MinimumSystemPartition", SystemPartitionSize);
XLOG(0, "got %s from ramdisk\n", optionsPlist);
}
free(plist);
}
XLOG(0, "start create restore options\n");
if (!info) info = createRoot("<dict></dict>");
addBoolToDictionary(info, "CreateFilesystemPartitions", TRUE);
addIntegerToDictionary(info, "SystemPartitionSize", SystemPartitionSize);
addBoolToDictionary(info, "UpdateBaseband", UpdateBaseband);
plist = getXmlFromRoot(info);
releaseDictionary(info);
XLOG(0, "%s", plist);
plistFile = createAbstractFileFromMemory((void**)&plist, sizeof(char) * strlen(plist));
add_hfs(volume, plistFile, optionsPlist);
free(plist);
}
示例14: doPatchInPlace
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);
}
示例15: copyAcrossVolumes
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;
}