0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-12 22:50:45 -05:00

44 lines
1.4 KiB
C#
Raw Permalink Normal View History

using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using ReCodeItCLI.Utils;
2024-12-31 13:46:44 -05:00
using ReCodeItLib.Utils;
using ReCodeItLib.ReMapper;
namespace ReCodeItCLI.Commands;
2024-12-31 14:20:44 -05:00
[Command("ReMap", Description = "Generates a re-mapped dll provided a mapping file and dll. If the dll is obfuscated, it will automatically de-obfuscate.")]
2024-06-22 12:39:10 -04:00
public class ReMap : ICommand
{
2024-12-31 13:47:51 -05:00
private ReMapper _remapper { get; set; } = new();
[CommandParameter(0, IsRequired = true, Description = "The absolute path to your mapping.json file, supports .json and .jsonc")]
2024-12-30 23:50:31 -05:00
public required string MappingJsonPath { get; init; }
2024-12-31 14:20:44 -05:00
[CommandParameter(1, IsRequired = true, Description = "The absolute path to your dll, containing all references that it needs to resolve.")]
2024-12-30 23:50:31 -05:00
public required string AssemblyPath { get; init; }
public ValueTask ExecuteAsync(IConsole console)
{
Debugger.TryWaitForDebuggerAttach();
DataProvider.Settings.MappingPath = MappingJsonPath;
var remaps = DataProvider.LoadMappingFile(MappingJsonPath);
2024-12-30 23:50:31 -05:00
var outPath = Path.GetDirectoryName(AssemblyPath);
if (outPath is null)
{
throw new DirectoryNotFoundException("OutPath could not be resolved.");
}
2024-12-30 23:50:31 -05:00
_remapper.InitializeRemap(remaps, AssemblyPath, outPath);
// Wait for log termination
Logger.Terminate();
while(Logger.IsRunning()) {}
return default;
}
}