fix ref to private.corelib with dnlib, dumper now works as before, (exluding quickDumper, still need to work on that)

This commit is contained in:
CWX 2024-08-12 12:52:15 +01:00
parent 0c08b56faa
commit 81d0d74fd8
4 changed files with 33 additions and 21 deletions

View File

@ -1,7 +1,4 @@
using System; using System.Reflection;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using DumpLib.Helpers; using DumpLib.Helpers;
using DumpLib.Models; using DumpLib.Models;

View File

@ -8,13 +8,13 @@ namespace DumpLib.Helpers
public static class ReflectionHelper public static class ReflectionHelper
{ {
private static Assembly _newtonAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Newtonsoft.Json.dll").Replace("\\\\", "\\")); 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 _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 _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("\\\\", "\\")); private static Assembly _comfortAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Comfort.dll").Replace("\\\\", "\\"));
/// <summary> /// <summary>
/// Method to get Singleton<> type from Comfort.dll /// Method to get Singleton<> type from Comfort.dll
/// </summary> /// </summary>
@ -32,7 +32,7 @@ namespace DumpLib.Helpers
throw; throw;
} }
} }
/// <summary> /// <summary>
/// Method to get ClientApplication<> type from EFT's assembly /// Method to get ClientApplication<> type from EFT's assembly
/// </summary> /// </summary>
@ -50,7 +50,7 @@ namespace DumpLib.Helpers
throw; throw;
} }
} }
/// <summary> /// <summary>
/// Method to get (as of 25/01/2024 - GInterface145) type from EFT's assembly /// Method to get (as of 25/01/2024 - GInterface145) type from EFT's assembly
/// </summary> /// </summary>
@ -69,7 +69,7 @@ namespace DumpLib.Helpers
throw; throw;
} }
} }
/// <summary> /// <summary>
/// Method to get TarkovApplication type from EFT's assembly /// Method to get TarkovApplication type from EFT's assembly
/// </summary> /// </summary>
@ -87,7 +87,7 @@ namespace DumpLib.Helpers
throw; throw;
} }
} }
/// <summary> /// <summary>
/// Method to get (as of 25/01/2024 - GClass1464) type from EFT's assembly /// Method to get (as of 25/01/2024 - GClass1464) type from EFT's assembly
/// </summary> /// </summary>
@ -127,7 +127,7 @@ namespace DumpLib.Helpers
throw; throw;
} }
} }
/// <summary> /// <summary>
/// Method to get FieldInfo of a field on the TarkovApplication Type for later use /// Method to get FieldInfo of a field on the TarkovApplication Type for later use
/// </summary> /// </summary>
@ -146,7 +146,7 @@ namespace DumpLib.Helpers
throw; throw;
} }
} }
/// <summary> /// <summary>
/// Method to get the Instance of a Singleton(Type) passed in /// Method to get the Instance of a Singleton(Type) passed in
/// </summary> /// </summary>
@ -167,7 +167,7 @@ namespace DumpLib.Helpers
throw; throw;
} }
} }
/// <summary> /// <summary>
/// Method to get BackendSession object from the instance passed in /// Method to get BackendSession object from the instance passed in
/// </summary> /// </summary>

View File

@ -12,9 +12,11 @@ public class DumperClass
private ModuleDefMD? _gameModule { get; set; } private ModuleDefMD? _gameModule { get; set; }
private ModuleDefMD? _checkerModule { get; set; } private ModuleDefMD? _checkerModule { get; set; }
private ModuleDefMD? _msModule { get; set; } private ModuleDefMD? _msModule { get; set; }
private ModuleDefMD? _dumpModule { get; set; }
private string _assemblyPath { get; set; } private string _assemblyPath { get; set; }
private string _fileCheckerPath { get; set; } private string _fileCheckerPath { get; set; }
private string _mscorlibPath { get; set; } private string _mscorlibPath { get; set; }
private string _dumpLibPath { get; set; }
private string _managedPath { get; set; } private string _managedPath { get; set; }
private List<TypeDef>? _gameTypes { get; set; } private List<TypeDef>? _gameTypes { get; set; }
private List<TypeDef>? _checkerTypes { get; set; } private List<TypeDef>? _checkerTypes { get; set; }
@ -27,6 +29,7 @@ public class DumperClass
_assemblyPath = Path.Combine(managedPath, "Assembly-Csharp-cleaned.dll"); _assemblyPath = Path.Combine(managedPath, "Assembly-Csharp-cleaned.dll");
_fileCheckerPath = Path.Combine(managedPath, "FilesChecker.dll"); _fileCheckerPath = Path.Combine(managedPath, "FilesChecker.dll");
_mscorlibPath = Path.Combine(managedPath, "mscorlib.dll"); _mscorlibPath = Path.Combine(managedPath, "mscorlib.dll");
_dumpLibPath = "./DumpLib.dll";
if (!File.Exists(_assemblyPath)) if (!File.Exists(_assemblyPath))
{ {
@ -40,12 +43,18 @@ public class DumperClass
if (!File.Exists(_mscorlibPath)) 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); _gameModule = DataProvider.LoadModule(_assemblyPath);
_checkerModule = DataProvider.LoadModule(_fileCheckerPath); _checkerModule = DataProvider.LoadModule(_fileCheckerPath);
_msModule = DataProvider.LoadModule(_mscorlibPath); _msModule = DataProvider.LoadModule(_mscorlibPath);
_dumpModule = DataProvider.LoadModule(_dumpLibPath);
_gameTypes = _gameModule.GetTypes().ToList(); _gameTypes = _gameModule.GetTypes().ToList();
_checkerTypes = _checkerModule.GetTypes().ToList(); _checkerTypes = _checkerModule.GetTypes().ToList();
_gameImporter = new Importer(_gameModule); _gameImporter = new Importer(_gameModule);
@ -56,19 +65,25 @@ public class DumperClass
{ {
if (_gameModule == null || _gameTypes == null) 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; return;
} }
if (_checkerModule == null || _checkerTypes == null) 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; return;
} }
if (_msModule == null) 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; return;
} }
@ -294,7 +309,7 @@ public class DumperClass
Logger.Log($"MainMenu is null or isnt 62 instructions, SOMETHING HAD CHANGED!", ConsoleColor.Red); 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); var index = method.Body.Instructions.First(x => x.OpCode == OpCodes.Ret);

View File

@ -160,11 +160,11 @@ public static class DumpyILHelper
}; };
} }
public static List<Instruction> GetDumpyTaskInstructions(MethodDef method, ModuleDefMD assembly, Importer? gameImporter) public static List<Instruction> GetDumpyTaskInstructions(MethodDef method, ModuleDefMD dumpModule, Importer? gameImporter)
{ {
return new List<Instruction> return new List<Instruction>
{ {
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) Instruction.Create(OpCodes.Pop)
}; };
} }