Пример #1
0
        public Dictionary <string, byte[]> unpackRam(Stream src)
        {
            Dictionary <string, byte[]> res = new Dictionary <string, byte[]>();
            BinaryDataReader            br  = new BinaryDataReader(src, false);

            br.ByteOrder = ByteOrder.BigEndian;

            br.BaseStream.Position = 0;
            br.ReadUInt32();               // Header
            br.ReadUInt16();               // Chunk length
            if (br.ReadUInt16() == 0xFFFE) // BOM
            {
                br.ByteOrder = ByteOrder.LittleEndian;
            }
            else
            {
                br.ByteOrder = ByteOrder.BigEndian;
            }
            br.ReadUInt32(); // File size
            UInt32 startingOff = br.ReadUInt32();

            br.ReadUInt32(); // Unknown;
            SFAT sfat = new SFAT();

            sfat.parse(br, (int)br.BaseStream.Position);
            SFNT sfnt = new SFNT();

            sfnt.parse(br, (int)br.BaseStream.Position, sfat, (int)startingOff);

            for (int m = 0; m < sfat.nodeCount; m++)
            {
                br.Seek(sfat.nodes[m].nodeOffset + startingOff, 0);
                byte[] temp;
                if (m == 0)
                {
                    temp = br.ReadBytes((int)sfat.nodes[m].EON);
                }
                else
                {
                    int tempInt = (int)sfat.nodes[m].EON - (int)sfat.nodes[m].nodeOffset;
                    temp = br.ReadBytes(tempInt);
                }
                res.Add(sfnt.fileNames[m], temp);
            }
            new SARC();
            return(res);
        }
Пример #2
0
        public static SarcData UnpackRamN(Stream src)
        {
            Dictionary <string, byte[]> res = new Dictionary <string, byte[]>();
            BinaryDataReader            br  = new BinaryDataReader(src, false);

            br.ByteOrder           = ByteOrder.LittleEndian;
            br.BaseStream.Position = 6;
            if (br.ReadUInt16() == 0xFFFE)
            {
                br.ByteOrder = ByteOrder.BigEndian;
            }
            br.BaseStream.Position = 0;
            if (br.ReadString(4) != "SARC")
            {
                throw new Exception("Wrong magic");
            }

            br.ReadUInt16();             // Chunk length
            br.ReadUInt16();             // BOM
            br.ReadUInt32();             // File size
            UInt32 startingOff = br.ReadUInt32();

            br.ReadUInt32();             // Unknown;
            SFAT sfat = new SFAT();

            sfat.parse(br, (int)br.BaseStream.Position);
            SFNT sfnt = new SFNT();

            sfnt.parse(br, (int)br.BaseStream.Position, sfat, (int)startingOff);

            bool HashOnly = false;

            if (sfat.nodeCount > 0)
            {
                if (sfat.nodes[0].fileBool != 1)
                {
                    HashOnly = true;
                }
            }

            for (int m = 0; m < sfat.nodeCount; m++)
            {
                br.Seek(sfat.nodes[m].nodeOffset + startingOff, 0);
                byte[] temp;
                if (m == 0)
                {
                    temp = br.ReadBytes((int)sfat.nodes[m].EON);
                }
                else
                {
                    int tempInt = (int)sfat.nodes[m].EON - (int)sfat.nodes[m].nodeOffset;
                    temp = br.ReadBytes(tempInt);
                }
                if (sfat.nodes[m].fileBool == 1)
                {
                    res.Add(sfnt.fileNames[m], temp);
                }
                else
                {
                    res.Add(sfat.nodes[m].hash.ToString("X8") + GuessFileExtension(temp), temp);
                }
            }

            return(new SarcData()
            {
                endianness = br.ByteOrder, HashOnly = HashOnly, Files = res
            });
        }