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

C# ProtectionParameters类代码示例

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

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



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

示例1: 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


示例2: 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


示例3: 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


示例4: 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


示例5: 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


示例6: 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


示例7: 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


示例8: ReplaceReference

		public static void ReplaceReference(CEContext ctx, ProtectionParameters parameters) {
			foreach (var entry in ctx.ReferenceRepl) {
				if (parameters.GetParameter<bool>(ctx.Context, entry.Key, "cfg"))
					ReplaceCFG(entry.Key, entry.Value, ctx);
				else
					ReplaceNormal(entry.Key, entry.Value);
			}
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:8,代码来源:ReferenceReplacer.cs


示例9: Analyze

		public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) {
			var method = def as MethodDef;
			if (method == null || !method.HasBody)
				return;

			// When a ldtoken instruction reference a definition,
			// most likely it would be used in reflection and thus probably should not be renamed.
			// Also, when ToString is invoked on enum,
			// the enum should not be renamed.
			for (int i = 0; i < method.Body.Instructions.Count; i++) {
				Instruction instr = method.Body.Instructions[i];
				if (instr.OpCode.Code == Code.Ldtoken) {
					if (instr.Operand is MemberRef) {
						IMemberForwarded member = ((MemberRef)instr.Operand).ResolveThrow();
						if (context.Modules.Contains((ModuleDefMD)member.Module))
							service.SetCanRename(member, false);
					}
					else if (instr.Operand is IField) {
						FieldDef field = ((IField)instr.Operand).ResolveThrow();
						if (context.Modules.Contains((ModuleDefMD)field.Module))
							service.SetCanRename(field, false);
					}
					else if (instr.Operand is IMethod) {
						var im = (IMethod)instr.Operand;
						if (!im.IsArrayAccessors()) {
							MethodDef m = im.ResolveThrow();
							if (context.Modules.Contains((ModuleDefMD)m.Module))
								service.SetCanRename(method, false);
						}
					}
					else if (instr.Operand is ITypeDefOrRef) {
						if (!(instr.Operand is TypeSpec)) {
							TypeDef type = ((ITypeDefOrRef)instr.Operand).ResolveTypeDefThrow();
							if (context.Modules.Contains((ModuleDefMD)type.Module) &&
							    HandleTypeOf(context, service, method, i)) {
								var t = type;
								do {
									DisableRename(service, t, false);
									t = t.DeclaringType;
								} while (t != null);
							}
						}
					}
					else
						throw new UnreachableException();
				}
				else if ((instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt) &&
				         ((IMethod)instr.Operand).Name == "ToString") {
					HandleEnum(context, service, method, i);
				}
				else if (instr.OpCode.Code == Code.Ldstr) {
					TypeDef typeDef = method.Module.FindReflection((string)instr.Operand);
					if (typeDef != null)
						service.AddReference(typeDef, new StringTypeReference(instr, typeDef));
				}
			}
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:57,代码来源:LdtokenEnumAnalyzer.cs


示例10: 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


示例11: Execute

			protected override void Execute(ConfuserContext context, ProtectionParameters parameters) {
				foreach (ModuleDef module in parameters.Targets.OfType<ModuleDef>()) {
					TypeRef attrRef = module.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "SuppressIldasmAttribute");
					var ctorRef = new MemberRefUser(module, ".ctor", MethodSig.CreateInstance(module.CorLibTypes.Void), attrRef);

					var attr = new CustomAttribute(ctorRef);
					module.CustomAttributes.Add(attr);
				}
			}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:9,代码来源:AntiILDasmProtection.cs


示例12: Execute

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

            context.Logger.Debug("Renaming...");
            foreach (IRenamer renamer in service.Renamers) {
                foreach (IDnlibDef def in parameters.Targets)
                    renamer.PreRename(context, service, def);
                context.CheckCancellation();
            }

            foreach (IDnlibDef def in parameters.Targets.WithProgress(context.Logger)) {
                bool canRename = service.CanRename(def);
                if (def is MethodDef)
                    if (canRename && parameters.GetParameter(context, def, "renameArgs", true)) {
                        foreach (ParamDef param in ((MethodDef)def).ParamDefs)
                            param.Name = null;
                    }

                if (!canRename)
                    continue;

                RenameMode mode = service.GetRenameMode(def);

                IList<INameReference> references = service.GetReferences(def);
                bool cancel = false;
                foreach (INameReference refer in references) {
                    cancel |= refer.ShouldCancelRename();
                    if (cancel) break;
                }
                if (cancel)
                    continue;

                if (def is TypeDef) {
                    var typeDef = (TypeDef)def;
                    if (parameters.GetParameter(context, def, "flatten", true)) {
                        typeDef.Name = service.ObfuscateName(typeDef.FullName, mode);
                        typeDef.Namespace = "";
                    }
                    else {
                        typeDef.Namespace = service.ObfuscateName(typeDef.Namespace, mode);
                        typeDef.Name = service.ObfuscateName(typeDef.Name, mode);
                    }
                }
                else
                    def.Name = service.ObfuscateName(def.Name, mode);

                foreach (INameReference refer in references.ToList()) {
                    if (!refer.UpdateNameReference(context, service)) {
                        context.Logger.ErrorFormat("Failed to update name reference on '{0}'.", def);
                        throw new ConfuserException(null);
                    }
                }
                context.CheckCancellation();
            }
        }
开发者ID:89sos98,项目名称:ConfuserEx,代码行数:56,代码来源:RenamePhase.cs


示例13: Execute

		protected override void Execute(ConfuserContext context, ProtectionParameters parameters) {
			bool disabledOpti = DisabledOptimization(context.CurrentModule);
			RandomGenerator random = context.Registry.GetService<IRandomService>().GetRandomGenerator(ControlFlowProtection._FullId);

			foreach (MethodDef method in parameters.Targets.OfType<MethodDef>().WithProgress(context.Logger))
				if (method.HasBody && method.Body.Instructions.Count > 0) {
					ProcessMethod(method.Body, ParseParameters(method, context, parameters, random, disabledOpti));
					context.CheckCancellation();
				}
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:10,代码来源:ControlFlowPhase.cs


示例14: Analyze

 public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
 {
     if (def is TypeDef)
         Analyze(context, service, (TypeDef)def, parameters);
     else if (def is MethodDef)
         Analyze(context, service, (MethodDef)def, parameters);
     else if (def is PropertyDef)
         Analyze(context, service, (PropertyDef)def, parameters);
     else if (def is FieldDef)
         Analyze(context, service, (FieldDef)def, parameters);
 }
开发者ID:RSchwoerer,项目名称:ConfuserEx,代码行数:11,代码来源:JsonAnalyzer.cs


示例15: Analyze

        public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
        {
            var module = def as ModuleDef;
            if (module == null) return;

            string asmName = module.Assembly.Name.String;
            if (!string.IsNullOrEmpty(module.Assembly.Culture) &&
                asmName.EndsWith(".resources")) {
                // Satellite assembly
                var satellitePattern = new Regex(string.Format("^(.*)\\.{0}\\.resources$", module.Assembly.Culture));
                string nameAsmName = asmName.Substring(0, asmName.Length - ".resources".Length);
                ModuleDef mainModule = context.Modules.SingleOrDefault(mod => mod.Assembly.Name == nameAsmName);
                if (mainModule == null) {
                    context.Logger.ErrorFormat("Could not find main assembly of satellite assembly '{0}'.", module.Assembly.FullName);
                    throw new ConfuserException(null);
                }

                string format = "{0}." + module.Assembly.Culture + ".resources";
                foreach (Resource res in module.Resources) {
                    Match match = satellitePattern.Match(res.Name);
                    if (!match.Success)
                        continue;
                    string typeName = match.Groups[1].Value;
                    TypeDef type = mainModule.FindReflectionThrow(typeName);
                    if (type == null) {
                        context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName);
                        continue;
                    }
                    service.ReduceRenameMode(type, RenameMode.ASCII);
                    service.AddReference(type, new ResourceReference(res, type, format));
                }
            }
            else {
                string format = "{0}.resources";
                foreach (Resource res in module.Resources) {
                    Match match = ResourceNamePattern.Match(res.Name);
                    if (!match.Success)
                        continue;
                    string typeName = match.Groups[1].Value;

                    if (typeName.EndsWith(".g")) // WPF resources, ignore
                        continue;

                    TypeDef type = module.FindReflection(typeName);
                    if (type == null) {
                        context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName);
                        continue;
                    }
                    service.ReduceRenameMode(type, RenameMode.ASCII);
                    service.AddReference(type, new ResourceReference(res, type, format));
                }
            }
        }
开发者ID:MulleDK19,项目名称:ConfuserEx,代码行数:53,代码来源:ResourceAnalyzer.cs


示例16: Execute

        protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
        {
            if (parameters.Targets.Any()) {
                var compression = context.Registry.GetService<ICompressionService>();
                var name = context.Registry.GetService<INameService>();
                var marker = context.Registry.GetService<IMarkerService>();
                var rt = context.Registry.GetService<IRuntimeService>();
                var moduleCtx = new CEContext {
                    Random = context.Registry.GetService<IRandomService>().GetRandomGenerator(Parent.Id),
                    Context = context,
                    Module = context.CurrentModule,
                    Marker = marker,
                    DynCipher = context.Registry.GetService<IDynCipherService>(),
                    Name = name
                };

                // Extract parameters
                moduleCtx.Mode = parameters.GetParameter(context, context.CurrentModule, "mode", Mode.Normal);
                moduleCtx.DecoderCount = parameters.GetParameter(context, context.CurrentModule, "decoderCount", 5);

                switch (moduleCtx.Mode) {
                    case Mode.Normal:
                        moduleCtx.ModeHandler = new NormalMode();
                        break;
                    case Mode.Dynamic:
                        moduleCtx.ModeHandler = new DynamicMode();
                        break;
                    case Mode.x86:
                        moduleCtx.ModeHandler = new x86Mode();
                        if ((context.CurrentModule.Cor20HeaderFlags & ComImageFlags.ILOnly) != 0)
                            context.CurrentModuleWriterOptions.Cor20HeaderOptions.Flags &= ~ComImageFlags.ILOnly;
                        break;
                    default:
                        throw new UnreachableException();
                }

                // Inject helpers
                MethodDef decomp = compression.GetRuntimeDecompressor(context.CurrentModule, member => {
                    name.MarkHelper(member, marker);
                    if (member is MethodDef)
                        ProtectionParameters.GetParameters(context, member).Remove(Parent);
                });
                InjectHelpers(context, compression, rt, moduleCtx);

                // Mutate codes
                MutateInitializer(moduleCtx, decomp);

                MethodDef cctor = context.CurrentModule.GlobalType.FindStaticConstructor();
                cctor.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, moduleCtx.InitMethod));

                context.Annotations.Set(context.CurrentModule, ConstantProtection.ContextKey, moduleCtx);
            }
        }
开发者ID:GavinHwa,项目名称:ConfuserEx,代码行数:53,代码来源:InjectPhase.cs


示例17: Analyze

		public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) {
			var method = def as MethodDef;
			if (method != null) {
				if (!method.HasBody)
					return;
				AnalyzeMethod(context, service, method);
			}

			var module = def as ModuleDefMD;
			if (module != null) {
				AnalyzeResources(context, service, module);
			}
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:13,代码来源:WPFAnalyzer.cs


示例18: Execute

		protected override void Execute(ConfuserContext context, ProtectionParameters parameters) {
			if (parameters.Targets.Any()) {
				if (!UTF8String.IsNullOrEmpty(context.CurrentModule.Assembly.Culture)) {
					context.Logger.DebugFormat("Skipping resource encryption for satellite assembly '{0}'.",
					                           context.CurrentModule.Assembly.FullName);
					return;
				}
				var compression = context.Registry.GetService<ICompressionService>();
				var name = context.Registry.GetService<INameService>();
				var marker = context.Registry.GetService<IMarkerService>();
				var rt = context.Registry.GetService<IRuntimeService>();
				var moduleCtx = new REContext {
					Random = context.Registry.GetService<IRandomService>().GetRandomGenerator(Parent.Id),
					Context = context,
					Module = context.CurrentModule,
					Marker = marker,
					DynCipher = context.Registry.GetService<IDynCipherService>(),
					Name = name
				};

				// Extract parameters
				moduleCtx.Mode = parameters.GetParameter(context, context.CurrentModule, "mode", Mode.Normal);

				switch (moduleCtx.Mode) {
					case Mode.Normal:
						moduleCtx.ModeHandler = new NormalMode();
						break;
					case Mode.Dynamic:
						moduleCtx.ModeHandler = new DynamicMode();
						break;
					default:
						throw new UnreachableException();
				}

				// Inject helpers
				MethodDef decomp = compression.GetRuntimeDecompressor(context.CurrentModule, member => {
					name.MarkHelper(member, marker, (Protection)Parent);
					if (member is MethodDef)
						ProtectionParameters.GetParameters(context, member).Remove(Parent);
				});
				InjectHelpers(context, compression, rt, moduleCtx);

				// Mutate codes
				MutateInitializer(moduleCtx, decomp);

				MethodDef cctor = context.CurrentModule.GlobalType.FindStaticConstructor();
				cctor.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, moduleCtx.InitMethod));

				new MDPhase(moduleCtx).Hook();
			}
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:51,代码来源:InjectPhase.cs


示例19: Analyze

		public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) {
			if (def is ModuleDef) {
				foreach (var type in ((ModuleDef)def).GetTypes())
					foreach (var prop in type.Properties)
						properties.AddListEntry(prop.Name, prop);
				return;
			}

			var method = def as MethodDef;
			if (method == null || !method.HasBody)
				return;

			AnalyzeMethod(context, service, method);
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:14,代码来源:WinFormsAnalyzer.cs


示例20: PostRename

        public void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
        {
            var module = def as ModuleDefMD;
            if (module == null)
                return;

            var wpfResInfo = context.Annotations.Get<Dictionary<string, Dictionary<string, BamlDocument>>>(module, BAMLKey);
            if (wpfResInfo == null)
                return;

            foreach (EmbeddedResource res in module.Resources.OfType<EmbeddedResource>())
            {
                Dictionary<string, BamlDocument> resInfo;

                if (!wpfResInfo.TryGetValue(res.Name, out resInfo))
                    continue;

                var stream = new MemoryStream();
                var writer = new ResourceWriter(stream);

                res.Data.Position = 0;
                var reader = new ResourceReader(new ImageStream(res.Data));
                IDictionaryEnumerator enumerator = reader.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var name = (string)enumerator.Key;
                    string typeName;
                    byte[] data;
                    reader.GetResourceData(name, out typeName, out data);

                    BamlDocument document;
                    if (resInfo.TryGetValue(name, out document))
                    {
                        var docStream = new MemoryStream();
                        docStream.Position = 4;
                        BamlWriter.WriteDocument(document, docStream);
                        docStream.Position = 0;
                        docStream.Write(BitConverter.GetBytes((int)docStream.Length - 4), 0, 4);
                        data = docStream.ToArray();
                        name = document.DocumentName;
                    }

                    writer.AddResourceData(name, typeName, data);
                }
                writer.Generate();
                res.Data = MemoryImageStream.Create(stream.ToArray());
            }
        }
开发者ID:nik-net,项目名称:ConfuserEx,代码行数:48,代码来源:WPFAnalyzer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Proto类代码示例发布时间:2022-05-24
下一篇:
C# ProtectionLevel类代码示例发布时间: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