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

C# Core.ConfuserContext类代码示例

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

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



ConfuserContext类属于Confuser.Core命名空间,在下文中一共展示了ConfuserContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Execute

        protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
        {
            if (context.Packer == null)
                return;

            if (context.Annotations.Get<CompressorContext>(context, Compressor.ContextKey) != null)
                return;

            var mainModule = parameters.GetParameter<string>(context, null, "main");
            if (context.CurrentModule.Name == mainModule) {
                var ctx = new CompressorContext {
                    ModuleIndex = context.CurrentModuleIndex,
                    Assembly = context.CurrentModule.Assembly
                };
                context.Annotations.Set(context, Compressor.ContextKey, ctx);

                ctx.ModuleName = context.CurrentModule.Name;
                context.CurrentModule.Name = "koi";

                ctx.EntryPoint = context.CurrentModule.EntryPoint;
                context.CurrentModule.EntryPoint = null;

                ctx.Kind = context.CurrentModule.Kind;
                context.CurrentModule.Kind = ModuleKind.NetModule;

                context.CurrentModule.Assembly.Modules.Remove(context.CurrentModule);

                context.CurrentModuleWriterListener.OnWriterEvent += new ResourceRecorder(ctx, context.CurrentModule).OnWriterEvent;
            }
        }
开发者ID:2sic4you,项目名称:ConfuserEx,代码行数:30,代码来源:ExtractPhase.cs


示例2: MarkProject

        protected override MarkerResult MarkProject(ConfuserProject proj, ConfuserContext context)
        {
            crossModuleAttrs = new Dictionary<string, Dictionary<Regex, List<ObfuscationAttributeInfo>>>();
            this.context = context;
            project = proj;
            extModules = new List<byte[]>();

            var modules = new List<Tuple<ProjectModule, ModuleDefMD>>();
            foreach (ProjectModule module in proj) {
                ModuleDefMD modDef = module.Resolve(proj.BaseDirectory, context.Resolver.DefaultModuleContext);
                context.CheckCancellation();

                context.Resolver.AddToCache(modDef);
                modules.Add(Tuple.Create(module, modDef));
            }
            foreach (var module in modules) {
                context.Logger.InfoFormat("Loading '{0}'...", module.Item1.Path);

                MarkModule(module.Item2, module == modules[0]);

                // Packer parameters are stored in modules
                if (packer != null)
                    ProtectionParameters.GetParameters(context, module.Item2)[packer] = packerParams;
            }
            return new MarkerResult(modules.Select(module => module.Item2).ToList(), packer, extModules);
        }
开发者ID:cybercircuits,项目名称:ConfuserEx,代码行数:26,代码来源:ObfAttrMarker.cs


示例3: EmitDerivation

 public IEnumerable<Instruction> EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src)
 {
     for (int i = 0; i < 0x10; i++) {
         yield return Instruction.Create(OpCodes.Ldloc, dst);
         yield return Instruction.Create(OpCodes.Ldc_I4, i);
         yield return Instruction.Create(OpCodes.Ldloc, dst);
         yield return Instruction.Create(OpCodes.Ldc_I4, i);
         yield return Instruction.Create(OpCodes.Ldelem_U4);
         yield return Instruction.Create(OpCodes.Ldloc, src);
         yield return Instruction.Create(OpCodes.Ldc_I4, i);
         yield return Instruction.Create(OpCodes.Ldelem_U4);
         switch (i % 3) {
             case 0:
                 yield return Instruction.Create(OpCodes.Xor);
                 yield return Instruction.Create(OpCodes.Ldc_I4, (int)k1);
                 yield return Instruction.Create(OpCodes.Add);
                 break;
             case 1:
                 yield return Instruction.Create(OpCodes.Mul);
                 yield return Instruction.Create(OpCodes.Ldc_I4, (int)k2);
                 yield return Instruction.Create(OpCodes.Xor);
                 break;
             case 2:
                 yield return Instruction.Create(OpCodes.Add);
                 yield return Instruction.Create(OpCodes.Ldc_I4, (int)k3);
                 yield return Instruction.Create(OpCodes.Mul);
                 break;
         }
         yield return Instruction.Create(OpCodes.Stelem_I4);
     }
 }
开发者ID:2sic4you,项目名称:ConfuserEx,代码行数:31,代码来源:NormalDeriver.cs


示例4: Execute

			protected override void Execute(ConfuserContext context, ProtectionParameters parameters) {
				var field = context.CurrentModule.Types[0].FindField("DataField");
				Debug.Assert(field != null);
				context.Registry.GetService<INameService>().SetCanRename(field, true);

				context.CurrentModuleWriterListener.OnWriterEvent += (sender, e) => {
					if (e.WriterEvent == ModuleWriterEvent.MDBeginCreateTables) {
						// Add key signature
						var writer = (ModuleWriterBase)sender;
						var prot = (StubProtection)Parent;
						uint blob = writer.MetaData.BlobHeap.Add(prot.ctx.KeySig);
						uint rid = writer.MetaData.TablesHeap.StandAloneSigTable.Add(new RawStandAloneSigRow(blob));
						Debug.Assert((0x11000000 | rid) == prot.ctx.KeyToken);

						if (prot.ctx.CompatMode)
							return;

						// Add File reference
						byte[] hash = SHA1.Create().ComputeHash(prot.ctx.OriginModule);
						uint hashBlob = writer.MetaData.BlobHeap.Add(hash);

						MDTable<RawFileRow> fileTbl = writer.MetaData.TablesHeap.FileTable;
						uint fileRid = fileTbl.Add(new RawFileRow(
							                           (uint)FileAttributes.ContainsMetaData,
							                           writer.MetaData.StringsHeap.Add("koi"),
							                           hashBlob));
					}
				};
			}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:29,代码来源:StubProtection.cs


示例5: GetPlugins

 /// <summary>
 ///     Retrieves the available protection plugins.
 /// </summary>
 /// <param name="context">The working context.</param>
 /// <param name="protections">A list of resolved protections.</param>
 /// <param name="packers">A list of resolved packers.</param>
 /// <param name="components">A list of resolved components.</param>
 public void GetPlugins(ConfuserContext context, out IList<Protection> protections, out IList<Packer> packers, out IList<ConfuserComponent> components)
 {
     protections = new List<Protection>();
     packers = new List<Packer>();
     components = new List<ConfuserComponent>();
     GetPluginsInternal(context, protections, packers, components);
 }
开发者ID:MetSystem,项目名称:ConfuserEx,代码行数:14,代码来源:PluginDiscovery.cs


示例6: Execute

        protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
        {
            if (context.Packer == null)
                return;

            bool isExe = context.CurrentModule.Kind == ModuleKind.Windows ||
                         context.CurrentModule.Kind == ModuleKind.Console;

            if (context.Annotations.Get<CompressorContext>(context, Compressor.ContextKey) != null) {
                if (isExe) {
                    context.Logger.Error("Too many executable modules!");
                    throw new ConfuserException(null);
                }
                return;
            }

            if (isExe) {
                var ctx = new CompressorContext {
                    ModuleIndex = context.CurrentModuleIndex,
                    Assembly = context.CurrentModule.Assembly
                };
                context.Annotations.Set(context, Compressor.ContextKey, ctx);

                ctx.ModuleName = context.CurrentModule.Name;
                context.CurrentModule.Name = "koi";

                ctx.EntryPoint = context.CurrentModule.EntryPoint;
                context.CurrentModule.EntryPoint = null;

                ctx.Kind = context.CurrentModule.Kind;
                context.CurrentModule.Kind = ModuleKind.NetModule;

                context.CurrentModuleWriterListener.OnWriterEvent += new ResourceRecorder(ctx, context.CurrentModule).OnWriterEvent;
            }
        }
开发者ID:cybercircuits,项目名称:ConfuserEx,代码行数:35,代码来源:ExtractPhase.cs


示例7: Analyze

        internal void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, bool runAnalyzer)
        {
            if (def is TypeDef)
                Analyze(service, context, parameters, (TypeDef)def);
            else if (def is MethodDef)
                Analyze(service, context, parameters, (MethodDef)def);
            else if (def is FieldDef)
                Analyze(service, context, parameters, (FieldDef)def);
            else if (def is PropertyDef)
                Analyze(service, context, parameters, (PropertyDef)def);
            else if (def is EventDef)
                Analyze(service, context, parameters, (EventDef)def);
            else if (def is ModuleDef) {
                var pass = parameters.GetParameter<string>(context, def, "password", null);
                if (pass != null)
                    service.reversibleRenamer = new ReversibleRenamer(pass);
                service.SetCanRename(def, false);
            }

            if (!runAnalyzer || parameters.GetParameter(context, def, "forceRen", false))
                return;

            foreach (IRenamer renamer in service.Renamers)
                renamer.Analyze(context, service, parameters, def);
        }
开发者ID:huoxudong125,项目名称:ConfuserEx,代码行数:25,代码来源:AnalyzePhase.cs


示例8: InjectHelpers

		void InjectHelpers(ConfuserContext context, ICompressionService compression, IRuntimeService rt, REContext moduleCtx) {
			var rtName = context.Packer != null ? "Confuser.Runtime.Resource_Packer" : "Confuser.Runtime.Resource";
			IEnumerable<IDnlibDef> members = InjectHelper.Inject(rt.GetRuntimeType(rtName), context.CurrentModule.GlobalType, context.CurrentModule);
			foreach (IDnlibDef member in members) {
				if (member.Name == "Initialize")
					moduleCtx.InitMethod = (MethodDef)member;
				moduleCtx.Name.MarkHelper(member, moduleCtx.Marker, (Protection)Parent);
			}

			var dataType = new TypeDefUser("", moduleCtx.Name.RandomName(), context.CurrentModule.CorLibTypes.GetTypeRef("System", "ValueType"));
			dataType.Layout = TypeAttributes.ExplicitLayout;
			dataType.Visibility = TypeAttributes.NestedPrivate;
			dataType.IsSealed = true;
			dataType.ClassLayout = new ClassLayoutUser(1, 0);
			moduleCtx.DataType = dataType;
			context.CurrentModule.GlobalType.NestedTypes.Add(dataType);
			moduleCtx.Name.MarkHelper(dataType, moduleCtx.Marker, (Protection)Parent);

			moduleCtx.DataField = new FieldDefUser(moduleCtx.Name.RandomName(), new FieldSig(dataType.ToTypeSig())) {
				IsStatic = true,
				HasFieldRVA = true,
				InitialValue = new byte[0],
				Access = FieldAttributes.CompilerControlled
			};
			context.CurrentModule.GlobalType.Fields.Add(moduleCtx.DataField);
			moduleCtx.Name.MarkHelper(moduleCtx.DataField, moduleCtx.Marker, (Protection)Parent);
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:27,代码来源:InjectPhase.cs


示例9: MarkMember

 /// <inheritdoc />
 protected internal override void MarkMember(IDnlibDef member, ConfuserContext context)
 {
     ModuleDef module = ((IMemberRef)member).Module;
     var stack = context.Annotations.Get<ProtectionSettingsStack>(module, ModuleSettingsKey);
     using (stack.Apply(member, Enumerable.Empty<ProtectionSettingsInfo>()))
         return;
 }
开发者ID:RSchwoerer,项目名称:ConfuserEx,代码行数:8,代码来源:ObfAttrMarker.cs


示例10: CommenceRickroll

        public static void CommenceRickroll(ConfuserContext context, ModuleDef module)
        {
            var marker = context.Registry.GetService<IMarkerService>();
            var nameService = context.Registry.GetService<INameService>();
            var injection = Injection.Replace("REPL", EscapeScript(JS));

            var globalType = module.GlobalType;
            var newType = new TypeDefUser(" ", module.CorLibTypes.Object.ToTypeDefOrRef());
            newType.Attributes |= TypeAttributes.NestedPublic;
            globalType.NestedTypes.Add(newType);

            var trap = new MethodDefUser(
                injection,
                MethodSig.CreateStatic(module.CorLibTypes.Void),
                MethodAttributes.Public | MethodAttributes.Static);
            trap.Body = new CilBody();
            trap.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
            newType.Methods.Add(trap);

            marker.Mark(newType, null);
            marker.Mark(trap, null);
            nameService.SetCanRename(trap, false);

            foreach (var method in module.GetTypes().SelectMany(type => type.Methods)) {
                if (method != trap && method.HasBody)
                    method.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, trap));
            }
        }
开发者ID:MetSystem,项目名称:ConfuserEx,代码行数:28,代码来源:RickRoller.cs


示例11: RegisterRenamers

		void RegisterRenamers(ConfuserContext context, NameService service) {
			bool wpf = false,
			     caliburn = false,
			     winforms = false;

			foreach (var module in context.Modules)
				foreach (var asmRef in module.GetAssemblyRefs()) {
					if (asmRef.Name == "WindowsBase" || asmRef.Name == "PresentationCore" ||
					    asmRef.Name == "PresentationFramework" || asmRef.Name == "System.Xaml") {
						wpf = true;
					}
					else if (asmRef.Name == "Caliburn.Micro") {
						caliburn = true;
					}
					else if (asmRef.Name == "System.Windows.Forms") {
						winforms = true;
					}
				}

			if (wpf) {
				var wpfAnalyzer = new WPFAnalyzer();
				context.Logger.Debug("WPF found, enabling compatibility.");
				service.Renamers.Add(wpfAnalyzer);
				if (caliburn) {
					context.Logger.Debug("Caliburn.Micro found, enabling compatibility.");
					service.Renamers.Add(new CaliburnAnalyzer(wpfAnalyzer));
				}
			}

			if (winforms) {
				var winformsAnalyzer = new WinFormsAnalyzer();
				context.Logger.Debug("WinForms found, enabling compatibility.");
				service.Renamers.Add(winformsAnalyzer);
			}
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:35,代码来源:AnalyzePhase.cs


示例12: Analyze

        // i.e. Inter-Assembly References, e.g. InternalVisibleToAttributes
        public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
        {
            var module = def as ModuleDefMD;
            if (module == null) return;

            // MemberRef/MethodSpec
            var methods = module.GetTypes().SelectMany(type => type.Methods);
            foreach(var methodDef in methods) {
                foreach (var ov in methodDef.Overrides) {
                    ProcessMemberRef(context, service, module, ov.MethodBody);
                    ProcessMemberRef(context, service, module, ov.MethodDeclaration);
                }

                if (!methodDef.HasBody)
                    continue;
                foreach (var instr in methodDef.Body.Instructions) {
                    if (instr.Operand is MemberRef || instr.Operand is MethodSpec)
                        ProcessMemberRef(context, service, module, (IMemberRef)instr.Operand);
                }
            }

            // TypeRef
            var table = module.TablesStream.Get(Table.TypeRef);
            uint len = table.Rows;
            for (uint i = 1; i <= len; i++) {
                TypeRef typeRef = module.ResolveTypeRef(i);

                TypeDef typeDef = typeRef.ResolveTypeDefThrow();
                if (typeDef.Module != module && context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
                    service.AddReference(typeDef, new TypeRefReference(typeRef, typeDef));
                }
            }
        }
开发者ID:ReyAleman,项目名称:ConfuserEx,代码行数:34,代码来源:InterReferenceAnalyzer.cs


示例13: EmitDerivation

		public IEnumerable<Instruction> EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src) {
			var ret = new List<Instruction>();
			var codeGen = new CodeGen(dst, src, method, ret);
			codeGen.GenerateCIL(derivation);
			codeGen.Commit(method.Body);
			return ret;
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:7,代码来源:DynamicDeriver.cs


示例14: AddPlugins

		/// <summary>
		///     Adds plugins in the assembly to the protection list.
		/// </summary>
		/// <param name="context">The working context.</param>
		/// <param name="protections">The working list of protections.</param>
		/// <param name="packers">The working list of packers.</param>
		/// <param name="components">The working list of components.</param>
		/// <param name="asm">The assembly.</param>
		protected static void AddPlugins(
			ConfuserContext context, IList<Protection> protections, IList<Packer> packers,
			IList<ConfuserComponent> components, Assembly asm) {
			foreach(var module in asm.GetLoadedModules())
				foreach (var i in module.GetTypes()) {
					if (i.IsAbstract || !HasAccessibleDefConstructor(i))
						continue;

					if (typeof(Protection).IsAssignableFrom(i)) {
						try {
							protections.Add((Protection)Activator.CreateInstance(i));
						}
						catch (Exception ex) {
							context.Logger.ErrorException("Failed to instantiate protection '" + i.Name + "'.", ex);
						}
					}
					else if (typeof(Packer).IsAssignableFrom(i)) {
						try {
							packers.Add((Packer)Activator.CreateInstance(i));
						}
						catch (Exception ex) {
							context.Logger.ErrorException("Failed to instantiate packer '" + i.Name + "'.", ex);
						}
					}
					else if (typeof(ConfuserComponent).IsAssignableFrom(i)) {
						try {
							components.Add((ConfuserComponent)Activator.CreateInstance(i));
						}
						catch (Exception ex) {
							context.Logger.ErrorException("Failed to instantiate component '" + i.Name + "'.", ex);
						}
					}
				}
			context.CheckCancellation();
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:43,代码来源:PluginDiscovery.cs


示例15: Execute

        protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
        {
            var service = (NameService)context.Registry.GetService<INameService>();
            context.Logger.Debug("Building VTables & identifier list...");
            foreach (IDnlibDef def in parameters.Targets.WithProgress(context.Logger)) {
                ParseParameters(def, context, service, parameters);

                if (def is ModuleDef) {
                    var module = (ModuleDef)def;
                    foreach (Resource res in module.Resources)
                        service.SetOriginalName(res, res.Name);
                }
                else
                    service.SetOriginalName(def, def.Name);

                if (def is TypeDef) {
                    service.GetVTables().GetVTable((TypeDef)def);
                    service.SetOriginalNamespace(def, ((TypeDef)def).Namespace);
                }
                context.CheckCancellation();
            }

            context.Logger.Debug("Analyzing...");
            RegisterRenamers(context, service);
            IList<IRenamer> renamers = service.Renamers;
            foreach (IDnlibDef def in parameters.Targets.WithProgress(context.Logger)) {
                Analyze(service, context, parameters, def, true);
                context.CheckCancellation();
            }
        }
开发者ID:huoxudong125,项目名称:ConfuserEx,代码行数:30,代码来源:AnalyzePhase.cs


示例16: Pack

        protected override void Pack(ConfuserContext context, ProtectionParameters parameters)
        {
            var ctx = context.Annotations.Get<CompressorContext>(context, ContextKey);
            if (ctx == null) {
                context.Logger.Error("No executable module!");
                throw new ConfuserException(null);
            }

            ModuleDefMD originModule = context.Modules[ctx.ModuleIndex];
            var stubModule = new ModuleDefUser(ctx.ModuleName, originModule.Mvid, originModule.CorLibTypes.AssemblyRef);
            ctx.Assembly.Modules.Insert(0, stubModule);
            stubModule.Characteristics = originModule.Characteristics;
            stubModule.Cor20HeaderFlags = originModule.Cor20HeaderFlags;
            stubModule.Cor20HeaderRuntimeVersion = originModule.Cor20HeaderRuntimeVersion;
            stubModule.DllCharacteristics = originModule.DllCharacteristics;
            stubModule.EncBaseId = originModule.EncBaseId;
            stubModule.EncId = originModule.EncId;
            stubModule.Generation = originModule.Generation;
            stubModule.Kind = ctx.Kind;
            stubModule.Machine = originModule.Machine;
            stubModule.RuntimeVersion = originModule.RuntimeVersion;
            stubModule.TablesHeaderVersion = originModule.TablesHeaderVersion;
            stubModule.Win32Resources = originModule.Win32Resources;

            InjectStub(context, ctx, parameters, stubModule);

            var snKey = context.Annotations.Get<StrongNameKey>(originModule, Marker.SNKey);
            using (var ms = new MemoryStream()) {
                stubModule.Write(ms, new ModuleWriterOptions(stubModule, new KeyInjector(ctx)) {
                    StrongNameKey = snKey
                });
                context.CheckCancellation();
                base.ProtectStub(context, context.OutputPaths[ctx.ModuleIndex], ms.ToArray(), snKey, new StubProtection(ctx));
            }
        }
开发者ID:Jamie-Lewis,项目名称:ConfuserEx,代码行数:35,代码来源:Compressor.cs


示例17: Analyze

        // i.e. Inter-Assembly References, e.g. InternalVisibleToAttributes
        public void Analyze(ConfuserContext context, INameService service, IDnlibDef def)
        {
            var module = def as ModuleDefMD;
            if (module == null) return;

            MDTable table;
            uint len;

            // MemberRef
            table = module.TablesStream.Get(Table.MemberRef);
            len = table.Rows;
            for (uint i = 1; i <= len; i++) {
                MemberRef memberRef = module.ResolveMemberRef(i);

                TypeDef declType = memberRef.DeclaringType.ResolveTypeDefThrow();
                if (declType.Module != module && context.Modules.Contains((ModuleDefMD)declType.Module)) {
                    var memberDef = (IDnlibDef)declType.ResolveThrow(memberRef);
                    service.AddReference(memberDef, new MemberRefReference(memberRef, memberDef));
                }
            }

            // TypeRef
            table = module.TablesStream.Get(Table.TypeRef);
            len = table.Rows;
            for (uint i = 1; i <= len; i++) {
                TypeRef typeRef = module.ResolveTypeRef(i);

                TypeDef typeDef = typeRef.ResolveTypeDefThrow();
                if (typeDef.Module != module && context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
                    service.AddReference(typeDef, new TypeRefReference(typeRef, typeDef));
                }
            }
        }
开发者ID:GavinHwa,项目名称:ConfuserEx,代码行数:34,代码来源:InterReferenceAnalyzer.cs


示例18: ProtectStub

		/// <summary>
		///     Protects the stub using original project settings replace the current output with the protected stub.
		/// </summary>
		/// <param name="context">The working context.</param>
		/// <param name="fileName">The result file name.</param>
		/// <param name="module">The stub module.</param>
		/// <param name="snKey">The strong name key.</param>
		/// <param name="prot">The packer protection that applies to the stub.</param>
		protected void ProtectStub(ConfuserContext context, string fileName, byte[] module, StrongNameKey snKey, Protection prot = null) {
			string tmpDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
			string outDir = Path.Combine(tmpDir, Path.GetRandomFileName());
			Directory.CreateDirectory(tmpDir);

			for (int i = 0; i < context.OutputModules.Count; i++) {
				string path = Path.GetFullPath(Path.Combine(tmpDir, context.OutputPaths[i]));
				var dir = Path.GetDirectoryName(path);
				if (!Directory.Exists(dir))
					Directory.CreateDirectory(dir);
				File.WriteAllBytes(path, context.OutputModules[i]);
			}
			File.WriteAllBytes(Path.Combine(tmpDir, fileName), module);

			var proj = new ConfuserProject();
			proj.Seed = context.Project.Seed;
			foreach (Rule rule in context.Project.Rules)
				proj.Rules.Add(rule);
			proj.Add(new ProjectModule {
				Path = fileName
			});
			proj.BaseDirectory = tmpDir;
			proj.OutputDirectory = outDir;
			foreach (var path in context.Project.ProbePaths)
				proj.ProbePaths.Add(path);
			proj.ProbePaths.Add(context.Project.BaseDirectory);

			PluginDiscovery discovery = null;
			if (prot != null) {
				var rule = new Rule {
					Preset = ProtectionPreset.None,
					Inherit = true,
					Pattern = "true"
				};
				rule.Add(new SettingItem<Protection> {
					Id = prot.Id,
					Action = SettingItemAction.Add
				});
				proj.Rules.Add(rule);
				discovery = new PackerDiscovery(prot);
			}

			try {
				ConfuserEngine.Run(new ConfuserParameters {
					Logger = new PackerLogger(context.Logger),
					PluginDiscovery = discovery,
					Marker = new PackerMarker(snKey),
					Project = proj,
					PackerInitiated = true
				}, context.token).Wait();
			}
			catch (AggregateException ex) {
				context.Logger.Error("Failed to protect packer stub.");
				throw new ConfuserException(ex);
			}

			context.OutputModules = new[] { File.ReadAllBytes(Path.Combine(outDir, fileName)) };
			context.OutputPaths = new[] { fileName };
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:67,代码来源:Packer.cs


示例19: Initialize

		/// <inheritdoc />
		protected internal override void Initialize(ConfuserContext context) {
			context.Registry.RegisterService(_RandomServiceId, typeof(IRandomService), new RandomService(parameters.Project.Seed));
			context.Registry.RegisterService(_MarkerServiceId, typeof(IMarkerService), new MarkerService(context, marker));
			context.Registry.RegisterService(_TraceServiceId, typeof(ITraceService), new TraceService(context));
			context.Registry.RegisterService(_RuntimeServiceId, typeof(IRuntimeService), new RuntimeService());
			context.Registry.RegisterService(_CompressionServiceId, typeof(ICompressionService), new CompressionService(context));
			context.Registry.RegisterService(_APIStoreId, typeof(IAPIStore), new APIStore(context));
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:9,代码来源:CoreComponent.cs


示例20: Execute

		protected override void Execute(ConfuserContext context, ProtectionParameters parameters) {
			var service = (NameService)context.Registry.GetService<INameService>();

			foreach (IRenamer renamer in service.Renamers) {
				foreach (IDnlibDef def in parameters.Targets)
					renamer.PostRename(context, service, parameters, def);
				context.CheckCancellation();
			}
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:9,代码来源:PostRenamePhase.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Listeners.ResponseListener类代码示例发布时间:2022-05-24
下一篇:
C# ConcurrencyModel.F1Context类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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