Add lookup() generic method. Useful when reloading module.

This commit is contained in:
de4dot 2011-11-06 12:16:06 +01:00
parent 9a21b09fac
commit fb2707a49b

View File

@ -18,5 +18,14 @@ namespace de4dot.deobfuscators {
}
Log.deIndent();
}
public static T lookup<T>(ModuleDefinition module, T def, string errorMessage) where T : MemberReference {
if (def == null)
return null;
var newDef = module.LookupToken(def.MetadataToken.ToInt32()) as T;
if (newDef == null)
throw new ApplicationException(errorMessage);
return newDef;
}
}
}