Exemplo n.º 1
0
        public static DrsFile Load(string fileName)
        {
            var ret = new DrsFile();

            using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (var br = new BinaryReader(fs, Encoding.ASCII))
                {
                    stackPos.Clear();
                    ret.signature = br.ReadBytes(56);
                    var numTables = br.ReadUInt32();
                    br.ReadUInt32();
                    for (var i = 0; i < numTables; i++)
                    {
                        var entries = new SortedDictionary <int, byte[]>();
                        ret.Add((DrsTableClass)Array.IndexOf(TableClassSignatures, new string(br.ReadChars(4))), entries);
                        var offset     = br.ReadInt32();
                        var numEntries = br.ReadInt32();
                        SavePositionAndSeek(fs, offset);
                        for (var j = 0; j < numEntries; j++)
                        {
                            var id         = br.ReadInt32();
                            var dataOffset = br.ReadInt32();
                            var size       = br.ReadInt32();
                            SavePositionAndSeek(fs, dataOffset);
                            entries.Add(id, br.ReadBytes(size));
                            RestorePosition(fs);
                        }
                        RestorePosition(fs);
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var drs = DrsFile.Load(@"D:\HawkEmpire\Manager\drs\graphics.drs");

            drs.Save(@"d:\graphics.drs");
            Console.WriteLine("Done");
            Console.ReadKey();
        }