Use ModuleDefMD.GetAssemblyRef()
This commit is contained in:
parent
f2f156dc40
commit
472d57ed0f
|
@ -175,24 +175,10 @@ namespace de4dot.code.deobfuscators {
|
||||||
}
|
}
|
||||||
|
|
||||||
AssemblyRef findAssemblyReference(string asmSimpleName) {
|
AssemblyRef findAssemblyReference(string asmSimpleName) {
|
||||||
AssemblyRef asmRef = null;
|
var asmRef = module.GetAssemblyRef(asmSimpleName);
|
||||||
foreach (var asmRef2 in findAssemblyReferences(asmSimpleName)) {
|
|
||||||
if (asmRef == null || asmRef.Version == null || (asmRef2.Version != null && asmRef2.Version > asmRef.Version))
|
|
||||||
asmRef = asmRef2;
|
|
||||||
}
|
|
||||||
if (asmRef == null)
|
if (asmRef == null)
|
||||||
throw new ApplicationException(string.Format("Could not find assembly {0} in assembly references", asmSimpleName));
|
throw new ApplicationException(string.Format("Could not find assembly {0} in assembly references", asmSimpleName));
|
||||||
return asmRef;
|
return asmRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AssemblyRef> findAssemblyReferences(string asmSimpleName) {
|
|
||||||
var asmRefs = new List<AssemblyRef>();
|
|
||||||
var name = new UTF8String(asmSimpleName);
|
|
||||||
foreach (var asmRef in module.GetAssemblyRefs()) {
|
|
||||||
if (UTF8String.Equals(asmRef.Name, name))
|
|
||||||
asmRefs.Add(asmRef);
|
|
||||||
}
|
|
||||||
return asmRefs;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,11 +211,9 @@ namespace de4dot.code.resources {
|
||||||
string tryGetRealAssemblyName(string assemblyName) {
|
string tryGetRealAssemblyName(string assemblyName) {
|
||||||
var simpleName = Utils.getAssemblySimpleName(assemblyName);
|
var simpleName = Utils.getAssemblySimpleName(assemblyName);
|
||||||
|
|
||||||
var name = new UTF8String(simpleName);
|
var asmRef = module.GetAssemblyRef(simpleName);
|
||||||
foreach (var asmRef in module.GetAssemblyRefs()) {
|
if (asmRef != null)
|
||||||
if (asmRef.Name == name)
|
|
||||||
return asmRef.FullName;
|
return asmRef.FullName;
|
||||||
}
|
|
||||||
|
|
||||||
var asm = TheAssemblyResolver.Instance.Resolve(new AssemblyNameInfo(simpleName), module);
|
var asm = TheAssemblyResolver.Instance.Resolve(new AssemblyNameInfo(simpleName), module);
|
||||||
return asm == null ? null : asm.FullName;
|
return asm == null ? null : asm.FullName;
|
||||||
|
|
|
@ -138,13 +138,7 @@ namespace de4dot.code.resources {
|
||||||
}
|
}
|
||||||
|
|
||||||
string getMscorlibFullname() {
|
string getMscorlibFullname() {
|
||||||
AssemblyRef mscorlibRef = null;
|
var mscorlibRef = module.GetAssemblyRef("mscorlib");
|
||||||
foreach (var asmRef in module.GetAssemblyRefs()) {
|
|
||||||
if (asmRef.Name != "mscorlib")
|
|
||||||
continue;
|
|
||||||
if (mscorlibRef == null || mscorlibRef.Version == null || (asmRef.Version != null && asmRef.Version >= mscorlibRef.Version))
|
|
||||||
mscorlibRef = asmRef;
|
|
||||||
}
|
|
||||||
if (mscorlibRef != null)
|
if (mscorlibRef != null)
|
||||||
return mscorlibRef.FullName;
|
return mscorlibRef.FullName;
|
||||||
|
|
||||||
|
|
2
dot10
2
dot10
|
@ -1 +1 @@
|
||||||
Subproject commit 7a952cd8b2afd4104ec5efaac20cb98ba0090f9c
|
Subproject commit da98052a05288943bcb29e813b3c3ba448ae2101
|
Loading…
Reference in New Issue
Block a user