mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-12 20:30:43 -05:00
commit
70ac2326fc
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,6 +21,7 @@ mono_crash.*
|
|||||||
[Dd]ebugPublic/
|
[Dd]ebugPublic/
|
||||||
[Rr]elease/
|
[Rr]elease/
|
||||||
[Rr]eleases/
|
[Rr]eleases/
|
||||||
|
WAIT_FOR_DEBUGGER/
|
||||||
x64/
|
x64/
|
||||||
x86/
|
x86/
|
||||||
[Ww][Ii][Nn]32/
|
[Ww][Ii][Nn]32/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"MappingPath": "",
|
"MappingPath": "",
|
||||||
"TypeNamesToMatch": [ // These are the only types considered when looking for a match
|
"TypeNamesToMatch": [
|
||||||
"Class",
|
"Class",
|
||||||
"GClass",
|
"GClass",
|
||||||
"GStruct",
|
"GStruct",
|
||||||
@ -9,12 +9,12 @@
|
|||||||
"Interface",
|
"Interface",
|
||||||
"GInterface"
|
"GInterface"
|
||||||
],
|
],
|
||||||
"MethodNamesToIgnore": [ // Don't try to match on these
|
"MethodNamesToIgnore": [
|
||||||
"method_",
|
"method_",
|
||||||
"smethod_",
|
"smethod_",
|
||||||
"vmethod_"
|
"vmethod_"
|
||||||
],
|
],
|
||||||
"FieldNamesToIgnore": [ // Don't try to match on these
|
"FieldNamesToIgnore": [
|
||||||
"action",
|
"action",
|
||||||
"bool",
|
"bool",
|
||||||
"dictionary",
|
"dictionary",
|
||||||
|
1138594
Assets/Templates/items.json
1138594
Assets/Templates/items.json
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,11 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||||
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
|
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -15,9 +17,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="Build">
|
<Target Name="PostBuild" AfterTargets="Build">
|
||||||
<Exec Command="pwsh -NoProfile -ExecutionPolicy Bypass .\PostBuild.ps1"
|
<Exec Command="pwsh -NoProfile -ExecutionPolicy Bypass .\PostBuild.ps1 $(ConfigurationName)" />
|
||||||
WorkingDirectory="$(ProjectDir)"
|
|
||||||
StandardOutputImportance="High"
|
|
||||||
StandardErrorImportance="High" />
|
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -13,7 +13,7 @@ if (Test-Path $buildPath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Copying ReCodeItCLI output..."
|
Write-Host "Copying ReCodeItCLI output..."
|
||||||
$cliOutputDir = Join-Path (Join-Path $solutionDir "ReCodeItCLI") "bin\$Configuration\net8.0"
|
$cliOutputDir = Join-Path (Join-Path $solutionDir "ReCodeItCLI") "bin\$Configuration\net9.0"
|
||||||
if (Test-Path $cliOutputDir) {
|
if (Test-Path $cliOutputDir) {
|
||||||
New-Item -Path $buildPath -ItemType Directory -ErrorAction SilentlyContinue
|
New-Item -Path $buildPath -ItemType Directory -ErrorAction SilentlyContinue
|
||||||
Copy-Item -Path (Join-Path $cliOutputDir "*.*") -Destination $buildPath -Recurse
|
Copy-Item -Path (Join-Path $cliOutputDir "*.*") -Destination $buildPath -Recurse
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
<LangVersion>latestmajor</LangVersion>
|
<LangVersion>latestmajor</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
56
README.md
56
README.md
@ -1,19 +1,51 @@
|
|||||||
# ReCodeIt
|
# Commands
|
||||||
|
|
||||||
![image](https://github.com/CJ-SPT/ReCodeIt/assets/161484149/3bdec51c-ca48-4678-a492-5cfd0595f980)
|
- `addmissingproperties` - This command will add missing properties to the provided mapping.json.
|
||||||
|
- Param `MappingsPath` - Path to the mapping.json file to be fixed
|
||||||
|
|
||||||
|
- Note: This is a development command and should not be used unless you know what you're doing. Always make backups when using this command.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
ReCodeIt is a .net assembly tool for working with obfuscated assemblies. It allows you to deobfuscate using de4dot, create remaps for types and generated a re-mapped reference for your project. It has two main components. The GUI pictured above and a CLI companion that can be placed on the system path for access anywhere on your machine at any given time.
|
- `automatch` - This command will Automatically try to generate a mapping object given old type and new type names.
|
||||||
|
- Param `AssemblyPath` - The absolute path to your assembly, folder must contain all references to be resolved.
|
||||||
|
- Param `MappingsPath` - Path to your mapping file so it can be updated if a match is found.
|
||||||
|
- Param `OldTypeName` - Full old type name including namespace `Foo.Bar` for nested classes `Foo.Bar/FooBar`
|
||||||
|
- Param `NewTypeName` - The name you want the type to be renamed to.
|
||||||
|
|
||||||
# Building
|
- This command will prompt you to append your created mapping to the mapping file.
|
||||||
- fork or clone the project to a local directory
|
- It will then prompt you to run the remap process.
|
||||||
- Make sure you have [.net 8 sdk](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) installed or install it through the visual studio installer.
|
|
||||||
- Open the solution in visual studio and build
|
|
||||||
- Run the project from visual studio or the build folder.
|
|
||||||
|
|
||||||
# Using
|
---
|
||||||
See the [wiki](https://github.com/CJ-SPT/ReCodeIt/wiki)
|
|
||||||
|
|
||||||
# Support me
|
- `deobfuscate` - This command will run the de4dot de-obfuscater over the assembly provided. It supports both the
|
||||||
|
primary game assembly and the launcher assembly.
|
||||||
|
- Param `AssemblyPath` - The absolute path to your obfuscated assembly or exe file, the folder must contain all
|
||||||
|
references needed to be resolved.
|
||||||
|
- Param `IsLauncher` - Is the target the EFT launcher?
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
- `Dumper` - Generates a dumper zip.
|
||||||
|
- Param `ManagedDirectory` - 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
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
- `GenRefCountList` - Generates a print out of the most used classes. Useful to prioritize remap targets.
|
||||||
|
- Param `AssemblyPath` - The absolute path to your de-obfuscated and remapped dll.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
- `regensig` - regenerates the signature of a mapping if it is failing
|
||||||
|
- Param `MappingPath` - The absolute path to mapping.json.
|
||||||
|
- Param `AssemblyPath` - The absolute path to the assembly you want to regenerate the signature for.
|
||||||
|
- Param `NewTypeName` - The new type name as listed in the mapping file.
|
||||||
|
- Param `OldTypeName` - Full old type name including namespace `Foo.Bar` for nested classes `Foo.Bar/FooBar`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
- `remap` - Generates a re-mapped dll provided a mapping file and dll. If the dll is obfuscated, it will automatically de-obfuscate.
|
||||||
|
- Param `MappingJsonPath` - The absolute path to the `mapping.json` file supports both `json` and `jsonc`.
|
||||||
|
- Param `AssemblyPath` - The absolute path to the dll generated from the `deobfuscate` command.
|
||||||
|
|
||||||
If you want to support the project you [buy me a coffee!](https://ko-fi.com/dirtbikercj)
|
|
||||||
|
26
ReCodeItCLI/Commands/AddMissingProperties.cs
Normal file
26
ReCodeItCLI/Commands/AddMissingProperties.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using CliFx;
|
||||||
|
using CliFx.Attributes;
|
||||||
|
using CliFx.Infrastructure;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
|
using ReCodeItLib.Utils;
|
||||||
|
|
||||||
|
namespace ReCodeItCLI.Commands;
|
||||||
|
|
||||||
|
[Command("AddMissingProperties", Description = "[DEVELOPMENT COMMAND] This command will add missing properties to the provided mapping.json.")]
|
||||||
|
public class AddMissingProperties : ICommand
|
||||||
|
{
|
||||||
|
[CommandParameter(0, IsRequired = true, Description = "Path to the mapping.json file to be fixed")]
|
||||||
|
public string MappingsPath { get; init; }
|
||||||
|
|
||||||
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
|
var remaps = DataProvider.LoadMappingFile(MappingsPath);
|
||||||
|
DataProvider.UpdateMapping(MappingsPath, remaps);
|
||||||
|
|
||||||
|
Logger.LogSync("Successfully updated mapping file");
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using CliFx;
|
using CliFx;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
using ReCodeItLib.Models;
|
using ReCodeItLib.Models;
|
||||||
using ReCodeItLib.ReMapper;
|
using ReCodeItLib.ReMapper;
|
||||||
using ReCodeItLib.Utils;
|
using ReCodeItLib.Utils;
|
||||||
@ -16,15 +17,16 @@ public class AutoMatchCommand : ICommand
|
|||||||
[CommandParameter(1, IsRequired = true, Description = "Path to your mapping file so it can be updated if a match is found")]
|
[CommandParameter(1, IsRequired = true, Description = "Path to your mapping file so it can be updated if a match is found")]
|
||||||
public string MappingsPath { get; init; }
|
public string MappingsPath { get; init; }
|
||||||
|
|
||||||
[CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace")]
|
[CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace `Foo.Bar` for nested classes `Foo.Bar/FooBar`")]
|
||||||
public required string OldTypeName { get; init; }
|
public required string OldTypeName { get; init; }
|
||||||
|
|
||||||
[CommandParameter(3, IsRequired = true, Description = "The name you want the type to be renamed to")]
|
[CommandParameter(3, IsRequired = true, Description = "The name you want the type to be renamed to")]
|
||||||
public required string NewTypeName { get; init; }
|
public required string NewTypeName { get; init; }
|
||||||
|
|
||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
Logger.LogSync("Finding match...");
|
Logger.LogSync("Finding match...");
|
||||||
|
|
||||||
var remaps = new List<RemapModel>();
|
var remaps = new List<RemapModel>();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using CliFx;
|
using CliFx;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
using ReCodeItLib.Utils;
|
using ReCodeItLib.Utils;
|
||||||
using ReCodeItLib.ReMapper;
|
using ReCodeItLib.ReMapper;
|
||||||
|
|
||||||
@ -17,6 +18,8 @@ public class DeObfuscate : ICommand
|
|||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
Logger.Log("Deobfuscating assembly...");
|
Logger.Log("Deobfuscating assembly...");
|
||||||
|
|
||||||
Deobfuscator.Deobfuscate(AssemblyPath, IsLauncher);
|
Deobfuscator.Deobfuscate(AssemblyPath, IsLauncher);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using CliFx;
|
using CliFx;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
using ReCodeItLib.Utils;
|
using ReCodeItLib.Utils;
|
||||||
using ReCodeItLib.Dumper;
|
using ReCodeItLib.Dumper;
|
||||||
|
|
||||||
@ -14,6 +15,8 @@ public class Dumper : ICommand
|
|||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
Logger.Log("Creating DumperClass...");
|
Logger.Log("Creating DumperClass...");
|
||||||
|
|
||||||
var dumper = new DumperClass(ManagedDirectory);
|
var dumper = new DumperClass(ManagedDirectory);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using dnlib.DotNet;
|
using dnlib.DotNet;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
|
|
||||||
namespace ReCodeItCLI.Commands;
|
namespace ReCodeItCLI.Commands;
|
||||||
|
|
||||||
@ -23,6 +24,8 @@ public class GenRefList : ICommand
|
|||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
var references = CountTypeReferences(AssemblyPath);
|
var references = CountTypeReferences(AssemblyPath);
|
||||||
|
|
||||||
// Sort and display the top 10 most referenced types
|
// Sort and display the top 10 most referenced types
|
||||||
|
25
ReCodeItCLI/Commands/GetRuntimeVersion.cs
Normal file
25
ReCodeItCLI/Commands/GetRuntimeVersion.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using CliFx;
|
||||||
|
using CliFx.Attributes;
|
||||||
|
using CliFx.Infrastructure;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
|
using ReCodeItLib.Utils;
|
||||||
|
|
||||||
|
namespace ReCodeItCLI.Commands;
|
||||||
|
|
||||||
|
[Command("GetRuntimeVersion", Description = "Prints out the .net runtime version this assembly targets")]
|
||||||
|
public class GetRuntimeVersion : ICommand
|
||||||
|
{
|
||||||
|
[CommandParameter(0, IsRequired = true, Description = "The absolute path to your dll.")]
|
||||||
|
public required string AssemblyPath { get; init; }
|
||||||
|
|
||||||
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
|
var module = DataProvider.LoadModule(AssemblyPath);
|
||||||
|
|
||||||
|
Logger.LogSync($"Target Runtime Version: {module.RuntimeVersion}");
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using CliFx;
|
using CliFx;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
using ReCodeItLib.Utils;
|
using ReCodeItLib.Utils;
|
||||||
using ReCodeItLib.ReMapper;
|
using ReCodeItLib.ReMapper;
|
||||||
|
|
||||||
@ -19,6 +20,8 @@ public class ReMap : ICommand
|
|||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
DataProvider.Settings.MappingPath = MappingJsonPath;
|
DataProvider.Settings.MappingPath = MappingJsonPath;
|
||||||
|
|
||||||
var remaps = DataProvider.LoadMappingFile(MappingJsonPath);
|
var remaps = DataProvider.LoadMappingFile(MappingJsonPath);
|
||||||
|
45
ReCodeItCLI/Commands/RegenerateSignature.cs
Normal file
45
ReCodeItCLI/Commands/RegenerateSignature.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using CliFx.Attributes;
|
||||||
|
using CliFx.Infrastructure;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
|
using ReCodeItLib.ReMapper;
|
||||||
|
using ReCodeItLib.Utils;
|
||||||
|
|
||||||
|
namespace ReCodeItCLI.Commands;
|
||||||
|
|
||||||
|
[Command("regensig", Description = "regenerates the signature of a mapping if it is failing")]
|
||||||
|
public class RegenerateSignature : CliFx.ICommand
|
||||||
|
{
|
||||||
|
[CommandParameter(0, IsRequired = true, Description = "The absolute path to the assembly you want to regenerate the signature for")]
|
||||||
|
public required string AssemblyPath { get; init; }
|
||||||
|
|
||||||
|
[CommandParameter(1, IsRequired = true, Description = "The absolute path to mapping.json")]
|
||||||
|
public required string MappingPath { get; init; }
|
||||||
|
|
||||||
|
[CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace `Foo.Bar` for nested classes `Foo.Bar/FooBar`")]
|
||||||
|
public required string OldTypeName { get; init; }
|
||||||
|
|
||||||
|
[CommandParameter(3, IsRequired = true, Description = "The new type name as listed in the mapping file")]
|
||||||
|
public required string NewTypeName { get; init; }
|
||||||
|
|
||||||
|
|
||||||
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
|
DataProvider.Settings.MappingPath = MappingPath;
|
||||||
|
var remaps = DataProvider.LoadMappingFile(MappingPath);
|
||||||
|
|
||||||
|
var target = remaps.SingleOrDefault(r => r.NewTypeName == NewTypeName);
|
||||||
|
|
||||||
|
if (target is null)
|
||||||
|
{
|
||||||
|
Logger.LogSync("Could not find signature to regenerate", ConsoleColor.Red);
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
new AutoMatcher(remaps, MappingPath)
|
||||||
|
.AutoMatch(AssemblyPath, OldTypeName, NewTypeName);
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,14 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>0.1.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
25
ReCodeItCLI/Utils/Debugger.cs
Normal file
25
ReCodeItCLI/Utils/Debugger.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using ReCodeItLib.Utils;
|
||||||
|
|
||||||
|
namespace ReCodeItCLI.Utils;
|
||||||
|
|
||||||
|
public static class Debugger
|
||||||
|
{
|
||||||
|
[Conditional("WAIT_FOR_DEBUGGER")]
|
||||||
|
public static void TryWaitForDebuggerAttach()
|
||||||
|
{
|
||||||
|
const int maxDots = 3;
|
||||||
|
var dotCount = 0;
|
||||||
|
|
||||||
|
while (!System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
var dots = new string('.', dotCount);
|
||||||
|
|
||||||
|
Console.Clear();
|
||||||
|
Logger.LogSync($"Waiting for debugger{dots}");
|
||||||
|
|
||||||
|
dotCount = (dotCount + 1) % (maxDots + 1);
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,41 +0,0 @@
|
|||||||
# RecodeIt Command Line
|
|
||||||
|
|
||||||
This is the command line interface for ReCodeIt. It offers a streamlined way to operate the application without the
|
|
||||||
use of the graphical user interface (GUI). It can be used to de-obfuscate, re-map, and other smaller utilities.
|
|
||||||
It can be placed on the system path and accessed from anywhere.
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
|
|
||||||
- `deobfuscate` - This command will run the de4dot de-obfuscater over the assembly provided. It supports both the
|
|
||||||
primary game assembly and the launcher assembly.
|
|
||||||
- Param `AssemblyPath` - The absolute path to your obfuscated assembly or exe file, the folder must contain all
|
|
||||||
references needed to be resolved.
|
|
||||||
- Param `IsLauncher` - Is the target the EFT launcher?
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
- `automatch` - This command will Automatically try to generate a mapping object given old type and new type names.
|
|
||||||
- `AssemblyPath` - The absolute path to your assembly, folder must contain all references to be resolved.
|
|
||||||
- `MappingsPath` - Path to your mapping file so it can be updated if a match is found.
|
|
||||||
- `OldTypeName` - Full old type name including namespace.
|
|
||||||
- `NewTypeName` - The name you want the type to be renamed to.
|
|
||||||
|
|
||||||
- This command will prompt you to append your created mapping to the mapping file.
|
|
||||||
- It will then prompt you to run the remap process.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
- `remap` - Generates a re-mapped dll provided a mapping file and dll. If the dll is obfuscated, it will automatically de-obfuscate.
|
|
||||||
- Param `MappingJsonPath` - The absolute path to the `mapping.json` file supports both `json` and `jsonc`.
|
|
||||||
- Param `AssemblyPath` - The absolute path to the dll generated from the `deobfuscate` command.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
- `GenRefCountList` - Generates a print out of the most used classes. Useful to prioritize remap targets.
|
|
||||||
- Param `AssemblyPath` - The absolute path to your de-obfuscated and remapped dll.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
- `Dumper` - Generates a dumper zip.
|
|
||||||
- Param `ManagedDirectory` - 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
|
|
23
RecodeIt.sln
23
RecodeIt.sln
@ -39,6 +39,7 @@ Global
|
|||||||
Release|ARM64 = Release|ARM64
|
Release|ARM64 = Release|ARM64
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
Release|x86 = Release|x86
|
Release|x86 = Release|x86
|
||||||
|
WAIT_FOR_DEBUGGER|Any CPU = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
@ -61,6 +62,8 @@ Global
|
|||||||
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Release|x86.ActiveCfg = Release|Any CPU
|
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Release|x86.Build.0 = Release|Any CPU
|
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|ARM.Build.0 = Debug|Any CPU
|
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -81,6 +84,8 @@ Global
|
|||||||
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Release|x86.ActiveCfg = Release|Any CPU
|
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Release|x86.Build.0 = Release|Any CPU
|
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E404EC0B-06D2-4964-8ABA-A634F259655C}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{E404EC0B-06D2-4964-8ABA-A634F259655C}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|ARM.Build.0 = Debug|Any CPU
|
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -101,6 +106,8 @@ Global
|
|||||||
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Release|x86.ActiveCfg = Release|Any CPU
|
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Release|x86.Build.0 = Release|Any CPU
|
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|ARM.Build.0 = Debug|Any CPU
|
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -120,6 +127,8 @@ Global
|
|||||||
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x64.Build.0 = Release|Any CPU
|
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x86.ActiveCfg = Release|Any CPU
|
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x86.Build.0 = Release|Any CPU
|
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|ARM.Build.0 = Debug|Any CPU
|
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -139,6 +148,8 @@ Global
|
|||||||
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x64.Build.0 = Release|Any CPU
|
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x86.ActiveCfg = Release|Any CPU
|
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x86.Build.0 = Release|Any CPU
|
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|ARM.Build.0 = Debug|Any CPU
|
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -158,6 +169,8 @@ Global
|
|||||||
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x64.Build.0 = Release|Any CPU
|
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x86.ActiveCfg = Release|Any CPU
|
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x86.Build.0 = Release|Any CPU
|
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|ARM.Build.0 = Debug|Any CPU
|
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -178,6 +191,8 @@ Global
|
|||||||
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Release|x86.ActiveCfg = Release|Any CPU
|
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Release|x86.Build.0 = Release|Any CPU
|
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|ARM.Build.0 = Debug|Any CPU
|
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -197,6 +212,8 @@ Global
|
|||||||
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x64.Build.0 = Release|Any CPU
|
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x86.ActiveCfg = Release|Any CPU
|
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x86.Build.0 = Release|Any CPU
|
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|ARM.Build.0 = Debug|Any CPU
|
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -216,6 +233,8 @@ Global
|
|||||||
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x64.Build.0 = Release|Any CPU
|
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x86.ActiveCfg = Release|Any CPU
|
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x86.Build.0 = Release|Any CPU
|
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{8365D905-3BC4-42A0-B072-035598C6AF8C}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{8365D905-3BC4-42A0-B072-035598C6AF8C}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM.Build.0 = Debug|Any CPU
|
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
@ -236,6 +255,8 @@ Global
|
|||||||
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x86.ActiveCfg = Release|Any CPU
|
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x86.Build.0 = Release|Any CPU
|
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
@ -256,6 +277,8 @@ Global
|
|||||||
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x64.Build.0 = Release|Any CPU
|
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x86.ActiveCfg = Release|Any CPU
|
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x86.Build.0 = Release|Any CPU
|
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{55E928FA-93D2-410C-8AF6-C074C63D126B}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
|
{55E928FA-93D2-410C-8AF6-C074C63D126B}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -5,11 +5,11 @@ public enum ENoMatchReason
|
|||||||
AmbiguousWithPreviousMatch,
|
AmbiguousWithPreviousMatch,
|
||||||
AmbiguousNewTypeNames,
|
AmbiguousNewTypeNames,
|
||||||
IsPublic,
|
IsPublic,
|
||||||
|
IsAbstract,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsNested,
|
IsNested,
|
||||||
IsSealed,
|
IsSealed,
|
||||||
IsInterface,
|
IsInterface,
|
||||||
IsStruct,
|
|
||||||
IsDerived,
|
IsDerived,
|
||||||
HasGenericParameters,
|
HasGenericParameters,
|
||||||
HasAttribute,
|
HasAttribute,
|
||||||
@ -26,6 +26,7 @@ public enum ENoMatchReason
|
|||||||
NestedTypeInclude,
|
NestedTypeInclude,
|
||||||
NestedTypeExclude,
|
NestedTypeExclude,
|
||||||
NestedTypeCount,
|
NestedTypeCount,
|
||||||
|
NestedVisibility,
|
||||||
EventsInclude,
|
EventsInclude,
|
||||||
EventsExclude
|
EventsExclude
|
||||||
}
|
}
|
@ -1,9 +1,12 @@
|
|||||||
namespace ReCodeItLib.Models;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace ReCodeItLib.Models;
|
||||||
|
|
||||||
public class ItemTemplateModel
|
public class ItemTemplateModel
|
||||||
{
|
{
|
||||||
public string? _id;
|
[JsonPropertyName("_id")]
|
||||||
public string? _name;
|
public string? Id { get; set; }
|
||||||
public string? _parent;
|
|
||||||
public string? _type;
|
[JsonPropertyName("_name")]
|
||||||
|
public string? Name { get; set; }
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
using dnlib.DotNet;
|
using System.Text.Json.Serialization;
|
||||||
using Newtonsoft.Json;
|
using dnlib.DotNet;
|
||||||
using ReCodeItLib.Enums;
|
using ReCodeItLib.Enums;
|
||||||
|
|
||||||
namespace ReCodeItLib.Models;
|
namespace ReCodeItLib.Models;
|
||||||
@ -15,7 +15,8 @@ public class RemapModel
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<ENoMatchReason> NoMatchReasons { get; set; } = [];
|
public List<ENoMatchReason> NoMatchReasons { get; set; } = [];
|
||||||
|
|
||||||
[JsonIgnore] public string AmbiguousTypeMatch { get; set; } = string.Empty;
|
[JsonIgnore]
|
||||||
|
public string AmbiguousTypeMatch { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a list of type candidates that made it through the filter
|
/// This is a list of type candidates that made it through the filter
|
||||||
@ -56,14 +57,12 @@ public class SearchParams
|
|||||||
public class GenericParams
|
public class GenericParams
|
||||||
{
|
{
|
||||||
public bool IsPublic { get; set; } = true;
|
public bool IsPublic { get; set; } = true;
|
||||||
|
public bool IsAbstract { get; set; }
|
||||||
public bool? IsAbstract { get; set; } = null;
|
public bool IsInterface { get; set; }
|
||||||
public bool? IsInterface { get; set; } = null;
|
public bool IsEnum { get; set; }
|
||||||
public bool? IsStruct { get; set; } = null;
|
public bool IsSealed { get; set; }
|
||||||
public bool? IsEnum { get; set; } = null;
|
|
||||||
public bool? IsSealed { get; set; } = null;
|
|
||||||
public bool? HasAttribute { get; set; } = null;
|
public bool? HasAttribute { get; set; } = null;
|
||||||
public bool? HasGenericParameters { get; set; } = null;
|
public bool HasGenericParameters { get; set; }
|
||||||
public bool? IsDerived { get; set; } = null;
|
public bool? IsDerived { get; set; } = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -97,6 +96,12 @@ public class PropertyParams
|
|||||||
public class NestedTypeParams
|
public class NestedTypeParams
|
||||||
{
|
{
|
||||||
public bool IsNested { get; set; }
|
public bool IsNested { get; set; }
|
||||||
|
public bool IsNestedAssembly { get; set; }
|
||||||
|
public bool IsNestedFamily { get; set; }
|
||||||
|
public bool IsNestedPrivate { get; set; }
|
||||||
|
public bool IsNestedPublic { get; set; }
|
||||||
|
public bool IsNestedFamilyAndAssembly { get; set; }
|
||||||
|
public bool IsNestedFamilyOrAssembly { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the nested types parent
|
/// Name of the nested types parent
|
||||||
|
@ -3,14 +3,16 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>0.1.0</Version>
|
<Version>0.1.0</Version>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dnlib" Version="4.4.0" />
|
<PackageReference Include="dnlib" Version="4.4.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -22,12 +22,9 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
out var module);
|
out var module);
|
||||||
|
|
||||||
Module = module;
|
Module = module;
|
||||||
CandidateTypes = Module.GetTypes()
|
|
||||||
.Where(t => TypesToMatch.Any(token => t.Name.StartsWith(token)))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var targetTypeDef = FindTargetType(oldTypeName);
|
var targetTypeDef = FindTargetType(oldTypeName);
|
||||||
|
|
||||||
if (targetTypeDef is null)
|
if (targetTypeDef is null)
|
||||||
{
|
{
|
||||||
Logger.LogSync($"Could not target type: {oldTypeName}", ConsoleColor.Red);
|
Logger.LogSync($"Could not target type: {oldTypeName}", ConsoleColor.Red);
|
||||||
@ -36,9 +33,24 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
|
|
||||||
Logger.LogSync($"Found target type: {targetTypeDef!.FullName}", ConsoleColor.Green);
|
Logger.LogSync($"Found target type: {targetTypeDef!.FullName}", ConsoleColor.Green);
|
||||||
|
|
||||||
var remapModel = new RemapModel();
|
if (targetTypeDef.IsNested)
|
||||||
remapModel.NewTypeName = newTypeName;
|
{
|
||||||
remapModel.AutoGenerated = true;
|
CandidateTypes = targetTypeDef.DeclaringType.NestedTypes
|
||||||
|
.Where(t => TypesToMatch.Any(token => t.Name.StartsWith(token)))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CandidateTypes = Module.Types
|
||||||
|
.Where(t => TypesToMatch.Any(token => t.Name.StartsWith(token)))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
var remapModel = new RemapModel()
|
||||||
|
{
|
||||||
|
NewTypeName = newTypeName,
|
||||||
|
AutoGenerated = true
|
||||||
|
};
|
||||||
|
|
||||||
StartFilter(targetTypeDef, remapModel, assemblyPath);
|
StartFilter(targetTypeDef, remapModel, assemblyPath);
|
||||||
}
|
}
|
||||||
@ -57,36 +69,42 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
{
|
{
|
||||||
if (!PassesGeneralChecks(target, candidate, remapModel.SearchParams.GenericParams))
|
if (!PassesGeneralChecks(target, candidate, remapModel.SearchParams.GenericParams))
|
||||||
{
|
{
|
||||||
|
Logger.LogSync($"Candidate: {candidate.Name} filtered out after general checks", ConsoleColor.Yellow);
|
||||||
CandidateTypes!.Remove(candidate);
|
CandidateTypes!.Remove(candidate);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ContainsTargetMethods(target, candidate, remapModel.SearchParams.Methods))
|
if (!ContainsTargetMethods(target, candidate, remapModel.SearchParams.Methods))
|
||||||
{
|
{
|
||||||
|
Logger.LogSync($"Candidate: {candidate.Name} filtered out after method checks", ConsoleColor.Yellow);
|
||||||
CandidateTypes!.Remove(candidate);
|
CandidateTypes!.Remove(candidate);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ContainsTargetFields(target, candidate, remapModel.SearchParams.Fields))
|
if (!ContainsTargetFields(target, candidate, remapModel.SearchParams.Fields))
|
||||||
{
|
{
|
||||||
|
Logger.LogSync($"Candidate: {candidate.Name} filtered out after field checks", ConsoleColor.Yellow);
|
||||||
CandidateTypes!.Remove(candidate);
|
CandidateTypes!.Remove(candidate);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ContainsTargetProperties(target, candidate, remapModel.SearchParams.Properties))
|
if (!ContainsTargetProperties(target, candidate, remapModel.SearchParams.Properties))
|
||||||
{
|
{
|
||||||
|
Logger.LogSync($"Candidate: {candidate.Name} filtered out after property checks", ConsoleColor.Yellow);
|
||||||
CandidateTypes!.Remove(candidate);
|
CandidateTypes!.Remove(candidate);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ContainsTargetNestedTypes(target, candidate, remapModel.SearchParams.NestedTypes))
|
if (!ContainsTargetNestedTypes(target, candidate, remapModel.SearchParams.NestedTypes))
|
||||||
{
|
{
|
||||||
|
Logger.LogSync($"Candidate: {candidate.Name} filtered out after nested checks", ConsoleColor.Yellow);
|
||||||
CandidateTypes!.Remove(candidate);
|
CandidateTypes!.Remove(candidate);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ContainsTargetEvents(target, candidate, remapModel.SearchParams.Events))
|
if (!ContainsTargetEvents(target, candidate, remapModel.SearchParams.Events))
|
||||||
{
|
{
|
||||||
|
Logger.LogSync($"Candidate: {candidate.Name} filtered out after event checks", ConsoleColor.Yellow);
|
||||||
CandidateTypes!.Remove(candidate);
|
CandidateTypes!.Remove(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,8 +120,11 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
|
|
||||||
new ReMapper().InitializeRemap(tmpList, assemblyPath, validate: true);
|
new ReMapper().InitializeRemap(tmpList, assemblyPath, validate: true);
|
||||||
|
|
||||||
ProcessEndQuestions(remapModel, assemblyPath);
|
if (remapModel.Succeeded)
|
||||||
return;
|
{
|
||||||
|
ProcessEndQuestions(remapModel, assemblyPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.LogSync("Could not find a match... :(", ConsoleColor.Red);
|
Logger.LogSync("Could not find a match... :(", ConsoleColor.Red);
|
||||||
@ -125,7 +146,6 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
parms.IsAbstract = target.IsAbstract;
|
parms.IsAbstract = target.IsAbstract;
|
||||||
parms.IsInterface = target.IsInterface;
|
parms.IsInterface = target.IsInterface;
|
||||||
parms.IsEnum = target.IsEnum;
|
parms.IsEnum = target.IsEnum;
|
||||||
parms.IsStruct = target.IsValueType && !target.IsEnum;
|
|
||||||
parms.HasGenericParameters = target.HasGenericParameters;
|
parms.HasGenericParameters = target.HasGenericParameters;
|
||||||
parms.IsSealed = target.IsSealed;
|
parms.IsSealed = target.IsSealed;
|
||||||
parms.HasAttribute = target.HasCustomAttributes;
|
parms.HasAttribute = target.HasCustomAttributes;
|
||||||
@ -183,7 +203,8 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
methods.ConstructorParameterCount = target.Methods.First(m => m.IsConstructor && m.Parameters.Count > 0).Parameters.Count - 1;
|
methods.ConstructorParameterCount = target.Methods.First(m => m.IsConstructor && m.Parameters.Count > 0).Parameters.Count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return commonMethods.Any();
|
// True if we have common methods, or all methods are constructors
|
||||||
|
return commonMethods.Any() || target.Methods.All(m => m.IsConstructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ContainsTargetFields(TypeDef target, TypeDef candidate, FieldParams fields)
|
private bool ContainsTargetFields(TypeDef target, TypeDef candidate, FieldParams fields)
|
||||||
@ -294,13 +315,19 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
|
|
||||||
nt.NestedTypeCount = target.NestedTypes.Count;
|
nt.NestedTypeCount = target.NestedTypes.Count;
|
||||||
nt.IsNested = target.IsNested;
|
nt.IsNested = target.IsNested;
|
||||||
|
nt.IsNestedAssembly = target.IsNestedAssembly;
|
||||||
|
nt.IsNestedFamily = target.IsNestedFamily;
|
||||||
|
nt.IsNestedPrivate = target.IsNestedPrivate;
|
||||||
|
nt.IsNestedPublic = target.IsNestedPublic;
|
||||||
|
nt.IsNestedFamilyAndAssembly = target.IsNestedFamilyAndAssembly;
|
||||||
|
nt.IsNestedFamilyOrAssembly = target.IsNestedFamilyOrAssembly;
|
||||||
|
|
||||||
if (target.DeclaringType is not null)
|
if (target.DeclaringType is not null)
|
||||||
{
|
{
|
||||||
nt.NestedTypeParentName = target.DeclaringType.Name.String;
|
nt.NestedTypeParentName = target.DeclaringType.Name.String;
|
||||||
}
|
}
|
||||||
|
|
||||||
return commonNts.Any() || !target.IsNested;
|
return commonNts.Any() || target.NestedTypes.Count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ContainsTargetEvents(TypeDef target, TypeDef candidate, EventParams events)
|
private bool ContainsTargetEvents(TypeDef target, TypeDef candidate, EventParams events)
|
||||||
@ -376,7 +403,7 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mappings.Add(remapModel);
|
mappings.Add(remapModel);
|
||||||
DataProvider.UpdateMapping(mappingPath, mappings);
|
DataProvider.UpdateMapping(mappingPath, mappings, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.LogSync("Would you like to run the remap process?... (y/n)", ConsoleColor.Yellow);
|
Logger.LogSync("Would you like to run the remap process?... (y/n)", ConsoleColor.Yellow);
|
||||||
|
@ -1,226 +0,0 @@
|
|||||||
using dnlib.DotNet;
|
|
||||||
using ReCodeItLib.Models;
|
|
||||||
|
|
||||||
namespace ReCodeItLib.ReMapper.Filters;
|
|
||||||
|
|
||||||
internal static class GenericTypeFilters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on public, or nested public or private if the nested flag is set. This is a
|
|
||||||
/// required property
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterPublic(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
// REQUIRED PROPERTY
|
|
||||||
if (parms.GenericParams.IsPublic)
|
|
||||||
{
|
|
||||||
if (parms.NestedTypes.IsNested is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsNestedPublic);
|
|
||||||
|
|
||||||
types = FilterNestedByName(types, parms);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsPublic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (parms.NestedTypes.IsNested is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsNestedPrivate
|
|
||||||
|| t.IsNestedFamily
|
|
||||||
|| t.IsNestedFamilyAndAssembly
|
|
||||||
|| t.IsNestedAssembly);
|
|
||||||
|
|
||||||
types = FilterNestedByName(types, parms);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsNotPublic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IEnumerable<TypeDef> FilterNestedByName(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
if (parms.NestedTypes.NestedTypeParentName is not "")
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.DeclaringType.Name.String == parms.NestedTypes.NestedTypeParentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on IsAbstract
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterAbstract(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
// Filter based on abstract or not
|
|
||||||
if (parms.GenericParams.IsAbstract is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsAbstract && !t.IsInterface);
|
|
||||||
}
|
|
||||||
else if (parms.GenericParams.IsAbstract is false)
|
|
||||||
{
|
|
||||||
types = types.Where(t => !t.IsAbstract);
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on IsAbstract
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterSealed(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
// Filter based on abstract or not
|
|
||||||
if (parms.GenericParams.IsSealed is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsSealed);
|
|
||||||
}
|
|
||||||
else if (parms.GenericParams.IsSealed is false)
|
|
||||||
{
|
|
||||||
types = types.Where(t => !t.IsSealed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on IsInterface
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterInterface(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
// Filter based on interface or not
|
|
||||||
if (parms.GenericParams.IsInterface is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsInterface);
|
|
||||||
}
|
|
||||||
else if (parms.GenericParams.IsInterface is false)
|
|
||||||
{
|
|
||||||
types = types.Where(t => !t.IsInterface);
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on IsStruct
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterStruct(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
if (parms.GenericParams.IsStruct is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsValueType && !t.IsEnum);
|
|
||||||
}
|
|
||||||
else if (parms.GenericParams.IsStruct is false)
|
|
||||||
{
|
|
||||||
types = types.Where(t => !t.IsValueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on IsEnum
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterEnum(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
// Filter based on enum or not
|
|
||||||
if (parms.GenericParams.IsEnum is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.IsEnum);
|
|
||||||
}
|
|
||||||
else if (parms.GenericParams.IsEnum is false)
|
|
||||||
{
|
|
||||||
types = types.Where(t => !t.IsEnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on HasAttribute
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterAttributes(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
// Filter based on HasAttribute or not
|
|
||||||
if (parms.GenericParams.HasAttribute is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.HasCustomAttributes);
|
|
||||||
}
|
|
||||||
else if (parms.GenericParams.HasAttribute is false)
|
|
||||||
{
|
|
||||||
types = types.Where(t => !t.HasCustomAttributes);
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on HasAttribute
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterDerived(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
// Filter based on IsDerived or not
|
|
||||||
if (parms.GenericParams.IsDerived is true)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.GetBaseType()?.Name?.String != "Object");
|
|
||||||
|
|
||||||
if (parms.GenericParams.MatchBaseClass is not null and not "")
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.GetBaseType()?.Name?.String == parms.GenericParams.MatchBaseClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (parms.GenericParams.IsDerived is false)
|
|
||||||
{
|
|
||||||
types = types.Where(t => t.GetBaseType()?.Name?.String is "Object");
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Filters based on method count
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="types"></param>
|
|
||||||
/// <param name="parms"></param>
|
|
||||||
/// <returns>Filtered list</returns>
|
|
||||||
public static IEnumerable<TypeDef> FilterByGenericParameters(IEnumerable<TypeDef> types, SearchParams parms)
|
|
||||||
{
|
|
||||||
if (parms.GenericParams.HasGenericParameters is null) return types;
|
|
||||||
|
|
||||||
types = types.Where(t => t.HasGenericParameters == parms.GenericParams.HasGenericParameters);
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
|
@ -71,4 +71,32 @@ internal static class NestedTypeFilters
|
|||||||
|
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<TypeDef> FilterByNestedVisibility(IEnumerable<TypeDef> types, SearchParams parms)
|
||||||
|
{
|
||||||
|
types = FilterNestedByName(types, parms);
|
||||||
|
|
||||||
|
var ntp = parms.NestedTypes;
|
||||||
|
|
||||||
|
types = types.Where(t =>
|
||||||
|
t.IsNestedAssembly == ntp.IsNestedAssembly
|
||||||
|
&& t.IsNestedFamily == ntp.IsNestedFamily
|
||||||
|
&& t.IsNestedPrivate == ntp.IsNestedPrivate
|
||||||
|
&& t.IsNestedPublic == ntp.IsNestedPublic
|
||||||
|
&& t.IsNestedFamilyAndAssembly == ntp.IsNestedFamilyAndAssembly
|
||||||
|
&& t.IsNestedFamilyOrAssembly == ntp.IsNestedFamilyOrAssembly
|
||||||
|
);
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<TypeDef> FilterNestedByName(IEnumerable<TypeDef> types, SearchParams parms)
|
||||||
|
{
|
||||||
|
if (parms.NestedTypes.NestedTypeParentName is not "")
|
||||||
|
{
|
||||||
|
types = types.Where(t => t.DeclaringType.Name.String == parms.NestedTypes.NestedTypeParentName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
}
|
}
|
@ -5,33 +5,7 @@ namespace ReCodeItLib.ReMapper;
|
|||||||
|
|
||||||
internal class Publicizer
|
internal class Publicizer
|
||||||
{
|
{
|
||||||
public void PublicizeClasses(ModuleDefMD definition, bool isLauncher = false)
|
public void PublicizeType(TypeDef type)
|
||||||
{
|
|
||||||
var types = definition.GetTypes();
|
|
||||||
|
|
||||||
var publicizeTasks = new List<Task>();
|
|
||||||
foreach (var type in types)
|
|
||||||
{
|
|
||||||
if (type.IsNested) continue; // Nested types are handled when publicizing the parent type
|
|
||||||
|
|
||||||
publicizeTasks.Add(
|
|
||||||
Task.Factory.StartNew(() =>
|
|
||||||
{
|
|
||||||
PublicizeType(type, isLauncher);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: This is broken. No idea why.
|
|
||||||
while (!publicizeTasks.TrueForAll(t => t.Status == TaskStatus.RanToCompletion))
|
|
||||||
{
|
|
||||||
Logger.DrawProgressBar(publicizeTasks.Where(t => t.IsCompleted)!.Count() + 1, publicizeTasks.Count, 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
Task.WaitAll(publicizeTasks.ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void PublicizeType(TypeDef type, bool isLauncher)
|
|
||||||
{
|
{
|
||||||
// if (type.CustomAttributes.Any(a => a.AttributeType.Name ==
|
// if (type.CustomAttributes.Any(a => a.AttributeType.Name ==
|
||||||
// nameof(CompilerGeneratedAttribute))) { return; }
|
// nameof(CompilerGeneratedAttribute))) { return; }
|
||||||
@ -45,7 +19,7 @@ internal class Publicizer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.IsSealed && !isLauncher)
|
if (type.IsSealed)
|
||||||
{
|
{
|
||||||
type.Attributes &= ~TypeAttributes.Sealed; // Remove the Sealed attribute if it exists
|
type.Attributes &= ~TypeAttributes.Sealed; // Remove the Sealed attribute if it exists
|
||||||
}
|
}
|
||||||
@ -63,7 +37,7 @@ internal class Publicizer
|
|||||||
|
|
||||||
foreach (var nestedType in type.NestedTypes)
|
foreach (var nestedType in type.NestedTypes)
|
||||||
{
|
{
|
||||||
PublicizeType(nestedType, isLauncher);
|
PublicizeType(nestedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,15 +11,13 @@ namespace ReCodeItLib.ReMapper;
|
|||||||
public class ReMapper
|
public class ReMapper
|
||||||
{
|
{
|
||||||
private ModuleDefMD? Module { get; set; }
|
private ModuleDefMD? Module { get; set; }
|
||||||
|
|
||||||
public static bool IsRunning { get; private set; } = false;
|
|
||||||
|
|
||||||
private static readonly Stopwatch Stopwatch = new();
|
private static readonly Stopwatch Stopwatch = new();
|
||||||
private string OutPath { get; set; } = string.Empty;
|
private string OutPath { get; set; } = string.Empty;
|
||||||
|
|
||||||
private List<RemapModel> _remaps = [];
|
private List<RemapModel> _remaps = [];
|
||||||
|
|
||||||
private List<string> _alreadyGivenNames = [];
|
private readonly List<string> _alreadyGivenNames = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start the remapping process
|
/// Start the remapping process
|
||||||
@ -30,9 +28,7 @@ public class ReMapper
|
|||||||
string outPath = "",
|
string outPath = "",
|
||||||
bool validate = false)
|
bool validate = false)
|
||||||
{
|
{
|
||||||
_remaps = [];
|
|
||||||
_remaps = remapModels;
|
_remaps = remapModels;
|
||||||
_alreadyGivenNames = [];
|
|
||||||
|
|
||||||
assemblyPath = AssemblyUtils.TryDeObfuscate(
|
assemblyPath = AssemblyUtils.TryDeObfuscate(
|
||||||
DataProvider.LoadModule(assemblyPath),
|
DataProvider.LoadModule(assemblyPath),
|
||||||
@ -44,18 +40,18 @@ public class ReMapper
|
|||||||
OutPath = outPath;
|
OutPath = outPath;
|
||||||
|
|
||||||
if (!Validate(_remaps)) return;
|
if (!Validate(_remaps)) return;
|
||||||
|
|
||||||
IsRunning = true;
|
|
||||||
Stopwatch.Start();
|
Stopwatch.Start();
|
||||||
|
|
||||||
var types = Module.GetTypes();
|
var types = Module.GetTypes();
|
||||||
|
|
||||||
|
var typeDefs = types as TypeDef[] ?? types.ToArray();
|
||||||
if (!validate)
|
if (!validate)
|
||||||
{
|
{
|
||||||
GenerateDynamicRemaps(assemblyPath, types);
|
GenerateDynamicRemaps(assemblyPath, typeDefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
FindBestMatches(types, validate);
|
FindBestMatches(typeDefs, validate);
|
||||||
ChooseBestMatches();
|
ChooseBestMatches();
|
||||||
|
|
||||||
// Don't go any further during a validation
|
// Don't go any further during a validation
|
||||||
@ -67,11 +63,8 @@ public class ReMapper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenameMatches(types);
|
RenameMatches(typeDefs);
|
||||||
|
|
||||||
Publicize();
|
Publicize();
|
||||||
|
|
||||||
// We are done, write the assembly
|
|
||||||
WriteAssembly();
|
WriteAssembly();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,9 +85,9 @@ public class ReMapper
|
|||||||
|
|
||||||
if (!validate)
|
if (!validate)
|
||||||
{
|
{
|
||||||
while (!tasks.TrueForAll(t => t.Status == TaskStatus.RanToCompletion))
|
while (!tasks.TrueForAll(t => t.Status is TaskStatus.RanToCompletion or TaskStatus.Faulted))
|
||||||
{
|
{
|
||||||
Logger.DrawProgressBar(tasks.Where(t => t.IsCompleted)!.Count() + 1, tasks.Count, 50);
|
Logger.DrawProgressBar(tasks.Count(t => t.IsCompleted), tasks.Count, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,9 +111,9 @@ public class ReMapper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!renameTasks.TrueForAll(t => t.Status == TaskStatus.RanToCompletion))
|
while (!renameTasks.TrueForAll(t => t.Status is TaskStatus.RanToCompletion or TaskStatus.Faulted))
|
||||||
{
|
{
|
||||||
Logger.DrawProgressBar(renameTasks.Where(t => t.IsCompleted)!.Count() + 1, renameTasks.Count, 50);
|
Logger.DrawProgressBar(renameTasks.Count(t => t.IsCompleted), renameTasks.Count, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.WaitAll(renameTasks.ToArray());
|
Task.WaitAll(renameTasks.ToArray());
|
||||||
@ -128,33 +121,51 @@ public class ReMapper
|
|||||||
|
|
||||||
private void Publicize()
|
private void Publicize()
|
||||||
{
|
{
|
||||||
// Don't publicize and unseal until after the remapping, so we can use those as search parameters
|
|
||||||
Logger.LogSync("\nPublicizing classes...", ConsoleColor.Green);
|
Logger.LogSync("\nPublicizing classes...", ConsoleColor.Green);
|
||||||
|
|
||||||
|
var publicizer = new Publicizer();
|
||||||
|
|
||||||
|
var publicizeTasks = new List<Task>(Module!.Types.Count(t => !t.IsNested));
|
||||||
|
foreach (var type in Module!.Types)
|
||||||
|
{
|
||||||
|
if (type.IsNested) continue; // Nested types are handled when publicizing the parent type
|
||||||
|
|
||||||
|
publicizeTasks.Add(
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
publicizer.PublicizeType(type);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogSync($"Exception in task: {ex.Message}", ConsoleColor.Red);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
new Publicizer().PublicizeClasses(Module);
|
Task.WaitAll(publicizeTasks.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Validate(List<RemapModel> remaps)
|
private static bool Validate(List<RemapModel> remaps)
|
||||||
{
|
{
|
||||||
var duplicateGroups = remaps
|
var duplicateGroups = remaps
|
||||||
.GroupBy(m => m.NewTypeName)
|
.GroupBy(m => m.NewTypeName)
|
||||||
.Where(g => g.Count() > 1)
|
.Where(g => g.Count() > 1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (duplicateGroups.Count() > 1)
|
if (duplicateGroups.Count <= 1) return true;
|
||||||
|
|
||||||
|
Logger.Log($"There were {duplicateGroups.Count} duplicated sets of remaps.", ConsoleColor.Yellow);
|
||||||
|
|
||||||
|
foreach (var duplicate in duplicateGroups)
|
||||||
{
|
{
|
||||||
Logger.Log($"There were {duplicateGroups.Count()} duplicated sets of remaps.", ConsoleColor.Yellow);
|
var duplicateNewTypeName = duplicate.Key;
|
||||||
|
Logger.Log($"Ambiguous NewTypeName: {duplicateNewTypeName} found. Cancelling Remap.", ConsoleColor.Red);
|
||||||
foreach (var duplicate in duplicateGroups)
|
|
||||||
{
|
|
||||||
var duplicateNewTypeName = duplicate.Key;
|
|
||||||
Logger.Log($"Ambiguous NewTypeName: {duplicateNewTypeName} found. Cancelling Remap.", ConsoleColor.Red);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -162,9 +173,10 @@ public class ReMapper
|
|||||||
/// where null is a third disabled state. Then we score the types based on the search parameters
|
/// where null is a third disabled state. Then we score the types based on the search parameters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mapping">Mapping to score</param>
|
/// <param name="mapping">Mapping to score</param>
|
||||||
|
/// <param name="types">Types to filter</param>
|
||||||
private void ScoreMapping(RemapModel mapping, IEnumerable<TypeDef> types)
|
private void ScoreMapping(RemapModel mapping, IEnumerable<TypeDef> types)
|
||||||
{
|
{
|
||||||
var tokens = DataProvider.Settings?.TypeNamesToMatch;
|
var tokens = DataProvider.Settings.TypeNamesToMatch;
|
||||||
|
|
||||||
if (mapping.UseForceRename)
|
if (mapping.UseForceRename)
|
||||||
{
|
{
|
||||||
@ -173,14 +185,13 @@ public class ReMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter down nested objects
|
// Filter down nested objects
|
||||||
if (mapping.SearchParams.NestedTypes.IsNested is false)
|
types = !mapping.SearchParams.NestedTypes.IsNested
|
||||||
{
|
? types.Where(type => tokens.Any(token => type.Name.StartsWith(token)))
|
||||||
types = types.Where(type => tokens!.Any(token => type.Name.StartsWith(token)));
|
: types.Where(t => t.DeclaringType != null);
|
||||||
}
|
|
||||||
|
|
||||||
if (mapping.SearchParams.NestedTypes.NestedTypeParentName != string.Empty)
|
if (mapping.SearchParams.NestedTypes.NestedTypeParentName != string.Empty)
|
||||||
{
|
{
|
||||||
types = types.Where(t => t.DeclaringType != null && t.DeclaringType.Name == mapping.SearchParams.NestedTypes.NestedTypeParentName);
|
types = types.Where(t => t.DeclaringType.Name == mapping.SearchParams.NestedTypes.NestedTypeParentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run through a series of filters and report an error if all types are filtered out.
|
// Run through a series of filters and report an error if all types are filtered out.
|
||||||
@ -195,16 +206,15 @@ public class ReMapper
|
|||||||
{
|
{
|
||||||
foreach (var type in types)
|
foreach (var type in types)
|
||||||
{
|
{
|
||||||
if (type.Name == mapping.OriginalTypeName)
|
if (type.Name != mapping.OriginalTypeName) continue;
|
||||||
{
|
|
||||||
mapping.TypePrimeCandidate = type;
|
mapping.TypePrimeCandidate = type;
|
||||||
mapping.OriginalTypeName = type.Name.String;
|
mapping.OriginalTypeName = type.Name.String;
|
||||||
mapping.Succeeded = true;
|
mapping.Succeeded = true;
|
||||||
|
|
||||||
_alreadyGivenNames.Add(mapping.OriginalTypeName);
|
_alreadyGivenNames.Add(mapping.OriginalTypeName);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,23 +243,23 @@ public class ReMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
var typeTable = (Dictionary<string, Type>)templateMappingClass
|
var typeTable = (Dictionary<string, Type>)templateMappingClass
|
||||||
.GetField("TypeTable")
|
.GetField("TypeTable")!
|
||||||
.GetValue(templateMappingClass);
|
.GetValue(templateMappingClass)!;
|
||||||
|
|
||||||
BuildAssociationFromTable(typeTable!, "ItemClass");
|
BuildAssociationFromTable(typeTable, "ItemClass");
|
||||||
|
|
||||||
var templateTypeTable = (Dictionary<string, Type>)templateMappingClass
|
var templateTypeTable = (Dictionary<string, Type>)templateMappingClass
|
||||||
.GetField("TemplateTypeTable")
|
.GetField("TemplateTypeTable")!
|
||||||
.GetValue(templateMappingClass);
|
.GetValue(templateMappingClass)!;
|
||||||
|
|
||||||
BuildAssociationFromTable(templateTypeTable!, "TemplateClass");
|
BuildAssociationFromTable(templateTypeTable, "TemplateClass");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildAssociationFromTable(Dictionary<string, Type> table, string extName)
|
private void BuildAssociationFromTable(Dictionary<string, Type> table, string extName)
|
||||||
{
|
{
|
||||||
foreach (var type in table)
|
foreach (var type in table)
|
||||||
{
|
{
|
||||||
if (!DataProvider.ItemTemplates!.TryGetValue(type.Key, out var template) ||
|
if (!DataProvider.ItemTemplates.TryGetValue(type.Key, out var template) ||
|
||||||
!type.Value.Name.StartsWith("GClass"))
|
!type.Value.Name.StartsWith("GClass"))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -258,10 +268,10 @@ public class ReMapper
|
|||||||
var remap = new RemapModel
|
var remap = new RemapModel
|
||||||
{
|
{
|
||||||
OriginalTypeName = type.Value.Name,
|
OriginalTypeName = type.Value.Name,
|
||||||
NewTypeName = $"{template._name}{extName}",
|
NewTypeName = $"{template.Name}{extName}",
|
||||||
UseForceRename = true
|
UseForceRename = true
|
||||||
};
|
};
|
||||||
|
|
||||||
_remaps.Add(remap);
|
_remaps.Add(remap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +325,7 @@ public class ReMapper
|
|||||||
{
|
{
|
||||||
var moduleName = Module?.Name;
|
var moduleName = Module?.Name;
|
||||||
|
|
||||||
var dllName = "-cleaned-remapped-publicized.dll";
|
const string dllName = "-cleaned-remapped-publicized.dll";
|
||||||
OutPath = Path.Combine(OutPath, moduleName?.Replace(".dll", dllName));
|
OutPath = Path.Combine(OutPath, moduleName?.Replace(".dll", dllName));
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -327,9 +337,8 @@ public class ReMapper
|
|||||||
Logger.LogSync(e);
|
Logger.LogSync(e);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.LogSync("\nCreating Hollow...", ConsoleColor.Green);
|
StartHollow();
|
||||||
Hollow();
|
|
||||||
|
|
||||||
var hollowedDir = Path.GetDirectoryName(OutPath);
|
var hollowedDir = Path.GetDirectoryName(OutPath);
|
||||||
var hollowedPath = Path.Combine(hollowedDir!, "Assembly-CSharp-hollowed.dll");
|
var hollowedPath = Path.Combine(hollowedDir!, "Assembly-CSharp-hollowed.dll");
|
||||||
@ -344,9 +353,9 @@ public class ReMapper
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataProvider.Settings?.MappingPath != string.Empty)
|
if (DataProvider.Settings.MappingPath != string.Empty)
|
||||||
{
|
{
|
||||||
DataProvider.UpdateMapping(DataProvider.Settings!.MappingPath!.Replace("mappings.", "mappings-new."), _remaps);
|
DataProvider.UpdateMapping(DataProvider.Settings.MappingPath.Replace("mappings.", "mappings-new."), _remaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
new Statistics(_remaps, Stopwatch, OutPath, hollowedPath)
|
new Statistics(_remaps, Stopwatch, OutPath, hollowedPath)
|
||||||
@ -354,24 +363,42 @@ public class ReMapper
|
|||||||
|
|
||||||
Stopwatch.Reset();
|
Stopwatch.Reset();
|
||||||
Module = null;
|
Module = null;
|
||||||
|
|
||||||
IsRunning = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hollows out all logic from the dll
|
/// Hollows out all logic from the dll
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Hollow()
|
private void StartHollow()
|
||||||
{
|
{
|
||||||
foreach (var type in Module!.GetTypes())
|
Logger.LogSync("Creating Hollow...", ConsoleColor.Green);
|
||||||
|
|
||||||
|
var tasks = new List<Task>(Module!.GetTypes().Count());
|
||||||
|
foreach (var type in Module.GetTypes())
|
||||||
{
|
{
|
||||||
foreach (var method in type.Methods.Where(m => m.HasBody))
|
tasks.Add(Task.Run(() =>
|
||||||
{
|
{
|
||||||
if (!method.HasBody) continue;
|
try
|
||||||
|
{
|
||||||
|
HollowType(type);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogSync($"Exception in task: {ex.Message}", ConsoleColor.Red);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
Task.WaitAll(tasks.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
method.Body = new CilBody();
|
private void HollowType(TypeDef type)
|
||||||
method.Body.Instructions.Add(OpCodes.Ret.ToInstruction());
|
{
|
||||||
}
|
foreach (var method in type.Methods.Where(m => m.HasBody))
|
||||||
|
{
|
||||||
|
if (!method.HasBody) continue;
|
||||||
|
|
||||||
|
method.Body = new CilBody();
|
||||||
|
method.Body.Instructions.Add(OpCodes.Ret.ToInstruction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,34 +7,26 @@ namespace ReCodeItLib.ReMapper;
|
|||||||
internal class Renamer
|
internal class Renamer
|
||||||
{
|
{
|
||||||
private static List<string> TokensToMatch => DataProvider.Settings!.TypeNamesToMatch;
|
private static List<string> TokensToMatch => DataProvider.Settings!.TypeNamesToMatch;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Only used by the manual remapper, should probably be removed
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="module"></param>
|
|
||||||
/// <param name="remap"></param>
|
|
||||||
/// <param name="direct"></param>
|
|
||||||
public void RenameAll(IEnumerable<TypeDef> types, RemapModel remap)
|
public void RenameAll(IEnumerable<TypeDef> types, RemapModel remap)
|
||||||
{
|
{
|
||||||
if (remap.TypePrimeCandidate is null)
|
if (remap.TypePrimeCandidate is null) return;
|
||||||
{
|
|
||||||
Logger.Log($"Unable to rename {remap.NewTypeName} as TypePrimeCandidate value is null/empty, skipping", ConsoleColor.Red);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename all fields and properties first
|
// Rename all fields and properties first
|
||||||
|
var typesToCheck = types as TypeDef[] ?? types.ToArray();
|
||||||
RenameAllFields(
|
RenameAllFields(
|
||||||
remap.TypePrimeCandidate.Name.String,
|
remap.TypePrimeCandidate.Name.String,
|
||||||
remap.NewTypeName,
|
remap.NewTypeName,
|
||||||
types);
|
typesToCheck);
|
||||||
|
|
||||||
RenameAllProperties(
|
RenameAllProperties(
|
||||||
remap!.TypePrimeCandidate!.Name.String,
|
remap.TypePrimeCandidate!.Name.String,
|
||||||
remap.NewTypeName,
|
remap.NewTypeName,
|
||||||
types);
|
typesToCheck);
|
||||||
|
|
||||||
FixMethods(types, remap);
|
FixMethods(typesToCheck, remap);
|
||||||
RenameType(types, remap);
|
|
||||||
|
remap.TypePrimeCandidate.Name = remap.NewTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FixMethods(
|
private static void FixMethods(
|
||||||
@ -43,15 +35,17 @@ internal class Renamer
|
|||||||
{
|
{
|
||||||
foreach (var type in typesToCheck)
|
foreach (var type in typesToCheck)
|
||||||
{
|
{
|
||||||
var methods = type.Methods
|
List<MethodDef> methodsToFix = [];
|
||||||
.Where(method => method.Name.StartsWith(remap!.TypePrimeCandidate!.Name.String)
|
|
||||||
&& type.Methods.Count(m2 => m2.Name.String.EndsWith(method.Name.String.Split(".")[1])) < 2);
|
methodsToFix.AddRange(
|
||||||
|
from method in type.Methods where method.Name.StartsWith(remap.TypePrimeCandidate!.Name.String)
|
||||||
|
let splitName = method.Name.String.Split(".") where splitName.Length != 1 select method);
|
||||||
|
|
||||||
foreach (var method in methods)
|
foreach (var method in methodsToFix)
|
||||||
{
|
{
|
||||||
var name = method.Name.String.Split(".");
|
var name = method.Name.String.Split(".");
|
||||||
|
|
||||||
if (methods.Count(m => m.Name.String.EndsWith(name[1])) > 1)
|
if (methodsToFix.Count(m => m.Name.String.EndsWith(name[1])) > 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
method.Name = name[1];
|
method.Name = name[1];
|
||||||
@ -59,43 +53,35 @@ internal class Renamer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Rename all fields recursively, returns number of fields changed
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="oldTypeName"></param>
|
|
||||||
/// <param name="newTypeName"></param>
|
|
||||||
/// <param name="typesToCheck"></param>
|
|
||||||
private static void RenameAllFields(
|
private static void RenameAllFields(
|
||||||
|
|
||||||
string oldTypeName,
|
string oldTypeName,
|
||||||
string newTypeName,
|
string newTypeName,
|
||||||
IEnumerable<TypeDef> typesToCheck)
|
IEnumerable<TypeDef> typesToCheck)
|
||||||
{
|
{
|
||||||
foreach (var type in typesToCheck)
|
var typeDefs = typesToCheck as TypeDef[] ?? typesToCheck.ToArray();
|
||||||
|
foreach (var type in typeDefs)
|
||||||
{
|
{
|
||||||
var fields = type.Fields
|
var fields = type.Fields
|
||||||
.Where(field => field.Name.IsFieldOrPropNameInList(TokensToMatch!));
|
.Where(field => field.Name.IsFieldOrPropNameInList(TokensToMatch));
|
||||||
|
|
||||||
if (!fields.Any()) { continue; }
|
var fieldCount = 0;
|
||||||
|
|
||||||
int fieldCount = 0;
|
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
if (field.FieldType.TypeName == oldTypeName)
|
if (field.FieldType.TypeName != oldTypeName) continue;
|
||||||
{
|
|
||||||
var newFieldName = GetNewFieldName(newTypeName, fieldCount);
|
var newFieldName = GetNewFieldName(newTypeName, fieldCount);
|
||||||
|
|
||||||
// Dont need to do extra work
|
// Dont need to do extra work
|
||||||
if (field.Name == newFieldName) { continue; }
|
if (field.Name == newFieldName) { continue; }
|
||||||
|
|
||||||
var oldName = field.Name.ToString();
|
var oldName = field.Name.ToString();
|
||||||
|
|
||||||
field.Name = newFieldName;
|
field.Name = newFieldName;
|
||||||
|
|
||||||
UpdateAllTypeFieldMemberRefs(typesToCheck, field, oldName);
|
UpdateAllTypeFieldMemberRefs(typeDefs, field, oldName);
|
||||||
|
|
||||||
fieldCount++;
|
fieldCount++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,12 +110,6 @@ internal class Renamer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Rename all properties recursively, returns number of fields changed
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="oldTypeName"></param>
|
|
||||||
/// <param name="newTypeName"></param>
|
|
||||||
/// <param name="typesToCheck"></param>
|
|
||||||
private static void RenameAllProperties(
|
private static void RenameAllProperties(
|
||||||
string oldTypeName,
|
string oldTypeName,
|
||||||
string newTypeName,
|
string newTypeName,
|
||||||
@ -138,61 +118,34 @@ internal class Renamer
|
|||||||
foreach (var type in typesToCheck)
|
foreach (var type in typesToCheck)
|
||||||
{
|
{
|
||||||
var properties = type.Properties
|
var properties = type.Properties
|
||||||
.Where(prop => prop.Name.IsFieldOrPropNameInList(TokensToMatch!));
|
.Where(prop => prop.Name.IsFieldOrPropNameInList(TokensToMatch));
|
||||||
|
|
||||||
if (!properties.Any()) { continue; }
|
var propertyCount = 0;
|
||||||
|
|
||||||
int propertyCount = 0;
|
|
||||||
foreach (var property in properties)
|
foreach (var property in properties)
|
||||||
{
|
{
|
||||||
if (property.PropertySig.RetType.TypeName == oldTypeName)
|
if (property.PropertySig.RetType.TypeName != oldTypeName) continue;
|
||||||
{
|
|
||||||
var newPropertyName = GetNewPropertyName(newTypeName, propertyCount);
|
var newPropertyName = GetNewPropertyName(newTypeName, propertyCount);
|
||||||
|
|
||||||
// Dont need to do extra work
|
// Dont need to do extra work
|
||||||
if (property.Name == newPropertyName) { continue; }
|
if (property.Name == newPropertyName) continue;
|
||||||
|
|
||||||
property.Name = new UTF8String(newPropertyName);
|
property.Name = newPropertyName;
|
||||||
|
|
||||||
propertyCount++;
|
propertyCount++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetNewFieldName(string NewName, int fieldCount = 0)
|
private static string GetNewFieldName(string newName, int fieldCount = 0)
|
||||||
{
|
{
|
||||||
string newFieldCount = fieldCount > 0 ? $"_{fieldCount}" : string.Empty;
|
var newFieldCount = fieldCount > 0 ? $"_{fieldCount}" : string.Empty;
|
||||||
|
|
||||||
return $"{char.ToLower(NewName[0])}{NewName[1..]}{newFieldCount}";
|
return $"{char.ToLower(newName[0])}{newName[1..]}{newFieldCount}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetNewPropertyName(string newName, int propertyCount = 0)
|
private static string GetNewPropertyName(string newName, int propertyCount = 0)
|
||||||
{
|
{
|
||||||
return propertyCount > 0 ? $"{newName}_{propertyCount}" : newName;
|
return propertyCount > 0 ? $"{newName}_{propertyCount}" : newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RenameType(IEnumerable<TypeDef> typesToCheck, RemapModel remap)
|
|
||||||
{
|
|
||||||
foreach (var type in typesToCheck)
|
|
||||||
{
|
|
||||||
if (type.HasNestedTypes)
|
|
||||||
{
|
|
||||||
RenameType(type.NestedTypes, remap!);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remap?.TypePrimeCandidate?.Name is null) { continue; }
|
|
||||||
|
|
||||||
if (remap.SearchParams.NestedTypes.IsNested is true &&
|
|
||||||
type.IsNested && type.Name == remap.TypePrimeCandidate.Name)
|
|
||||||
{
|
|
||||||
type.Name = remap.NewTypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type.FullName == remap.TypePrimeCandidate.Name)
|
|
||||||
{
|
|
||||||
type.Name = remap.NewTypeName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -53,27 +53,31 @@ public class Statistics(
|
|||||||
|
|
||||||
foreach (var remap in remapModels)
|
foreach (var remap in remapModels)
|
||||||
{
|
{
|
||||||
if (remap.Succeeded is false && remap.NoMatchReasons.Contains(ENoMatchReason.AmbiguousWithPreviousMatch))
|
switch (remap.Succeeded)
|
||||||
{
|
{
|
||||||
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
|
case false when remap.NoMatchReasons.Contains(ENoMatchReason.AmbiguousWithPreviousMatch):
|
||||||
Logger.Log("Ambiguous match with a previous match during matching. Skipping remap.", ConsoleColor.Red);
|
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
|
||||||
Logger.Log($"New Type Name: {remap.NewTypeName}", ConsoleColor.Red);
|
Logger.Log("Ambiguous match with a previous match during matching. Skipping remap.", ConsoleColor.Red);
|
||||||
Logger.Log($"{remap.AmbiguousTypeMatch} already assigned to a previous match.", ConsoleColor.Red);
|
Logger.Log($"New Type Name: {remap.NewTypeName}", ConsoleColor.Red);
|
||||||
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
|
Logger.Log($"{remap.AmbiguousTypeMatch} already assigned to a previous match.", ConsoleColor.Red);
|
||||||
}
|
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
|
||||||
else if (remap.Succeeded is false)
|
|
||||||
{
|
failures++;
|
||||||
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
|
break;
|
||||||
Logger.Log($"Renaming {remap.NewTypeName} failed with reason(s)", ConsoleColor.Red);
|
case false:
|
||||||
|
|
||||||
foreach (var reason in remap.NoMatchReasons)
|
|
||||||
{
|
{
|
||||||
Logger.Log($"Reason: {reason}", ConsoleColor.Red);
|
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
|
||||||
}
|
Logger.Log($"Renaming {remap.NewTypeName} failed with reason(s)", ConsoleColor.Red);
|
||||||
|
|
||||||
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
|
foreach (var reason in remap.NoMatchReasons)
|
||||||
failures++;
|
{
|
||||||
continue;
|
Logger.Log($"Reason: {reason}", ConsoleColor.Red);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
|
||||||
|
failures++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validate && remap.Succeeded)
|
if (validate && remap.Succeeded)
|
||||||
|
@ -22,83 +22,76 @@ public class TypeFilters
|
|||||||
|
|
||||||
private static bool FilterTypesByGeneric(RemapModel mapping, ref IEnumerable<TypeDef> types)
|
private static bool FilterTypesByGeneric(RemapModel mapping, ref IEnumerable<TypeDef> types)
|
||||||
{
|
{
|
||||||
types = GenericTypeFilters.FilterPublic(types, mapping.SearchParams);
|
var parms = mapping.SearchParams;
|
||||||
|
|
||||||
|
types = types.Where(t => t.IsPublic == parms.GenericParams.IsPublic);
|
||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsPublic);
|
AddNoMatchReason(mapping, ENoMatchReason.IsPublic);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
types = GenericTypeFilters.FilterAbstract(types, mapping.SearchParams);
|
types = types.Where(t => t.IsAbstract == parms.GenericParams.IsAbstract);
|
||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsPublic);
|
AddNoMatchReason(mapping, ENoMatchReason.IsAbstract);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
types = GenericTypeFilters.FilterSealed(types, mapping.SearchParams);
|
types = types.Where(t => t.IsSealed == parms.GenericParams.IsSealed);
|
||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsSealed);
|
AddNoMatchReason(mapping, ENoMatchReason.IsSealed);
|
||||||
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
types = types.Where(t => t.IsInterface == parms.GenericParams.IsInterface);
|
||||||
|
|
||||||
|
if (!types.Any())
|
||||||
|
{
|
||||||
|
AddNoMatchReason(mapping, ENoMatchReason.IsInterface);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
types = GenericTypeFilters.FilterInterface(types, mapping.SearchParams);
|
types = types.Where(t => t.IsEnum == parms.GenericParams.IsEnum);
|
||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsInterface);
|
AddNoMatchReason(mapping, ENoMatchReason.IsEnum);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
types = GenericTypeFilters.FilterStruct(types, mapping.SearchParams);
|
types = FilterAttributes(types, mapping.SearchParams);
|
||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsStruct);
|
AddNoMatchReason(mapping, ENoMatchReason.HasAttribute);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
types = GenericTypeFilters.FilterEnum(types, mapping.SearchParams);
|
types = FilterDerived(types, mapping.SearchParams);
|
||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsEnum);
|
AddNoMatchReason(mapping, ENoMatchReason.IsDerived);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
types = GenericTypeFilters.FilterAttributes(types, mapping.SearchParams);
|
types = types.Where(t => t.HasGenericParameters == parms.GenericParams.HasGenericParameters);
|
||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.HasAttribute);
|
AddNoMatchReason(mapping, ENoMatchReason.HasGenericParameters);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
types = GenericTypeFilters.FilterDerived(types, mapping.SearchParams);
|
|
||||||
|
|
||||||
if (!types.Any())
|
|
||||||
{
|
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsDerived);
|
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
types = GenericTypeFilters.FilterByGenericParameters(types, mapping.SearchParams);
|
|
||||||
|
|
||||||
if (!types.Any())
|
|
||||||
{
|
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.HasGenericParameters);
|
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -112,7 +105,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.MethodsInclude);
|
AddNoMatchReason(mapping, ENoMatchReason.MethodsInclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -121,7 +114,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.MethodsExclude);
|
AddNoMatchReason(mapping, ENoMatchReason.MethodsExclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -130,7 +123,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.MethodsCount);
|
AddNoMatchReason(mapping, ENoMatchReason.MethodsCount);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -139,7 +132,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.ConstructorParameterCount);
|
AddNoMatchReason(mapping, ENoMatchReason.ConstructorParameterCount);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -153,7 +146,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.FieldsInclude);
|
AddNoMatchReason(mapping, ENoMatchReason.FieldsInclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -162,7 +155,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.FieldsExclude);
|
AddNoMatchReason(mapping, ENoMatchReason.FieldsExclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -171,7 +164,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.FieldsCount);
|
AddNoMatchReason(mapping, ENoMatchReason.FieldsCount);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -185,7 +178,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.PropertiesInclude);
|
AddNoMatchReason(mapping, ENoMatchReason.PropertiesInclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -194,7 +187,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.PropertiesExclude);
|
AddNoMatchReason(mapping, ENoMatchReason.PropertiesExclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -203,7 +196,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.PropertiesCount);
|
AddNoMatchReason(mapping, ENoMatchReason.PropertiesCount);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -217,7 +210,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.NestedTypeInclude);
|
AddNoMatchReason(mapping, ENoMatchReason.NestedTypeInclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -226,7 +219,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.NestedTypeExclude);
|
AddNoMatchReason(mapping, ENoMatchReason.NestedTypeExclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -235,7 +228,16 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.NestedTypeCount);
|
AddNoMatchReason(mapping, ENoMatchReason.NestedTypeCount);
|
||||||
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
types = NestedTypeFilters.FilterByNestedVisibility(types, mapping.SearchParams);
|
||||||
|
|
||||||
|
if (!types.Any())
|
||||||
|
{
|
||||||
|
AddNoMatchReason(mapping, ENoMatchReason.NestedVisibility);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -249,7 +251,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.EventsInclude);
|
AddNoMatchReason(mapping, ENoMatchReason.EventsInclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -258,7 +260,7 @@ public class TypeFilters
|
|||||||
|
|
||||||
if (!types.Any())
|
if (!types.Any())
|
||||||
{
|
{
|
||||||
AllTypesFilteredOutFor(mapping, ENoMatchReason.EventsExclude);
|
AddNoMatchReason(mapping, ENoMatchReason.EventsExclude);
|
||||||
mapping.TypeCandidates.UnionWith(types);
|
mapping.TypeCandidates.UnionWith(types);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -266,13 +268,43 @@ public class TypeFilters
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private static IEnumerable<TypeDef> FilterAttributes(IEnumerable<TypeDef> types, SearchParams parms)
|
||||||
/// This is used to log that all types for a given remap were filtered out.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="remap">remap model that failed</param>
|
|
||||||
/// <param name="noMatchReason">Reason for filtering</param>
|
|
||||||
private static void AllTypesFilteredOutFor(RemapModel remap, ENoMatchReason noMatchReason)
|
|
||||||
{
|
{
|
||||||
Logger.Log($"All types filtered out after `{noMatchReason}` filter for: `{remap.NewTypeName}`", ConsoleColor.Red);
|
// Filter based on HasAttribute or not
|
||||||
|
if (parms.GenericParams.HasAttribute is true)
|
||||||
|
{
|
||||||
|
types = types.Where(t => t.HasCustomAttributes);
|
||||||
|
}
|
||||||
|
else if (parms.GenericParams.HasAttribute is false)
|
||||||
|
{
|
||||||
|
types = types.Where(t => !t.HasCustomAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<TypeDef> FilterDerived(IEnumerable<TypeDef> types, SearchParams parms)
|
||||||
|
{
|
||||||
|
// Filter based on IsDerived or not
|
||||||
|
if (parms.GenericParams.IsDerived is true)
|
||||||
|
{
|
||||||
|
types = types.Where(t => t.GetBaseType()?.Name?.String != "Object");
|
||||||
|
|
||||||
|
if (parms.GenericParams.MatchBaseClass is not null and not "")
|
||||||
|
{
|
||||||
|
types = types.Where(t => t.GetBaseType()?.Name?.String == parms.GenericParams.MatchBaseClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (parms.GenericParams.IsDerived is false)
|
||||||
|
{
|
||||||
|
types = types.Where(t => t.GetBaseType()?.Name?.String is "Object");
|
||||||
|
}
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AddNoMatchReason(RemapModel remap, ENoMatchReason noMatchReason)
|
||||||
|
{
|
||||||
|
remap.NoMatchReasons.Add(noMatchReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,9 @@
|
|||||||
using dnlib.DotNet;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using dnlib.DotNet;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using ReCodeItLib.Models;
|
using ReCodeItLib.Models;
|
||||||
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||||
|
|
||||||
namespace ReCodeItLib.Utils;
|
namespace ReCodeItLib.Utils;
|
||||||
|
|
||||||
@ -27,26 +30,33 @@ public static class DataProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
var jsonText = File.ReadAllText(path);
|
var jsonText = File.ReadAllText(path);
|
||||||
|
|
||||||
var remaps = JsonConvert.DeserializeObject<List<RemapModel>>(jsonText);
|
JsonSerializerOptions settings = new()
|
||||||
|
{
|
||||||
|
AllowTrailingCommas = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
var remaps = JsonSerializer.Deserialize<List<RemapModel>>(jsonText, settings);
|
||||||
|
|
||||||
return remaps ?? [];
|
return remaps ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateMapping(string path, List<RemapModel> remaps)
|
public static void UpdateMapping(string path, List<RemapModel> remaps, bool respectNullableAnnotations = true)
|
||||||
{
|
{
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
File.Create(path).Close();
|
File.Create(path).Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonSerializerSettings settings = new()
|
JsonSerializerOptions settings = new()
|
||||||
{
|
{
|
||||||
NullValueHandling = NullValueHandling.Ignore,
|
WriteIndented = true,
|
||||||
Formatting = Formatting.Indented
|
RespectNullableAnnotations = !respectNullableAnnotations,
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
|
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||||
};
|
};
|
||||||
|
|
||||||
var jsonText = JsonConvert.SerializeObject(remaps, settings);
|
var jsonText = JsonSerializer.Serialize(remaps, settings);
|
||||||
|
|
||||||
File.WriteAllText(path, jsonText);
|
File.WriteAllText(path, jsonText);
|
||||||
|
|
||||||
@ -73,7 +83,12 @@ public static class DataProvider
|
|||||||
var settingsPath = Path.Combine(DataPath, "Settings.jsonc");
|
var settingsPath = Path.Combine(DataPath, "Settings.jsonc");
|
||||||
var jsonText = File.ReadAllText(settingsPath);
|
var jsonText = File.ReadAllText(settingsPath);
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<Settings>(jsonText);
|
JsonSerializerOptions settings = new()
|
||||||
|
{
|
||||||
|
AllowTrailingCommas = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonSerializer.Deserialize<Settings>(jsonText, settings)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<string, ItemTemplateModel> LoadItems()
|
private static Dictionary<string, ItemTemplateModel> LoadItems()
|
||||||
@ -81,6 +96,12 @@ public static class DataProvider
|
|||||||
var itemsPath = Path.Combine(DataPath, "items.json");
|
var itemsPath = Path.Combine(DataPath, "items.json");
|
||||||
var jsonText = File.ReadAllText(itemsPath);
|
var jsonText = File.ReadAllText(itemsPath);
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<Dictionary<string, ItemTemplateModel>>(jsonText);
|
JsonSerializerOptions settings = new()
|
||||||
|
{
|
||||||
|
RespectNullableAnnotations = true,
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonSerializer.Deserialize<Dictionary<string, ItemTemplateModel>>(jsonText, settings)!;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using Newtonsoft.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using ReCodeItLib.Models;
|
using ReCodeItLib.Models;
|
||||||
|
|
||||||
namespace ReCodeItLib.Utils;
|
namespace ReCodeItLib.Utils;
|
||||||
@ -123,12 +124,13 @@ public static class Logger
|
|||||||
|
|
||||||
public static void LogRemapModel(RemapModel remapModel)
|
public static void LogRemapModel(RemapModel remapModel)
|
||||||
{
|
{
|
||||||
var settings = new JsonSerializerSettings()
|
JsonSerializerOptions settings = new()
|
||||||
{
|
{
|
||||||
NullValueHandling = NullValueHandling.Ignore
|
WriteIndented = true,
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
};
|
};
|
||||||
|
|
||||||
var str = JsonConvert.SerializeObject(remapModel, Formatting.Indented, settings);
|
var str = JsonSerializer.Serialize(remapModel, settings);
|
||||||
LogSync(str, ConsoleColor.Blue);
|
LogSync(str, ConsoleColor.Blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\De4DotCommon.props" />
|
<Import Project="..\De4DotCommon.props" />
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net48</TargetFramework>
|
<TargetFramework>net48</TargetFramework>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\De4DotCommon.props" />
|
<Import Project="..\De4DotCommon.props" />
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\De4DotCommon.props" />
|
<Import Project="..\De4DotCommon.props" />
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user