public HFSPlusCatalogFile(ref byte[] rawData) : base(ref rawData) { ushort flags = dataOperations.convToLE(BitConverter.ToUInt16(rawData, 2)); this.fileLockedBit = (fileFlags.kHFSFileLockedBit & (fileFlags)flags) == fileFlags.kHFSFileLockedBit; this.fileLockedMask = (fileFlags.kHFSFileLockedMask & (fileFlags)flags) == fileFlags.kHFSFileLockedMask; this.threadExistsBit = (fileFlags.kHFSThreadExistsBit & (fileFlags)flags) == fileFlags.kHFSThreadExistsBit; this.threadExistsMask = (fileFlags.kHFSThreadExistsMask & (fileFlags)flags) == fileFlags.kHFSThreadExistsMask; this.reserved1 = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 4)); this.fileID = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 8)); this.createDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 12))); this.contentModDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 16))); this.attributeModDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 20))); this.accessDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 24))); this.backupDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 28))); byte[] filePermissions = new byte[16]; Array.Copy(rawData, 32, filePermissions, 0, 16); byte[] fileUserInfo = new byte[16]; Array.Copy(rawData, 48, fileUserInfo, 0, 16); byte[] fileFinderInfo = new byte[16]; Array.Copy(rawData, 64, fileFinderInfo, 0, 16); this.userInfo = HFSPlusFinderInfo.getFileUserInfo(ref fileUserInfo); this.finderInfo = HFSPlusFinderInfo.getFileFinderInfo(ref fileFinderInfo); this.permissions = getHFSPlusPermissions(ref filePermissions); this.textEncoding = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 80)); this.reserved2 = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 84)); this.dataFork = new hfsPlusForkData(ref rawData, 88); this.resourceFork = new hfsPlusForkData(ref rawData, 168); }
public HFSPlusCatalogFolder(ref byte[] rawData) : base(ref rawData) { this.flags = dataOperations.convToLE(BitConverter.ToUInt16(rawData, 2)); this.valence = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 4)); this.folderID = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 8)); this.createDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 12))); this.contentModDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 16))); this.attributeModDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 20))); this.accessDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 24))); this.backupDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 28))); byte[] folderPermissions = new byte[16]; Array.Copy(rawData, 32, folderPermissions, 0, 16); byte[] folderUserInfo = new byte[16]; Array.Copy(rawData, 48, folderUserInfo, 0, 16); byte[] folderFinderInfo = new byte[16]; Array.Copy(rawData, 64, folderFinderInfo, 0, 16); this.userInfo = HFSPlusFinderInfo.getFolderUserInfo(ref folderUserInfo); this.finderInfo = HFSPlusFinderInfo.getFolderFinderInfo(ref folderFinderInfo); this.permissions = getHFSPlusPermissions(ref folderPermissions); this.textEncoding = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 80)); this.reserved = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 84)); }
private ListViewItem getNodeRowContents(TreeNode theTree) { ListViewItem row = new ListViewItem(theTree.Text); if (theTree.Tag != null) { string tagType = theTree.Tag.GetType().ToString(); switch (tagType) { case "Disk_Reader.HFSPlusCatalogFolder": HFSPlusCatalogFolder folderTag = (HFSPlusCatalogFolder)theTree.Tag; row.Tag = folderTag; row.SubItems.Add(folderTag.folderID.ToString()); if (folderTag.createDate > HFSPlus.FromHFSPlusTime(0)) { row.SubItems.Add(folderTag.createDate.ToString()); } else { row.SubItems.Add(""); } if (folderTag.contentModDate > HFSPlus.FromHFSPlusTime(0)) { row.SubItems.Add(folderTag.contentModDate.ToString()); } else { row.SubItems.Add(""); } if (folderTag.attributeModDate > HFSPlus.FromHFSPlusTime(0)) { row.SubItems.Add(folderTag.attributeModDate.ToString()); } else { row.SubItems.Add(""); } if (folderTag.backupDate > HFSPlus.FromHFSPlusTime(0)) { row.SubItems.Add(folderTag.backupDate.ToString()); } else { row.SubItems.Add(""); } if (folderTag.accessDate > HFSPlus.FromHFSPlusTime(0)) { row.SubItems.Add(folderTag.accessDate.ToString()); } else { row.SubItems.Add(""); } string folderPermissions = ""; if (folderTag.permissions.fileMode.owner.read) { folderPermissions += "r"; } else { folderPermissions += "-"; } if (folderTag.permissions.fileMode.owner.write) { folderPermissions += "w"; } else { folderPermissions += "-"; } if (folderTag.permissions.fileMode.owner.execute) { folderPermissions += "x"; } else { folderPermissions += "-"; } folderPermissions += "/"; if (folderTag.permissions.fileMode.group.read) { folderPermissions += "r"; } else { folderPermissions += "-"; } if (folderTag.permissions.fileMode.group.write) { folderPermissions += "w"; } else { folderPermissions += "-"; } if (folderTag.permissions.fileMode.group.execute) { folderPermissions += "x"; } else { folderPermissions += "-"; } folderPermissions += "/"; if (folderTag.permissions.fileMode.other.read) { folderPermissions += "r"; } else { folderPermissions += "-"; } if (folderTag.permissions.fileMode.other.write) { folderPermissions += "w"; } else { folderPermissions += "-"; } if (folderTag.permissions.fileMode.other.execute) { folderPermissions += "x"; } else { folderPermissions += "-"; } row.SubItems.Add(folderPermissions); row.SubItems.Add(""); // data fork size row.SubItems.Add(""); // resource fork size row.SubItems.Add(""); // data start sector LBA row.SubItems.Add(""); // rsrc start sector row.SubItems.Add(""); // data fragments count row.SubItems.Add(""); // rsrc fragments count row.SubItems.Add(""); // data fork MD5 row.SubItems.Add(""); // data fork SHA1 row.SubItems.Add(""); // resource fork MD5 row.SubItems.Add(""); // resource fork SHA1 row.SubItems.Add(""); // is deleted row.SubItems.Add(folderTag.path); break; case "Disk_Reader.HFSPlus+volumeHeader": HFSPlus.volumeHeader headerTag = (HFSPlus.volumeHeader)theTree.Tag; row.Tag = headerTag; row.SubItems.Add(""); // CNID if (headerTag.createDate > HFSPlus.FromHFSPlusTime(0)) { row.SubItems.Add(headerTag.createDate.ToString()); } else { row.SubItems.Add(""); } if (headerTag.modifyDate > HFSPlus.FromHFSPlusTime(0)) { row.SubItems.Add(headerTag.modifyDate.ToString()); } else { row.SubItems.Add(""); } row.SubItems.Add(""); // attribute mod date if (headerTag.backupDate > HFSPlus.FromHFSPlusTime(0)) { row.SubItems.Add(headerTag.backupDate.ToString()); } else { row.SubItems.Add(""); } row.SubItems.Add(""); // access date row.SubItems.Add(""); // permissions row.SubItems.Add(""); // data fork size row.SubItems.Add(""); // resource fork size row.SubItems.Add(""); // data start sector LBA row.SubItems.Add(""); // rsrc start sector row.SubItems.Add(""); // data fragments count row.SubItems.Add(""); // rsrc fragments count row.SubItems.Add(""); // data fork MD5 row.SubItems.Add(""); // data fork SHA1 row.SubItems.Add(""); // resource fork MD5 row.SubItems.Add(""); // resource fork SHA1 row.SubItems.Add(""); // is deleted row.SubItems.Add(headerTag.path); break; case "Disk_Reader.HFSPlusCatalogFile": HFSPlusCatalogFile fileTag = (HFSPlusCatalogFile)theTree.Tag; row.Tag = fileTag; row.SubItems.Add(fileTag.fileID.ToString()); if (fileTag.createDate > HFSPlus.FromHFSPlusTime(0)) // creation date { row.SubItems.Add(fileTag.createDate.ToString()); } else { row.SubItems.Add(""); } if (fileTag.contentModDate > HFSPlus.FromHFSPlusTime(0)) // content mod date { row.SubItems.Add(fileTag.contentModDate.ToString()); } else { row.SubItems.Add(""); } if (fileTag.attributeModDate > HFSPlus.FromHFSPlusTime(0)) // attributes mod date { row.SubItems.Add(fileTag.attributeModDate.ToString()); } else { row.SubItems.Add(""); } if (fileTag.backupDate > HFSPlus.FromHFSPlusTime(0)) // backup date { row.SubItems.Add(fileTag.backupDate.ToString()); } else { row.SubItems.Add(""); } if (fileTag.accessDate > HFSPlus.FromHFSPlusTime(0)) // access date - Mac OS X does not use this - only POSIX implementations { row.SubItems.Add(fileTag.accessDate.ToString()); } else { row.SubItems.Add(""); } string filePermissions = ""; if (fileTag.permissions.fileMode.owner.read) { filePermissions += "r"; } else { filePermissions += "-"; } if (fileTag.permissions.fileMode.owner.write) { filePermissions += "w"; } else { filePermissions += "-"; } if (fileTag.permissions.fileMode.owner.execute) { filePermissions += "x"; } else { filePermissions += "-"; } filePermissions += "/"; if (fileTag.permissions.fileMode.group.read) { filePermissions += "r"; } else { filePermissions += "-"; } if (fileTag.permissions.fileMode.group.write) { filePermissions += "w"; } else { filePermissions += "-"; } if (fileTag.permissions.fileMode.group.execute) { filePermissions += "x"; } else { filePermissions += "-"; } filePermissions += "/"; if (fileTag.permissions.fileMode.other.read) { filePermissions += "r"; } else { filePermissions += "-"; } if (fileTag.permissions.fileMode.other.write) { filePermissions += "w"; } else { filePermissions += "-"; } if (fileTag.permissions.fileMode.other.execute) { filePermissions += "x"; } else { filePermissions += "-"; } row.SubItems.Add(filePermissions); // file permissions row.SubItems.Add(fileTag.dataFork.forkDataValues.logicalSize.ToString()); // data fork size int rsrccount = 0; if (fileTag.resourceFork != null) { row.SubItems.Add(fileTag.resourceFork.forkDataValues.logicalSize.ToString()); // only try to iterate through resource fork extents if a resource fork exists // (volume metadata files do not have a resource fork) for (int i = 0; i < fileTag.dataFork.forkDataValues.extents.Count(); i++) { if (fileTag.resourceFork.forkDataValues.extents[i].blockCount > 0) { rsrccount++; } } } else { row.SubItems.Add("0"); // resource fork size } if (fileTag.dataFork.forkDataValues.extents[0].startBlock > 0) { row.SubItems.Add(fileTag.dataFork.forkDataValues.extents[0].startBlock.ToString()); } else { row.SubItems.Add(""); // start sector LBA } if (fileTag.resourceFork != null) { if (fileTag.resourceFork.forkDataValues.extents[0].startBlock > 0) { row.SubItems.Add(fileTag.resourceFork.forkDataValues.extents[0].startBlock.ToString()); } else { row.SubItems.Add(""); // resource start sector } } int datacount = 0; for (int i = 0; i < fileTag.dataFork.forkDataValues.extents.Count(); i++) { if (fileTag.dataFork.forkDataValues.extents[i].blockCount > 0) { datacount++; } } row.SubItems.Add(datacount.ToString()); // data fragments count row.SubItems.Add(rsrccount.ToString()); // resource fragments count row.SubItems.Add(""); // data fork MD5 row.SubItems.Add(""); // data fork SHA1 row.SubItems.Add(""); // resource fork MD5 row.SubItems.Add(""); // resource fork SHA1 row.SubItems.Add(""); // is deleted row.SubItems.Add(fileTag.path); break; case "Disk_Reader.attributesLeafNode+HFSPlusAttrForkData": break; case "Disk_Reader.attributesLeafNode+HFSPlusAttrInlineData": attributesLeafNode.HFSPlusAttrInlineData inlineTag = (attributesLeafNode.HFSPlusAttrInlineData)theTree.Tag; row.Tag = inlineTag; row.SubItems.Add(inlineTag.key.fileID.ToString()); row.SubItems.Add(""); // creation date row.SubItems.Add(""); // content mod date row.SubItems.Add(""); // attributes mod date row.SubItems.Add(""); // backup date row.SubItems.Add(""); // access date row.SubItems.Add(""); // file permissions row.SubItems.Add(inlineTag.otherData.Length.ToString()); // data fork size row.SubItems.Add(""); // resource fork size row.SubItems.Add(""); // data start sector LBA row.SubItems.Add(""); // rsrc start sector LBA row.SubItems.Add(""); // data fragments count row.SubItems.Add(""); // rsrc fragments count row.SubItems.Add(""); // data fork MD5 row.SubItems.Add(""); // data fork SHA1 row.SubItems.Add(""); // resource fork MD5 row.SubItems.Add(""); // resource fork SHA1 row.SubItems.Add(""); // is deleted row.SubItems.Add(""); // path break; } } return(row); }