コード例 #1
0
ファイル: ARC.cs プロジェクト: ScanMountGoat/ArcCross
        /// <summary>
        /// Reads file system table from Arc
        /// </summary>
        /// <param name="fileSystemTable"></param>
        private void ReadFileSystem(byte[] fileSystemTable)
        {
            using (ExtBinaryReader reader = new ExtBinaryReader(new MemoryStream(fileSystemTable)))
            {
                FSHeader = reader.ReadType <_sFileSystemHeader>();

                uint ExtraFolder = 0;
                uint ExtraCount  = 0;

                if (fileSystemTable.Length >= 0x2992DD4)
                {
                    // Version 3+
                    Version = reader.ReadInt32();

                    ExtraFolder = reader.ReadUInt32();
                    ExtraCount  = reader.ReadUInt32();

                    reader.ReadBytes(0x10);  // some extra thing :thinking
                }
                else
                {
                    Version = 0x00020000;
                    reader.BaseStream.Seek(0x3C, SeekOrigin.Begin);
                }

                // skip this for now
                regionalbytes = reader.ReadBytes(0xE * 12);

                // Streams
                StreamHeader = reader.ReadType <_sStreamHeader>();

                streamUnk = reader.ReadType <_sStreamUnk>(StreamHeader.UnkCount);

                streamHashToName = reader.ReadType <_sStreamHashToName>(StreamHeader.StreamHashCount);

                streamNameToHash = reader.ReadType <_sStreamNameToHash>(StreamHeader.StreamHashCount);

                streamIndexToFile = reader.ReadType <_sStreamIndexToOffset>(StreamHeader.StreamIndexToOffsetCount);

                streamOffsets = reader.ReadType <_sStreamOffset>(StreamHeader.StreamOffsetCount);

                Console.WriteLine(reader.BaseStream.Position.ToString("X"));

                // Unknown
                uint UnkCount1 = reader.ReadUInt32();
                uint UnkCount2 = reader.ReadUInt32();
                fileInfoUnknownTable     = reader.ReadType <_sFileInformationUnknownTable>(UnkCount2);
                filePathToIndexHashGroup = reader.ReadType <_sHashIndexGroup>(UnkCount1);

                // FileTables

                fileInfoPath = reader.ReadType <_sFileInformationPath>(FSHeader.FileInformationPathCount);

                fileInfoIndex = reader.ReadType <_sFileInformationIndex>(FSHeader.FileInformationIndexCount);

                // directory tables

                // directory hashes by length and index to directory probably 0x6000 something
                Console.WriteLine(reader.BaseStream.Position.ToString("X"));
                directoryHashGroup = reader.ReadType <_sHashIndexGroup>(FSHeader.DirectoryCount);

                directoryList = reader.ReadType <_sDirectoryList>(FSHeader.DirectoryCount);

                directoryOffsets = reader.ReadType <_sDirectoryOffset>(FSHeader.DirectoryOffsetCount1 + FSHeader.DirectoryOffsetCount2 + ExtraFolder);

                directoryChildHashGroup = reader.ReadType <_sHashIndexGroup>(FSHeader.DirectoryHashSearchCount);

                // file information tables
                Console.WriteLine(reader.BaseStream.Position.ToString("X"));
                fileInfoV2 = reader.ReadType <_sFileInformationV2>(FSHeader.FileInformationCount + FSHeader.SubFileCount2 + ExtraCount);

                fileInfoSubIndex = reader.ReadType <_sFileInformationSubIndex>(FSHeader.FileInformationSubIndexCount + FSHeader.SubFileCount2 + ExtraCount);

                subFiles = reader.ReadType <_sSubFileInfo>(FSHeader.SubFileCount + FSHeader.SubFileCount2);

                Console.WriteLine(reader.BaseStream.Position.ToString("X"));
                //uint max = 0;

                /*using (StreamWriter writer = new StreamWriter(new FileStream("FS1.txt", FileMode.Create)))
                 *  for (int i = 0; i < (int)FSHeader.FileInformationCount; i++)
                 *  {
                 *      var fileinfo = fileInfoV2[i];
                 *      var path = fileInfoPath[fileinfo.PathIndex];
                 *      var subindex = fileInfoSubIndex[fileinfo.SubIndexIndex];
                 *      writer.WriteLine(fileinfo.Flags.ToString("X") + " " + fileinfo.PathIndex.ToString("X") + " " + subindex.SubFileIndex.ToString("X") + " " + HashDict.GetString(path.Path) + " " + HashDict.GetString(path.FileName));
                 *      //max = Math.Max(max, fp.SomeIndex2);
                 *  }
                 * using (StreamWriter writer = new StreamWriter(new FileStream("FS2.txt", FileMode.Create)))
                 * for (int i = (int)FSHeader.FileInformationCount ;i < fileInfoV2.Length; i++)
                 *  {
                 *      var fileinfo = fileInfoV2[i];
                 *      var path = fileInfoPath[fileinfo.PathIndex];
                 *      var subindex = fileInfoSubIndex[fileinfo.SubIndexIndex];
                 *      writer.WriteLine(fileinfo.Flags.ToString("X") + " " + fileinfo.PathIndex.ToString("X") + " " + subindex.SubFileIndex.ToString("X") + " " + HashDict.GetString(path.Path) + " " + HashDict.GetString(path.FileName));
                 *      //max = Math.Max(max, fp.SomeIndex2);
                 *  }*/
                //Console.WriteLine("Max: " + max.ToString("X"));

                /*int MaxIntTableValue = 0;
                 * foreach (var g in fileInfoIndex)
                 * {
                 *  MaxIntTableValue = Math.Max((int)g.FileInformationIndex, MaxIntTableValue);
                 *  //Console.WriteLine(HashDict.GetString(g.Hash));
                 * }
                 * Console.WriteLine("Max table value: " + MaxIntTableValue.ToString("X"));*/

                /*var flags = new System.Collections.Generic.List<uint>();
                 * foreach (var g in fileInfoV2)
                 * {
                 *  if (!flags.Contains(g.Flags))
                 *      flags.Add(g.Flags);
                 * }*/
                /*using (StreamWriter writer = new StreamWriter(new FileStream("print.txt", FileMode.Create)))
                 *  foreach (var g in PathNameHashLengthLookup)
                 *  {
                 *      writer.WriteLine(HashDict.GetString(g.FilePathHash) + " " + HashDict.GetString(PathNameHashGroupLookup[IndexTable[g.ExtensionHash]].FileNameHash));
                 *  }*/
            }
        }
コード例 #2
0
ファイル: ARC.cs プロジェクト: jam1garner/ArcCross
        /// <summary>
        /// Reads file system table from Arc
        /// </summary>
        /// <param name="fileSystemTable"></param>
        private void ReadFileSystem(byte[] fileSystemTable)
        {
            using (ExtBinaryReader reader = new ExtBinaryReader(new MemoryStream(fileSystemTable)))
            {
                fsHeader = reader.ReadType <_sFileSystemHeader>();

                uint extraFolder   = 0;
                uint extraCount    = 0;
                uint extraCount2   = 0;
                uint extraSubCount = 0;

                if (fileSystemTable.Length >= 0x2992DD4)
                {
                    // Version 3+
                    Version = reader.ReadInt32();

                    extraFolder = reader.ReadUInt32();
                    extraCount  = reader.ReadUInt32();

                    reader.ReadBytes(8);  // some extra thing :thinking
                    extraCount2   = reader.ReadUInt32();
                    extraSubCount = reader.ReadUInt32();
                }
                else
                {
                    Version = 0x00020000;
                    reader.BaseStream.Seek(0x3C, SeekOrigin.Begin);
                }

                // skip this for now
                regionalBytes = reader.ReadBytes(0xE * 12);

                // Streams
                streamHeader = reader.ReadType <_sStreamHeader>();

                streamUnk = reader.ReadType <_sStreamUnk>(streamHeader.UnkCount);

                streamHashToName = reader.ReadType <_sStreamHashToName>(streamHeader.StreamHashCount);

                streamNameToHash = reader.ReadType <_sStreamNameToHash>(streamHeader.StreamHashCount);

                streamIndexToFile = reader.ReadType <_sStreamIndexToOffset>(streamHeader.StreamIndexToOffsetCount);

                streamOffsets = reader.ReadType <_sStreamOffset>(streamHeader.StreamOffsetCount);

                Console.WriteLine(reader.BaseStream.Position.ToString("X"));

                // Unknown
                uint unkCount1 = reader.ReadUInt32();
                uint unkCount2 = reader.ReadUInt32();
                fileInfoUnknownTable     = reader.ReadType <_sFileInformationUnknownTable>(unkCount2);
                filePathToIndexHashGroup = reader.ReadType <_sHashIndexGroup>(unkCount1);

                // FileTables

                fileInfoPath = reader.ReadType <_sFileInformationPath>(fsHeader.FileInformationPathCount);

                fileInfoIndex = reader.ReadType <_sFileInformationIndex>(fsHeader.FileInformationIndexCount);

                // directory tables

                // directory hashes by length and index to directory probably 0x6000 something
                Console.WriteLine(reader.BaseStream.Position.ToString("X"));
                directoryHashGroup = reader.ReadType <_sHashIndexGroup>(fsHeader.DirectoryCount);

                directoryList = reader.ReadType <_sDirectoryList>(fsHeader.DirectoryCount);

                directoryOffsets = reader.ReadType <_sDirectoryOffset>(fsHeader.DirectoryOffsetCount1 + fsHeader.DirectoryOffsetCount2 + extraFolder);

                directoryChildHashGroup = reader.ReadType <_sHashIndexGroup>(fsHeader.DirectoryHashSearchCount);

                // file information tables
                Console.WriteLine(reader.BaseStream.Position.ToString("X"));
                fileInfoV2 = reader.ReadType <_sFileInformationV2>(fsHeader.FileInformationCount + fsHeader.SubFileCount2 + extraCount);

                fileInfoSubIndex = reader.ReadType <_sFileInformationSubIndex>(fsHeader.FileInformationSubIndexCount + fsHeader.SubFileCount2 + extraCount2);

                subFiles = reader.ReadType <_sSubFileInfo>(fsHeader.SubFileCount + fsHeader.SubFileCount2 + extraSubCount);
                Console.WriteLine("End:" + reader.BaseStream.Position.ToString("X"));
            }
        }