• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DotNet.ModuleContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中dnlib.DotNet.ModuleContext的典型用法代码示例。如果您正苦于以下问题:C# ModuleContext类的具体用法?C# ModuleContext怎么用?C# ModuleContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ModuleContext类属于dnlib.DotNet命名空间,在下文中一共展示了ModuleContext类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
开发者ID:crajeshbe,项目名称:ILAST,代码行数:26,代码来源:Program.cs


示例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;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:7,代码来源:De4dotWrapper.cs


示例3: ILAST

        public ILAST(MethodDef method, ModuleContext modCtx)
        {
            Method = method;
            Method.DeclaringType.Module.Context = modCtx;
            Elements = new List<Element>();

            ProcessMethod();
        }
开发者ID:crajeshbe,项目名称:ILAST,代码行数:8,代码来源:ILAST.cs


示例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);
		}
开发者ID:mamingxiu,项目名称:dnExplorer,代码行数:52,代码来源:dnModule.cs


示例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);
        }
开发者ID:n017,项目名称:dotPeek.Deobfuscator,代码行数:13,代码来源:AssemblyDeobfuscatorManager.cs


示例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));
        }
开发者ID:n017,项目名称:ConfuserDeobfuscator,代码行数:14,代码来源:ObfuscatedFile.cs


示例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;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:17,代码来源:De4dotWrapper.cs


示例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;
        }
开发者ID:T0T4R4,项目名称:Reflexil,代码行数:17,代码来源:De4dotHelper.cs


示例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;
			}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:21,代码来源:FilesDeobfuscator.cs


示例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;
			}
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:17,代码来源:ModuleDefMD.cs


示例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));
 }
开发者ID:dmirmilshteyn,项目名称:dnlib,代码行数:10,代码来源:ModuleDefMD.cs


示例12: AssemblyModule

		public AssemblyModule(string filename, ModuleContext moduleContext) {
			this.filename = Utils.GetFullPath(filename);
			this.moduleContext = moduleContext;
		}
开发者ID:RafaelRMachado,项目名称:de4dot,代码行数:4,代码来源:AssemblyModule.cs


示例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;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:11,代码来源:DeobfuscateDialogViewModel.cs


示例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;
        }
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:27,代码来源:AssemblyResolver.cs


示例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;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:25,代码来源:ModuleDefMD.cs


示例16: FindExactAssembly

 /// <summary>
 /// Finds an assembly that exactly matches the requested assembly
 /// </summary>
 /// <param name="assembly">Assembly name to find</param>
 /// <param name="paths">Search paths or <c>null</c> if none</param>
 /// <param name="moduleContext">Module context</param>
 /// <returns>An <see cref="AssemblyDef"/> instance or <c>null</c> if an exact match
 /// couldn't be found.</returns>
 AssemblyDef FindExactAssembly(AssemblyNameInfo assembly, IEnumerable<string> paths, ModuleContext moduleContext)
 {
     if (paths == null)
         return null;
     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.Equals(assembly, new AssemblyNameInfo(asm))) {
                 mod = null;
                 return asm;
             }
         }
         catch {
         }
         finally {
             if (mod != null)
                 mod.Dispose();
         }
     }
     return null;
 }
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:32,代码来源:AssemblyResolver.cs


示例17: AssemblyResolver

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="defaultModuleContext">Module context for all resolved assemblies</param>
 public AssemblyResolver(ModuleContext defaultModuleContext)
     : this(defaultModuleContext, true)
 {
 }
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:8,代码来源:AssemblyResolver.cs


示例18: LoadAssemblies

        static List<AssemblyDef> LoadAssemblies(string target)
        {
            AssemblyResolver asmResolver = new AssemblyResolver();
            ModuleContext modCtx = new ModuleContext(asmResolver);
            asmResolver.DefaultModuleContext = modCtx;
            asmResolver.EnableTypeDefCache = true;

            var directory = Path.GetFullPath(Path.GetDirectoryName(target));
            asmResolver.PreSearchPaths.Add(directory);

            List<AssemblyDef> assemblies = new List<AssemblyDef>();
            
            foreach (var asm in Directory.GetFiles(directory, "*.*")
                .Where(f=>Path.GetExtension(f.ToLower()) == ".exe" || Path.GetExtension(f.ToLower())==".dll"))
            {
                try
                {
                    var def = AssemblyDef.Load(asm);
                    def.Modules[0].Context = modCtx;
                    asmResolver.AddToCache(def);
                    assemblies.Add(def);
                }
                catch
                {
                    //Ignore
                }
            }

            return assemblies;
        }
开发者ID:kekekeks,项目名称:PerspexVS,代码行数:30,代码来源:MetadataLoader.cs



注:本文中的dnlib.DotNet.ModuleContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DotNet.ModuleDefMD类代码示例发布时间:2022-05-26
下一篇:
C# DotNet.MethodSig类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap