Update detection of delegate fields and remove useless method
This commit is contained in:
parent
d3c801efb6
commit
6963e89581
|
@ -90,7 +90,7 @@ namespace de4dot.code.deobfuscators {
|
||||||
foreach (var type in module.Types) {
|
foreach (var type in module.Types) {
|
||||||
if (type.BaseType == null || type.BaseType.FullName != "System.MulticastDelegate")
|
if (type.BaseType == null || type.BaseType.FullName != "System.MulticastDelegate")
|
||||||
continue;
|
continue;
|
||||||
var cctor = findMethod(type, ".cctor");
|
var cctor = DotNetUtils.getMethod(type, ".cctor");
|
||||||
if (cctor == null || !cctor.HasBody)
|
if (cctor == null || !cctor.HasBody)
|
||||||
continue;
|
continue;
|
||||||
if (!type.HasFields)
|
if (!type.HasFields)
|
||||||
|
@ -106,7 +106,7 @@ namespace de4dot.code.deobfuscators {
|
||||||
|
|
||||||
Log.indent();
|
Log.indent();
|
||||||
foreach (var field in type.Fields) {
|
foreach (var field in type.Fields) {
|
||||||
if (!field.IsStatic || field.IsPublic)
|
if (!field.IsStatic)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MethodReference calledMethod;
|
MethodReference calledMethod;
|
||||||
|
@ -114,7 +114,7 @@ namespace de4dot.code.deobfuscators {
|
||||||
getCallInfo(context, field, out calledMethod, out callOpcode);
|
getCallInfo(context, field, out calledMethod, out callOpcode);
|
||||||
|
|
||||||
if (calledMethod == null)
|
if (calledMethod == null)
|
||||||
throw new ApplicationException("calledMethod is null");
|
continue;
|
||||||
addDelegateInfo(new DelegateInfo(field, calledMethod, callOpcode));
|
addDelegateInfo(new DelegateInfo(field, calledMethod, callOpcode));
|
||||||
Log.v("Field: {0}, Opcode: {1}, Method: {2} ({3:X8})", field.Name, callOpcode, calledMethod, calledMethod.MetadataToken.ToUInt32());
|
Log.v("Field: {0}, Opcode: {1}, Method: {2} ({3:X8})", field.Name, callOpcode, calledMethod, calledMethod.MetadataToken.ToUInt32());
|
||||||
}
|
}
|
||||||
|
@ -139,16 +139,6 @@ namespace de4dot.code.deobfuscators {
|
||||||
proxyMethodToField[proxyMethod] = proxyField;
|
proxyMethodToField[proxyMethod] = proxyField;
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodDefinition findMethod(TypeDefinition type, string name) {
|
|
||||||
if (!type.HasMethods)
|
|
||||||
return null;
|
|
||||||
foreach (var method in type.Methods) {
|
|
||||||
if (method.Name == name)
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
DelegateInfo getDelegateInfo(FieldReference field) {
|
DelegateInfo getDelegateInfo(FieldReference field) {
|
||||||
if (field == null)
|
if (field == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user