protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.Inspection, new AnalyzePhase(this)); pipeline.InsertPostStage(PipelineStage.BeginModule, new RenamePhase(this)); pipeline.InsertPreStage(PipelineStage.EndModule, new PostRenamePhase(this)); pipeline.InsertPostStage(PipelineStage.SaveModules, new ExportMapPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new LdfldPhase(this)); pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new CallvirtPhase(this)); pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new CtorCallProtection(this)); pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new MultiplyPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { if (!ctx.CompatMode) { pipeline.InsertPreStage(PipelineStage.Inspection, new InjPhase(this)); } pipeline.InsertPostStage(PipelineStage.BeginModule, new SigPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.Inspection, new InitializePhase(this, KoiInfo.KoiDirectory)); pipeline.InsertPreStage(PipelineStage.EndModule, new MarkPhase(this)); pipeline.InsertPreStage(PipelineStage.Debug, new FinalizePhase(this)); pipeline.InsertPreStage(PipelineStage.Pack, new SavePhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { if (pipeline == null) { throw new ArgumentNullException(nameof(pipeline)); } pipeline.InsertPreStage(PipelineStage.Inspection, new AnalyzePhase(this)); pipeline.InsertPostStage(PipelineStage.ProcessModule, new ScramblePhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { //find all types that need to be modified pipeline.InsertPostStage(PipelineStage.Inspection, new MemoryEditAnalyzePhase(this)); //insert type pipeline.InsertPostStage(PipelineStage.BeginModule, new MemoryEditInjectPhase(this)); //change type and apply IL changes pipeline.InsertPreStage(PipelineStage.ProcessModule, new MemoryEditApplyPhase(this)); }
protected internal override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new ControlFlowPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.BeginModule, new InvalidMDPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.ProcessModule, new ReduceMetadataOptimizationPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.Inspection, new InjPhase(this)); pipeline.InsertPostStage(PipelineStage.BeginModule, new SigPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.BeginModule, new ReferenceProxyPhase(this)); }
/// <summary> /// Runs the protection pipeline. /// </summary> /// <param name="pipeline">The protection pipeline.</param> /// <param name="context">The context.</param> static void RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) { Func<IList<IDnlibDef>> getAllDefs = () => context.Modules.SelectMany(module => module.FindDefinitions()).ToList(); Func<ModuleDef, IList<IDnlibDef>> getModuleDefs = module => module.FindDefinitions().ToList(); context.CurrentModuleIndex = -1; pipeline.ExecuteStage(PipelineStage.Inspection, Inspection, () => getAllDefs(), context); var options = new ModuleWriterOptionsBase[context.Modules.Count]; var listeners = new ModuleWriterListener[context.Modules.Count]; for (int i = 0; i < context.Modules.Count; i++) { context.CurrentModuleIndex = i; context.CurrentModuleWriterOptions = null; context.CurrentModuleWriterListener = null; pipeline.ExecuteStage(PipelineStage.BeginModule, BeginModule, () => getModuleDefs(context.CurrentModule), context); pipeline.ExecuteStage(PipelineStage.ProcessModule, ProcessModule, () => getModuleDefs(context.CurrentModule), context); pipeline.ExecuteStage(PipelineStage.OptimizeMethods, OptimizeMethods, () => getModuleDefs(context.CurrentModule), context); pipeline.ExecuteStage(PipelineStage.EndModule, EndModule, () => getModuleDefs(context.CurrentModule), context); options[i] = context.CurrentModuleWriterOptions; listeners[i] = context.CurrentModuleWriterListener; } for (int i = 0; i < context.Modules.Count; i++) { context.CurrentModuleIndex = i; context.CurrentModuleWriterOptions = options[i]; context.CurrentModuleWriterListener = listeners[i]; pipeline.ExecuteStage(PipelineStage.WriteModule, WriteModule, () => getModuleDefs(context.CurrentModule), context); context.OutputModules[i] = context.CurrentModuleOutput; context.OutputSymbols[i] = context.CurrentModuleSymbol; context.CurrentModuleWriterOptions = null; context.CurrentModuleWriterListener = null; context.CurrentModuleOutput = null; context.CurrentModuleSymbol = null; } context.CurrentModuleIndex = -1; pipeline.ExecuteStage(PipelineStage.Debug, Debug, () => getAllDefs(), context); pipeline.ExecuteStage(PipelineStage.Pack, Pack, () => getAllDefs(), context); pipeline.ExecuteStage(PipelineStage.SaveModules, SaveModules, () => getAllDefs(), context); if (!context.PackerInitiated) context.Logger.Info("Done."); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.ProcessModule, new DisConstConfusion.DisConstConfusionPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { //watermark is added in the inspection stage, this executes right after pipeline.InsertPostStage(PipelineStage.Inspection, new AntiWatermarkPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.BeginModule, new AntiDumpPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.ProcessModule, new MutationPhase(this)); pipeline.InsertPostStage(PipelineStage.ProcessModule, new TestPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.WriteModule, new ExtractPhase(this)); }
/// <summary> /// Inserts protection stages into processing pipeline. /// </summary> /// <param name="pipeline">The processing pipeline.</param> protected internal abstract void PopulatePipeline(ProtectionPipeline pipeline);
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.ProcessModule, new InjectPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { throw new NotSupportedException(); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new ControlFlowPhase(this)); }
/// <inheritdoc /> protected override void PopulatePipeline(ProtectionPipeline pipeline) => pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new HardeningPhase(this));
/// <summary> /// Runs the engine. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="token">The cancellation token.</param> static void RunInternal(ConfuserParameters parameters, CancellationToken token) { // 1. Setup context var context = new ConfuserContext(); context.Logger = parameters.GetLogger(); context.Project = parameters.Project; context.PackerInitiated = parameters.PackerInitiated; context.token = token; PrintInfo(context); bool ok = false; try { var asmResolver = new AssemblyResolver(); asmResolver.EnableTypeDefCache = true; asmResolver.DefaultModuleContext = new ModuleContext(asmResolver); context.Resolver = asmResolver; context.BaseDirectory = Path.Combine(Environment.CurrentDirectory, parameters.Project.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar); context.OutputDirectory = Path.Combine(parameters.Project.BaseDirectory, parameters.Project.OutputDirectory.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar); foreach (string probePath in parameters.Project.ProbePaths) asmResolver.PostSearchPaths.Insert(0, Path.Combine(context.BaseDirectory, probePath)); context.CheckCancellation(); Marker marker = parameters.GetMarker(); // 2. Discover plugins context.Logger.Debug("Discovering plugins..."); IList<Protection> prots; IList<Packer> packers; IList<ConfuserComponent> components; parameters.GetPluginDiscovery().GetPlugins(context, out prots, out packers, out components); context.Logger.InfoFormat("Discovered {0} protections, {1} packers.", prots.Count, packers.Count); context.CheckCancellation(); // 3. Resolve dependency context.Logger.Debug("Resolving component dependency..."); try { var resolver = new DependencyResolver(prots); prots = resolver.SortDependency(); } catch (CircularDependencyException ex) { context.Logger.ErrorException("", ex); throw new ConfuserException(ex); } components.Insert(0, new CoreComponent(parameters, marker)); foreach (Protection prot in prots) components.Add(prot); foreach (Packer packer in packers) components.Add(packer); context.CheckCancellation(); // 4. Load modules context.Logger.Info("Loading input modules..."); marker.Initalize(prots, packers); MarkerResult markings = marker.MarkProject(parameters.Project, context); context.Modules = markings.Modules.ToList().AsReadOnly(); foreach (var module in context.Modules) module.EnableTypeDefFindCache = true; context.OutputModules = Enumerable.Repeat<byte[]>(null, markings.Modules.Count).ToArray(); context.OutputSymbols = Enumerable.Repeat<byte[]>(null, markings.Modules.Count).ToArray(); context.OutputPaths = Enumerable.Repeat<string>(null, markings.Modules.Count).ToArray(); context.Packer = markings.Packer; context.ExternalModules = markings.ExternalModules; context.CheckCancellation(); // 5. Initialize components context.Logger.Info("Initializing..."); foreach (ConfuserComponent comp in components) { try { comp.Initialize(context); } catch (Exception ex) { context.Logger.ErrorException("Error occured during initialization of '" + comp.Name + "'.", ex); throw new ConfuserException(ex); } context.CheckCancellation(); } context.CheckCancellation(); // 6. Build pipeline context.Logger.Debug("Building pipeline..."); var pipeline = new ProtectionPipeline(); context.Pipeline = pipeline; foreach (ConfuserComponent comp in components) { comp.PopulatePipeline(pipeline); } context.CheckCancellation(); //7. Run pipeline RunPipeline(pipeline, context); ok = true; } catch (AssemblyResolveException ex) { context.Logger.ErrorException("Failed to resolve an assembly, check if all dependencies are present in the correct version.", ex); PrintEnvironmentInfo(context); } catch (TypeResolveException ex) { context.Logger.ErrorException("Failed to resolve a type, check if all dependencies are present in the correct version.", ex); PrintEnvironmentInfo(context); } catch (MemberRefResolveException ex) { context.Logger.ErrorException("Failed to resolve a member, check if all dependencies are present in the correct version.", ex); PrintEnvironmentInfo(context); } catch (IOException ex) { context.Logger.ErrorException("An IO error occurred, check if all input/output locations are readable/writable.", ex); } catch (OperationCanceledException) { context.Logger.Error("Operation cancelled."); } catch (ConfuserException) { // Exception is already handled/logged, so just ignore and report failure } catch (Exception ex) { context.Logger.ErrorException("Unknown error occurred.", ex); } finally { if (context.Resolver != null) context.Resolver.Clear(); context.Logger.Finish(ok); } }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.ProcessModule, new FakeObfuscatorTypesPhase(this)); pipeline.InsertPostStage(PipelineStage.ProcessModule, new FakeObfuscatorAttributesPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { //TODO: Add something here }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { // }
protected internal override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.ProcessModule, new AntiDumpPhase(this)); }
// Token: 0x06000210 RID: 528 RVA: 0x00012703 File Offset: 0x00010903 protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.ProcessModule, new FakeAttributes.FakeAttributesPhase(this)); }
// Token: 0x060001EA RID: 490 RVA: 0x00011C8E File Offset: 0x0000FE8E protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.EndModule, new EraseHeadersProtection.ErasePhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new InjectPhase(this)); pipeline.InsertPreStage(PipelineStage.EndModule, new MDPhase(this)); }
// Token: 0x060001EA RID: 490 RVA: 0x00011C8E File Offset: 0x0000FE8E protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.EndModule, new HideMethodsPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.Inspection, new AnalyzePhase(this)); pipeline.InsertPostStage(PipelineStage.Inspection, new ScramblePhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { //pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new ControlFlowPhase(this)); //pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new ControlFlowPhase2(this)); pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new ControlFlowNewPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.ProcessModule, new AntiHttpDebugger.AntiHttpDebuggerPhase(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.EndModule, new OverwritesHeadersProtection.Overwrite(this)); }
protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.BeginModule, new FakeNative.FakeNativePhase(this)); }