private static CacheVersion DetectCacheVersion(EndianReader reader) { var version = GetMapFileVersion(reader); var buildDate = GetBuildDate(reader, version); return(CacheVersionDetection.GetFromBuildName(buildDate)); }
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)); } }
public uint TagAddressToOffset(uint address) { var baseAddress = CacheVersionDetection.IsInPlatform(CachePlatform.Only64Bit, Version) ? BaseMapFile.Header.VirtualBaseAddress64 : (ulong)BaseMapFile.Header.VirtualBaseAddress32; var unpackedAddress = CacheVersionDetection.IsInPlatform(CachePlatform.Only64Bit, Version) ? (((ulong)address << 2) + 0x50000000) : (ulong)address; return((uint)(unpackedAddress - (baseAddress - (ulong)BaseMapFile.Header.SectionTable.GetSectionOffset(CacheFileSectionType.TagSection)))); }
private static bool IsModifiedReachFormat(EndianReader reader) { reader.SeekTo(0x120); var version = CacheVersionDetection.GetFromBuildName(reader.ReadString(0x20)); if (version == CacheVersion.Unknown) { return(false); } else { return(true); } }
public HaloOnlineCacheContext(DirectoryInfo directory) : base(directory) { var tagNames = LoadTagNames(); using (var stream = OpenTagCacheRead()) TagCache = new TagCache(stream, tagNames); if (CacheVersion.Unknown == (Version = CacheVersionDetection.DetectFromTagCache(TagCache, out var closestVersion))) { Version = closestVersion; } Deserializer = new TagDeserializer(Version == CacheVersion.Unknown ? closestVersion : Version); Serializer = new TagSerializer(Version == CacheVersion.Unknown ? closestVersion : Version); StringIdResolver stringIdResolver = null; if (CacheVersionDetection.Compare(Version, CacheVersion.HaloOnline700123) >= 0) { stringIdResolver = new StringIdResolverMS30(); } else if (CacheVersionDetection.Compare(Version, CacheVersion.HaloOnline498295) >= 0) { stringIdResolver = new StringIdResolverMS28(); } else { stringIdResolver = new StringIdResolverMS23(); } using (var stream = OpenStringIdCacheRead()) StringIdCache = new StringIdCache(stream, stringIdResolver); TagGroup.Instances[new Tag("obje")] = new TagGroup(new Tag("obje"), Tag.Null, Tag.Null, GetStringId("object")); TagGroup.Instances[new Tag("item")] = new TagGroup(new Tag("item"), new Tag("obje"), Tag.Null, GetStringId("item")); TagGroup.Instances[new Tag("devi")] = new TagGroup(new Tag("devi"), new Tag("obje"), Tag.Null, GetStringId("device")); TagGroup.Instances[new Tag("unit")] = new TagGroup(new Tag("unit"), new Tag("obje"), Tag.Null, GetStringId("unit")); TagGroup.Instances[new Tag("rm ")] = new TagGroup(new Tag("rm "), Tag.Null, Tag.Null, GetStringId("render_method")); TagGroup.Instances[new Tag("test")] = new TagGroup(new Tag("test"), Tag.Null, Tag.Null, GetStringId("test_blah")); }
public GameCacheContextGen3(MapFile mapFile, EndianReader reader) { BaseMapFile = mapFile; Version = BaseMapFile.Version; Deserializer = new TagDeserializer(Version); LocalesKey = SetLocalesKey(); StringsKey = SetStringsKey(); TagsKey = SetTagsKey(); NetworkKey = SetNetworkKey(); StringMods = SetStringMods(); LocaleGlobalsSize = SetLocaleGlobalsSize(); LocaleGlobalsOffset = SetLocaleGlobalsOffset(); var interop = mapFile.Header.GetInterop(); if (interop != null && interop.ResourceBaseAddress == 0) { Magic = (int)(interop.RuntimeBaseAddress - mapFile.Header.GetMemoryBufferSize()); } else { mapFile.Header.ApplyMagic(mapFile.Header.GetStringIDsIndicesOffset() - mapFile.Header.GetHeaderSize(mapFile.Version)); var resourcePartition = mapFile.Header.GetPartitions()[(int)CacheFilePartitionType.Resources]; var resourceSection = interop.Sections[(int)CacheFileSectionType.Resource]; Magic = BitConverter.ToInt32(BitConverter.GetBytes(resourcePartition.BaseAddress), 0) - (interop.DebugSectionSize + resourceSection.Size); } if (mapFile.Header.GetTagIndexAddress() == 0) { return; } mapFile.Header.SetTagIndexAddress(BitConverter.ToUInt32(BitConverter.GetBytes(mapFile.Header.GetTagIndexAddress() - Magic), 0)); IndexHeader = mapFile.GetIndexHeader(reader, Magic); Strings = CreateStringTable(reader); IndexItems = CreateCacheIndexTable(reader); LocaleTables = new List <CacheLocaleTable>(); switch (mapFile.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(mapFile.Version)); } foreach (var language in Enum.GetValues(typeof(GameLanguage))) { LocaleTables.Add(CreateLocaleTable(reader, (GameLanguage)language)); } }