private void ObfuscateType(TypeDefinition type) { if (type.IsRuntimeSpecialName) { return; } if (type.IsSpecialName) { return; } if (type.Name.Contains("Resources")) { return; } if (!DecompileMeCheck.CheckName(type.FullName)) { return; } if (_excludedTypesNames.Contains(type.FullName)) { return; } //---- Obfuscate string initialTypeName = type.FullName; string notes = "살歸type"; string obtypeName = ObfuscateString(ObfuscationItem.Type, type.Name, notes); if (obtypeName == initialTypeName) { return; } if (NameObfuscated != null) { NameObfuscated(ObfuscationItem.Type, initialTypeName, type.Name, notes); } type.Name = obtypeName; //---- Update the type references in other assemblies foreach (AssemblyDefinition assembly in assembliesDefinitions) { foreach (ModuleDefinition module in assembly.Modules) { foreach (TypeReference typeReference in module.TypeReferences) { if (typeReference.FullName == initialTypeName) { NSLinker.AddNewNameSpace(typeReference.FullName, type.FullName); typeReference.Name = type.Name; } } } } //---- Prepare ressources names if (!initialTypeName.Contains("/")) { string veryoldName = NSLinker.GetOriginalName(initialTypeName); if (!_resourcesMapping.ContainsKey(veryoldName)) { // Save the obfuscation mapping _resourcesMapping.Add(veryoldName, type.FullName); } } //---- Obfuscate methods foreach (MethodDefinition method in type.Methods) { ObfuscateMethod(type, initialTypeName, method); } //---- Obfuscate fields foreach (FieldDefinition field in type.Fields) { ObfuscateField(type, field); } //---- Obfuscate properties foreach (PropertyDefinition property in type.Properties) { ObfuscateProperty(type, property); } }
private void ObfuscateNamespace(TypeDefinition type) { if (type.IsRuntimeSpecialName) { return; } if (type.IsSpecialName) { return; } if (type.Name.Contains("Resources")) { return; } if (!DecompileMeCheck.CheckName(type.FullName)) { return; } if (_excludedTypesNames.Contains(type.FullName)) { return; } //---- Obfuscate string initialFullName = type.FullName; string initialNamespace = type.Namespace; type.Namespace = GetObfuscatedNamespace(type.Namespace); if (initialFullName != type.FullName) { NSLinker.AddNewNameSpace(initialFullName, type.FullName); } //---- Update the type references in other assemblies foreach (AssemblyDefinition assembly in assembliesDefinitions) { foreach (ModuleDefinition module in assembly.Modules) { foreach (TypeReference typeReference in module.TypeReferences) { if (typeReference.Namespace == initialNamespace) { NSLinker.AddNewNameSpace(typeReference.FullName, type.FullName); typeReference.Namespace = type.Namespace; } } } } //---- Resources Dictionary <string, string> newDictionary = new Dictionary <string, string>(); foreach (string key in _resourcesMapping.Keys) { string resValue = _resourcesMapping[key]; if (resValue.Contains(".")) { if (resValue.Substring(0, resValue.LastIndexOf('.')) == initialNamespace) { resValue = type.Namespace + resValue.Substring(resValue.LastIndexOf('.')); } } newDictionary.Add(key, resValue); } _resourcesMapping = newDictionary; }