List <IAnnotationProvider> GetTargets(ModuleDefinition mod, IConfusion cion) { List <IAnnotationProvider> mems = new List <IAnnotationProvider>(); IDictionary <IConfusion, NameValueCollection> sets = (mod as IAnnotationProvider).Annotations["ConfusionSets"] as IDictionary <IConfusion, NameValueCollection>; if (sets != null) { foreach (KeyValuePair <IConfusion, NameValueCollection> kv in sets) { if (kv.Key == cion && (kv.Key.Target & Target.Module) == Target.Module) { mems.Add(mod); } } } foreach (TypeDefinition type in mod.Types) { sets = (type as IAnnotationProvider).Annotations["ConfusionSets"] as IDictionary <IConfusion, NameValueCollection>; if (sets != null) { foreach (KeyValuePair <IConfusion, NameValueCollection> kv in sets) { if (kv.Key == cion && (kv.Key.Target & Target.Types) == Target.Types) { mems.Add(type); } } } GetTargets(type, mems, cion); } return(mems); }
private void ProcessConfig(string cfg, ObfuscationSettings cs) { MatchCollection matches = Regex.Matches(cfg, @"(\+|\-|)\[([^,\]]*)(?:,([^\]]*))?\]"); foreach (Match match in matches) { string id = match.Groups[2].Value.ToLower(); switch (match.Groups[1].Value) { case null: case "": case "+": if (id == "preset") { FillPreset((Preset)Enum.Parse(typeof(Preset), match.Groups[3].Value, true), cs); } else if (id == "new") { cs.Clear(); } else { if (!Confusions.ContainsKey(id)) { cr.Log("Warning: Cannot find confusion id '" + id + "'."); break; } IConfusion now = (from i in cs.Keys where i.ID == id select i).FirstOrDefault() ?? Confusions[id]; if (!cs.ContainsKey(now)) { cs[now] = new NameValueCollection(); } NameValueCollection nv = cs[now]; if (!string.IsNullOrEmpty(match.Groups[3].Value)) { foreach (string param in match.Groups[3].Value.Split(',')) { string[] p = param.Split('='); if (p.Length == 1) { nv[p[0].ToLower()] = "true"; } else { nv[p[0].ToLower()] = p[1]; } } } } break; case "-": cs.Remove((from i in cs.Keys where i.ID == id select i).FirstOrDefault()); break; } } }
void GetTargets(TypeDefinition type, List <IAnnotationProvider> mems, IConfusion cion) { foreach (TypeDefinition nType in type.NestedTypes) { IDictionary <IConfusion, NameValueCollection> sets = (nType as IAnnotationProvider).Annotations["ConfusionSets"] as IDictionary <IConfusion, NameValueCollection>; if (sets != null) { foreach (KeyValuePair <IConfusion, NameValueCollection> kv in sets) { if (kv.Key == cion && (kv.Key.Target & Target.Types) == Target.Types) { mems.Add(nType); } } } GetTargets(nType, mems, cion); } foreach (MethodDefinition mtd in type.Methods) { IDictionary <IConfusion, NameValueCollection> sets = (mtd as IAnnotationProvider).Annotations["ConfusionSets"] as IDictionary <IConfusion, NameValueCollection>; if (sets != null) { foreach (KeyValuePair <IConfusion, NameValueCollection> kv in sets) { if (kv.Key == cion && (kv.Key.Target & Target.Methods) == Target.Methods) { mems.Add(mtd); } } } } foreach (FieldDefinition fld in type.Fields) { IDictionary <IConfusion, NameValueCollection> sets = (fld as IAnnotationProvider).Annotations["ConfusionSets"] as IDictionary <IConfusion, NameValueCollection>; if (sets != null) { foreach (KeyValuePair <IConfusion, NameValueCollection> kv in sets) { if (kv.Key == cion && (kv.Key.Target & Target.Fields) == Target.Fields) { mems.Add(fld); } } } } foreach (EventDefinition evt in type.Events) { IDictionary <IConfusion, NameValueCollection> sets = (evt as IAnnotationProvider).Annotations["ConfusionSets"] as IDictionary <IConfusion, NameValueCollection>; if (sets != null) { foreach (KeyValuePair <IConfusion, NameValueCollection> kv in sets) { if (kv.Key == cion && (kv.Key.Target & Target.Events) == Target.Events) { mems.Add(evt); } } } } foreach (PropertyDefinition prop in type.Properties) { IDictionary <IConfusion, NameValueCollection> sets = (prop as IAnnotationProvider).Annotations["ConfusionSets"] as IDictionary <IConfusion, NameValueCollection>; if (sets != null) { foreach (KeyValuePair <IConfusion, NameValueCollection> kv in sets) { if (kv.Key == cion && (kv.Key.Target & Target.Properties) == Target.Properties) { mems.Add(prop); } } } } }
public CopyMarker(AssemblySetting settings, IConfusion exclude) { origin = settings; this.exclude = exclude; }
public FcBus() { _confusion = new PRConfusion(); }
public CopyMarker(AssemblyDefinition asm, IConfusion exclude) { origin = asm; this.exclude = exclude; }