Example #1
0
        public void ExtractFile(out byte[] buffer, DiscFile discfile)
        {
            buffer = new byte[discfile.Size];

            //Salva as configurações antigas da partição
            uint pro = PartitionRawOffset;
            uint pdo = PartitionDataOffset;
            uint pds = PartitionDataSize;
            uint pbl = PartitionBlock;

            //Seta as configurações para a partição alvo

            PartitionRawOffset  = Partitions[discfile.Partition].RawOffset;
            PartitionDataOffset = Partitions[discfile.Partition].DataOffset;
            PartitionDataSize   = Partitions[discfile.Partition].DataSize;
            PartitionBlock      = Partitions[discfile.Partition].Block;

            //Lê o arquivo
            PartitionRead(discfile.Offset, buffer, discfile.Size, false);

            //Restaura as configurações antigas de partição
            PartitionRawOffset  = pro;
            PartitionDataOffset = pdo;
            PartitionDataSize   = pds;
            PartitionBlock      = pbl;
        }
Example #2
0
        public void ExtractFile(String outfile, DiscFile discfile)
        {
            byte[] buffer;
            ExtractFile(out buffer, discfile);

            File.WriteAllBytes(outfile, buffer);
            buffer = null;
        }
Example #3
0
        public uint DoFst(byte[] fst, uint namespos, uint i)
        {
            uint size = _be32(fst, 12 * i + 8);

            if (i == 0)
            {
                for (uint j = 1; j < size;)
                {
                    j = DoFst(fst, namespos, j);
                }

                return(size);
            }

            if (fst[12 * i] != 0)
            {
                for (uint j = i + 1; j < size;)
                {
                    j = DoFst(fst, namespos, j);
                }
                return(size);
            }
            else
            {
                uint offset = _be32(fst, 12 * i + 4);
                PartitionRead(offset, null, size, true);

                if (GenerateExtendedInfo)
                {
                    String name = "";
                    Char   c    = '\0';
                    int    k    = (int)(namespos + (_be32(fst, 12 * i) & 0x00ffffff));
                    while ((c = (char)fst[k]) != '\0')
                    {
                        name += c; k++;
                    }

                    DiscFile f = new DiscFile();
                    f.Name      = name;
                    f.Size      = size;
                    f.Offset    = offset;
                    f.Partition = partIndex;

                    Partitions[partIndex].Files[fileIndex++] = f;
                }

                return(i + 1);
            }
        }
Example #4
0
        public void DoFiles()
        {
            byte[] b = new byte[0x480];
            PartitionRead(0, b, 0x480, false);

            uint dol_offset = _be32(b, 0x0420);
            uint fst_offset = _be32(b, 0x0424);
            uint fst_size   = _be32(b, 0x0428) << 2;

            uint apl_offset = 0x2440 >> 2;

            byte[] apl_header = new byte[0x20];
            PartitionRead(apl_offset, apl_header, 32, false);
            uint apl_size = 0x20 + _be32(apl_header, 0x14) + _be32(apl_header, 0x18);

            PartitionRead(apl_offset, null, apl_size, true);
            PartitionRead(dol_offset, null, (fst_offset - dol_offset) << 2, true);

            byte[] fst = new byte[fst_size];
            PartitionRead(fst_offset, fst, fst_size, false);

            uint nFiles = _be32(fst, 8);

            if (GenerateExtendedInfo)
            {
                Partitions[partIndex].Files = new DiscFile[nFiles];
            }

            if (nFiles > 1)
            {
                DoFst(fst, 12 * nFiles, 0);
            }

            if (GenerateExtendedInfo)
            {
                DiscFile[] trim = new DiscFile[fileIndex];
                Array.Copy(Partitions[partIndex].Files, trim, fileIndex);

                Partitions[partIndex].Files = null;
                Partitions[partIndex].Files = trim;
                trim = null;
            }

            b          = null;
            apl_header = null;
            fst        = null;
        }