public Iso9660PathTableRecord(byte[] pathBytes, bool isLittleEndian) { this.LengthOfDirectoryIdentifier = ParseFile.ParseSimpleOffset(pathBytes, 0, 1)[0]; this.ExtendedAttributeRecordLength = ParseFile.ParseSimpleOffset(pathBytes, 1, 1)[0]; if (isLittleEndian) { this.LocationOfExtent = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(pathBytes, 2, 4), 0); } else { this.LocationOfExtent = ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(pathBytes, 2, 4)); } if (isLittleEndian) { this.DirectoryNumberOfParentDirectory = BitConverter.ToUInt16(ParseFile.ParseSimpleOffset(pathBytes, 6, 2), 0); } else { this.DirectoryNumberOfParentDirectory = ByteConversion.GetUInt16BigEndian(ParseFile.ParseSimpleOffset(pathBytes, 6, 2)); } this.DirectoryIdentifierBytes = ParseFile.ParseSimpleOffset(pathBytes, 8, this.LengthOfDirectoryIdentifier); this.DirectoryIdentifier = ByteConversion.GetEncodedText(this.DirectoryIdentifierBytes, ByteConversion.GetPredictedCodePageForTags(this.DirectoryIdentifierBytes)); if (this.LengthOfDirectoryIdentifier % 2 == 1) { this.PaddingByte = ParseFile.ParseSimpleOffset(pathBytes, this.LengthOfDirectoryIdentifier + 8, 1)[0]; } }
public void Initialize(FileStream isoStream, long offset, bool isRawDump) { byte[] volumeIdentifierBytes; byte[] imageDateBytes; string imageDateString; this.VolumeBaseOffset = offset; this.IsRawDump = isRawDump; this.VolumeType = VolumeDataType.Data; this.DirectoryStructureArray = new ArrayList(); // get identifier volumeIdentifierBytes = ParseFile.ParseSimpleOffset(isoStream, this.VolumeBaseOffset + 0x20, 64); volumeIdentifierBytes = FileUtil.ReplaceNullByteWithSpace(volumeIdentifierBytes); this.VolumeIdentifier = ByteConversion.GetEncodedText(volumeIdentifierBytes, ByteConversion.GetPredictedCodePageForTags(volumeIdentifierBytes)).Trim();; // get date imageDateBytes = ParseFile.ParseSimpleOffset(isoStream, this.VolumeBaseOffset + 0x2440, 0xA); imageDateString = ByteConversion.GetAsciiText(imageDateBytes); try { this.ImageCreationTime = new DateTime(int.Parse(imageDateString.Substring(0, 4)), int.Parse(imageDateString.Substring(5, 2)), int.Parse(imageDateString.Substring(8, 2))); } catch (Exception) { this.ImageCreationTime = new DateTime(); } // set bit shift for GC or WII if (this.IsGameCubeDisc(isoStream)) { this.OffsetBitShiftValue = 0; this.FormatDescription = NintendoGameCube.FORMAT_DESCRIPTION_STRING; } else { this.OffsetBitShiftValue = 2; this.FormatDescription = NintendoWiiOpticalDisc.FORMAT_DESCRIPTION_STRING_DECRYPTED; } // get offset of file table this.RootDirectoryOffset = (long)ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(isoStream, this.VolumeBaseOffset + 0x424, 4)); this.RootDirectoryOffset <<= this.OffsetBitShiftValue; this.LoadDirectories(isoStream); }
public void Initialize(FileStream isoStream, long offset, bool isRawDump) { byte[] volumeIdentifierBytes; byte[] imageDateBytes; string imageDateString; this.IsRawDump = isRawDump; this.DirectoryStructureArray = new ArrayList(); this.FormatDescription = NintendoWiiOpticalDisc.FORMAT_DESCRIPTION_STRING; this.VolumeType = VolumeDataType.Data; // get identifier volumeIdentifierBytes = DiscReader.GetBytes(isoStream, this.VolumeBaseOffset, this.DataOffset, 0x20, 64, this.PartitionKey); volumeIdentifierBytes = FileUtil.ReplaceNullByteWithSpace(volumeIdentifierBytes); this.VolumeIdentifier = ByteConversion.GetEncodedText(volumeIdentifierBytes, ByteConversion.GetPredictedCodePageForTags(volumeIdentifierBytes)).Trim();; // get date imageDateBytes = DiscReader.GetBytes(isoStream, this.VolumeBaseOffset, this.DataOffset, 0x2440, 0xA, this.PartitionKey); imageDateString = ByteConversion.GetAsciiText(imageDateBytes); try { this.ImageCreationTime = new DateTime(int.Parse(imageDateString.Substring(0, 4)), int.Parse(imageDateString.Substring(5, 2)), int.Parse(imageDateString.Substring(8, 2))); } catch (Exception) { this.ImageCreationTime = new DateTime(); } // get offset of file table this.RootDirectoryOffset = (long)ByteConversion.GetUInt32BigEndian(DiscReader.GetBytes(isoStream, this.VolumeBaseOffset, this.DataOffset, 0x424, 4, this.PartitionKey)); this.RootDirectoryOffset <<= 2; this.LoadDirectories(isoStream); }
} // 4 bytes each, for total of SubDirectoryCount LBAs public Panasonic3doDirectoryRecord(byte[] directoryBytes) { this.DirectoryItemTypeBytes = ParseFile.ParseSimpleOffset(directoryBytes, 0, 4); this.Unknown1 = ParseFile.ParseSimpleOffset(directoryBytes, 4, 4); this.DirectoryItemTypeTextFlagBytes = ParseFile.ParseSimpleOffset(directoryBytes, 8, 4); this.DirectoryItemTypeTextFlag = ByteConversion.GetEncodedText(this.DirectoryItemTypeTextFlagBytes, ByteConversion.GetPredictedCodePageForTags(this.DirectoryItemTypeTextFlagBytes)); this.DirectoryItemLogicalBlockSize = ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(directoryBytes, 0xC, 4)); this.DirectoryItemSize = ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(directoryBytes, 0x10, 4)); this.DirectoryItemSizeInSectors = ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(directoryBytes, 0x14, 4)); this.Unknown2 = ParseFile.ParseSimpleOffset(directoryBytes, 0x18, 4); this.Unknown3 = ParseFile.ParseSimpleOffset(directoryBytes, 0x1C, 4); this.DirectoryItemNameBytes = ParseFile.ParseSimpleOffset(directoryBytes, 0x20, 0x20); this.DirectoryItemName = ByteConversion.GetEncodedText(FileUtil.ReplaceNullByteWithSpace(this.DirectoryItemNameBytes), ByteConversion.GetPredictedCodePageForTags(this.DirectoryItemNameBytes)).Trim(); this.SubDirectoryCount = ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(directoryBytes, 0x40, 4)) + 1; this.SubDirectoryLbas = new uint[this.SubDirectoryCount]; for (uint i = 0; i < this.SubDirectoryCount; i++) { this.SubDirectoryLbas[i] = ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(directoryBytes, (int)(0x44 + (i * 4)), 4)); } }
public NullDcGdiDirectoryRecord(byte[] directoryBytes, bool volumeContainsXaData) { byte[] xaAttributes; ushort xaItemDetails; this.LengthOfDirectoryRecord = directoryBytes[0]; if (this.LengthOfDirectoryRecord > 0) { this.ExtendedAttributeRecordLength = directoryBytes[1]; this.LocationOfExtent = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(directoryBytes, 2, 4), 0); this.DataLength = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(directoryBytes, 0x0A, 4), 0); if (ParseFile.CompareSegmentUsingSourceOffset(directoryBytes, 0x12, Iso9660.EMPTY_FILE_DATETIME.Length, Iso9660.EMPTY_FILE_DATETIME)) { this.RecordingDateAndTime = DateTime.MinValue; } else { this.RecordingDateAndTime = new DateTime(directoryBytes[0x12] + 1900, directoryBytes[0x13], directoryBytes[0x14], directoryBytes[0x15], directoryBytes[0x16], directoryBytes[0x17]); } this.FileFlags = directoryBytes[0x19]; this.FlagExistance = (this.FileFlags & 0x1) == 0x1 ? true : false; this.FlagDirectory = (this.FileFlags & 0x2) == 0x2 ? true : false; this.FlagAssociatedFile = (this.FileFlags & 0x4) == 0x4 ? true : false; this.FlagRecord = (this.FileFlags & 0x08) == 0x08 ? true : false; this.FlagProtection = (this.FileFlags & 0x10) == 0x10 ? true : false; this.FlagMultiExtent = (this.FileFlags & 0x80) == 0x80 ? true : false; this.FileUnitSize = directoryBytes[0x1A]; this.InterleaveGapSize = directoryBytes[0x1B]; this.VolumeSequenceNumber = BitConverter.ToUInt16(ParseFile.ParseSimpleOffset(directoryBytes, 0x1C, 2), 0); this.LengthOfFileIdentifier = directoryBytes[0x20]; this.FileIdentifier = ParseFile.ParseSimpleOffset(directoryBytes, 0x21, this.LengthOfFileIdentifier); // parse identifier if ((this.LengthOfFileIdentifier == 1) && (this.FileIdentifier[0] == 0)) { this.FileIdentifierString = "."; } else if ((this.LengthOfFileIdentifier == 1) && (this.FileIdentifier[0] == 1)) { this.FileIdentifierString = ".."; } else if (this.LengthOfFileIdentifier > 0) { this.FileIdentifierString = ByteConversion.GetEncodedText(this.FileIdentifier, ByteConversion.GetPredictedCodePageForTags(this.FileIdentifier)); } if (this.LengthOfFileIdentifier % 2 == 0) { this.PaddingField = ParseFile.ParseSimpleOffset(directoryBytes, 0x21 + this.LengthOfFileIdentifier, 1); } else { this.PaddingField = new byte[0]; } this.ItemMode = CdSectorType.Unknown; // CD-XA if (volumeContainsXaData) { if (directoryBytes.Length >= (0x21 + this.LengthOfFileIdentifier + this.PaddingField.Length + 0xE)) { xaAttributes = ParseFile.ParseSimpleOffset(directoryBytes, 0x21 + this.LengthOfFileIdentifier + this.PaddingField.Length, 0xE); //verify cut size // verify this is an XA entry if (ParseFile.CompareSegmentUsingSourceOffset(xaAttributes, 6, XA_SIGNATURE.Length, XA_SIGNATURE)) { xaItemDetails = ByteConversion.GetUInt16BigEndian(ParseFile.ParseSimpleOffset(xaAttributes, 4, 2)); if ((xaItemDetails & XA_ATTR_INTERLEAVED) == XA_ATTR_INTERLEAVED) { this.ItemMode = CdSectorType.XaInterleaved; this.DataLength = (uint)(this.DataLength / (uint)CdRom.NON_RAW_SECTOR_SIZE) * (uint)CdRom.RAW_SECTOR_SIZE; } else if ((xaItemDetails & XA_ATTR_MODE2FORM1) == XA_ATTR_MODE2FORM1) { this.ItemMode = CdSectorType.Mode2Form1; } else if ((xaItemDetails & XA_ATTR_MODE2FORM2) == XA_ATTR_MODE2FORM2) { this.ItemMode = CdSectorType.Mode2Form2; this.DataLength = (uint)(this.DataLength / (uint)CdRom.NON_RAW_SECTOR_SIZE) * (uint)CdRom.RAW_SECTOR_SIZE; } else if ((xaItemDetails & XA_ATTR_CDDA) == XA_ATTR_CDDA) { this.ItemMode = CdSectorType.Audio; this.DataLength = (uint)(this.DataLength / (uint)CdRom.NON_RAW_SECTOR_SIZE) * (uint)CdRom.RAW_SECTOR_SIZE; } else { this.ItemMode = CdSectorType.Unknown; } } } } /* * public byte[] SystemUse { set; get; } */ } }
public GreenBookCdiDirectoryRecord(byte[] directoryBytes) { this.LengthOfDirectoryRecord = directoryBytes[0]; if (this.LengthOfDirectoryRecord > 0) { this.ExtendedAttributeRecordLength = directoryBytes[1]; this.LocationOfExtent = ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(directoryBytes, 6, 4)); this.DataLength = ByteConversion.GetUInt32BigEndian(ParseFile.ParseSimpleOffset(directoryBytes, 0x0E, 4)); this.RecordingDateAndTime = new DateTime(directoryBytes[0x12] + 1900, directoryBytes[0x13], directoryBytes[0x14], directoryBytes[0x15], directoryBytes[0x16], directoryBytes[0x17]); this.FileFlags = directoryBytes[this.LengthOfDirectoryRecord - 6]; ushort cdiItemDetails = ByteConversion.GetUInt16BigEndian(ParseFile.ParseSimpleOffset(directoryBytes, this.LengthOfDirectoryRecord - 6, 2)); if ((cdiItemDetails & CDI_ATTR_DIRECTORY) == CDI_ATTR_DIRECTORY) { this.FlagDirectory = true; } //else if ((cdiItemDetails & CDI_ATTR_MODE2FORM1) == CDI_ATTR_MODE2FORM1) //{ // this.ItemMode = CdSectorType.Mode2Form1; //} //else if ((cdiItemDetails & CDI_ATTR_MODE2FORM2) == CDI_ATTR_MODE2FORM2) //{ // this.ItemMode = CdSectorType.Mode2Form2; // this.DataLength = (uint)(this.DataLength / (uint)CdRom.NON_RAW_SECTOR_SIZE) * (uint)CdRom.RAW_SECTOR_SIZE; //} //else if ((cdiItemDetails & CDI_ATTR_CDDA) == CDI_ATTR_CDDA) //{ // this.ItemMode = CdSectorType.Audio; // this.DataLength = (uint)(this.DataLength / (uint)CdRom.NON_RAW_SECTOR_SIZE) * (uint)CdRom.RAW_SECTOR_SIZE; //} //else //{ // this.ItemMode = CdSectorType.Unknown; //} /* * this.FlagExistance = (this.FileFlags & 0x1) == 0x1 ? true : false; * this.FlagDirectory = (this.FileFlags & 0x2) == 0x2 ? true : false; * this.FlagAssociatedFile = (this.FileFlags & 0x4) == 0x4 ? true : false; * this.FlagRecord = (this.FileFlags & 0x08) == 0x08 ? true : false; * this.FlagProtection = (this.FileFlags & 0x10) == 0x10 ? true : false; * this.FlagMultiExtent = (this.FileFlags & 0x80) == 0x80 ? false : true; */ this.FileUnitSize = directoryBytes[0x1A]; this.InterleaveGapSize = directoryBytes[0x1B]; this.VolumeSequenceNumber = BitConverter.ToUInt16(ParseFile.ParseSimpleOffset(directoryBytes, 0x1E, 2), 0); this.LengthOfFileIdentifier = directoryBytes[0x20]; this.FileIdentifier = ParseFile.ParseSimpleOffset(directoryBytes, 0x21, this.LengthOfFileIdentifier); // parse identifier if (this.LengthOfFileIdentifier > 1) { this.FileIdentifierString = ByteConversion.GetEncodedText(this.FileIdentifier, ByteConversion.GetPredictedCodePageForTags(this.FileIdentifier)); } else if (this.FileIdentifier[0] == 0) { this.FileIdentifierString = "."; } else if (this.FileIdentifier[0] == 1) { this.FileIdentifierString = ".."; } /* * * public byte[] PaddingField { set; get; } * public byte[] SystemUse { set; get; } */ } }
private void parseDirectoryRecord( FileStream isoStream, NintendoGameCubeDirectoryRecord directoryRecord, DateTime creationDateTime, long baseOffset, long rootDirectoryOffset, long directoryOffset, long nameTableOffset, string parentDirectory, int offsetBitShiftValue) { long directoryRecordEndOffset; long newDirectoryEndOffset; long currentOffset = baseOffset + directoryOffset; int itemNameSize; byte[] itemNameBytes; string itemName; NintendoGameCubeDirectoryRecord newDirectoryRecord; NintendoGameCubeDirectoryStructure newDirectory; NintendoGameCubeFileStructure newFile; directoryRecordEndOffset = rootDirectoryOffset + (directoryRecord.FileSize * 0xC); currentOffset += 0xC; while (currentOffset < directoryRecordEndOffset) { newDirectoryRecord = new NintendoGameCubeDirectoryRecord(ParseFile.ParseSimpleOffset(isoStream, currentOffset, 0xC), offsetBitShiftValue); itemNameSize = ParseFile.GetSegmentLength(isoStream, (int)(nameTableOffset + newDirectoryRecord.NameOffset), Constants.NullByteArray); itemNameBytes = ParseFile.ParseSimpleOffset(isoStream, nameTableOffset + newDirectoryRecord.NameOffset, itemNameSize); itemName = ByteConversion.GetEncodedText(itemNameBytes, ByteConversion.GetPredictedCodePageForTags(itemNameBytes)); if (!newDirectoryRecord.IsDirectory) { newFile = new NintendoGameCubeFileStructure(parentDirectory, this.SourceFilePath, itemName, baseOffset, newDirectoryRecord.FileOffset, newDirectoryRecord.FileSize, creationDateTime); this.FileArray.Add(newFile); currentOffset += 0xC; } else { newDirectory = new NintendoGameCubeDirectoryStructure(isoStream, isoStream.Name, newDirectoryRecord, creationDateTime, baseOffset, rootDirectoryOffset, currentOffset, nameTableOffset, itemName, parentDirectory, offsetBitShiftValue); this.SubDirectoryArray.Add(newDirectory); newDirectoryEndOffset = rootDirectoryOffset + (newDirectoryRecord.FileSize * 0xC); currentOffset = newDirectoryEndOffset; } } }
private void parseDirectoryRecord( FileStream isoStream, NintendoWiiOpticalDiscDirectoryRecord directoryRecord, DateTime creationDateTime, long baseOffset, long dataSectionOffset, long rootDirectoryOffset, long directoryOffset, long nameTableOffset, string parentDirectory, NintendoWiiEncryptedDiscReader discReader, byte[] partitionKey) { long directoryRecordEndOffset; long newDirectoryEndOffset; long currentOffset = directoryOffset; int itemNameSize; byte[] itemNameBytes; string itemName; byte[] newDirectoryRecordBytes; NintendoWiiOpticalDiscDirectoryRecord newDirectoryRecord; NintendoWiiOpticalDiscDirectoryStructure newDirectory; NintendoWiiOpticalDiscFileStructure newFile; directoryRecordEndOffset = rootDirectoryOffset + (directoryRecord.FileSize * 0xC); currentOffset += 0xC; while (currentOffset < directoryRecordEndOffset) { newDirectoryRecordBytes = discReader.GetBytes(isoStream, baseOffset, dataSectionOffset, currentOffset, 0xC, partitionKey); newDirectoryRecord = new NintendoWiiOpticalDiscDirectoryRecord(newDirectoryRecordBytes); itemNameBytes = discReader.GetBytes(isoStream, baseOffset, dataSectionOffset, nameTableOffset + newDirectoryRecord.NameOffset, 512, partitionKey); itemNameSize = ParseFile.GetSegmentLength(itemNameBytes, 0, Constants.NullByteArray); itemNameBytes = discReader.GetBytes(isoStream, baseOffset, dataSectionOffset, nameTableOffset + newDirectoryRecord.NameOffset, itemNameSize, partitionKey); itemName = ByteConversion.GetEncodedText(itemNameBytes, ByteConversion.GetPredictedCodePageForTags(itemNameBytes)); if (!newDirectoryRecord.IsDirectory) { newFile = new NintendoWiiOpticalDiscFileStructure(parentDirectory, this.SourceFilePath, itemName, baseOffset, dataSectionOffset, newDirectoryRecord.FileOffset, newDirectoryRecord.FileSize, creationDateTime, discReader, partitionKey); this.FileArray.Add(newFile); currentOffset += 0xC; } else { newDirectory = new NintendoWiiOpticalDiscDirectoryStructure(isoStream, isoStream.Name, newDirectoryRecord, creationDateTime, baseOffset, dataSectionOffset, rootDirectoryOffset, currentOffset, nameTableOffset, itemName, parentDirectory, discReader, partitionKey); this.SubDirectoryArray.Add(newDirectory); newDirectoryEndOffset = rootDirectoryOffset + (newDirectoryRecord.FileSize * 0xC); currentOffset = newDirectoryEndOffset; } } }
public string GetSetName() { return(ByteConversion.GetEncodedText( FileUtil.ReplaceNullByteWithSpace(this.IdGameTitle), ByteConversion.GetPredictedCodePageForTags(this.IdGameTitle)).Trim()); }