remove unused class and dataProvider changes, fix lib to compile correctly for use
This commit is contained in:
parent
7c0575d423
commit
a43b6abf4c
Binary file not shown.
@ -34,8 +34,8 @@ public class DumperClass
|
|||||||
|
|
||||||
// will explode if they are not there?
|
// will explode if they are not there?
|
||||||
// TODO: [CWX] TRIED OVERRDING
|
// TODO: [CWX] TRIED OVERRDING
|
||||||
_gameModule = DataProvider.LoadModule(_assemblyPath, _managedPath);
|
_gameModule = DataProvider.LoadModule(_assemblyPath);
|
||||||
_checkerModule = DataProvider.LoadModule(_fileCheckerPath, _managedPath);
|
_checkerModule = DataProvider.LoadModule(_fileCheckerPath);
|
||||||
_gameTypes = _gameModule.GetTypes().ToList();
|
_gameTypes = _gameModule.GetTypes().ToList();
|
||||||
_checkerTypes = _checkerModule.GetTypes().ToList();
|
_checkerTypes = _checkerModule.GetTypes().ToList();
|
||||||
}
|
}
|
||||||
@ -74,7 +74,6 @@ public class DumperClass
|
|||||||
SetDumpyTaskCode(dumpyTaskType[0]);
|
SetDumpyTaskCode(dumpyTaskType[0]);
|
||||||
|
|
||||||
// TODO: Write game assembly to file
|
// TODO: Write game assembly to file
|
||||||
|
|
||||||
_gameModule.Write(Path.Combine(_managedPath, "Assembly-CSharp-dumper.dll"));
|
_gameModule.Write(Path.Combine(_managedPath, "Assembly-CSharp-dumper.dll"));
|
||||||
|
|
||||||
// get types
|
// get types
|
||||||
@ -93,7 +92,7 @@ public class DumperClass
|
|||||||
|
|
||||||
public void CreateDumpFolders()
|
public void CreateDumpFolders()
|
||||||
{
|
{
|
||||||
// create dumper folders
|
// TODO: create dumper folders
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -302,7 +301,7 @@ public class DumperClass
|
|||||||
|
|
||||||
foreach (var li in liList)
|
foreach (var li in liList)
|
||||||
{
|
{
|
||||||
method.Body.Instructions.Append(li);
|
method.Body.Instructions.Add(li);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +330,7 @@ public class DumperClass
|
|||||||
|
|
||||||
foreach (var li in liList)
|
foreach (var li in liList)
|
||||||
{
|
{
|
||||||
method.Body.Instructions.Append(li);
|
method.Body.Instructions.Add(li);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||||||
using dnlib.DotNet;
|
using dnlib.DotNet;
|
||||||
using dnlib.DotNet.Emit;
|
using dnlib.DotNet.Emit;
|
||||||
using DumpLib;
|
using DumpLib;
|
||||||
|
using ReCodeIt.Utils;
|
||||||
|
|
||||||
namespace ReCodeItLib.Dumper;
|
namespace ReCodeItLib.Dumper;
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ public static class DumpyInstructionsHelper
|
|||||||
{
|
{
|
||||||
// TODO: [CWX] TRIED CHANGING OPTIONS
|
// TODO: [CWX] TRIED CHANGING OPTIONS
|
||||||
var importer = new Importer(assembly, ImporterOptions.TryToUseExistingAssemblyRefs);
|
var importer = new Importer(assembly, ImporterOptions.TryToUseExistingAssemblyRefs);
|
||||||
|
var test = ModuleDefMD.Load("C:\\Battlestate Games\\Escape from Tarkov\\EscapeFromTarkov_Data\\Managed\\mscorlib.dll");
|
||||||
|
|
||||||
// Add our own local variables
|
// Add our own local variables
|
||||||
|
|
||||||
@ -51,9 +53,9 @@ public static class DumpyInstructionsHelper
|
|||||||
|
|
||||||
// var2 index1 ExceptionType
|
// var2 index1 ExceptionType
|
||||||
// TODO: [CWX] this is the problem, Exception is being imported via System.Private.CoreLib... Needs to come from MsCorLib in EFT managed Dir
|
// TODO: [CWX] this is the problem, Exception is being imported via System.Private.CoreLib... Needs to come from MsCorLib in EFT managed Dir
|
||||||
var typer = typeof(System.Exception);
|
var typer = test.GetTypes().First(x => x.Name.ToLower() == "exception");
|
||||||
var sptExceptionType = importer.Import(typer);
|
var sptExceptionType = importer.Import(typer);
|
||||||
var sptException = new Local(sptExceptionType.ToTypeSig(true));
|
var sptException = new Local(sptExceptionType.ToTypeSig());
|
||||||
method.Body.Variables.Add(sptException);
|
method.Body.Variables.Add(sptException);
|
||||||
|
|
||||||
return new List<Instruction>
|
return new List<Instruction>
|
||||||
@ -101,23 +103,24 @@ public static class DumpyInstructionsHelper
|
|||||||
public static List<Instruction> GetEnsureConsistencyInstructions(ModuleDefMD assembly, ModuleDefMD fileChecker, MethodDef method)
|
public static List<Instruction> GetEnsureConsistencyInstructions(ModuleDefMD assembly, ModuleDefMD fileChecker, MethodDef method)
|
||||||
{
|
{
|
||||||
var importer = new Importer(assembly);
|
var importer = new Importer(assembly);
|
||||||
|
var test = ModuleDefMD.Load("C:\\Battlestate Games\\Escape from Tarkov\\EscapeFromTarkov_Data\\Managed\\mscorlib.dll");
|
||||||
|
|
||||||
// init local vars
|
// init local vars
|
||||||
// var1 index0 TimeSpan type
|
// var1 index0 TimeSpan type
|
||||||
var sptTimeSpanType = importer.Import(typeof(TimeSpan));
|
var sptTimeSpanType = importer.Import(test.GetTypes().First(x => x.Name == "TimeSpan"));
|
||||||
var sptClass = new Local(sptTimeSpanType.ToTypeSig());
|
var sptClass = new Local(sptTimeSpanType.ToTypeSig());
|
||||||
method.Body.Variables.Add(sptClass);
|
method.Body.Variables.Add(sptClass);
|
||||||
|
|
||||||
// Create genericInstance of a method
|
// Create genericInstance of a method
|
||||||
var type = fileChecker.GetTypes().First(DumpyTypeHelper.GetEnsureConsistencyType).NestedTypes[0].Interfaces[0].Interface;
|
var type = fileChecker.GetTypes().First(DumpyTypeHelper.GetEnsureConsistencyType).NestedTypes[0].Interfaces[0].Interface;
|
||||||
var typeMethod = importer.Import(typeof(Task).GetMethod("FromResult"));
|
var typeMethod = importer.Import(test.GetTypes().First(x => x.Name == "Task").Methods.First(x => x.Name == "FromResult"));
|
||||||
var generac = new MethodSpecUser(typeMethod.ResolveMethodDef(), new GenericInstMethodSig(type.ToTypeSig()));
|
var generac = new MethodSpecUser(typeMethod as IMethodDefOrRef, new GenericInstMethodSig(type.ToTypeSig()));
|
||||||
|
|
||||||
return new List<Instruction>
|
return new List<Instruction>
|
||||||
{
|
{
|
||||||
// return Task.FromResult<ICheckResult>(ConsistencyController.CheckResult.Succeed(default(TimeSpan)));
|
// return Task.FromResult<ICheckResult>(ConsistencyController.CheckResult.Succeed(default(TimeSpan)));
|
||||||
Instruction.Create(OpCodes.Ldloca_S, method.Body.Variables[0]),
|
Instruction.Create(OpCodes.Ldloca_S, method.Body.Variables[0]),
|
||||||
Instruction.Create(OpCodes.Initobj, importer.Import(typeof(TimeSpan))),
|
Instruction.Create(OpCodes.Initobj, sptTimeSpanType),
|
||||||
Instruction.Create(OpCodes.Ldloc_0),
|
Instruction.Create(OpCodes.Ldloc_0),
|
||||||
Instruction.Create(OpCodes.Call, fileChecker.GetTypes().First(DumpyTypeHelper.GetEnsureConsistencyType).NestedTypes[0].Methods.First(x => x.Name == "Succeed")),
|
Instruction.Create(OpCodes.Call, fileChecker.GetTypes().First(DumpyTypeHelper.GetEnsureConsistencyType).NestedTypes[0].Methods.First(x => x.Name == "Succeed")),
|
||||||
Instruction.Create(OpCodes.Call, generac),
|
Instruction.Create(OpCodes.Call, generac),
|
||||||
@ -135,10 +138,11 @@ public static class DumpyInstructionsHelper
|
|||||||
public static List<Instruction> GetRunValidationInstructions(ModuleDefMD assembly, MethodDef method)
|
public static List<Instruction> GetRunValidationInstructions(ModuleDefMD assembly, MethodDef method)
|
||||||
{
|
{
|
||||||
var importer = new Importer(assembly);
|
var importer = new Importer(assembly);
|
||||||
|
var test = ModuleDefMD.Load("C:\\Battlestate Games\\Escape from Tarkov\\EscapeFromTarkov_Data\\Managed\\mscorlib.dll");
|
||||||
|
|
||||||
// Create genericInstance of a method
|
// Create genericInstance of a method
|
||||||
var type = assembly.GetTypes().First(DumpyTypeHelper.GetRunValidationType).NestedTypes[0];
|
var type = assembly.GetTypes().First(DumpyTypeHelper.GetRunValidationType).NestedTypes[0];
|
||||||
var typeMethod = importer.Import(typeof(AsyncTaskMethodBuilder).GetMethod("Start"));
|
var typeMethod = importer.Import(test.GetTypes().First(x => x.Name == "AsyncTaskMethodBuilder").Methods.First(x => x.Name == "Start"));
|
||||||
var generac = new MethodSpecUser(typeMethod as IMethodDefOrRef, new GenericInstMethodSig(type.ToTypeSig()));
|
var generac = new MethodSpecUser(typeMethod as IMethodDefOrRef, new GenericInstMethodSig(type.ToTypeSig()));
|
||||||
|
|
||||||
return new List<Instruction>
|
return new List<Instruction>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
using dnlib.DotNet;
|
|
||||||
|
|
||||||
namespace ReCodeItLib.Dumper;
|
|
||||||
|
|
||||||
public class TestAssResolver : AssemblyResolver
|
|
||||||
{
|
|
||||||
// TODO: [CWX] tried overriding a few things, even passing back all assemblies from managed folder
|
|
||||||
public TestAssResolver(string path, ModuleContext context = null) : base(context)
|
|
||||||
{
|
|
||||||
ManagedPath = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string? ManagedPath { get; set; }
|
|
||||||
|
|
||||||
protected override IEnumerable<string> PreFindAssemblies(IAssembly assembly, ModuleDef sourceModule, bool matchExactly)
|
|
||||||
{
|
|
||||||
// get all files in dir
|
|
||||||
// return them as list of strings
|
|
||||||
Console.WriteLine("FUCKING HELL");
|
|
||||||
|
|
||||||
var array = Directory.GetFiles(ManagedPath, "*.dll");
|
|
||||||
var array2 = base.PreFindAssemblies(assembly, sourceModule, matchExactly).ToArray();
|
|
||||||
Array.Copy(array2, array, array2.Length);
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
}
|
|
@ -127,32 +127,4 @@ public static class DataProvider
|
|||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ModuleDefMD LoadModule(string path, string dir)
|
|
||||||
{
|
|
||||||
var mcOptions = new ModuleCreationOptions(CreateModuleContext(path, dir));
|
|
||||||
ModuleDefMD module = ModuleDefMD.Load(path, mcOptions);
|
|
||||||
|
|
||||||
module.Context = mcOptions.Context;
|
|
||||||
|
|
||||||
if (module is null)
|
|
||||||
{
|
|
||||||
throw new NullReferenceException("Module is null...");
|
|
||||||
}
|
|
||||||
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModuleContext CreateModuleContext(string path, string dir) {
|
|
||||||
var ctx = new ModuleContext();
|
|
||||||
var asmRe = new TestAssResolver(dir, ctx);
|
|
||||||
asmRe.EnableFrameworkRedirect = false;
|
|
||||||
asmRe.FindExactMatch = false;
|
|
||||||
var res = new Resolver(asmRe);
|
|
||||||
res.ProjectWinMDRefs = false;
|
|
||||||
ctx.AssemblyResolver = asmRe;
|
|
||||||
ctx.Resolver = res;
|
|
||||||
asmRe.DefaultModuleContext = ctx;
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user