Fix renaming of non-external pinvoke methods
This commit is contained in:
parent
a85bb4fc6e
commit
0dc129d340
|
@ -382,16 +382,19 @@ namespace de4dot.code.renamer {
|
||||||
var checker = NameChecker;
|
var checker = NameChecker;
|
||||||
|
|
||||||
// PInvoke methods' EntryPoint is always valid. It has to, so always rename.
|
// PInvoke methods' EntryPoint is always valid. It has to, so always rename.
|
||||||
if (!NameChecker.isValidMethodName(info.oldName) || methodDef.MethodDef.ImplMap != null) {
|
bool isValidName = NameChecker.isValidMethodName(info.oldName);
|
||||||
|
bool isExternPInvoke = methodDef.MethodDef.ImplMap != null && methodDef.MethodDef.RVA == 0;
|
||||||
|
if (!isValidName || isExternPInvoke) {
|
||||||
INameCreator nameCreator = null;
|
INameCreator nameCreator = null;
|
||||||
string newName = info.suggestedName;
|
string newName = info.suggestedName;
|
||||||
if (methodDef.MethodDef.ImplMap != null)
|
string newName2;
|
||||||
newName = getPinvokeName(methodDef);
|
if (methodDef.MethodDef.ImplMap != null && !string.IsNullOrEmpty(newName2 = getPinvokeName(methodDef)))
|
||||||
|
newName = newName2;
|
||||||
else if (methodDef.isStatic())
|
else if (methodDef.isStatic())
|
||||||
nameCreator = variableNameState.staticMethodNameCreator;
|
nameCreator = variableNameState.staticMethodNameCreator;
|
||||||
else
|
else
|
||||||
nameCreator = variableNameState.instanceMethodNameCreator;
|
nameCreator = variableNameState.instanceMethodNameCreator;
|
||||||
if (newName != null)
|
if (!string.IsNullOrEmpty(newName))
|
||||||
nameCreator = new NameCreator2(newName);
|
nameCreator = new NameCreator2(newName);
|
||||||
renameMethod(methodDef, variableNameState.getNewMethodName(info.oldName, nameCreator));
|
renameMethod(methodDef, variableNameState.getNewMethodName(info.oldName, nameCreator));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user