Esempio n. 1
0
        public void PrepareRenameTypes(TypeRenamerState state)
        {
            var checker = NameChecker;

            if (newNamespace == null && oldNamespace != "")
            {
                if (type.TypeDef.IsNested)
                {
                    newNamespace = "";
                }
                else if (!checker.IsValidNamespaceName(oldNamespace))
                {
                    newNamespace = state.CreateNamespace(type.TypeDef, oldNamespace);
                }
            }

            string origClassName = null;

            if (IsWinFormsClass())
            {
                origClassName = FindWindowsFormsClassName(type);
            }
            if (IsModuleType())
            {
                if (oldNamespace != "")
                {
                    newNamespace = "";
                }
                Rename("<Module>");
            }
            else if (!checker.IsValidTypeName(oldName))
            {
                if (origClassName != null && checker.IsValidTypeName(origClassName))
                {
                    Rename(state.GetTypeName(oldName, origClassName));
                }
                else
                {
                    var nameCreator = type.IsGlobalType() ?
                                      state.globalTypeNameCreator :
                                      state.internalTypeNameCreator;
                    string newBaseType = null;
                    var    baseInfo    = GetBase();
                    if (baseInfo != null && baseInfo.renamed)
                    {
                        newBaseType = baseInfo.newName;
                    }
                    Rename(nameCreator.Create(type.TypeDef, newBaseType));
                }
            }

            PrepareRenameGenericParams(type.GenericParams, checker);
        }
Esempio n. 2
0
        public void prepareRenameTypes(TypeRenamerState state)
        {
            var checker = NameChecker;

            if (newNamespace == null && oldNamespace != "")
            {
                if (type.TypeDefinition.IsNested)
                {
                    newNamespace = "";
                }
                else if (!checker.isValidNamespaceName(oldNamespace))
                {
                    newNamespace = state.createNamespace(this.type.TypeDefinition, oldNamespace);
                }
            }

            string origClassName = null;

            if (isWinFormsClass())
            {
                origClassName = findWindowsFormsClassName(type);
            }
            if (isModuleType())
            {
                if (oldNamespace != "")
                {
                    newNamespace = "";
                }
                rename("<Module>");
            }
            else if (!checker.isValidTypeName(oldName))
            {
                if (origClassName != null && checker.isValidTypeName(origClassName))
                {
                    rename(state.getTypeName(oldName, origClassName));
                }
                else
                {
                    ITypeNameCreator nameCreator = type.isGlobalType() ?
                                                   state.globalTypeNameCreator :
                                                   state.internalTypeNameCreator;
                    string   newBaseType = null;
                    TypeInfo baseInfo    = getBase();
                    if (baseInfo != null && baseInfo.renamed)
                    {
                        newBaseType = baseInfo.newName;
                    }
                    rename(nameCreator.create(type.TypeDefinition, newBaseType));
                }
            }

            prepareRenameGenericParams(type.GenericParams, checker);
        }
Esempio n. 3
0
		void PrepareRenameTypes(IEnumerable<MTypeDef> types, TypeRenamerState state) {
			foreach (var typeDef in types) {
				memberInfos.Type(typeDef).PrepareRenameTypes(state);
				PrepareRenameTypes(typeDef.derivedTypes, state);
			}
		}
Esempio n. 4
0
		void RenameTypeDefs() {
			if (isVerbose)
				Logger.v("Renaming obfuscated type definitions");

			foreach (var module in modules.TheModules) {
				if (module.ObfuscatedFile.RemoveNamespaceWithOneType)
					RemoveOneClassNamespaces(module);
			}

			var state = new TypeRenamerState();
			foreach (var type in modules.AllTypes)
				state.AddTypeName(memberInfos.Type(type).oldName);
			PrepareRenameTypes(modules.BaseTypes, state);
			FixClsTypeNames();
			RenameTypeDefs(modules.NonNestedTypes);
		}
Esempio n. 5
0
		public void PrepareRenameTypes(TypeRenamerState state) {
			var checker = NameChecker;

			if (newNamespace == null && oldNamespace != "") {
				if (type.TypeDef.IsNested)
					newNamespace = "";
				else if (!checker.IsValidNamespaceName(oldNamespace))
					newNamespace = state.CreateNamespace(this.type.TypeDef, oldNamespace);
			}

			string origClassName = null;
			if (IsWinFormsClass())
				origClassName = FindWindowsFormsClassName(type);
			if (IsModuleType()) {
				if (oldNamespace != "")
					newNamespace = "";
				Rename("<Module>");
			}
			else if (!checker.IsValidTypeName(oldName)) {
				if (origClassName != null && checker.IsValidTypeName(origClassName))
					Rename(state.GetTypeName(oldName, origClassName));
				else {
					ITypeNameCreator nameCreator = type.IsGlobalType() ?
											state.globalTypeNameCreator :
											state.internalTypeNameCreator;
					string newBaseType = null;
					TypeInfo baseInfo = GetBase();
					if (baseInfo != null && baseInfo.renamed)
						newBaseType = baseInfo.newName;
					Rename(nameCreator.Create(type.TypeDef, newBaseType));
				}
			}

			PrepareRenameGenericParams(type.GenericParams, checker);
		}
Esempio n. 6
0
        void renameTypeDefinitions()
        {
            Log.v("Renaming obfuscated type definitions");

            foreach (var module in modules.TheModules) {
                if (module.ObfuscatedFile.RemoveNamespaceWithOneType)
                    removeOneClassNamespaces(module);
            }

            var state = new TypeRenamerState();
            foreach (var type in modules.AllTypes)
                state.addTypeName(memberInfos.type(type).oldName);
            prepareRenameTypes(modules.BaseTypes, state);
            fixClsTypeNames();
            renameTypeDefinitions(modules.NonNestedTypes);
        }