当前位置: 首页>>代码示例>>C++>>正文


C++ AbstractFile::close方法代码示例

本文整理汇总了C++中AbstractFile::close方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractFile::close方法的具体用法?C++ AbstractFile::close怎么用?C++ AbstractFile::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AbstractFile的用法示例。


在下文中一共展示了AbstractFile::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:AmesianX,项目名称:libdmg-hfsplus,代码行数:35,代码来源:partition.c

示例2: 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);
}
开发者ID:AmesianX,项目名称:libdmg-hfsplus,代码行数:26,代码来源:partition.c

示例3: 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);
}
开发者ID:arkanoid1,项目名称:xpwn,代码行数:29,代码来源:hfs.c

示例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;
}
开发者ID:GreySyntax,项目名称:libxpwn-hfs,代码行数:35,代码来源:partition.c

示例5: 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;
}
开发者ID:GreySyntax,项目名称:libxpwn-hfs,代码行数:53,代码来源:partition.c

示例6: 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;
}
开发者ID:DomT4,项目名称:iTunnel,代码行数:14,代码来源:hfsdll.c

示例7: 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);
}
开发者ID:0neday,项目名称:xpwn,代码行数:49,代码来源:pwnutil.c

示例8: sizeof

void
replaceCertificateAbstractFile(AbstractFile * file, AbstractFile * certificate)
{
	uint32_t signatureBE;
	uint32_t signatureLE;
	AbstractFile *f;

	file->seek(file, 0);
	file->read(file, &signatureBE, sizeof(signatureBE));
	signatureLE = signatureBE;
	FLIPENDIAN(signatureBE);
	FLIPENDIANLE(signatureLE);
	file->seek(file, 0);

	if (signatureBE == SIGNATURE_8900) {
		f = createAbstractFileFrom8900(file);
		replaceCertificate8900(f, certificate);
		f->close(f);
	} else if (signatureLE == IMG3_SIGNATURE) {
		f = createAbstractFileFromImg3(file);
		replaceCertificateImg3(f, certificate);
		f->close(f);
	}
}
开发者ID:123457890b,项目名称:opensn0w,代码行数:24,代码来源:nor_files.c

示例9: 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);
}
开发者ID:boxingcow,项目名称:xpwn,代码行数:48,代码来源:hfslib.c

示例10: 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);
}
开发者ID:AmesianX,项目名称:libdmg-hfsplus,代码行数:47,代码来源:partition.c

示例11: 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);
}
开发者ID:0neday,项目名称:xpwn,代码行数:46,代码来源:pwnutil.c

示例12: 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);
}
开发者ID:0neday,项目名称:xpwn,代码行数:46,代码来源:pwnutil.c

示例13: readApplePartitionMap

void readApplePartitionMap(AbstractFile* file, ResourceKey* resources, unsigned int BlockSize) {
  AbstractFile* bufferFile;
  BLKXTable* blkx;
  Partition* partition;
  int i;
  
  blkx = (BLKXTable*) (getDataByID(getResourceByKey(resources, "blkx"), 0)->data);

  partition = (Partition*) malloc(512);
  bufferFile = createAbstractFileFromMemory((void**)&partition, 512);
  extractBLKX(file, bufferFile, blkx);
  bufferFile->close(bufferFile);

  flipPartition(partition, FALSE, BlockSize);
  
  for(i = 0; i < partition->pmMapBlkCnt; i++) {
    if(partition[i].pmSig != APPLE_PARTITION_MAP_SIGNATURE) {
      break;
    }
    
    printf("pmSig:\t\t\t0x%x\n", partition[i].pmSig);
    printf("pmSigPad:\t\t0x%x\n", partition[i].pmSigPad);
    printf("pmMapBlkCnt:\t\t0x%x\n", partition[i].pmMapBlkCnt);
    printf("pmPartName:\t\t%s\n", partition[i].pmPartName);
    printf("pmParType:\t\t%s\n", partition[i].pmParType);
    printf("pmPyPartStart:\t\t0x%x\n", partition[i].pmPyPartStart);
    printf("pmPartBlkCnt:\t\t0x%x\n", partition[i].pmPartBlkCnt);
    printf("pmLgDataStart:\t\t0x%x\n", partition[i].pmLgDataStart);
    printf("pmDataCnt:\t\t0x%x\n", partition[i].pmDataCnt);
    printf("pmPartStatus:\t\t0x%x\n", partition[i].pmPartStatus);
    printf("pmLgBootStart:\t\t0x%x\n", partition[i].pmLgBootStart);
    printf("pmBootSize:\t\t0x%x\n", partition[i].pmBootSize);
    printf("pmBootAddr:\t\t0x%x\n", partition[i].pmBootAddr);
    printf("pmBootAddr2:\t\t0x%x\n", partition[i].pmBootAddr2);
    printf("pmBootEntry:\t\t0x%x\n", partition[i].pmBootEntry);
    printf("pmBootEntry2:\t\t0x%x\n", partition[i].pmBootEntry2);
    printf("pmBootCksum:\t\t0x%x\n", partition[i].pmBootCksum);
    printf("pmProcessor:\t\t\t%s\n\n", partition[i].pmProcessor);
  }

  free(partition);
}
开发者ID:AmesianX,项目名称:libdmg-hfsplus,代码行数:42,代码来源:partition.c

示例14: xpwntool_get_kbag

char* xpwntool_get_kbag(char* fileName)
{
	char* strbuf = NULL;
	AbstractFile* inFile;
	inFile = openAbstractFile2(createAbstractFileFromFile(fopen(fileName, "rb")), NULL, NULL);
	if (inFile != NULL && inFile->type == AbstractFileTypeImg3) {
		Img3Info* i3i = (Img3Info*)(inFile->data);
		if (i3i != NULL) {
			Img3Element* kbag = i3i->kbag;
			if (kbag != NULL && kbag->data != NULL && kbag->header != NULL) {
				size_t buflen = 1 + 2 * kbag->header->dataSize;
				strbuf = (char*)HeapAlloc(GetProcessHeap(), 0, buflen);
				char* bytes = (char*)kbag->data;
				for (size_t i = 0; i <  kbag->header->dataSize; ++i) {
					snprintf(strbuf + 2 * i, 2, "%02X", (unsigned char) bytes[i]);
				}
				strbuf[buflen-1] = '\0';
				return strbuf;
			}
		}
		inFile->close(inFile);
	}
	return strbuf;
}
开发者ID:DomT4,项目名称:iTunnel,代码行数:24,代码来源:xpwndll.c

示例15: addAllInFolder

void addAllInFolder(HFSCatalogNodeID folderID, Volume* volume, const char* parentName) {
	CatalogRecordList* list;
	CatalogRecordList* theList;
	char cwd[1024];
	char fullName[1024];
	char testBuffer[1024];
	char* pathComponent;
	int pathLen;
	
	char* name;
	
	DIR* dir;
	DIR* tmp;
	
	HFSCatalogNodeID cnid;
	
	struct dirent* ent;
	
	AbstractFile* file;
	HFSPlusCatalogFile* outFile;
	
	strcpy(fullName, parentName);
	pathComponent = fullName + strlen(fullName);
	
	ASSERT(getcwd(cwd, 1024) != NULL, "cannot get current working directory");
	
	theList = list = getFolderContents(folderID, volume);
	
	ASSERT((dir = opendir(cwd)) != NULL, "opendir");
	
	while((ent = readdir(dir)) != NULL) {
		if(ent->d_name[0] == '.' && (ent->d_name[1] == '\0' || (ent->d_name[1] == '.' && ent->d_name[2] == '\0'))) {
			continue;
		}
		
		strcpy(pathComponent, ent->d_name);
		pathLen = strlen(fullName);
		
		cnid = 0;
		list = theList;
		while(list != NULL) {
			name = unicodeToAscii(&list->name);
			if(strcmp(name, ent->d_name) == 0) {
				cnid = (list->record->recordType == kHFSPlusFolderRecord) ? (((HFSPlusCatalogFolder*)list->record)->folderID)
				: (((HFSPlusCatalogFile*)list->record)->fileID);
				free(name);
				break;
			}
			free(name);
			list = list->next;
		}
		
		if((tmp = opendir(ent->d_name)) != NULL) {
			closedir(tmp);
			printf("folder: %s\n", fullName); fflush(stdout);
			
			if(cnid == 0) {
				cnid = newFolder(fullName, volume);
			}
			
			fullName[pathLen] = '/';
			fullName[pathLen + 1] = '\0';
			ASSERT(chdir(ent->d_name) == 0, "chdir");
			addAllInFolder(cnid, volume, fullName);
			ASSERT(chdir(cwd) == 0, "chdir");
		} else {
			printf("file: %s\n", fullName);	fflush(stdout);
			if(cnid == 0) {
				cnid = newFile(fullName, volume);
			}
			file = createAbstractFileFromFile(fopen(ent->d_name, "rb"));
			ASSERT(file != NULL, "fopen");
			outFile = (HFSPlusCatalogFile*)getRecordByCNID(cnid, volume);
			writeToHFSFile(outFile, file, volume);
			file->close(file);
			free(outFile);
			
			if(strncmp(fullName, "/Applications/", sizeof("/Applications/") - 1) == 0) {
				testBuffer[0] = '\0';
				strcpy(testBuffer, "/Applications/");
				strcat(testBuffer, ent->d_name);
				strcat(testBuffer, ".app/");
				strcat(testBuffer, ent->d_name);
				if(strcmp(testBuffer, fullName) == 0) {
					if(strcmp(ent->d_name, "Installer") == 0
					|| strcmp(ent->d_name, "BootNeuter") == 0
					) {
						printf("Giving setuid permissions to %s...\n", fullName); fflush(stdout);
						chmodFile(fullName, 04755, volume);
					} else {
						printf("Giving permissions to %s\n", fullName); fflush(stdout);
						chmodFile(fullName, 0755, volume);
					}
				}
			} else if(strncmp(fullName, "/bin/", sizeof("/bin/") - 1) == 0
				|| strncmp(fullName, "/Applications/BootNeuter.app/bin/", sizeof("/Applications/BootNeuter.app/bin/") - 1) == 0
				|| strncmp(fullName, "/sbin/", sizeof("/sbin/") - 1) == 0
				|| strncmp(fullName, "/usr/sbin/", sizeof("/usr/sbin/") - 1) == 0
				|| strncmp(fullName, "/usr/bin/", sizeof("/usr/bin/") - 1) == 0
				|| strncmp(fullName, "/usr/libexec/", sizeof("/usr/libexec/") - 1) == 0
//.........这里部分代码省略.........
开发者ID:boxingcow,项目名称:xpwn,代码行数:101,代码来源:hfslib.c


注:本文中的AbstractFile::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。