示例#1
0
        public CacheFile(HaloOnlineCacheContext cacheContext, FileInfo file, CacheVersion version, bool memory)
        {
            CacheContext = cacheContext;
            File         = file;
            Version      = version;
            Deserializer = new TagDeserializer(Version);

            Stream = memory ? new MemoryStream() : (Stream)file.OpenRead();

            if (memory)
            {
                using (var fileStream = file.OpenRead())
                {
                    fileStream.Seek(0, SeekOrigin.Begin);
                    fileStream.CopyTo(Stream);
                }
            }

            Reader = new EndianReader(Stream, EndianFormat.LittleEndian);

            Reader.SeekTo(0);
            if (Reader.ReadTag() == "daeh")
            {
                Reader.Format = EndianFormat.BigEndian;
            }

            Reader.SeekTo(0);
            Header = Deserializer.Deserialize <CacheFileHeader>(new DataSerializationContext(Reader));
        }
示例#2
0
        public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
        {
            result = null;

            if (args.Count != 2)
            {
                error = $"{args.Count} arguments supplied; should be 2";
                return(false);
            }
            else
            {
                var cacheAddressType = SetFieldCommand.ParseArgs(cacheContext, typeof(CacheResourceAddressType), null, args.Take(1).ToList());
                if (!(cacheAddressType is CacheResourceAddressType))
                {
                    error = $"Failed to parse `{args[0]}` as `CacheAddressType`";
                    return(false);
                }
                else if (!int.TryParse(args[1], out int offset))
                {
                    error = $"Failed to parse `{args[1]}` as `int` (offset).";
                    return(false);
                }
                else
                {
                    result = new CacheResourceAddress((cacheAddressType as CacheResourceAddressType?).Value, offset);
                    error  = null;
                    return(true);
                }
            }
        }
示例#3
0
        public CacheFileGen3(HaloOnlineCacheContext cacheContext, FileInfo file, CacheVersion version, bool memory)
            : base(cacheContext, file, version, memory)
        {
            if (Header.Interop.ResourceBaseAddress == 0)
            {
                Magic = (int)(Header.Interop.RuntimeBaseAddress - Header.MemoryBufferSize);
            }
            else
            {
                Header.Magic = Header.StringIDsIndicesOffset - (int)TagStructure.GetTagStructureInfo(typeof(CacheFileHeader), version).TotalSize;

                Header.TagNamesBufferOffset   -= Header.Magic;
                Header.TagNamesIndicesOffset  -= Header.Magic;
                Header.StringIDsIndicesOffset -= Header.Magic;
                Header.StringIDsBufferOffset  -= Header.Magic;

                var resourcePartition = Header.Partitions[(int)CacheFilePartitionType.Resources];
                var resourceSection   = Header.Interop.Sections[(int)CacheFileSectionType.Resource];
                Magic = BitConverter.ToInt32(BitConverter.GetBytes(resourcePartition.BaseAddress), 0) - (Header.Interop.DebugSectionSize + resourceSection.Size);
            }

            if (Header.TagIndexAddress == 0)
            {
                return;
            }

            Header.TagIndexAddress = BitConverter.ToUInt32(BitConverter.GetBytes(Header.TagIndexAddress - Magic), 0);

            IndexHeader  = new CacheIndexHeader(this);
            IndexItems   = new IndexTable(this);
            Strings      = new StringTable(this);
            LocaleTables = new List <LocaleTable>();

            switch (version)
            {
            case CacheVersion.Halo3Retail:
                Resolver = new StringIdResolverHalo3();
                break;

            case CacheVersion.Halo3ODST:
                Resolver = new StringIdResolverHalo3ODST();
                break;

            case CacheVersion.HaloReach:
                Resolver = new StringIdResolverHaloReach();
                break;

            default:
                throw new NotSupportedException(CacheVersionDetection.GetBuildName(version));
            }

            foreach (var language in Enum.GetValues(typeof(GameLanguage)))
            {
                LocaleTables.Add(new LocaleTable(this, (GameLanguage)language));
            }
        }
示例#4
0
 public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 1)
     {
         error = $"{args.Count} arguments supplied; should be 1";
         return(false);
     }
     else if (!cacheContext.TryGetTag(args[0], out var tag))
     {
         error = $"Unable to locate tag: {args[0]}";
         return(false);
     }
     else
     {
         result = tag;
         error  = null;
         return(true);
     }
 }
示例#5
0
        public CacheFileGen2(HaloOnlineCacheContext cacheContext, FileInfo file, CacheVersion version, bool memory) :
            base(cacheContext, file, version, memory)
        {
            if (file.Name == "mainmenu.map" && MainMenuCache?.File.FullName != file.FullName)
            {
                MainMenuCache = this;
            }
            else if (file.Name == "shared.map" && SharedCache?.File.FullName != file.FullName)
            {
                SharedCache = this;
            }
            else if (file.Name == "single_player_shared.map" && SharedCache?.File.FullName != file.FullName)
            {
                SinglePlayerSharedCache = this;
            }

            IndexHeader  = new CacheIndexHeader(this);
            IndexItems   = new IndexTable(this);
            Strings      = new StringTable(this);
            LocaleTables = new List <LocaleTable>();
        }