예제 #1
0
        internal static SARC analyzeSARC(string path)
        {
            SARC sarc = new SARC
            {
                FileName  = Path.GetFileNameWithoutExtension(path),
                FilePath  = Path.GetDirectoryName(path),
                Extension = Path.GetExtension(path)
            };
            BinaryReader br = new BinaryReader(File.OpenRead(path));

            sarc.valid     = true;
            sarc.Signature = new string(br.ReadChars(4));
            if (sarc.Signature != "SARC")
            {
                sarc.valid = false;
                return(sarc);
            }
            sarc.HeaderSize = br.ReadUInt16();
            sarc.Endianness = br.ReadUInt16();
            sarc.FileSize   = br.ReadUInt32();
            sarc.DataOffset = br.ReadUInt32();
            sarc.Unknown    = br.ReadUInt32();
            sarc.SFat       = new SFAT {
                Signature = new string(br.ReadChars(4))
            };
            if (sarc.SFat.Signature != "SFAT")
            {
                sarc.valid = false;
                return(sarc);
            }
            sarc.SFat.HeaderSize = br.ReadUInt16();
            sarc.SFat.EntryCount = br.ReadUInt16();
            sarc.SFat.HashMult   = br.ReadUInt32();
            sarc.SFat.Entries    = new List <SFATEntry>();
            for (int i = 0; i < sarc.SFat.EntryCount; i++)
            {
                SFATEntry s = new SFATEntry
                {
                    FileNameHash   = br.ReadUInt32(),
                    FileNameOffset = br.ReadUInt32(),
                    FileDataStart  = br.ReadUInt32(),
                    FileDataEnd    = br.ReadUInt32()
                };
                sarc.SFat.Entries.Add(s);
            }
            sarc.SFnt = new SFNT {
                Signature = new string(br.ReadChars(4))
            };
            if (sarc.SFnt.Signature != "SFNT")
            {
                sarc.valid = false;
                return(sarc);
            }
            sarc.SFnt.HeaderSize   = br.ReadUInt16();
            sarc.SFnt.Unknown      = br.ReadUInt16();
            sarc.SFnt.StringOffset = (uint)br.BaseStream.Position;
            return(sarc);
        }
예제 #2
0
파일: ARCUtil.cs 프로젝트: WilliamO7/pk3DS
 internal static SARC analyzeSARC(string path)
 {
     SARC sarc = new SARC
     {
         FileName = Path.GetFileNameWithoutExtension(path),
         FilePath = Path.GetDirectoryName(path),
         Extension = Path.GetExtension(path)
     };
     BinaryReader br = new BinaryReader(File.OpenRead(path));
     sarc.valid = true;
     sarc.Signature = new string(br.ReadChars(4));
     if (sarc.Signature != "SARC")
     {
         sarc.valid = false;
         return sarc;
     }
     sarc.HeaderSize = br.ReadUInt16();
     sarc.Endianness = br.ReadUInt16();
     sarc.FileSize = br.ReadUInt32();
     sarc.DataOffset = br.ReadUInt32();
     sarc.Unknown = br.ReadUInt32();
     sarc.SFat = new SFAT { Signature = new string(br.ReadChars(4)) };
     if (sarc.SFat.Signature != "SFAT")
     {
         sarc.valid = false;
         return sarc;
     }
     sarc.SFat.HeaderSize = br.ReadUInt16();
     sarc.SFat.EntryCount = br.ReadUInt16();
     sarc.SFat.HashMult = br.ReadUInt32();
     sarc.SFat.Entries = new List<SFATEntry>();
     for (int i = 0; i < sarc.SFat.EntryCount; i++)
     {
         SFATEntry s = new SFATEntry
         {
             FileNameHash = br.ReadUInt32(),
             FileNameOffset = br.ReadUInt32(),
             FileDataStart = br.ReadUInt32(),
             FileDataEnd = br.ReadUInt32()
         };
         sarc.SFat.Entries.Add(s);
     }
     sarc.SFnt = new SFNT { Signature = new string(br.ReadChars(4)) };
     if (sarc.SFnt.Signature != "SFNT")
     {
         sarc.valid = false;
         return sarc;
     }
     sarc.SFnt.HeaderSize = br.ReadUInt16();
     sarc.SFnt.Unknown = br.ReadUInt16();
     sarc.SFnt.StringOffset = (uint)br.BaseStream.Position;
     return sarc;
 }