static void DumpFileInfo(SerializedFile container, string exportPath) { Console.WriteLine($"Dumping container {container.Name }"); Directory.CreateDirectory(Path.GetDirectoryName(exportPath)); using (var sw = new StreamWriter($"{exportPath}.txt")) { WriteFileInfo(container, sw); sw.WriteLine(""); DumpObjectInfo(container.FetchAssets(), sw); if (container.Name == "globalgamemanagers") { BuildSettings buildSettings = (BuildSettings)container.FetchAssets().FirstOrDefault(asset => asset is BuildSettings); if (buildSettings != null) { sw.WriteLine(""); DumpBuildSettings(buildSettings, sw); } MonoManager monoManager = (MonoManager)container.FetchAssets().FirstOrDefault(asset => asset is MonoManager); if (monoManager != null) { sw.WriteLine(""); DumpMonoManager(monoManager, sw); } } } }
internal static void DumpTypeInfo(SerializedFile serializedFile, StreamWriter sw) { foreach (var asset in serializedFile.FetchAssets().Where(asset => asset is MonoScript)) { var monoScript = asset as MonoScript; sw.WriteLine($"\t[{monoScript.AssemblyName}]{monoScript.Namespace}.{monoScript.ClassName} - {HashToString(monoScript.PropertiesHash)}"); } sw.WriteLine($"SerializedFile"); sw.WriteLine($"Name {serializedFile.Name}"); sw.WriteLine($"NameOrigin {serializedFile.NameOrigin}"); sw.WriteLine($"Platform {serializedFile.Platform}"); sw.WriteLine($"Version {serializedFile.Version}"); sw.WriteLine($"Preloads:"); foreach (var ptr in serializedFile.Metadata.Preloads) { sw.WriteLine($"\t{ptr}"); } var hierarchy = serializedFile.Metadata.Hierarchy; sw.WriteLine($"TypeTree Version {hierarchy.Version}"); sw.WriteLine($"TypeTree Platform {hierarchy.Platform}"); var SerializeTypeTrees = Util.GetMember <bool>(hierarchy, "SerializeTypeTrees"); sw.WriteLine($"TypeTree SerializeTypeTrees {SerializeTypeTrees}"); var Unknown = Util.GetMember <int>(hierarchy, "Unknown"); sw.WriteLine($"TypeTree Unknown {Unknown}"); sw.WriteLine($""); var types = Util.GetMember <IReadOnlyList <object> >(hierarchy, "Types"); foreach (var type in types) { var ClassID = Util.GetMember <ClassIDType> (type, "ClassID"); var ScriptID = Util.GetMember <short>(type, "ScriptID"); var IsStrippedType = Util.GetMember <bool>(type, "IsStrippedType"); var Tree = Util.GetMember <object>(type, "Tree"); var ScriptHash = Util.GetMember <Hash128>(type, "ScriptHash"); var TypeHash = Util.GetMember <Hash128>(type, "TypeHash"); var monoScript = serializedFile.FetchAssets().FirstOrDefault(asset => asset is MonoScript ms && CompareHash(ms.PropertiesHash, TypeHash)) as MonoScript; string scriptType = monoScript == null ? "\tNo Script" : $"\tMonoScript is [{monoScript.AssemblyName}]{monoScript.Namespace}.{monoScript.ClassName}"; sw.WriteLine(scriptType); sw.WriteLine($"\tType: ClassID {ClassID}, ScriptID {ScriptID}, IsStrippedType {IsStrippedType}, ScriptHash {HashToString(ScriptHash)}, TypeHash {HashToString(TypeHash)}"); var Dump = Util.GetMember <string>(Tree, "Dump"); sw.WriteLine($"\t{Dump}"); sw.WriteLine($""); } sw.WriteLine($""); }