private void ProcessPackers(ICustomAttributeProvider provider, out NameValueCollection param, out Packer packer) { CustomAttribute attr = GetAttribute(provider.CustomAttributes, "PackerAttribute"); if (attr == null) { param = null; packer = null; return; } CustomAttributeNamedArgument stripArg = attr.Properties.FirstOrDefault(arg => arg.Name == "StripAfterObfuscation"); bool strip = true; if (!stripArg.Equals(default(CustomAttributeNamedArgument))) { strip = (bool)stripArg.Argument.Value; } if (strip) { provider.CustomAttributes.Remove(attr); } CustomAttributeNamedArgument cfgArg = attr.Properties.FirstOrDefault(arg => arg.Name == "Config"); string cfg = ""; if (!cfgArg.Equals(default(CustomAttributeNamedArgument))) { cfg = (string)cfgArg.Argument.Value; } if (string.IsNullOrEmpty(cfg)) { param = null; packer = null; return; } param = new NameValueCollection(); Match match = Regex.Match(cfg, @"([^:]+)(?::(?:([^=]*=[^,]*),?)*)?"); packer = Packers[match.Groups[1].Value]; foreach (Capture arg in match.Groups[2].Captures) { string[] args = arg.Value.Split('='); param.Add(args[0], args[1]); } }
private bool ProcessAttribute(ICustomAttributeProvider provider, Marking setting) { CustomAttribute att = GetAttribute(provider.CustomAttributes, "ConfusingAttribute"); if (att == null) { setting.StartLevel(); return(false); } CustomAttributeNamedArgument stripArg = att.Properties.FirstOrDefault(arg => arg.Name == "StripAfterObfuscation"); bool strip = true; if (!stripArg.Equals(default(CustomAttributeNamedArgument))) { strip = (bool)stripArg.Argument.Value; } if (strip) { provider.CustomAttributes.Remove(att); } CustomAttributeNamedArgument excludeArg = att.Properties.FirstOrDefault(arg => arg.Name == "Exclude"); bool exclude = false; if (!excludeArg.Equals(default(CustomAttributeNamedArgument))) { exclude = (bool)excludeArg.Argument.Value; } if (exclude) { setting.CurrentConfusions.Clear(); } CustomAttributeNamedArgument applyToMembersArg = att.Properties.FirstOrDefault(arg => arg.Name == "ApplyToMembers"); bool applyToMembers = true; if (!applyToMembersArg.Equals(default(CustomAttributeNamedArgument))) { applyToMembers = (bool)applyToMembersArg.Argument.Value; } if (applyToMembers) { setting.StartLevel(); } else { setting.SkipLevel(); } try { if (!exclude) { CustomAttributeNamedArgument featureArg = att.Properties.FirstOrDefault(arg => arg.Name == "Config"); string feature = "all"; if (!featureArg.Equals(default(CustomAttributeNamedArgument))) { feature = (string)featureArg.Argument.Value; } if (string.Equals(feature, "all", StringComparison.OrdinalIgnoreCase)) { FillPreset(Preset.Maximum, setting.CurrentConfusions); } else if (string.Equals(feature, "default", StringComparison.OrdinalIgnoreCase)) { FillPreset(Preset.Normal, setting.CurrentConfusions); } else { ProcessConfig(feature, setting.CurrentConfusions); } } return(exclude && applyToMembers); } catch { cr.Log("Warning: Cannot process ConfusingAttribute at '" + provider.ToString() + "'. ConfusingAttribute ignored."); return(false); } }