本文整理汇总了C#中dnlib.DotNet.ModuleContext类的典型用法代码示例。如果您正苦于以下问题:C# ModuleContext类的具体用法?C# ModuleContext怎么用?C# ModuleContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleContext类属于dnlib.DotNet命名空间,在下文中一共展示了ModuleContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var asmDef = AssemblyDef.Load(args[0]);
var method = asmDef.ManifestModule.EntryPoint.DeclaringType.FindMethod("Foo");
var asmResolver = new AssemblyResolver();
var modCtx = new ModuleContext(asmResolver);
var ast = new ILAST(method, modCtx);
Console.WriteLine("-------------------------------");
Console.WriteLine(" Standard AST");
Console.WriteLine("-------------------------------");
foreach (Element element in ast.Elements)
Console.WriteLine("{0}: {1}", element.GetType().Name, element);
ILAST.SimplifyElements(ast.Elements);
Console.WriteLine("\n-------------------------------");
Console.WriteLine(" Simplified AST");
Console.WriteLine("-------------------------------");
foreach (Element element in ast.Elements)
Console.WriteLine("{0}: {1}", element.GetType().Name, element);
Console.WriteLine(asmDef);
}
示例2: SearchDeobfuscator
public IObfuscatedFile SearchDeobfuscator(string filename)
{
ModuleContext context = new ModuleContext();
ObfuscatedFile.Options fileOptions = new ObfuscatedFile.Options { Filename = filename };
ObfuscatedFile ofile = CreateObfuscationFile(fileOptions, context);
return ofile;
}
示例3: ILAST
public ILAST(MethodDef method, ModuleContext modCtx)
{
Method = method;
Method.DeclaringType.Module.Context = modCtx;
Elements = new List<Element>();
ProcessMethod();
}
示例4: dnModule
public dnModule(byte[] module, string fileName, ModuleContext ctx) {
RawData = module;
ErrorMessage = null;
Name = Path.GetFileName(fileName);
var creator = new dnModuleStreamCreator(module, fileName);
try {
Image = new PEImage(creator, ImageLayout.File, true);
}
catch (Exception ex) {
ErrorMessage += string.Format("Error while loading PE Image:{0}{1}{0}{0}",
Environment.NewLine, ex);
Image = null;
return;
}
try {
MetaData = MetaDataCreator.CreateMetaData(Image);
}
catch (Exception ex) {
ErrorMessage += string.Format("Error while loading MetaData:{0}{1}{0}{0}",
Environment.NewLine, ex);
MetaData = null;
return;
}
try {
ModuleDef = (ModuleDefMD)loadInternal.Invoke(null, new object[] {
MetaData, new ModuleCreationOptions {
TryToLoadPdbFromDisk = true,
Context = ctx
}
});
ModuleDef.EnableTypeDefFindCache = true;
}
catch (Exception ex) {
ErrorMessage = string.Format("Error while loading ModuleDef:{0}{1}{0}{0}",
Environment.NewLine, ex);
ModuleDef = null;
return;
}
if (ModuleDef.Assembly != null)
Name = ModuleDef.Assembly.Name;
else
Name = ModuleDef.Name;
if (string.IsNullOrEmpty(Name))
Name = Path.GetFileName(fileName);
}
示例5: Execute
public FileSystemPath Execute(IAssemblyFile existingAssemblyFile, string newFileName, IProgressIndicator progressIndicator)
{
var context = new ModuleContext();
var fileOptions = new ObfuscatedFile.Options
{
Filename = existingAssemblyFile.Location.FullPath,
NewFilename = newFileName,
};
IObfuscatedFile obfuscationFile = CreateObfuscationFile(fileOptions, context);
return Deobfuscate(obfuscationFile, progressIndicator);
}
示例6: ObfuscatedFile
public ObfuscatedFile(Options options, ModuleContext moduleContext, IAssemblyClientFactory assemblyClientFactory, MemoryStream ms)
{
this.assemblyClientFactory = assemblyClientFactory;
this.options = options;
userStringDecrypterMethods = options.StringDecrypterMethods.Count > 0;
options.Filename = Utils.getFullPath(options.Filename);
assemblyModule = new AssemblyModule(options.Filename, moduleContext, ms);
if (options.NewFilename == null)
options.NewFilename = getDefaultNewFilename();
if (string.Equals(options.Filename, options.NewFilename, StringComparison.OrdinalIgnoreCase))
throw new UserException(string.Format("filename is same as new filename! ({0})", options.Filename));
}
示例7: CreateObfuscationFile
public ObfuscatedFile CreateObfuscationFile(ObfuscatedFile.Options fileOptions, ModuleContext moduleContext)
{
ObfuscatedFile ofile = new ObfuscatedFile(fileOptions, moduleContext, new NewAppDomainAssemblyClientFactory());
ofile.DeobfuscatorContext = new DeobfuscatorContext();
try
{
ofile.Load(CreateDeobfuscatorInfos().Select(di => di.CreateDeobfuscator()).ToList());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
return ofile;
}
示例8: SearchDeobfuscator
public static IObfuscatedFile SearchDeobfuscator(string filename)
{
TheAssemblyResolver.Instance.ClearAll();
var fileOptions = new ObfuscatedFile.Options { Filename = filename };
var moduleContext = new ModuleContext(TheAssemblyResolver.Instance);
var ofile = new ObfuscatedFile(fileOptions, moduleContext, new NewAppDomainAssemblyClientFactory())
{
DeobfuscatorContext = new DeobfuscatorContext(),
};
try { ofile.Load(CreateDeobfuscatorInfos().Select(di => di.CreateDeobfuscator()).ToList()); }
catch (Exception) { return null; }
return ofile;
}
示例9: Options
public Options() {
ModuleContext = new ModuleContext(TheAssemblyResolver.Instance);
DeobfuscatorInfos = new List<IDeobfuscatorInfo>();
Files = new List<IObfuscatedFile>();
SearchDirs = new List<SearchDir>();
DefaultStringDecrypterMethods = new List<string>();
RenamerFlags = RenamerFlags.RenameNamespaces |
RenamerFlags.RenameTypes |
RenamerFlags.RenameProperties |
RenamerFlags.RenameEvents |
RenamerFlags.RenameFields |
RenamerFlags.RenameMethods |
RenamerFlags.RenameMethodArgs |
RenamerFlags.RenameGenericParams |
RenamerFlags.RestorePropertiesFromNames |
RenamerFlags.RestoreEventsFromNames |
RenamerFlags.RestoreProperties |
RenamerFlags.RestoreEvents;
RenameSymbols = true;
ControlFlowDeobfuscation = true;
}
示例10: Load
/// <summary>
/// Creates a <see cref="ModuleDefMD"/> instance from a file
/// </summary>
/// <param name="fileName">File name of an existing .NET module/assembly</param>
/// <param name="context">Module context or <c>null</c></param>
/// <returns>A new <see cref="ModuleDefMD"/> instance</returns>
public static ModuleDefMD Load(string fileName, ModuleContext context) {
DotNetFile dnFile = null;
try {
return Load(dnFile = DotNetFile.Load(fileName), context);
}
catch {
if (dnFile != null)
dnFile.Dispose();
throw;
}
}
示例11: Load
/// <summary>
/// Creates a <see cref="ModuleDefMD"/> instance from a file
/// </summary>
/// <param name="fileName">File name of an existing .NET module/assembly</param>
/// <param name="context">Module context or <c>null</c></param>
/// <returns>A new <see cref="ModuleDefMD"/> instance</returns>
public static ModuleDefMD Load(string fileName, ModuleContext context)
{
return Load(fileName, new ModuleCreationOptions(context));
}
示例12: AssemblyModule
public AssemblyModule(string filename, ModuleContext moduleContext) {
this.filename = Utils.GetFullPath(filename);
this.moduleContext = moduleContext;
}
示例13: UpdateObfuscationFileWithOptions
private IObfuscatedFile UpdateObfuscationFileWithOptions(De4dotWrapper de4Dot, string location, string newFile)
{
ObfuscatedFile.Options options = new ObfuscatedFile.Options();
options.ControlFlowDeobfuscation = this.EnableControlFlowDeobfuscation;
options.NewFilename = newFile;
options.KeepObfuscatorTypes = this.KeepObfuscatorClasses;
options.Filename = location;
var context = new ModuleContext();
ObfuscatedFile result = de4Dot.CreateObfuscationFile(options, context);
return result;
}
示例14: FindClosestAssembly
AssemblyDef FindClosestAssembly(AssemblyNameInfo assembly, AssemblyDef closest, IEnumerable<string> paths, ModuleContext moduleContext)
{
if (paths == null)
return closest;
var asmComparer = new AssemblyNameComparer(AssemblyNameComparerFlags.All);
foreach (var path in paths) {
ModuleDefMD mod = null;
try {
mod = ModuleDefMD.Load(path, moduleContext);
var asm = mod.Assembly;
if (asm != null && asmComparer.CompareClosest(assembly, new AssemblyNameInfo(closest), new AssemblyNameInfo(asm)) == 1) {
if (!IsCached(closest) && closest != null && closest.ManifestModule != null)
closest.ManifestModule.Dispose();
closest = asm;
mod = null;
}
}
catch {
}
finally {
if (mod != null)
mod.Dispose();
}
}
return closest;
}
示例15: ModuleDefMD
/// <summary>
/// Constructor
/// </summary>
/// <param name="dnFile">The loaded .NET file</param>
/// <param name="context">Module context or <c>null</c></param>
/// <exception cref="ArgumentNullException">If <paramref name="dnFile"/> is <c>null</c></exception>
ModuleDefMD(DotNetFile dnFile, ModuleContext context)
: base(null, 1) {
#if DEBUG
if (dnFile == null)
throw new ArgumentNullException("dnFile");
#endif
this.dnFile = dnFile;
this.context = context;
Initialize();
this.Kind = GetKind();
this.Characteristics = MetaData.PEImage.ImageNTHeaders.FileHeader.Characteristics;
this.DllCharacteristics = MetaData.PEImage.ImageNTHeaders.OptionalHeader.DllCharacteristics;
this.RuntimeVersion = MetaData.VersionString;
this.Machine = MetaData.PEImage.ImageNTHeaders.FileHeader.Machine;
this.Cor20HeaderFlags = MetaData.ImageCor20Header.Flags;
this.Cor20HeaderRuntimeVersion = (uint)(MetaData.ImageCor20Header.MajorRuntimeVersion << 16) | MetaData.ImageCor20Header.MinorRuntimeVersion;
this.TablesHeaderVersion = MetaData.TablesStream.Version;
}