Пример #1
0
		/// <summary>
		///     Returns only the targets with the specified type and used by specified component.
		/// </summary>
		/// <param name="context">The working context.</param>
		/// <param name="targets">List of targets.</param>
		/// <param name="phase">The component phase.</param>
		/// <returns>Filtered targets.</returns>
		static IList<IDnlibDef> Filter(ConfuserContext context, IList<IDnlibDef> targets, ProtectionPhase phase) {
			ProtectionTargets targetType = phase.Targets;

			IEnumerable<IDnlibDef> filter = targets;
			if ((targetType & ProtectionTargets.Modules) == 0)
				filter = filter.Where(def => !(def is ModuleDef));
			if ((targetType & ProtectionTargets.Types) == 0)
				filter = filter.Where(def => !(def is TypeDef));
			if ((targetType & ProtectionTargets.Methods) == 0)
				filter = filter.Where(def => !(def is MethodDef));
			if ((targetType & ProtectionTargets.Fields) == 0)
				filter = filter.Where(def => !(def is FieldDef));
			if ((targetType & ProtectionTargets.Properties) == 0)
				filter = filter.Where(def => !(def is PropertyDef));
			if ((targetType & ProtectionTargets.Events) == 0)
				filter = filter.Where(def => !(def is EventDef));

			if (phase.ProcessAll)
				return filter.ToList();
			return filter.Where(def => {
				ProtectionSettings parameters = ProtectionParameters.GetParameters(context, def);
				Debug.Assert(parameters != null);
				if (parameters == null) {
					context.Logger.ErrorFormat("'{0}' not marked for obfuscation, possibly a bug.", def);
					throw new ConfuserException(null);
				}
				return parameters.ContainsKey(phase.Parent);
			}).ToList();
		}
Пример #2
0
 /// <summary>
 ///     Inserts the phase into post-processing pipeline of the specified stage.
 /// </summary>
 /// <param name="stage">The pipeline stage.</param>
 /// <param name="phase">The protection phase.</param>
 // Token: 0x060002FB RID: 763 RVA: 0x00012840 File Offset: 0x00010A40
 public void InsertPostStage(PipelineStage stage, ProtectionPhase phase)
 {
     this.postStage[stage].Add(phase);
 }
Пример #3
0
        /// <summary>
        ///     Returns only the targets with the specified type and used by specified component.
        /// </summary>
        /// <param name="context">The working context.</param>
        /// <param name="targets">List of targets.</param>
        /// <param name="phase">The component phase.</param>
        /// <returns>Filtered targets.</returns>
        // Token: 0x060002FE RID: 766 RVA: 0x00012B84 File Offset: 0x00010D84
        private static IList <IDnlibDef> Filter(ConfuserContext context, IList <IDnlibDef> targets, ProtectionPhase phase)
        {
            ProtectionTargets       targetType = phase.Targets;
            IEnumerable <IDnlibDef> filter     = targets;

            if ((targetType & ProtectionTargets.Modules) == (ProtectionTargets)0)
            {
                filter = from def in filter
                         where !(def is ModuleDef)
                         select def;
            }
            if ((targetType & ProtectionTargets.Types) == (ProtectionTargets)0)
            {
                filter = from def in filter
                         where !(def is TypeDef)
                         select def;
            }
            if ((targetType & ProtectionTargets.Methods) == (ProtectionTargets)0)
            {
                filter = from def in filter
                         where !(def is MethodDef)
                         select def;
            }
            if ((targetType & ProtectionTargets.Fields) == (ProtectionTargets)0)
            {
                filter = from def in filter
                         where !(def is FieldDef)
                         select def;
            }
            if ((targetType & ProtectionTargets.Properties) == (ProtectionTargets)0)
            {
                filter = from def in filter
                         where !(def is PropertyDef)
                         select def;
            }
            if ((targetType & ProtectionTargets.Events) == (ProtectionTargets)0)
            {
                filter = from def in filter
                         where !(def is EventDef)
                         select def;
            }
            if (phase.ProcessAll)
            {
                return(filter.ToList <IDnlibDef>());
            }
            return(filter.Where(delegate(IDnlibDef def)
            {
                ProtectionSettings parameters = ProtectionParameters.GetParameters(context, def);
                if (parameters == null)
                {
                    context.Logger.ErrorFormat("'{0}' not marked for obfuscation, possibly a bug.", new object[]
                    {
                        def
                    });
                    throw new ConfuserException(null);
                }
                return parameters.ContainsKey(phase.Parent);
            }).ToList <IDnlibDef>());
        }
Пример #4
0
 /// <summary>
 ///     Inserts the phase into pre-processing pipeline of the specified stage.
 /// </summary>
 /// <param name="stage">The pipeline stage.</param>
 /// <param name="phase">The protection phase.</param>
 public void InsertPreStage(PipelineStage stage, ProtectionPhase phase)
 {
     preStage[stage].Add(phase);
 }