public Dictionary <string, string> GenerateRMPFilenames() { Dictionary <string, string> result = new Dictionary <string, string>(); foreach (KeyValuePair <Location, Unique> pair in LocationMap) { string hash1 = pair.Value.ContHashContainer.ContHashMD5_2.ToString("x"); string hash2 = pair.Value.ContHashContainer.ContHashMD5_1.ToString("x"); string hash3 = pair.Value.ContHashContainer.ContHashMD5_4.ToString("x"); string hash4 = pair.Value.ContHashContainer.ContHashMD5_3.ToString("x"); string hash5 = pair.Value.ContHashTex.ToString("x"); string fileSize = pair.Value.FileSize.ToString(); string filename = String.Format(RMPFormat, hash1, hash2, hash3, hash4, hash5, fileSize); string tmp = HashCollisionString.Substring((int)pair.Key.LocStrIdx); if (tmp.IndexOf('!') > 0) { tmp = tmp.Substring(0, tmp.IndexOf('!')); } tmp = MurmurHash2Shenmue.GetFullFilename(tmp, false).Substring(1); result.Add(tmp.Substring(0, tmp.Length - 9), filename); /* * uint hash2_ = MurmurHash2Shenmue.GetFilenameHashPlain(filename); * string fFilename = MurmurHash2Shenmue.GetFullFilename(filename, hash2_); * uint hash1_ = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0); * * Console.WriteLine("{0} => {1} LocHash: {2:X8} ({2}), FileSize: {3}, HashedFilename: {4} ({5:X8})", * tmp, filename, pair.Key.LocHash, pair.Value.FileSize, fFilename, hash1_); */ } return(result); }
/* * /engine/assets/shaders/uber_vs.hlsl?CAPS=_SHAD;_HASPRE;_BILLBOARD; */ public static void GenerateShaderFilenames() { foreach (string filename in ShaderFilenames) { uint secondHash = MurmurHash2Shenmue.GetFilenameHashPlain(filename); string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash); uint hash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0); FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, secondHash, fullFilename, ArchiveTypes.Shader); FilenameDatabase.Add(entry); } /* * List<List<string>> combos = GetAllCombos(ShaderSuffixParameter); * foreach(List<string> parameters in combos) * { * foreach (string fname in ShaderFilenames) * { * string filename = String.Format(Suffix, fname, parameters.Aggregate((i, j) => i + ";" + j)); * * uint secondHash = MurmurHash2Shenmue.GetFilenameHashPlain(filename, false); * string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash); * uint hash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0); * FilenameDatabase.Add(hash, secondHash, fullFilename); * * Console.WriteLine("[{0:X8}|{1:X8}] {2}", hash, secondHash, filename); * } * } */ }
public static void GenerateCommonFilenames() { //AssetRemapping.json string assetRemapping = MurmurHash2Shenmue.GetFullFilename(AssetRemapping, false); byte[] assetRemappingBuffer = MurmurHash2Shenmue.GetFilenameHash(assetRemapping, false); uint assetRemappingFirstHash = BitConverter.ToUInt32(assetRemappingBuffer, 0); FilenameDatabaseEntry e = new FilenameDatabaseEntry(assetRemappingFirstHash, 0, assetRemapping); FilenameDatabase.Add(e); bool exists = false; byte[] buffer = FilenameCrawler.GetBufferFromEntry(e, out exists); if (exists) { AssetRemappingJSON remappingStructure = new AssetRemappingJSON(buffer); List <string> BadMap = new List <string>(); List <string> BruteforceFilenames = new List <string>(); foreach (KeyValuePair <string, string> filename in remappingStructure.GenerateRMPFilenames()) { uint hash2 = MurmurHash2Shenmue.GetFilenameHashPlain(filename.Value); string fFilename = MurmurHash2Shenmue.GetFullFilename(filename.Value, hash2); uint hash1 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0); FilenameDatabase.Add(hash1, hash2, filename.Key); /* * string[] splitted = filename.Key.Split('/'); * string name = splitted[splitted.Length - 1]; * splitted = name.Split('.'); * name = splitted[0]; * if (char.IsDigit(name[name.Length - 1])) * { * string val = filename.Key.Substring(0, filename.Key.Length - 14); * if (!BadMap.Contains(val)) * { * BadMap.Add(val); * BruteforceFilenames.Add(filename.Key.Substring(0, filename.Key.Length - 9)); * } * } */ } /* * foreach (string filename in BruteforceFilenames) * { * string[] splitted = filename.Split('.'); * for (int i = 0; i < 9; i++) * { * string name = splitted[0].Substring(0, splitted[0].Length - 1); * * foreach (string ext in ImageExtensions) * { * string tmp = name + i.ToString() + "." + ext; * tmp = tmp.Remove(0, 12); * * uint secondHash = MurmurHash2Shenmue.GetFilenameHashPlain(tmp); * string fullFilename = MurmurHash2Shenmue.GetFullFilename(tmp, secondHash); * uint hash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0); * FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, secondHash, fullFilename); * FilenameDatabase.Add(entry); * } * } * } */ } //SDTextureOverride.json uint sdTextureOverrideSecondHash = MurmurHash2Shenmue.GetFilenameHashPlain(SDTextureOverride); string sdTextureOverride = MurmurHash2Shenmue.GetFullFilename(SDTextureOverride, sdTextureOverrideSecondHash); uint sdTextureOverrideFirstHash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(sdTextureOverride), 0); e = new FilenameDatabaseEntry(sdTextureOverrideFirstHash, sdTextureOverrideSecondHash, sdTextureOverride); FilenameDatabase.Add(e); exists = false; buffer = FilenameCrawler.GetBufferFromEntry(e, out exists); if (exists) { List <string> textures = GetSDTextureOverrideFiles(buffer); if (textures.Count > 0) { foreach (string texFilename in textures) { uint hash2 = MurmurHash2Shenmue.GetFilenameHashPlain(texFilename); string fFilename = MurmurHash2Shenmue.GetFullFilename(texFilename, hash2); uint hash1 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0); FilenameDatabase.Add(hash1, hash2, fFilename); string newString = texFilename + "?usage=0"; hash2 = MurmurHash2Shenmue.GetFilenameHashPlain(newString); fFilename = MurmurHash2Shenmue.GetFullFilename(newString, hash2); hash1 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0); FilenameDatabase.Add(hash1, hash2, fFilename); } } } //Hardcoded Filenames foreach (string filename in HardcodedFilenames) { uint secondHash = MurmurHash2Shenmue.GetFilenameHashPlain(filename); string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash); uint hash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0); FilenameDatabase.Add(hash, secondHash, fullFilename); } //Fontdefs foreach (string filename in GenerateFontdefFilenames()) { uint secondHash = MurmurHash2Shenmue.GetFilenameHashPlain(filename); string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash); uint hash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0); FilenameDatabase.Add(hash, secondHash, fullFilename); } //UI Filenames foreach (string filename in UIFilenames) { uint secondHash = MurmurHash2Shenmue.GetFilenameHashPlain(filename); string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash); uint hash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0); FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, secondHash, fullFilename); FilenameDatabase.Add(entry); bool exist = false; byte[] buf = FilenameCrawler.GetBufferFromEntry(entry, out exist); if (exist) { List <string> images = GetImagesFromUI(buf); foreach (string btn in ButtonFilenames) { images.Add(String.Format(SuffixUIFormat, btn, 0)); } if (images.Count > 0) { foreach (string imageFilename in images) { uint hash2 = MurmurHash2Shenmue.GetFilenameHashPlain(imageFilename); string fFilename = MurmurHash2Shenmue.GetFullFilename(imageFilename, hash2); uint hash1 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0); FilenameDatabase.Add(hash1, hash2, fFilename); } } } } //LD Filenames (LOADSCREEN.UI) foreach (string ldFile in GetLDFiles()) { uint hash2 = MurmurHash2Shenmue.GetFilenameHashPlain(ldFile); string fFilename = MurmurHash2Shenmue.GetFullFilename(ldFile, hash2); uint hash1 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0); FilenameDatabase.Add(hash1, hash2, fFilename); } //Credits Filenames foreach (string creditFile in GetCreditFilenames()) { uint hash2 = MurmurHash2Shenmue.GetFilenameHashPlain(creditFile); string fFilename = MurmurHash2Shenmue.GetFullFilename(creditFile, hash2); uint hash1 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0); FilenameDatabase.Add(hash1, hash2, fFilename); } }