From 81d0d74fd8c75e90fc455c836bdbd363dab2b6f8 Mon Sep 17 00:00:00 2001 From: CWX Date: Mon, 12 Aug 2024 12:52:15 +0100 Subject: [PATCH] fix ref to private.corelib with dnlib, dumper now works as before, (exluding quickDumper, still need to work on that) --- DumpLib/DumpyTool.cs | 5 +---- DumpLib/Helpers/ReflectionHelper.cs | 20 ++++++++++---------- RecodeItLib/Dumper/DumperClass.cs | 25 ++++++++++++++++++++----- RecodeItLib/Dumper/DumpyILHelper.cs | 4 ++-- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/DumpLib/DumpyTool.cs b/DumpLib/DumpyTool.cs index 7cc5886..776a6d9 100644 --- a/DumpLib/DumpyTool.cs +++ b/DumpLib/DumpyTool.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Reflection; -using System.Threading.Tasks; +using System.Reflection; using Newtonsoft.Json; using DumpLib.Helpers; using DumpLib.Models; diff --git a/DumpLib/Helpers/ReflectionHelper.cs b/DumpLib/Helpers/ReflectionHelper.cs index 1e80ee1..ab11148 100644 --- a/DumpLib/Helpers/ReflectionHelper.cs +++ b/DumpLib/Helpers/ReflectionHelper.cs @@ -8,13 +8,13 @@ namespace DumpLib.Helpers public static class ReflectionHelper { private static Assembly _newtonAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Newtonsoft.Json.dll").Replace("\\\\", "\\")); - + private static Assembly _msAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\mscorlib.dll").Replace("\\\\", "\\")); - + private static Assembly _eftAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Assembly-CSharp.dll").Replace("\\\\", "\\")); private static Assembly _comfortAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Comfort.dll").Replace("\\\\", "\\")); - + /// /// Method to get Singleton<> type from Comfort.dll /// @@ -32,7 +32,7 @@ namespace DumpLib.Helpers throw; } } - + /// /// Method to get ClientApplication<> type from EFT's assembly /// @@ -50,7 +50,7 @@ namespace DumpLib.Helpers throw; } } - + /// /// Method to get (as of 25/01/2024 - GInterface145) type from EFT's assembly /// @@ -69,7 +69,7 @@ namespace DumpLib.Helpers throw; } } - + /// /// Method to get TarkovApplication type from EFT's assembly /// @@ -87,7 +87,7 @@ namespace DumpLib.Helpers throw; } } - + /// /// Method to get (as of 25/01/2024 - GClass1464) type from EFT's assembly /// @@ -127,7 +127,7 @@ namespace DumpLib.Helpers throw; } } - + /// /// Method to get FieldInfo of a field on the TarkovApplication Type for later use /// @@ -146,7 +146,7 @@ namespace DumpLib.Helpers throw; } } - + /// /// Method to get the Instance of a Singleton(Type) passed in /// @@ -167,7 +167,7 @@ namespace DumpLib.Helpers throw; } } - + /// /// Method to get BackendSession object from the instance passed in /// diff --git a/RecodeItLib/Dumper/DumperClass.cs b/RecodeItLib/Dumper/DumperClass.cs index 6da596e..bbcea92 100644 --- a/RecodeItLib/Dumper/DumperClass.cs +++ b/RecodeItLib/Dumper/DumperClass.cs @@ -12,9 +12,11 @@ public class DumperClass private ModuleDefMD? _gameModule { get; set; } private ModuleDefMD? _checkerModule { get; set; } private ModuleDefMD? _msModule { get; set; } + private ModuleDefMD? _dumpModule { get; set; } private string _assemblyPath { get; set; } private string _fileCheckerPath { get; set; } private string _mscorlibPath { get; set; } + private string _dumpLibPath { get; set; } private string _managedPath { get; set; } private List? _gameTypes { get; set; } private List? _checkerTypes { get; set; } @@ -27,6 +29,7 @@ public class DumperClass _assemblyPath = Path.Combine(managedPath, "Assembly-Csharp-cleaned.dll"); _fileCheckerPath = Path.Combine(managedPath, "FilesChecker.dll"); _mscorlibPath = Path.Combine(managedPath, "mscorlib.dll"); + _dumpLibPath = "./DumpLib.dll"; if (!File.Exists(_assemblyPath)) { @@ -40,12 +43,18 @@ public class DumperClass if (!File.Exists(_mscorlibPath)) { - Logger.Log($"File FilesChecker.dll does not exist at {_fileCheckerPath}", ConsoleColor.Red); + Logger.Log($"File FilesChecker.dll does not exist at {_mscorlibPath}", ConsoleColor.Red); + } + + if (!File.Exists(_dumpLibPath)) + { + Logger.Log($"File DumpLib.dll does not exist at {_dumpLibPath}", ConsoleColor.Red); } _gameModule = DataProvider.LoadModule(_assemblyPath); _checkerModule = DataProvider.LoadModule(_fileCheckerPath); _msModule = DataProvider.LoadModule(_mscorlibPath); + _dumpModule = DataProvider.LoadModule(_dumpLibPath); _gameTypes = _gameModule.GetTypes().ToList(); _checkerTypes = _checkerModule.GetTypes().ToList(); _gameImporter = new Importer(_gameModule); @@ -56,19 +65,25 @@ public class DumperClass { if (_gameModule == null || _gameTypes == null) { - Logger.Log($"_gameModule or _gameTypes in DumpyRemake was null", ConsoleColor.Red); + Logger.Log($"_gameModule or _gameTypes in CreateDumper() was null", ConsoleColor.Red); return; } if (_checkerModule == null || _checkerTypes == null) { - Logger.Log($"_checkerModule or _checkerTypes in DumpyRemake was null", ConsoleColor.Red); + Logger.Log($"_checkerModule or _checkerTypes in CreateDumper() was null", ConsoleColor.Red); return; } if (_msModule == null) { - Logger.Log($"_msModule in DumpyRemake was null", ConsoleColor.Red); + Logger.Log($"_msModule in CreateDumper() was null", ConsoleColor.Red); + return; + } + + if (_dumpModule == null) + { + Logger.Log($"_dumpModule in CreateDumper() was null", ConsoleColor.Red); return; } @@ -294,7 +309,7 @@ public class DumperClass Logger.Log($"MainMenu is null or isnt 62 instructions, SOMETHING HAD CHANGED!", ConsoleColor.Red); } - var liList = DumpyILHelper.GetDumpyTaskInstructions(method, _gameModule, _gameImporter); + var liList = DumpyILHelper.GetDumpyTaskInstructions(method,_dumpModule, _gameImporter); var index = method.Body.Instructions.First(x => x.OpCode == OpCodes.Ret); diff --git a/RecodeItLib/Dumper/DumpyILHelper.cs b/RecodeItLib/Dumper/DumpyILHelper.cs index 7f2852b..0ed41a1 100644 --- a/RecodeItLib/Dumper/DumpyILHelper.cs +++ b/RecodeItLib/Dumper/DumpyILHelper.cs @@ -160,11 +160,11 @@ public static class DumpyILHelper }; } - public static List GetDumpyTaskInstructions(MethodDef method, ModuleDefMD assembly, Importer? gameImporter) + public static List GetDumpyTaskInstructions(MethodDef method, ModuleDefMD dumpModule, Importer? gameImporter) { return new List { - Instruction.Create(OpCodes.Call, gameImporter?.Import(typeof(DumpyTool).GetMethod("StartDumpyTask"))), + Instruction.Create(OpCodes.Call, gameImporter?.Import(dumpModule.GetTypes().First(x => x.Name == "DumpyTool").Methods.First(m => m.Name == "StartDumpyTask"))), Instruction.Create(OpCodes.Pop) }; }