예제 #1
0
파일: xattr.c 프로젝트: 114577922/xpwn
XAttrList* getAllExtendedAttributes(HFSCatalogNodeID CNID, Volume* volume) {
	BTree* tree;
	HFSPlusAttrKey key;
	HFSPlusAttrRecord* record;
	uint32_t nodeNumber;
	int recordNumber;
	BTNodeDescriptor* descriptor;
	HFSPlusAttrKey* currentKey;
	off_t recordOffset;
	XAttrList* list = NULL;
	XAttrList* lastItem = NULL;
	XAttrList* item = NULL;

	if(!volume->attrTree)
		return NULL;

	memset(&key, 0 , sizeof(HFSPlusAttrKey));
	key.fileID = CNID;
	key.startBlock = 0;
	key.name.length = 0;
	key.keyLength = sizeof(HFSPlusAttrKey) - sizeof(HFSUniStr255) + sizeof(key.name.length) + (sizeof(uint16_t) * key.name.length);

	tree = volume->attrTree;
	record = (HFSPlusAttrRecord*) search(tree, (BTKey*)(&key), NULL, &nodeNumber, &recordNumber);
	if(record == NULL)
		return NULL;

	free(record);
	
	while(nodeNumber != 0) {    
		descriptor = readBTNodeDescriptor(nodeNumber, tree);

		while(recordNumber < descriptor->numRecords) {
			recordOffset = getRecordOffset(recordNumber, nodeNumber, tree);
			currentKey = (HFSPlusAttrKey*) READ_KEY(tree, recordOffset, tree->io);

			if(currentKey->fileID == CNID) {
				item = (XAttrList*) malloc(sizeof(XAttrList));
				item->name = (char*) malloc(currentKey->name.length + 1);
				int i;
				for(i = 0; i < currentKey->name.length; i++) {
					item->name[i] = currentKey->name.unicode[i];
				}
				item->name[currentKey->name.length] = '\0';
				item->next = NULL;

				if(lastItem != NULL) {
					lastItem->next = item;
				} else {
					list = item;
				}

				lastItem = item;

				free(currentKey);
			} else {
				free(currentKey);
				free(descriptor);
				return list;
			}

			recordNumber++;
		}

		nodeNumber = descriptor->fLink;
		recordNumber = 0;

		free(descriptor);
	}
	return list;
}
예제 #2
0
파일: catalog.c 프로젝트: mucit/opensn0w
CatalogRecordList* getFolderContents(HFSCatalogNodeID CNID, Volume* volume) {
	BTree* tree;
	HFSPlusCatalogThread* record; 
	HFSPlusCatalogKey key;
	uint32_t nodeNumber;
	int recordNumber;

	BTNodeDescriptor* descriptor;
	off_t recordOffset;
	off_t recordDataOffset;
	HFSPlusCatalogKey* currentKey;

	CatalogRecordList* list;
	CatalogRecordList* lastItem;
	CatalogRecordList* item;

	char pathBuffer[1024];
	HFSPlusCatalogRecord* toReturn;
	HFSPlusCatalogKey nkey;
	int exact;

	tree = volume->catalogTree;

	key.keyLength = sizeof(key.parentID) + sizeof(key.nodeName.length);
	key.parentID = CNID;
	key.nodeName.length = 0;

	list = NULL;

	record = (HFSPlusCatalogThread*) search(tree, (BTKey*)(&key), NULL, &nodeNumber, &recordNumber);

	if(record == NULL)
		return NULL;

	free(record);

	++recordNumber;

	while(nodeNumber != 0) {    
		descriptor = readBTNodeDescriptor(nodeNumber, tree);

		while(recordNumber < descriptor->numRecords) {
			recordOffset = getRecordOffset(recordNumber, nodeNumber, tree);
			currentKey = (HFSPlusCatalogKey*) READ_KEY(tree, recordOffset, tree->io);
			recordDataOffset = recordOffset + currentKey->keyLength + sizeof(currentKey->keyLength);

			if(currentKey->parentID == CNID) {
				item = (CatalogRecordList*) malloc(sizeof(CatalogRecordList));
				item->name = currentKey->nodeName;
				item->record = (HFSPlusCatalogRecord*) READ_DATA(tree, recordDataOffset, tree->io);

				if(item->record->recordType == kHFSPlusFileRecord && (((HFSPlusCatalogFile*)item->record)->userInfo.fileType) == kHardLinkFileType) {
					sprintf(pathBuffer, "iNode%d", ((HFSPlusCatalogFile*)item->record)->permissions.special.iNodeNum);
					nkey.parentID = volume->metadataDir;
					ASCIIToUnicode(pathBuffer, &nkey.nodeName); 
					nkey.keyLength = sizeof(nkey.parentID) + sizeof(nkey.nodeName.length) + (sizeof(uint16_t) * nkey.nodeName.length);

					toReturn = (HFSPlusCatalogRecord*) search(volume->catalogTree, (BTKey*)(&nkey), &exact, NULL, NULL);

					free(item->record);
					item->record = toReturn;
				}
				item->next = NULL;

				if(list == NULL) {
					list = item;
				} else {
					lastItem->next = item;
				}

				lastItem = item;
				free(currentKey);
			} else {
				free(currentKey);
				free(descriptor);
				return list;
			}

			recordNumber++;
		}

		nodeNumber = descriptor->fLink;
		recordNumber = 0;

		free(descriptor);
	}

	return list;
}
예제 #3
0
CatalogRecordList* getFolderContents(HFSCatalogNodeID CNID, Volume* volume) {
  BTree* tree;
  HFSPlusCatalogThread* record; 
  HFSPlusCatalogKey key;
  uint32_t nodeNumber;
  int recordNumber;
  
  BTNodeDescriptor* descriptor;
  off_t recordOffset;
  off_t recordDataOffset;
  HFSPlusCatalogKey* currentKey;
  
  CatalogRecordList* list;
  CatalogRecordList* lastItem;
  CatalogRecordList* item;
  
  tree = volume->catalogTree;
  
  key.keyLength = sizeof(key.parentID) + sizeof(key.nodeName.length);
  key.parentID = CNID;
  key.nodeName.length = 0;
  
  list = NULL;
  
  record = (HFSPlusCatalogThread*) search(tree, (BTKey*)(&key), NULL, &nodeNumber, &recordNumber);
  
  if(record == NULL)
    return NULL;
  
  free(record);
  
  ++recordNumber;
  
  while(nodeNumber != 0) {    
    descriptor = readBTNodeDescriptor(nodeNumber, tree);
       
    while(recordNumber < descriptor->numRecords) {
      recordOffset = getRecordOffset(recordNumber, nodeNumber, tree);
      currentKey = (HFSPlusCatalogKey*) READ_KEY(tree, recordOffset, tree->io);
      recordDataOffset = recordOffset + currentKey->keyLength + sizeof(currentKey->keyLength);
      
      if(currentKey->parentID == CNID) {
        item = (CatalogRecordList*) malloc(sizeof(CatalogRecordList));
        item->name = currentKey->nodeName;
        item->record = (HFSPlusCatalogRecord*) READ_DATA(tree, recordDataOffset, tree->io);
        item->next = NULL;

        if(list == NULL) {
          list = item;
        } else {
          lastItem->next = item;
        }
        
        lastItem = item;
        free(currentKey);
      } else {
        free(currentKey);
        free(descriptor);
        return list;
      }
      
      recordNumber++;
    }
    
    nodeNumber = descriptor->fLink;
    recordNumber = 0;
	
	free(descriptor);
  }
  
  return list;
}
예제 #4
0
btn2btn::btn2btn(std::vector<MGField>& fields) {
  BEGIN_READ_DEF;
  READ_KEY(out_button);
}
예제 #5
0
axis2btns::axis2btns(std::vector<MGField>& fields) {
  BEGIN_READ_DEF;
  READ_KEY(neg_btn);
  READ_KEY(pos_btn);
}