Ejemplo n.º 1
0
        public void LoadDirectories(FileStream isoStream)
        {
            byte[] rootDirectoryBytes;
            NintendoWiiOpticalDiscDirectoryRecord    rootDirectoryRecord;
            NintendoWiiOpticalDiscDirectoryStructure rootDirectory;

            // Get name table offset
            rootDirectoryBytes = DiscReader.GetBytes(isoStream, this.VolumeBaseOffset,
                                                     this.DataOffset, this.RootDirectoryOffset, 0xC, this.PartitionKey);
            rootDirectoryRecord  = new NintendoWiiOpticalDiscDirectoryRecord(rootDirectoryBytes);
            this.NameTableOffset = this.RootDirectoryOffset + ((long)rootDirectoryRecord.FileSize * 0xC);

            rootDirectory = new NintendoWiiOpticalDiscDirectoryStructure(isoStream,
                                                                         isoStream.Name, rootDirectoryRecord, this.ImageCreationTime,
                                                                         this.VolumeBaseOffset, this.DataOffset, this.RootDirectoryOffset,
                                                                         this.RootDirectoryOffset, this.NameTableOffset,
                                                                         String.Empty, String.Empty, this.DiscReader, this.PartitionKey);

            this.DirectoryStructureArray.Add(rootDirectory);
        }
Ejemplo n.º 2
0
        public NintendoWiiOpticalDiscDirectoryStructure(
            FileStream isoStream,
            string sourceFilePath,
            NintendoWiiOpticalDiscDirectoryRecord directoryRecord,
            DateTime creationDateTime,
            long baseOffset,
            long dataSectionOffset,
            long rootDirectoryOffset,
            long directoryOffset,
            long nameTableOffset,
            string directoryName,
            string parentDirectory,
            NintendoWiiEncryptedDiscReader discReader,
            byte[] partitionKey)
        {
            string nextDirectory;

            this.SourceFilePath        = sourceFilePath;
            this.SubDirectoryArray     = new ArrayList();
            this.FileArray             = new ArrayList();
            this.DirectoryRecordOffset = directoryOffset;

            if (String.IsNullOrEmpty(parentDirectory))
            {
                this.ParentDirectoryName = String.Empty;
                this.DirectoryName       = directoryName;
                nextDirectory            = this.DirectoryName;
            }
            else
            {
                this.ParentDirectoryName = parentDirectory;
                this.DirectoryName       = directoryName;
                nextDirectory            = this.ParentDirectoryName + Path.DirectorySeparatorChar + this.DirectoryName;
            }

            this.parseDirectoryRecord(isoStream, directoryRecord, creationDateTime, baseOffset, dataSectionOffset, rootDirectoryOffset, directoryOffset, nameTableOffset, nextDirectory, discReader, partitionKey);
        }
Ejemplo n.º 3
0
        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;
                }
            }
        }