Assembly resolver now parses *.config files
This commit is contained in:
parent
d35e92b53c
commit
2a0e92eaff
|
@ -21,6 +21,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Xml;
|
||||||
using Mono.Cecil;
|
using Mono.Cecil;
|
||||||
|
|
||||||
namespace de4dot.code {
|
namespace de4dot.code {
|
||||||
|
@ -87,8 +88,11 @@ namespace de4dot.code {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addModule(ModuleDefinition module) {
|
public void addModule(ModuleDefinition module) {
|
||||||
if (module.FullyQualifiedName != "")
|
if (module.FullyQualifiedName != "") {
|
||||||
addSearchDirectory(Path.GetDirectoryName(module.FullyQualifiedName));
|
addSearchDirectory(Path.GetDirectoryName(module.FullyQualifiedName));
|
||||||
|
if (module.FullyQualifiedName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
|
||||||
|
addConfigFile(module.FullyQualifiedName + ".config");
|
||||||
|
}
|
||||||
|
|
||||||
var assembly = module.Assembly;
|
var assembly = module.Assembly;
|
||||||
if (assembly != null) {
|
if (assembly != null) {
|
||||||
|
@ -100,6 +104,32 @@ namespace de4dot.code {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addConfigFile(string configFilename) {
|
||||||
|
var dirName = Utils.getDirName(Utils.getFullPath(configFilename));
|
||||||
|
addSearchDirectory(dirName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
using (var xmlStream = new FileStream(configFilename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
|
||||||
|
var doc = new XmlDocument();
|
||||||
|
doc.Load(XmlReader.Create(xmlStream));
|
||||||
|
foreach (var tmp in doc.GetElementsByTagName("probing")) {
|
||||||
|
var probingElem = tmp as XmlElement;
|
||||||
|
if (probingElem == null)
|
||||||
|
continue;
|
||||||
|
var privatePath = probingElem.GetAttribute("privatePath");
|
||||||
|
if (string.IsNullOrEmpty(privatePath))
|
||||||
|
continue;
|
||||||
|
foreach (var path in privatePath.Split(';'))
|
||||||
|
addSearchDirectory(Path.Combine(dirName, path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException) {
|
||||||
|
}
|
||||||
|
catch (XmlException) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeModule(ModuleDefinition module) {
|
public void removeModule(ModuleDefinition module) {
|
||||||
var assembly = module.Assembly;
|
var assembly = module.Assembly;
|
||||||
if (assembly == null)
|
if (assembly == null)
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Runtime.Remoting" />
|
<Reference Include="System.Runtime.Remoting" />
|
||||||
|
<Reference Include="System.XML" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AssemblyClient\AssemblyClient.cs" />
|
<Compile Include="AssemblyClient\AssemblyClient.cs" />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user