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

Fix some compiler warnings

This commit is contained in:
Cj 2024-12-30 23:50:31 -05:00
parent 65041c3e3b
commit 1505b01bba
6 changed files with 22 additions and 15 deletions

View File

@ -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;

View File

@ -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)
{

View File

@ -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<string> 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<string, int> CountTypeReferences(string assemblyPath)
private static Dictionary<string, int> CountTypeReferences(string assemblyPath)
{
var typeReferenceCounts = new Dictionary<string, int>();
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;

View File

@ -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();

View File

@ -26,11 +26,11 @@
<Output TaskParameter="OutputItems" ItemName="OutputPath" />
</Target>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(Configuration)' == '$(Configuration)'">
<RemoveDir Directories="$(SolutionDir)Build\**\*.*" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == '$(Configuration)'">
<ItemGroup>
<de4dot Include="$(SolutionDir)de4dot\$(Configuration)\net48\*.*" />
<templates Include="$(SolutionDir)Assets\Templates\**\*.*" />

View File

@ -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();