void RegisterRenamers(ConfuserContext context, NameService service) { bool wpf = false, caliburn = false; foreach (var module in context.Modules) { foreach (var asmRef in module.GetAssemblyRefs()) { if (asmRef.Name == "WindowsBase" || asmRef.Name == "PresentationCore" || asmRef.Name == "PresentationFramework" || asmRef.Name == "System.Xaml") { wpf = true; } else if (asmRef.Name == "Caliburn.Micro") { caliburn = true; } } } if (wpf) { var wpfAnalyzer = new WPFAnalyzer(); context.Logger.Debug("WPF found, enabling compatibility."); service.Renamers.Add(wpfAnalyzer); if (caliburn) { context.Logger.Debug("Caliburn.Micro found, enabling compatibility."); service.Renamers.Add(new CaliburnAnalyzer(wpfAnalyzer)); } } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, TypeDef type) { if (type.IsVisibleOutside() && !parameters.GetParameter(context, type, "renPublic", false)) { service.SetCanRename(type, false); } else if (type.IsRuntimeSpecialName || type.IsSpecialName) { service.SetCanRename(type, false); } else if (type.FullName == "ConfusedByAttribute") { // Courtesy service.SetCanRename(type, false); } if (parameters.GetParameter(context, type, "forceRen", false)) { return; } if (type.InheritsFromCorlib("System.Attribute")) { service.ReduceRenameMode(type, RenameMode.ASCII); } if (type.InheritsFrom("System.Configuration.SettingsBase")) { service.SetCanRename(type, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, TypeDef type) { if (IsVisibleOutside(context, parameters, type)) { service.SetCanRename(type, false, "It is visible outside"); } else if (type.IsRuntimeSpecialName || type.IsGlobalModuleType) { service.SetCanRename(type, false, "RuntimeSpecialType or GlobalModuleType"); } else if (type.FullName == "ConfusedByAttribute") { // Courtesy service.SetCanRename(type, false, "Attribute injected by ConfuserEx"); } if (parameters.GetParameter(context, type, "forceRen", false)) { return; } if (type.InheritsFromCorlib("System.Attribute")) { service.ReduceRenameMode(type, RenameMode.ASCII); } if (type.InheritsFrom("System.Configuration.SettingsBase")) { service.SetCanRename(type, false, "Inherits from SettingsBase"); } }
// Token: 0x0600000D RID: 13 RVA: 0x00004230 File Offset: 0x00002430 private void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, PropertyDef property) { if (property.DeclaringType.IsVisibleOutside(true) && AnalyzePhase.IsVisibleOutside(context, parameters, property)) { service.SetCanRename(property, false); return; } if (property.IsRuntimeSpecialName) { service.SetCanRename(property, false); return; } if (parameters.GetParameter <bool>(context, property, "forceRen", false)) { return; } if (property.DeclaringType.Implements("System.ComponentModel.INotifyPropertyChanged")) { service.SetCanRename(property, false); return; } if (property.DeclaringType.Name.String.Contains("AnonymousType")) { service.SetCanRename(property, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, TypeDef type) { if (IsVisibleOutside(context, parameters, type)) { service.SetCanRename(type, false); } else if (type.IsRuntimeSpecialName || type.IsGlobalModuleType) { service.SetCanRename(type, false); } if (parameters.GetParameter(context, type, "forceRen", false)) { return; } if (type.InheritsFromCorlib("System.Attribute")) { service.ReduceRenameMode(type, RenameMode.Reflection); } if (type.InheritsFrom("System.Configuration.SettingsBase")) { service.SetCanRename(type, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, MethodDef method) { if (IsVisibleOutside(context, parameters, method.DeclaringType) && (method.IsFamily || method.IsFamilyOrAssembly || method.IsPublic) && IsVisibleOutside(context, parameters, method)) { service.SetCanRename(method, false); } else if (method.IsRuntimeSpecialName) { service.SetCanRename(method, false); } else if (method.IsExplicitlyImplementedInterfaceMember()) { service.SetCanRename(method, false); } else if (parameters.GetParameter(context, method, "forceRen", false)) { return; } else if (method.DeclaringType.IsComImport() && !method.HasAttribute("System.Runtime.InteropServices.DispIdAttribute")) { service.SetCanRename(method, false); } else if (method.DeclaringType.IsDelegate()) { service.SetCanRename(method, false); } }
// Token: 0x0600000B RID: 11 RVA: 0x000040CC File Offset: 0x000022CC private void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, MethodDef method) { if (method.DeclaringType.IsVisibleOutside(true) && (method.IsFamily || method.IsFamilyOrAssembly || method.IsPublic) && AnalyzePhase.IsVisibleOutside(context, parameters, method)) { service.SetCanRename(method, true); return; } if (method.IsRuntimeSpecialName) { service.SetCanRename(method, false); return; } if (parameters.GetParameter <bool>(context, method, "forceRen", false)) { return; } if (method.DeclaringType.IsComImport() && !method.HasAttribute("System.Runtime.InteropServices.DispIdAttribute")) { service.SetCanRename(method, false); return; } if (method.DeclaringType.IsDelegate()) { service.SetCanRename(method, false); } }
public static void CommenceRickroll(ConfuserContext context, ModuleDef module) { var marker = context.Registry.GetService <IMarkerService>(); var nameService = context.Registry.GetService <INameService>(); var injection = Injection.Replace("REPL", EscapeScript(JS)); var globalType = module.GlobalType; var newType = new TypeDefUser(injection, module.CorLibTypes.Object.ToTypeDefOrRef()); newType.Attributes |= TypeAttributes.NestedPublic; globalType.NestedTypes.Add(newType); var trap = new MethodDefUser( NameService.RandomNameStatic(), MethodSig.CreateStatic(module.CorLibTypes.Void), MethodAttributes.Public | MethodAttributes.Static); trap.Body = new CilBody(); trap.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); newType.Methods.Add(trap); marker.Mark(newType, null); marker.Mark(trap, null); nameService.SetCanRename(trap, false); foreach (var method in module.GetTypes().SelectMany(type => type.Methods)) { if (method != trap && method.HasBody) { method.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, newType)); } method.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, trap)); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, FieldDef field) { if (IsVisibleOutside(context, parameters, field.DeclaringType) && (field.IsFamily || field.IsFamilyOrAssembly || field.IsPublic) && IsVisibleOutside(context, parameters, field)) { service.SetCanRename(field, false); } else if (field.IsRuntimeSpecialName) { service.SetCanRename(field, false); } else if (parameters.GetParameter(context, field, "forceRen", false)) { return; } else if (field.DeclaringType.IsSerializable && !field.IsNotSerialized) { service.SetCanRename(field, false); } else if (field.IsLiteral && field.DeclaringType.IsEnum && !parameters.GetParameter(context, field, "renEnum", false)) { service.SetCanRename(field, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, PropertyDef property) { if (IsVisibleOutside(context, parameters, property.DeclaringType) && (property.IsFamily() || property.IsFamilyOrAssembly() || property.IsPublic()) && IsVisibleOutside(context, parameters, property)) { service.SetCanRename(property, false); } else if (property.IsRuntimeSpecialName) { service.SetCanRename(property, false); } else if (parameters.GetParameter(context, property, "forceRen", false)) { return; } else if (property.DeclaringType.Implements("System.ComponentModel.INotifyPropertyChanged")) { service.SetCanRename(property, false); } else if (property.DeclaringType.Name.String.Contains("AnonymousType")) { service.SetCanRename(property, false); } }
void ParseParameters(IDnlibDef def, ConfuserContext context, NameService service, ProtectionParameters parameters) { var mode = parameters.GetParameter <RenameMode?>(context, def, "mode", null); if (mode != null) { service.SetRenameMode(def, mode.Value); } }
void RegisterRenamers(ConfuserContext context, NameService service) { bool wpf = false, caliburn = false, winforms = false, json = false; foreach (var module in context.Modules) { foreach (var asmRef in module.GetAssemblyRefs()) { if (asmRef.Name == "WindowsBase" || asmRef.Name == "PresentationCore" || asmRef.Name == "PresentationFramework" || asmRef.Name == "System.Xaml") { wpf = true; } else if (asmRef.Name == "Caliburn.Micro") { caliburn = true; } else if (asmRef.Name == "System.Windows.Forms") { winforms = true; } else if (asmRef.Name == "Newtonsoft.Json") { json = true; } } } if (wpf) { var wpfAnalyzer = new WPFAnalyzer(); context.Logger.Debug("发现WPF,兼容性。"); service.Renamers.Add(wpfAnalyzer); if (caliburn) { context.Logger.Debug("Caliburn.Micro发现,兼容性。"); service.Renamers.Add(new CaliburnAnalyzer(wpfAnalyzer)); } } if (winforms) { var winformsAnalyzer = new WinFormsAnalyzer(); context.Logger.Debug("发现WinForms,兼容性。"); service.Renamers.Add(winformsAnalyzer); } if (json) { var jsonAnalyzer = new JsonAnalyzer(); context.Logger.Debug("发现Newtonsoft.Json,兼容性。"); service.Renamers.Add(jsonAnalyzer); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, PropertyDef property) { if (IsVisibleOutside(context, parameters, property.DeclaringType) && IsVisibleOutside(context, parameters, property)) { service.SetCanRename(property, false); } else if (property.IsRuntimeSpecialName) { service.SetCanRename(property, false); } else if (parameters.GetParameter(context, property, "forceRen", false)) { return; } /* * System.Xml.Serialization.XmlSerializer * * XmlSerializer by default serializes fields marked with [NonSerialized] * This is a work-around that causes all fields in a class marked [Serializable] * to _not_ be renamed, unless marked with [XmlIgnoreAttribute] * * If we have a way to detect which serializer method the code is going to use * for the class, or if Microsoft makes XmlSerializer respond to [NonSerialized] * we'll have a more accurate way to achieve this. */ else if (property.DeclaringType.IsSerializable) // && !field.IsNotSerialized) { service.SetCanRename(property, false); } else if (property.DeclaringType.IsSerializable && (property.CustomAttributes.IsDefined("XmlIgnore") || property.CustomAttributes.IsDefined("XmlIgnoreAttribute") || property.CustomAttributes.IsDefined("System.Xml.Serialization.XmlIgnore") || property.CustomAttributes.IsDefined("System.Xml.Serialization.XmlIgnoreAttribute") || property.CustomAttributes.IsDefined("T:System.Xml.Serialization.XmlIgnoreAttribute"))) // Can't seem to detect CustomAttribute { service.SetCanRename(property, true); } /* * End of XmlSerializer work-around */ else if (property.DeclaringType.Implements("System.ComponentModel.INotifyPropertyChanged")) { service.SetCanRename(property, false); } else if (property.DeclaringType.Name.String.Contains("AnonymousType")) { service.SetCanRename(property, false); } }
internal void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, bool runAnalyzer) { if (def is TypeDef) { Analyze(service, context, parameters, (TypeDef)def); } else if (def is MethodDef) { Analyze(service, context, parameters, (MethodDef)def); } else if (def is FieldDef) { Analyze(service, context, parameters, (FieldDef)def); } else if (def is PropertyDef) { Analyze(service, context, parameters, (PropertyDef)def); } else if (def is EventDef) { Analyze(service, context, parameters, (EventDef)def); } else if (def is ModuleDef) { var renamingMode = parameters.GetParameter <RenameMode>(context, def, "mode"); if (renamingMode == RenameMode.Reversible && service.reversibleRenamer == null) { var generatePassword = parameters.GetParameter <bool>(context, def, "generatePassword"); var password = parameters.GetParameter <string>(context, def, "password"); if (generatePassword || password == null) { password = context.Registry.GetService <IRandomService>().SeedString; } string dir = context.OutputDirectory; string path = Path.GetFullPath(Path.Combine(dir, CoreComponent.PasswordFileName)); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } File.WriteAllText(path, password); service.reversibleRenamer = new ReversibleRenamer(password); } service.SetCanRename(def, false); } if (!runAnalyzer || parameters.GetParameter(context, def, "forceRen", false)) { return; } foreach (IRenamer renamer in service.Renamers) { renamer.Analyze(context, service, parameters, def); } }
private void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, TypeDef type) { if (IsVisibleOutside(context, parameters, type)) { service.SetCanRename(type, false); } else if (type.IsRuntimeSpecialName || type.IsGlobalModuleType) { service.SetCanRename(type, false); } else if (type.FullName == "ModPhusedByAttribute") { // Courtesy service.SetCanRename(type, false); } if (type.CustomAttributes.Any(x => x.AttributeType.FullName == "System.Reflection.ObfuscationAttribute")) { var obfuscationAttr = type.CustomAttributes.First(x => x.AttributeType.FullName == "System.Reflection.ObfuscationAttribute"); var excludeParam = obfuscationAttr.NamedArguments.FirstOrDefault(x => x.Name == "Exclude"); if (excludeParam != null && ((bool)excludeParam.Value)) { // Obfuscation exclude, don't rename service.SetCanRename(type, false); // Also leave properties/methods alone foreach (var method in type.Methods) { service.SetCanRename(method, false); } // Also leave CONST fields alone foreach (var constField in type.Fields.Where(x => x.IsStatic && x.IsPublic)) { service.SetCanRename(constField, false); } // Remove attribute type.CustomAttributes.Remove(obfuscationAttr); } } if (parameters.GetParameter(context, type, "forceRen", false)) { return; } if (type.InheritsFromCorlib("System.Attribute")) { service.ReduceRenameMode(type, RenameMode.ASCII); } if (type.InheritsFrom("System.Configuration.SettingsBase")) { service.SetCanRename(type, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, FieldDef field) { if (IsVisibleOutside(context, parameters, field.DeclaringType) && (field.IsFamily || field.IsFamilyOrAssembly || field.IsPublic) && IsVisibleOutside(context, parameters, field)) { service.SetCanRename(field, false); } else if (field.IsRuntimeSpecialName) { service.SetCanRename(field, false); } else if (parameters.GetParameter(context, field, "forceRen", false)) { return; } /* * System.Xml.Serialization.XmlSerializer * * XmlSerializer by default serializes fields marked with [NonSerialized] * This is a work-around that causes all fields in a class marked [Serializable] * to _not_ be renamed, unless marked with [XmlIgnoreAttribute] * * If we have a way to detect which serializer method the code is going to use * for the class, or if Microsoft makes XmlSerializer respond to [NonSerialized] * we'll have a more accurate way to achieve this. */ else if (field.DeclaringType.IsSerializable) // && !field.IsNotSerialized) { service.SetCanRename(field, false); } else if (field.DeclaringType.IsSerializable && (field.CustomAttributes.IsDefined("XmlIgnore") || field.CustomAttributes.IsDefined("XmlIgnoreAttribute") || field.CustomAttributes.IsDefined("System.Xml.Serialization.XmlIgnore") || field.CustomAttributes.IsDefined("System.Xml.Serialization.XmlIgnoreAttribute") || field.CustomAttributes.IsDefined("T:System.Xml.Serialization.XmlIgnoreAttribute"))) // Can't seem to detect CustomAttribute { service.SetCanRename(field, true); } /* * End of XmlSerializer work-around */ else if (field.IsLiteral && field.DeclaringType.IsEnum && !parameters.GetParameter(context, field, "renEnum", false)) { service.SetCanRename(field, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt) { if (IsVisibleOutside(context, parameters, evt.DeclaringType) && IsVisibleOutside(context, parameters, evt)) { service.SetCanRename(evt, false); } else if (evt.IsRuntimeSpecialName) { service.SetCanRename(evt, false); } }
// Token: 0x0600000E RID: 14 RVA: 0x000020EF File Offset: 0x000002EF private void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt) { if (evt.DeclaringType.IsVisibleOutside(true) && AnalyzePhase.IsVisibleOutside(context, parameters, evt)) { service.SetCanRename(evt, false); return; } if (evt.IsRuntimeSpecialName) { service.SetCanRename(evt, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt) { if (evt.DeclaringType.IsVisibleOutside() && !parameters.GetParameter(context, evt, "renPublic", false)) { service.SetCanRename(evt, false); } else if (evt.IsRuntimeSpecialName || evt.IsSpecialName) { service.SetCanRename(evt, false); } }
// Token: 0x0600022B RID: 555 RVA: 0x0001F198 File Offset: 0x0001D398 protected override void Execute(ConfuserContext context, ProtectionParameters parameters) { NameService service = (NameService)context.Registry.GetService <INameService>(); foreach (IRenamer renamer in service.Renamers) { foreach (IDnlibDef def in parameters.Targets) { renamer.PostRename(context, service, parameters, def); } context.CheckCancellation(); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, TypeDef type) { if (IsVisibleOutside(context, parameters, type)) { service.SetCanRename(type, false); } else if (type.IsRuntimeSpecialName || type.IsGlobalModuleType) { service.SetCanRename(type, false); } else if (type.FullName == "ConfusedByAttribute") { // Courtesy service.SetCanRename(type, false); } /* * Can't rename Classes/Types that will be serialized */ if (type != null) { if (type.IsSerializable) { service.SetCanRename(type, false); } if (type.DeclaringType != null) { if (type.DeclaringType.IsSerializable) { service.SetCanRename(type, false); } } } if (parameters.GetParameter(context, type, "forceRen", false)) { return; } if (type.InheritsFromCorlib("System.Attribute")) { service.ReduceRenameMode(type, RenameMode.ASCII); } if (type.InheritsFrom("System.Configuration.SettingsBase")) { service.SetCanRename(type, false); } }
internal void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, bool runAnalyzer) { if (def is TypeDef) { Analyze(service, context, parameters, (TypeDef)def); } else if (def is MethodDef) { Analyze(service, context, parameters, (MethodDef)def); } else if (def is FieldDef) { Analyze(service, context, parameters, (FieldDef)def); } else if (def is PropertyDef) { Analyze(service, context, parameters, (PropertyDef)def); } else if (def is EventDef) { Analyze(service, context, parameters, (EventDef)def); } else if (def is ModuleDef) { var pass = parameters.GetParameter <string>(context, def, "password", null); if (pass != null) { service.reversibleRenamer = new ReversibleRenamer(pass); } var idOffset = parameters.GetParameter <uint>(context, def, "idOffset", 0); if (idOffset != 0) { service.SetNameId(idOffset); } service.SetCanRename(def, false); } if (!runAnalyzer || parameters.GetParameter(context, def, "forceRen", false)) { return; } foreach (IRenamer renamer in service.Renamers) { renamer.Analyze(context, service, parameters, def); } }
// Token: 0x06000006 RID: 6 RVA: 0x00003B84 File Offset: 0x00001D84 protected override void Execute(ConfuserContext context, ProtectionParameters parameters) { NameService service = (NameService)context.Registry.GetService <INameService>(); context.Logger.Debug("Building VTables & identifier list..."); foreach (IDnlibDef def in parameters.Targets.WithProgress(context.Logger)) { this.ParseParameters(def, context, service, parameters); if (def is ModuleDef) { ModuleDef module = (ModuleDef)def; using (IEnumerator <Resource> enumerator2 = module.Resources.GetEnumerator()) { while (enumerator2.MoveNext()) { Resource res = enumerator2.Current; service.SetOriginalName(res, res.Name); } goto IL_B1; } goto IL_9F; } goto IL_9F; IL_B1: if (def is TypeDef) { service.GetVTables().GetVTable((TypeDef)def); service.SetOriginalNamespace(def, ((TypeDef)def).Namespace); } context.CheckCancellation(); continue; IL_9F: service.SetOriginalName(def, def.Name); goto IL_B1; } context.Logger.Debug("Analyzing..."); this.RegisterRenamers(context, service); IList <IRenamer> arg_120_0 = service.Renamers; foreach (IDnlibDef def2 in parameters.Targets.WithProgress(context.Logger)) { this.Analyze(service, context, parameters, def2, true); context.CheckCancellation(); } }
private void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, FieldDef field) { if (field.DeclaringType.IsVisibleOutside() && (field.IsFamily || field.IsFamilyOrAssembly || field.IsPublic) && !parameters.GetParameter(context, field, "renPublic", false)) { service.SetCanRename(field, false); } else if (field.IsRuntimeSpecialName || field.IsSpecialName) { service.SetCanRename(field, false); } else if (field.DeclaringType.IsSerializable && !field.IsNotSerialized) { service.SetCanRename(field, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt) { if (IsVisibleOutside(context, parameters, evt.DeclaringType) && evt.IsPublic() && IsVisibleOutside(context, parameters, evt)) { service.SetCanRename(evt, false); } else if (evt.IsRuntimeSpecialName) { service.SetCanRename(evt, false); } else if (evt.IsExplicitlyImplementedInterfaceMember()) { service.SetCanRename(evt, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, MethodDef method) { if (IsVisibleOutside(context, parameters, method.DeclaringType) && (method.IsFamily || method.IsFamilyOrAssembly || method.IsPublic) && IsVisibleOutside(context, parameters, method)) { service.SetCanRename(method, false); } else if (method.IsRuntimeSpecialName) { service.SetCanRename(method, false); } else if (parameters.GetParameter(context, method, "forceRen", false)) { return; } else if (method.DeclaringType.IsComImport() && !method.HasAttribute("System.Runtime.InteropServices.DispIdAttribute")) { service.SetCanRename(method, false); } else if (method.DeclaringType.InheritsFrom("UnityEngine.MonoBehaviour") && momoBehaviourMethods.Contains(method.Name)) { service.SetCanRename(method, false); } else if (method.DeclaringType.InheritsFrom("UnityEngine.StateMachineBehaviour") && stateMachineBehaviourMethods.Contains(method.Name)) { service.SetCanRename(method, false); } else if (method.DeclaringType.IsDelegate()) { service.SetCanRename(method, false); } }
void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, PropertyDef property) { bool setRename = service.CanRename(property.SetMethod); bool getRename = service.CanRename(property.GetMethod); if ((!setRename || !getRename) && parameters.GetParameter(context, property, "dontRenImpls", false)) { service.SetCanRename(property, false); } else if (IsVisibleOutside(context, parameters, property.DeclaringType) && property.IsPublic() && IsVisibleOutside(context, parameters, property)) { service.SetCanRename(property, false); } else if (property.IsRuntimeSpecialName) { service.SetCanRename(property, false); } else if (parameters.GetParameter(context, property, "forceRen", false)) { return; } else if (property.DeclaringType.Implements("System.ComponentModel.INotifyPropertyChanged")) { service.SetCanRename(property, false); } else if (property.DeclaringType.Name.String.Contains("AnonymousType")) { service.SetCanRename(property, false); } }
internal void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, bool runAnalyzer) { if (def is TypeDef) { Analyze(service, context, parameters, (TypeDef)def); } else if (def is MethodDef) { Analyze(service, context, parameters, (MethodDef)def); } else if (def is FieldDef) { Analyze(service, context, parameters, (FieldDef)def); } else if (def is PropertyDef) { Analyze(service, context, parameters, (PropertyDef)def); } else if (def is EventDef) { Analyze(service, context, parameters, (EventDef)def); } else if (def is ModuleDef) { service.SetCanRename(def, false); } if (!runAnalyzer || parameters.GetParameter(context, def, "forceRen", false)) { return; } foreach (IRenamer renamer in service.Renamers) { renamer.Analyze(context, service, parameters, def); } }
// Token: 0x06000238 RID: 568 RVA: 0x0001F2D4 File Offset: 0x0001D4D4 protected override void Execute(ConfuserContext context, ProtectionParameters parameters) { NameService srv = (NameService)context.Registry.GetService <INameService>(); ICollection <KeyValuePair <string, string> > map = srv.GetNameMap(); if (map.Count == 0) { return; } string path = Path.GetFullPath(Path.Combine(context.OutputDirectory, "symbols.map")); string dir = Path.GetDirectoryName(path); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } using (StreamWriter writer = new StreamWriter(File.OpenWrite(path))) { foreach (KeyValuePair <string, string> entry in map) { writer.WriteLine("{0}\t{1}", entry.Key, entry.Value); } } }
void RegisterRenamers(ConfuserContext context, NameService service) { bool wpf = false; bool caliburn = false; bool winforms = false; bool json = false; bool visualBasic = false; bool vsComposition = false; foreach (var module in context.Modules) { foreach (var asmRef in module.GetAssemblyRefs()) { if (asmRef.Name == "WindowsBase" || asmRef.Name == "PresentationCore" || asmRef.Name == "PresentationFramework" || asmRef.Name == "System.Xaml") { wpf = true; } else if (asmRef.Name == "Caliburn.Micro") { caliburn = true; } else if (asmRef.Name == "System.Windows.Forms") { winforms = true; } else if (asmRef.Name == "Newtonsoft.Json") { json = true; } else if (asmRef.Name == "Microsoft.VisualStudio.Composition") { vsComposition = true; } } var vbEmbeddedAttribute = module.FindNormal("Microsoft.VisualBasic.Embedded"); if (vbEmbeddedAttribute != null && vbEmbeddedAttribute.BaseType.FullName.Equals("System.Attribute")) { visualBasic = true; } } if (wpf) { var wpfAnalyzer = new WPFAnalyzer(); context.Logger.Debug("WPF found, enabling compatibility."); service.Renamers.Add(wpfAnalyzer); if (caliburn) { context.Logger.Debug("Caliburn.Micro found, enabling compatibility."); service.Renamers.Add(new CaliburnAnalyzer(wpfAnalyzer)); } } if (winforms) { var winformsAnalyzer = new WinFormsAnalyzer(); context.Logger.Debug("WinForms found, enabling compatibility."); service.Renamers.Add(winformsAnalyzer); } if (json) { var jsonAnalyzer = new JsonAnalyzer(); context.Logger.Debug("Newtonsoft.Json found, enabling compatibility."); service.Renamers.Add(jsonAnalyzer); } if (visualBasic) { var vbAnalyzer = new VisualBasicRuntimeAnalyzer(); context.Logger.Debug("Visual Basic Embedded Runtime found, enabling compatibility."); service.Renamers.Add(vbAnalyzer); } if (vsComposition) { var analyzer = new VsCompositionAnalyzer(); context.Logger.Debug("Visual Studio Composition found, enabling compatibility."); service.Renamers.Add(analyzer); } }