Merge branch 'master' into goliath
This commit is contained in:
commit
d344c05404
|
@ -86,10 +86,34 @@ namespace de4dot.code.renamer {
|
|||
prepareRenameMemberDefinitions(scopes);
|
||||
renameMemberDefinitions();
|
||||
renameMemberReferences();
|
||||
removeUselessOverrides(scopes);
|
||||
renameResources();
|
||||
modules.cleanUp();
|
||||
}
|
||||
|
||||
void removeUselessOverrides(MethodNameScopes scopes) {
|
||||
foreach (var scope in scopes.getAllScopes()) {
|
||||
foreach (var method in scope.Methods) {
|
||||
if (!method.Owner.HasModule)
|
||||
continue;
|
||||
if (!method.isPublic())
|
||||
continue;
|
||||
var overrides = method.MethodDefinition.Overrides;
|
||||
for (int i = 0; i < overrides.Count; i++) {
|
||||
var overrideMethod = overrides[i];
|
||||
if (method.MethodDefinition.Name != overrideMethod.Name)
|
||||
continue;
|
||||
Log.v("Removed useless override from method {0} ({1:X8}), override: {2:X8}",
|
||||
method.MethodDefinition,
|
||||
method.MethodDefinition.MetadataToken.ToInt32(),
|
||||
overrideMethod.MetadataToken.ToInt32());
|
||||
overrides.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void renameTypeDefinitions() {
|
||||
Log.v("Renaming obfuscated type definitions");
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace de4dot.code.renamer {
|
|||
if (type.TypeDefinition.IsNested)
|
||||
newNamespace = "";
|
||||
else if (!checker.isValidNamespaceName(oldNamespace))
|
||||
newNamespace = state.createNamespace(oldNamespace);
|
||||
newNamespace = state.createNamespace(this.type.TypeDefinition, oldNamespace);
|
||||
}
|
||||
|
||||
string origClassName = null;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace de4dot.code.renamer {
|
||||
class TypeRenamerState {
|
||||
|
@ -44,11 +45,25 @@ namespace de4dot.code.renamer {
|
|||
return existingNames.getName(oldName, new NameCreator2(newName));
|
||||
}
|
||||
|
||||
public string createNamespace(string ns) {
|
||||
public string createNamespace(TypeDefinition type, string ns) {
|
||||
string newName;
|
||||
if (namespaceToNewName.TryGetValue(ns, out newName))
|
||||
|
||||
string asmFullName;
|
||||
if (type.Module.Assembly != null)
|
||||
asmFullName = type.Module.Assembly.FullName;
|
||||
else
|
||||
asmFullName = "<no assembly>";
|
||||
|
||||
// Make sure that two namespaces with the same names in different modules aren't renamed
|
||||
// to the same name.
|
||||
var key = string.Format(" [{0}] [{1}] [{2}] [{3}] ",
|
||||
type.Module.FullyQualifiedName,
|
||||
asmFullName,
|
||||
type.Module.Name,
|
||||
ns);
|
||||
if (namespaceToNewName.TryGetValue(key, out newName))
|
||||
return newName;
|
||||
return namespaceToNewName[ns] = createNamespaceName.create();
|
||||
return namespaceToNewName[key] = createNamespaceName.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user