mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-13 02:50:45 -05:00
Don't automatch deobfuscator given method names
This commit is contained in:
parent
c9a036d6db
commit
82eec7b657
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"MappingPath": "",
|
"MappingPath": "",
|
||||||
"TokensToMatch": [
|
"TypeNamesToMatch": [
|
||||||
"Class",
|
"Class",
|
||||||
"GClass",
|
"GClass",
|
||||||
"GStruct",
|
"GStruct",
|
||||||
@ -8,5 +8,10 @@
|
|||||||
"ValueStruct",
|
"ValueStruct",
|
||||||
"Interface",
|
"Interface",
|
||||||
"GInterface"
|
"GInterface"
|
||||||
|
],
|
||||||
|
"MethodsToIgnore": [
|
||||||
|
"method_",
|
||||||
|
"smethod_",
|
||||||
|
"vmethod_"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -13,7 +13,12 @@ public class Settings
|
|||||||
public string MappingPath { get; set; } = string.Empty;
|
public string MappingPath { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The re-mapper will look for these tokens in class names, otherwise they will be skipped
|
/// The re-mapper will look for these classes, otherwise they will be skipped
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required List<string> TokensToMatch { get; set; }
|
public required List<string> TypeNamesToMatch { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of method names to be ignored during the auto-match process.
|
||||||
|
/// </summary>
|
||||||
|
public required List<string> MethodsToIgnore { get; set; }
|
||||||
}
|
}
|
@ -10,8 +10,8 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
|
|
||||||
private List<TypeDef>? CandidateTypes { get; set; }
|
private List<TypeDef>? CandidateTypes { get; set; }
|
||||||
|
|
||||||
private static List<string> _tokens = DataProvider.Settings.TypeNamesToMatch;
|
private static readonly List<string> TypesToMatch = DataProvider.Settings.TypeNamesToMatch;
|
||||||
private static List<string> _methodsToIgnore = DataProvider.Settings.TypeNamesToMatch;
|
private static readonly List<string> MethodsToIgnore = DataProvider.Settings.MethodsToIgnore;
|
||||||
|
|
||||||
public void AutoMatch(string assemblyPath, string oldTypeName, string newTypeName)
|
public void AutoMatch(string assemblyPath, string oldTypeName, string newTypeName)
|
||||||
{
|
{
|
||||||
@ -22,8 +22,7 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
|
|
||||||
Module = module;
|
Module = module;
|
||||||
CandidateTypes = Module.GetTypes()
|
CandidateTypes = Module.GetTypes()
|
||||||
.Where(t => _tokens.Any(token => t.Name.StartsWith(token)))
|
.Where(t => TypesToMatch.Any(token => t.Name.StartsWith(token)))
|
||||||
// .Where(t => t.Name != oldTypeName)
|
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var targetTypeDef = FindTargetType(oldTypeName);
|
var targetTypeDef = FindTargetType(oldTypeName);
|
||||||
@ -166,17 +165,21 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
|
|||||||
// Methods in target that are not in candidate
|
// Methods in target that are not in candidate
|
||||||
var includeMethods = target.Methods
|
var includeMethods = target.Methods
|
||||||
.Where(m => !m.IsConstructor && !m.IsGetter && !m.IsSetter)
|
.Where(m => !m.IsConstructor && !m.IsGetter && !m.IsSetter)
|
||||||
|
.Where(m => !MethodsToIgnore.Any(mi => m.Name.String.StartsWith(mi)))
|
||||||
.Select(s => s.Name.ToString())
|
.Select(s => s.Name.ToString())
|
||||||
.Except(candidate.Methods
|
.Except(candidate.Methods
|
||||||
.Where(m => !m.IsConstructor && !m.IsGetter && !m.IsSetter)
|
.Where(m => !m.IsConstructor && !m.IsGetter && !m.IsSetter)
|
||||||
|
.Where(m => !MethodsToIgnore.Any(mi => m.Name.String.StartsWith(mi)))
|
||||||
.Select(s => s.Name.ToString()));
|
.Select(s => s.Name.ToString()));
|
||||||
|
|
||||||
// Methods in candidate that are not in target
|
// Methods in candidate that are not in target
|
||||||
var excludeMethods = candidate.Methods
|
var excludeMethods = candidate.Methods
|
||||||
.Where(m => !m.IsConstructor && !m.IsGetter && !m.IsSetter)
|
.Where(m => !m.IsConstructor && !m.IsGetter && !m.IsSetter)
|
||||||
|
.Where(m => !MethodsToIgnore.Any(mi => m.Name.String.StartsWith(mi)))
|
||||||
.Select(s => s.Name.ToString())
|
.Select(s => s.Name.ToString())
|
||||||
.Except(target.Methods
|
.Except(target.Methods
|
||||||
.Where(m => !m.IsConstructor && !m.IsGetter && !m.IsSetter)
|
.Where(m => !m.IsConstructor && !m.IsGetter && !m.IsSetter)
|
||||||
|
.Where(m => !MethodsToIgnore.Any(mi => m.Name.String.StartsWith(mi)))
|
||||||
.Select(s => s.Name.ToString()));
|
.Select(s => s.Name.ToString()));
|
||||||
|
|
||||||
foreach (var include in includeMethods)
|
foreach (var include in includeMethods)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user