public static void DumpTypeTree(string filePath, string exportPath) { Directory.CreateDirectory(Path.GetDirectoryName(exportPath)); var fileCollection = new FileCollection(); var scheme = FileCollection.LoadScheme(filePath, Path.GetFileName(filePath)); var seralizedFiles = new List <SerializedFile>(); if (scheme is SerializedFileScheme serializedFileScheme) { var serializedFile = serializedFileScheme.ReadFile(fileCollection, fileCollection.AssemblyManager); seralizedFiles.Add(serializedFile); } else if (scheme is BundleFileScheme bundleFileScheme) { var bundleFile = bundleFileScheme.ReadFile(fileCollection, fileCollection.AssemblyManager); seralizedFiles.AddRange(bundleFile.SerializedFiles); } else { throw new Exception(); } using (var sw = new StreamWriter(exportPath)) { foreach (var file in seralizedFiles) { DumpTypeInfo(file, sw); } } }
public static void DumpSerializedTypes(string filePath, string managedPath, string exportPath) { Util.PrepareExportDirectory(exportPath); Directory.CreateDirectory(exportPath); var fileCollection = new FileCollection(); fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono; foreach (var assembly in Directory.GetFiles(managedPath, "*.dll", SearchOption.TopDirectoryOnly)) { fileCollection.AssemblyManager.Load(assembly); } var scheme = FileCollection.LoadScheme(filePath, Path.GetFileName(filePath)); var seralizedFiles = new List <SerializedFile>(); if (scheme is SerializedFileScheme serializedFileScheme) { var serializedFile = serializedFileScheme.ReadFile(fileCollection, fileCollection.AssemblyManager); seralizedFiles.Add(serializedFile); } else if (scheme is BundleFileScheme bundleFileScheme) { var bundleFile = bundleFileScheme.ReadFile(fileCollection, fileCollection.AssemblyManager); seralizedFiles.AddRange(bundleFile.SerializedFiles); } else { throw new Exception(); } using (var sw = new StreamWriter($"{exportPath}/dump.txt")) { foreach (var serializedFile in seralizedFiles) { var assets = serializedFile.FetchAssets(); foreach (var asset in assets) { if (asset is MonoScript monoscript && monoscript.AssemblyName == "Assembly-CSharp") { SerializableType behaviourType = monoscript.GetBehaviourType(); if (behaviourType != null) { var Structure = behaviourType.CreateBehaviourStructure(); sw.WriteLine($"[{monoscript.AssemblyName}]{monoscript.Namespace}.{monoscript.Name}"); DumpSerializedTypes(Structure, sw, 0); sw.WriteLine($""); } else { sw.WriteLine($"[{monoscript.AssemblyName}]{monoscript.Namespace}.{monoscript.Name} - No Behaviour Type"); sw.WriteLine($""); } } } } } }
static void DumpFile(string filepath, string exportPath) { var filename = Path.GetFileName(filepath); try { var fileCollection = new FileCollection(); var scheme = FileCollection.LoadScheme(filepath, Path.GetFileName(filepath)); if (scheme is SerializedFileScheme serializedFileScheme) { var serializedFile = serializedFileScheme.ReadFile(fileCollection, fileCollection.AssemblyManager); DumpFileInfo(serializedFile, Path.Combine(exportPath, filename)); } if (scheme is BundleFileScheme bundleFileScheme) { var bundleFile = bundleFileScheme.ReadFile(fileCollection, fileCollection.AssemblyManager); DumpFileListInfo(bundleFile, Path.Combine(exportPath, filename)); } if (scheme is ArchiveFileScheme archiveFileScheme) { var archiveFile = archiveFileScheme.ReadFile(fileCollection, fileCollection.AssemblyManager); DumpFileListInfo(archiveFile, Path.Combine(exportPath, filename)); } if (scheme is WebFileScheme webFileScheme) { var webfile = webFileScheme.ReadFile(fileCollection, fileCollection.AssemblyManager); DumpFileListInfo(webfile, Path.Combine(exportPath, filename)); } if (scheme is ResourceFileScheme resourceFileScheme) { var resourceFile = resourceFileScheme.ReadFile(); UnknownFileType(resourceFile, filepath, Path.Combine(exportPath, filename)); } } catch (Exception ex) { var errMessage = $"Error dumping file {filepath}\n{ex.ToString()}"; Logger.Log(LogType.Error, LogCategory.General, errMessage); File.WriteAllText($"{exportPath}/{filename}.err.txt", errMessage); } }