Пример #1
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);
 }
Пример #2
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>
        private static IList <ISDnlibDef> Filter(ConfuserContext context, IList <ISDnlibDef> targets, ProtectionPhase phase)
        {
            ProtectionTargets targetType = phase.Targets;

            IEnumerable <ISDnlibDef> 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());
        }