// Token: 0x060001BA RID: 442 RVA: 0x0000E898 File Offset: 0x0000CA98 private void ProcessModule(ModuleDefMD module, Dictionary <Rule, PatternExpression> rules, string snKeyPath, string snKeyPass, List <ObfAttrMarker.ObfuscationAttributeInfo> settingAttrs, Dictionary <Regex, List <ObfAttrMarker.ObfuscationAttributeInfo> > namespaceAttrs) { this.context.Annotations.Set <StrongNameKey>(module, Marker.SNKey, Marker.LoadSNKey(this.context, (snKeyPath == null) ? null : Path.Combine(this.project.BaseDirectory, snKeyPath), snKeyPass)); ObfAttrMarker.ProtectionSettingsStack moduleStack = new ObfAttrMarker.ProtectionSettingsStack(); moduleStack.Push(this.ProcessAttributes(settingAttrs)); this.ApplySettings(module, rules, moduleStack.GetInfos(), null); Dictionary <Regex, ObfAttrMarker.ProtectionSettingsStack> nsSettings = namespaceAttrs.ToDictionary((KeyValuePair <Regex, List <ObfAttrMarker.ObfuscationAttributeInfo> > kvp) => kvp.Key, delegate(KeyValuePair <Regex, List <ObfAttrMarker.ObfuscationAttributeInfo> > kvp) { ObfAttrMarker.ProtectionSettingsStack nsStack = new ObfAttrMarker.ProtectionSettingsStack(moduleStack); nsStack.Push(this.ProcessAttributes(kvp.Value)); return(nsStack); }); foreach (TypeDef type in module.Types) { ObfAttrMarker.ProtectionSettingsStack typeStack = ObfAttrMarker.MatchNamespace(nsSettings, type.Namespace) ?? moduleStack; typeStack.Push(this.ProcessAttributes(ObfAttrMarker.ReadObfuscationAttributes(type))); this.ApplySettings(type, rules, typeStack.GetInfos(), null); this.ProcessTypeMembers(type, rules, typeStack); typeStack.Pop(); } }
// Token: 0x060001BC RID: 444 RVA: 0x0000ECB0 File Offset: 0x0000CEB0 private void ProcessMember(IDnlibDef member, Dictionary <Rule, PatternExpression> rules, ObfAttrMarker.ProtectionSettingsStack stack) { stack.Push(this.ProcessAttributes(ObfAttrMarker.ReadObfuscationAttributes(member))); this.ApplySettings(member, rules, stack.GetInfos(), null); stack.Pop(); }
// Token: 0x060001BB RID: 443 RVA: 0x0000E9DC File Offset: 0x0000CBDC private void ProcessTypeMembers(TypeDef type, Dictionary <Rule, PatternExpression> rules, ObfAttrMarker.ProtectionSettingsStack stack) { foreach (TypeDef nestedType in type.NestedTypes) { stack.Push(this.ProcessAttributes(ObfAttrMarker.ReadObfuscationAttributes(nestedType))); this.ApplySettings(nestedType, rules, stack.GetInfos(), null); this.ProcessTypeMembers(nestedType, rules, stack); stack.Pop(); } foreach (PropertyDef prop in type.Properties) { stack.Push(this.ProcessAttributes(ObfAttrMarker.ReadObfuscationAttributes(prop))); this.ApplySettings(prop, rules, stack.GetInfos(), null); if (prop.GetMethod != null) { this.ProcessMember(prop.GetMethod, rules, stack); } if (prop.SetMethod != null) { this.ProcessMember(prop.SetMethod, rules, stack); } foreach (MethodDef i in prop.OtherMethods) { this.ProcessMember(i, rules, stack); } stack.Pop(); } foreach (EventDef evt in type.Events) { stack.Push(this.ProcessAttributes(ObfAttrMarker.ReadObfuscationAttributes(evt))); this.ApplySettings(evt, rules, stack.GetInfos(), null); if (evt.AddMethod != null) { this.ProcessMember(evt.AddMethod, rules, stack); } if (evt.RemoveMethod != null) { this.ProcessMember(evt.RemoveMethod, rules, stack); } if (evt.InvokeMethod != null) { this.ProcessMember(evt.InvokeMethod, rules, stack); } foreach (MethodDef j in evt.OtherMethods) { this.ProcessMember(j, rules, stack); } stack.Pop(); } foreach (MethodDef method in type.Methods) { if (method.SemanticsAttributes == MethodSemanticsAttributes.None) { this.ProcessMember(method, rules, stack); } } foreach (FieldDef field in type.Fields) { this.ProcessMember(field, rules, stack); } }
// Token: 0x060001B7 RID: 439 RVA: 0x0000E3C4 File Offset: 0x0000C5C4 private void MarkModule(ProjectModule projModule, ModuleDefMD module, Dictionary <Rule, PatternExpression> rules, bool isMain) { List <ObfAttrMarker.ObfuscationAttributeInfo> settingAttrs = new List <ObfAttrMarker.ObfuscationAttributeInfo>(); string snKeyPath = projModule.SNKeyPath; string snKeyPass = projModule.SNKeyPassword; Dictionary <Regex, List <ObfAttrMarker.ObfuscationAttributeInfo> > namespaceAttrs; if (!this.crossModuleAttrs.TryGetValue(module.Name, out namespaceAttrs)) { namespaceAttrs = new Dictionary <Regex, List <ObfAttrMarker.ObfuscationAttributeInfo> >(); } foreach (ObfAttrMarker.ObfuscationAttributeInfo attr in ObfAttrMarker.ReadObfuscationAttributes(module.Assembly)) { if (string.IsNullOrEmpty(attr.FeatureName)) { settingAttrs.Add(attr); } else if (attr.FeatureName.Equals("generate debug symbol", StringComparison.OrdinalIgnoreCase)) { if (!isMain) { throw new ArgumentException("Only main module can set 'generate debug symbol'."); } this.project.Debug = bool.Parse(attr.FeatureValue); } else if (attr.FeatureName.Equals("random seed", StringComparison.OrdinalIgnoreCase)) { if (!isMain) { throw new ArgumentException("Only main module can set 'random seed'."); } this.project.Seed = attr.FeatureValue; } else if (attr.FeatureName.Equals("strong name key", StringComparison.OrdinalIgnoreCase)) { snKeyPath = Path.Combine(this.project.BaseDirectory, attr.FeatureValue); } else if (attr.FeatureName.Equals("strong name key password", StringComparison.OrdinalIgnoreCase)) { snKeyPass = attr.FeatureValue; } else if (attr.FeatureName.Equals("packer", StringComparison.OrdinalIgnoreCase)) { if (!isMain) { throw new ArgumentException("Only main module can set 'packer'."); } new ObfAttrParser(this.packers).ParsePackerString(attr.FeatureValue, out this.packer, out this.packerParams); } else if (attr.FeatureName.Equals("external module", StringComparison.OrdinalIgnoreCase)) { if (!isMain) { throw new ArgumentException("Only main module can add external modules."); } byte[] rawModule = new ProjectModule { Path = attr.FeatureValue }.LoadRaw(this.project.BaseDirectory); this.extModules.Add(rawModule); } else { Match match = ObfAttrMarker.NSInModulePattern.Match(attr.FeatureName); if (match.Success) { if (!isMain) { throw new ArgumentException("Only main module can set cross module obfuscation."); } Regex ns = ObfAttrMarker.TranslateNamespaceRegex(match.Groups[1].Value); string targetModule = match.Groups[2].Value; ObfAttrMarker.ObfuscationAttributeInfo x = attr; x.FeatureName = ""; Dictionary <Regex, List <ObfAttrMarker.ObfuscationAttributeInfo> > targetModuleAttrs; if (!this.crossModuleAttrs.TryGetValue(targetModule, out targetModuleAttrs)) { targetModuleAttrs = new Dictionary <Regex, List <ObfAttrMarker.ObfuscationAttributeInfo> >(); this.crossModuleAttrs[targetModule] = targetModuleAttrs; } targetModuleAttrs.AddListEntry(ns, x); } else { match = ObfAttrMarker.NSPattern.Match(attr.FeatureName); if (match.Success) { Regex ns2 = ObfAttrMarker.TranslateNamespaceRegex(match.Groups[1].Value); ObfAttrMarker.ObfuscationAttributeInfo x2 = attr; x2.FeatureName = ""; namespaceAttrs.AddListEntry(ns2, x2); } } } } if (this.project.Debug) { module.LoadPdb(); } this.ProcessModule(module, rules, snKeyPath, snKeyPass, settingAttrs, namespaceAttrs); }