void RestorePropertiesAndEvents(MethodNameGroups groups) { var allGroups = groups.GetAllGroups(); RestoreVirtualProperties(allGroups); RestorePropertiesFromNames2(allGroups); ResetVirtualPropertyNames(allGroups); RestoreVirtualEvents(allGroups); RestoreEventsFromNames2(allGroups); ResetVirtualEventNames(allGroups); }
static List<MethodNameGroup> GetSorted(MethodNameGroups groups) { var allGroups = new List<MethodNameGroup>(groups.GetAllGroups()); allGroups.Sort((a, b) => b.Count.CompareTo(a.Count)); return allGroups; }
void RemoveUselessOverrides(MethodNameGroups groups) { foreach (var group in groups.GetAllGroups()) { foreach (var method in group.Methods) { if (!method.Owner.HasModule) continue; if (!method.IsPublic()) continue; var overrides = method.MethodDef.Overrides; for (int i = 0; i < overrides.Count; i++) { var overrideMethod = overrides[i].MethodDeclaration; if (method.MethodDef.Name != overrideMethod.Name) continue; if (isVerbose) Logger.v("Removed useless override from method {0} ({1:X8}), override: {2:X8}", Utils.RemoveNewlines(method.MethodDef), method.MethodDef.MDToken.ToInt32(), overrideMethod.MDToken.ToInt32()); overrides.RemoveAt(i); i--; } } } }
void RestoreMethodArgs(MethodNameGroups groups) { foreach (var group in groups.GetAllGroups()) { if (group.Methods[0].VisibleParameterCount == 0) continue; var argNames = GetValidArgNames(group); foreach (var method in group.Methods) { if (!method.Owner.HasModule) continue; var nameChecker = method.Owner.Module.ObfuscatedFile.NameChecker; for (int i = 0; i < argNames.Length; i++) { var argName = argNames[i]; if (argName == null || !nameChecker.IsValidMethodArgName(argName)) continue; var info = memberInfos.Param(method.ParamDefs[i]); if (nameChecker.IsValidMethodArgName(info.oldName)) continue; info.newName = argName; } } } }