diff --git a/ReCodeItCLI/Commands/DeObfuscate.cs b/ReCodeItCLI/Commands/DeObfuscate.cs index 16f2cb1..af9e441 100644 --- a/ReCodeItCLI/Commands/DeObfuscate.cs +++ b/ReCodeItCLI/Commands/DeObfuscate.cs @@ -10,7 +10,7 @@ namespace ReCodeItCLI.Commands; public class DeObfuscate : ICommand { [CommandParameter(0, IsRequired = true, Description = "The absolute path to your obfuscated assembly or exe file, folder must contain all references to be resolved.")] - public string AssemblyPath { get; init; } + public required string AssemblyPath { get; init; } [CommandParameter(1, IsRequired = false, Description = "Is the target the EFT launcher?")] public bool IsLauncher { get; init; } = false; diff --git a/ReCodeItCLI/Commands/Dumper.cs b/ReCodeItCLI/Commands/Dumper.cs index a5fb067..de308ab 100644 --- a/ReCodeItCLI/Commands/Dumper.cs +++ b/ReCodeItCLI/Commands/Dumper.cs @@ -10,7 +10,7 @@ namespace ReCodeItCLI.Commands; public class Dumper : ICommand { [CommandParameter(0, IsRequired = true, Description = "The absolute path to your Managed folder for EFT, folder must contain all references to be resolved. Assembly-CSharp-cleaned.dll, mscorlib.dll, FilesChecker.dll")] - public string ManagedDirectory { get; init; } + public required string ManagedDirectory { get; init; } public ValueTask ExecuteAsync(IConsole console) { diff --git a/ReCodeItCLI/Commands/GenRefList.cs b/ReCodeItCLI/Commands/GenRefList.cs index a6d75b4..9f8b2b3 100644 --- a/ReCodeItCLI/Commands/GenRefList.cs +++ b/ReCodeItCLI/Commands/GenRefList.cs @@ -9,7 +9,7 @@ namespace ReCodeItCLI.Commands; public class GenRefList : ICommand { [CommandParameter(0, IsRequired = true, Description = "The absolute path to your de-obfuscated and remapped dll.")] - public string AssemblyPath { get; init; } + public required string AssemblyPath { get; init; } private static readonly List Match = new() { @@ -28,22 +28,21 @@ public class GenRefList : ICommand // Sort and display the top 10 most referenced types foreach (var pair in references.OrderByDescending(p => p.Value).Take(100)) { - Console.WriteLine($"{pair.Key}: {pair.Value}"); + console.Output.WriteLine($"{pair.Key}: {pair.Value}"); } return default; } - public static Dictionary CountTypeReferences(string assemblyPath) + private static Dictionary CountTypeReferences(string assemblyPath) { var typeReferenceCounts = new Dictionary(); - using (var module = ModuleDefMD.Load(assemblyPath)) + using var module = ModuleDefMD.Load(assemblyPath); + + foreach (var type in module.GetTypes()) { - foreach (var type in module.GetTypes()) - { - CountReferencesInType(type, typeReferenceCounts); - } + CountReferencesInType(type, typeReferenceCounts); } return typeReferenceCounts; diff --git a/ReCodeItCLI/Commands/ReMap.cs b/ReCodeItCLI/Commands/ReMap.cs index e04052a..d17db94 100644 --- a/ReCodeItCLI/Commands/ReMap.cs +++ b/ReCodeItCLI/Commands/ReMap.cs @@ -12,10 +12,10 @@ public class ReMap : ICommand private ReCodeItRemapper _remapper { get; set; } = new(); [CommandParameter(0, IsRequired = true, Description = "The absolute path to your mapping.json file, supports .json and .jsonc")] - public string MappingJsonPath { get; init; } + public required string MappingJsonPath { get; init; } [CommandParameter(1, IsRequired = true, Description = "The absolute path to your de-obfuscated dll, containing all references that it needs to resolve.")] - public string AssemblyPath { get; init; } + public required string AssemblyPath { get; init; } [CommandParameter(2, IsRequired = true, Description = "If true, the re-mapper will publicize all types, methods, and properties")] public bool Publicize { get; init; } @@ -36,8 +36,15 @@ public class ReMap : ICommand remapperSettings.Publicize = Publicize; var remaps = DataProvider.LoadMappingFile(MappingJsonPath); + + var outPath = Path.GetDirectoryName(AssemblyPath); + + if (outPath is null) + { + throw new DirectoryNotFoundException("OutPath could not be resolved."); + } - _remapper.InitializeRemap(remaps, AssemblyPath, Path.GetDirectoryName(AssemblyPath)); + _remapper.InitializeRemap(remaps, AssemblyPath, outPath); // Wait for log termination Logger.Terminate(); diff --git a/ReCodeItCLI/ReCodeItCLI.csproj b/ReCodeItCLI/ReCodeItCLI.csproj index 6fd71bd..d3dadb7 100644 --- a/ReCodeItCLI/ReCodeItCLI.csproj +++ b/ReCodeItCLI/ReCodeItCLI.csproj @@ -26,11 +26,11 @@ - + - + diff --git a/RecodeItLib/Remapper/DeObfuscator.cs b/RecodeItLib/Remapper/DeObfuscator.cs index a7a81bc..ca610f4 100644 --- a/RecodeItLib/Remapper/DeObfuscator.cs +++ b/RecodeItLib/Remapper/DeObfuscator.cs @@ -60,6 +60,7 @@ public static class Deobfuscator : $"--un-name \"!^<>[a-z0-9]$&!^<>[a-z0-9]__.*$&![A-Z][A-Z]\\$<>.*$&^[a-zA-Z_<{{$][a-zA-Z_0-9<>{{}}$.`-]*$\" \"{assemblyPath}\" --strtyp delegate --strtok \"{token}\""; var executablePath = Path.Combine(AppContext.BaseDirectory, "de4dot", "de4dot-x64.exe"); + var two = 2; var process = Process.Start(executablePath, cmd); process.WaitForExit();