Beispiel #1
0
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);
}
Beispiel #2
0
io_func* openDmgFile(AbstractFile* abstractIn) {
	off_t fileLength;
	DMG* dmg;	
	ResourceData* blkx;
	ResourceData* curData;
	
	io_func* toReturn;

	if(abstractIn == NULL) {
		return NULL;
	}

    dmg = (DMG*) malloc(sizeof(DMG));
	dmg->dmg = abstractIn;

	fileLength = abstractIn->getLength(abstractIn);
	abstractIn->seek(abstractIn, fileLength - sizeof(UDIFResourceFile));
	readUDIFResourceFile(abstractIn, &dmg->resourceFile);
	
    dmg->resourceXML = malloc(dmg->resourceFile.fUDIFXMLLength + 1);
    ASSERT( abstractIn->seek(abstractIn, (off_t)(dmg->resourceFile.fUDIFXMLOffset)) == 0, "fseeko" );
    ASSERT( abstractIn->read(abstractIn, dmg->resourceXML, (size_t)dmg->resourceFile.fUDIFXMLLength) == (size_t)dmg->resourceFile.fUDIFXMLLength, "fread" );
    dmg->resourceXML[dmg->resourceFile.fUDIFXMLLength] = 0;
    
	dmg->resources = readResources(dmg->resourceXML, dmg->resourceFile.fUDIFXMLLength);
	dmg->numBLKX = 0;
	
	blkx = (getResourceByKey(dmg->resources, "blkx"))->data;
	
	curData = blkx;
	while(curData != NULL) {
		dmg->numBLKX++;
		curData = curData->next;	
	}
	
	dmg->blkx = (BLKXTable**) malloc(sizeof(BLKXTable*) * dmg->numBLKX);
	
	int i = 0;
	while(blkx != NULL) {
		dmg->blkx[i] = (BLKXTable*)(blkx->data);
		i++;
		blkx = blkx->next;
	}

	dmg->offset = 0;
	dmg->runType = BLOCK_TERMINATOR; // causes cacheOffset on first read attempt
	dmg->runData = NULL;

	toReturn = (io_func*) malloc(sizeof(io_func));
	
	toReturn->data = dmg;
	toReturn->read = &dmgFileRead;
	toReturn->write = &dmgFileWrite;
	toReturn->close = &closeDmgFile;
	
	return toReturn;
}
Beispiel #3
0
io_func* openDmgFile(AbstractFile* abstractIn) {
	off_t fileLength;
	UDIFResourceFile resourceFile;
	DMG* dmg;	
	ResourceData* blkx;
	ResourceData* curData;
	int i;
	
	io_func* toReturn;

	if(abstractIn == NULL) {
		return NULL;
	}
	
	fileLength = abstractIn->getLength(abstractIn);
	abstractIn->seek(abstractIn, fileLength - sizeof(UDIFResourceFile));
	readUDIFResourceFile(abstractIn, &resourceFile);
	
	dmg = (DMG*) malloc(sizeof(DMG));
	dmg->dmg = abstractIn;
	dmg->resources = readResources(abstractIn, &resourceFile);
	dmg->numBLKX = 0;
	
	blkx = (getResourceByKey(dmg->resources, "blkx"))->data;
	
	curData = blkx;
	while(curData != NULL) {
		dmg->numBLKX++;
		curData = curData->next;	
	}
	
	dmg->blkx = (BLKXTable**) malloc(sizeof(BLKXTable*) * dmg->numBLKX);
	
	i = 0;
	while(blkx != NULL) {
		dmg->blkx[i] = (BLKXTable*)(blkx->data);
		i++;
		blkx = blkx->next;
	}

	dmg->offset = 0;
	
	dmg->runData = NULL;
	cacheOffset(dmg, 0);
	
	toReturn = (io_func*) malloc(sizeof(io_func));
	
	toReturn->data = dmg;
	toReturn->read = &dmgFileRead;
	toReturn->write = &dmgFileWrite;
	toReturn->close = &closeDmgFile;
	
	return toReturn;
}
Beispiel #4
0
NSizResource* readNSiz(ResourceKey* resources) {
  ResourceData* curData;
  NSizResource* toReturn;
  NSizResource* curNSiz;
  char* curLoc;
  uint32_t modifyDate;
  
  curData = getResourceByKey(resources, "nsiz")->data;
  toReturn = NULL;
   
  while(curData != NULL) {
    curLoc = (char*) curData->data;
    
    if(toReturn == NULL) {
      toReturn = (NSizResource*) malloc(sizeof(NSizResource));
      curNSiz = toReturn;
    } else {
      curNSiz->next = (NSizResource*) malloc(sizeof(NSizResource));
      curNSiz = curNSiz->next;
    }
    
    curNSiz->next = NULL;
    
    readNSizResource(curNSiz, &curLoc);
    
    
    printf("block-checksum-2:\t0x%x\n", curNSiz->blockChecksum2);
    printf("part-num:\t\t0x%x\n", curNSiz->partitionNumber);
    printf("version:\t\t0x%x\n", curNSiz->version);
    
    if(curNSiz->isVolume) {
      printf("has SHA1:\t\t%d\n", curNSiz->sha1Digest != NULL);
      printf("bytes:\t\t\t0x%x\n", curNSiz->bytes);
      modifyDate = APPLE_TO_UNIX_TIME(curNSiz->modifyDate);
      printf("date:\t\t\t%s", ctime((time_t*)(&modifyDate)));
      printf("volume-signature:\t0x%x\n", curNSiz->volumeSignature);
    }
    
    printf("\n");
    
    curData = curData->next;
  }
  
  return toReturn;
}
Beispiel #5
0
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);
}