예제 #1
0
        private void BuildRomFsFile(FileStream isoStream, long ivfcOffset, long fileEntryOffset, long fileBlockOffset, long romFsDataOffset)
        {
            RomFsFileEntry file = new RomFsFileEntry();

            // Nintendo3dsCtrFile tempFile;
            byte[] nameBytes;

            // load dir
            file.ParentDirOffset = ParseFile.ReadUintLE(isoStream, ivfcOffset + fileBlockOffset + fileEntryOffset);
            file.SiblingOffset   = ParseFile.ReadInt32LE(isoStream, ivfcOffset + fileBlockOffset + fileEntryOffset + 4);
            file.DataOffset      = ParseFile.ReadUlongLE(isoStream, ivfcOffset + fileBlockOffset + fileEntryOffset + 8);
            file.DataSize        = ParseFile.ReadUlongLE(isoStream, ivfcOffset + fileBlockOffset + fileEntryOffset + 0x10);
            file.WeirdOffset     = ParseFile.ReadUintLE(isoStream, ivfcOffset + fileBlockOffset + fileEntryOffset + 0x18);
            file.NameSize        = ParseFile.ReadUintLE(isoStream, ivfcOffset + fileBlockOffset + fileEntryOffset + 0x1C);

            // build directory name
            if (file.NameSize > 0)
            {
                nameBytes = ParseFile.ParseSimpleOffset(isoStream, ivfcOffset + fileBlockOffset + fileEntryOffset + 0x20, (int)file.NameSize);
                file.Name = ByteConversion.GetUtf16LeText(nameBytes);
            }
            else // this is root
            {
                file.Name = "NO_NAME_FOUND"; // @TODO Make this a constant
            }

            this.FileName = file.Name;
            this.Offset   = ivfcOffset + romFsDataOffset + (long)file.DataOffset;
            this.Size     = (long)file.DataSize;

            // get sibling
            this.SiblingOffset = file.SiblingOffset;
        }
예제 #2
0
        private void BuildDirectory(FileStream isoStream, long ivfcOffset, long directoryEntryOffset, long directoryBlockOffset,
                                    long fileBlockOffset)
        {
            RomFsDirEntry           dir  = new RomFsDirEntry();
            RomFsFileEntry          file = new RomFsFileEntry();
            Nintendo3dsCtrDirectory tempDir;
            Nintendo3dsCtrFile      tempFile;

            byte[] nameBytes;
            string nextDirectory;

            // load dir
            dir.ParentOffset  = ParseFile.ReadUintLE(isoStream, ivfcOffset + directoryBlockOffset + directoryEntryOffset);
            dir.SiblingOffset = ParseFile.ReadInt32LE(isoStream, ivfcOffset + directoryBlockOffset + directoryEntryOffset + 4);
            dir.ChildOffset   = ParseFile.ReadInt32LE(isoStream, ivfcOffset + directoryBlockOffset + directoryEntryOffset + 8);
            dir.FileOffset    = ParseFile.ReadInt32LE(isoStream, ivfcOffset + directoryBlockOffset + directoryEntryOffset + 0xC);
            dir.WeirdOffset   = ParseFile.ReadInt32LE(isoStream, ivfcOffset + directoryBlockOffset + directoryEntryOffset + 0x10);
            dir.NameSize      = ParseFile.ReadUintLE(isoStream, ivfcOffset + directoryBlockOffset + directoryEntryOffset + 0x14);

            // build directory name
            if (dir.NameSize > 0)
            {
                nameBytes = ParseFile.ParseSimpleOffset(isoStream, ivfcOffset + directoryBlockOffset + directoryEntryOffset + 0x18, (int)dir.NameSize);
                dir.Name  = ByteConversion.GetUtf16LeText(nameBytes);
            }
            else // this is root
            {
                dir.Name = "RomFS"; // @TODO Make this a constant
            }

            this.DirectoryName = dir.Name;
            nextDirectory      = this.ParentDirectoryName + Path.DirectorySeparatorChar + this.DirectoryName;

            // add files
            if (dir.FileOffset != -1)
            {
                tempFile = new Nintendo3dsCtrFile(isoStream, nextDirectory, isoStream.Name,
                                                  null, ivfcOffset, -1, Nintendo3dsCtr.FileSystemType.RomFS, this.IvfcLevels[2],
                                                  dir.FileOffset, fileBlockOffset, this.RomFsDataOffset);
                this.FileArray.Add(tempFile);

                while (tempFile.SiblingOffset != -1)
                {
                    tempFile = new Nintendo3dsCtrFile(isoStream, nextDirectory, isoStream.Name,
                                                      null, ivfcOffset, -1, Nintendo3dsCtr.FileSystemType.RomFS, this.IvfcLevels[2],
                                                      tempFile.SiblingOffset, fileBlockOffset, this.RomFsDataOffset);

                    this.FileArray.Add(tempFile);
                }
            }

            // get sibling dir
            if (dir.SiblingOffset != -1)
            {
                tempDir = new Nintendo3dsCtrDirectory(isoStream, isoStream.Name, this.ParentDirectoryName,
                                                      ivfcOffset, Nintendo3dsCtr.FileSystemType.RomFS, this.IvfcLevels, dir.SiblingOffset, directoryBlockOffset,
                                                      fileBlockOffset, this.RomFsDataOffset);
                this.SiblingDirectory = tempDir;
            }

            // add subdirs
            if (dir.ChildOffset != -1)
            {
                tempDir = new Nintendo3dsCtrDirectory(isoStream, isoStream.Name, nextDirectory,
                                                      ivfcOffset, Nintendo3dsCtr.FileSystemType.RomFS, this.IvfcLevels, dir.ChildOffset, directoryBlockOffset,
                                                      fileBlockOffset, this.RomFsDataOffset);
                this.SubDirectoryArray.Add(tempDir);

                while (tempDir.SiblingDirectory != null)
                {
                    this.SubDirectoryArray.Add(tempDir.SiblingDirectory);
                    tempDir = tempDir.SiblingDirectory;
                }
            }
        }