public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs) { var stringList = new List <string>(); foreach (var method in methodDefs) { MethodDef addMethod = null; if (method.Body != null && method.Body.Instructions != null) { for (int i = 0; i < method.Body.Instructions.Count; i++) { var previnsn = i == 0 ? null : method.Body.Instructions[i - 1]; var insn = method.Body.Instructions[i]; var nextinsn = i + 1 == method.Body.Instructions.Count ? null : method.Body.Instructions[i + 1]; if (insn.OpCode == OpCodes.Call && previnsn != null && previnsn.OpCode == OpCodes.Ldloc_1) { if (insn.Operand is IMethodDefOrRef) { var callingMethod = insn.Operand as IMethodDefOrRef; if (ClrHelper.MatchesSig(callingMethod.MethodSig, "?")) { addMethod = callingMethod.ResolveMethodDef(); } } } if (insn.OpCode != OpCodes.Call || previnsn == null || previnsn.OpCode != OpCodes.Ldc_I4) { continue; } if (!insn.ToString().EndsWith(Program.DeobfuscatorInsn)) { continue; } var str = StringDeobfuscator.Deobfuscate((int)previnsn.Operand); stringList.Add(str); } } if (IsInitOpts(stringList)) { var @class = MappingManager.GetClass("GuiOptions").OrElse(new ClassObj("GuiOptions", className)); MappingManager.AddClass(@class); @class.AddMethod("OnInit", method.Name); if (addMethod != null) { @class.AddMethod("AddOption", addMethod.Name); } } stringList.Clear(); } }
public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs) { var rect = methodDefs.Where(m => ClrHelper.MatchesSig(m, "Vector2", "Vector2", "Single", "Color")); if (!rect.Any()) { return; } var clazz = new ClassObj("CompRect", className); MappingManager.AddClass(clazz); }
private void FindValueField(ClassObj clazz, IList <MethodDef> methodDefs) { var methodContaingValueFld = methodDefs.First(m => ClrHelper.MatchesSig(m, "Double", "Boolean", "Boolean")); var pattern = GetOpcodePattern(methodContaingValueFld, 1, OpCodes.Ldarg_0, OpCodes.Ldfld, OpCodes.Ldarg_1, OpCodes.Beq_S); if (!pattern.IsPresent()) { Console.WriteLine("Pattern not found while finding valueFld"); return; } clazz.AddField("SliderValue", (pattern.Get().Operand as FieldDef).Name); }
public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs) { foreach (var method in methodDefs) { if (method.Name.Equals(".ctor")) { if (ClrHelper.MatchesSig(method, "String", "String", "Boolean", "EventHandler")) { MappingManager.AddClass(new ClassObj("OptionsCheckbox", className)); } } } }
public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs) { ClassObj @class = null; foreach (var method in methodDefs) { var strings = GetMethodStrings(method); if (!ClrHelper.MatchesSig(method, "Mods", "Boolean", "Boolean", "Boolean", "Boolean")) { continue; } if (!strings.Contains("DoubleTime") || !strings.Contains("DT") || !strings.Contains("None") || !strings.Contains("Cinema")) { continue; } @class = MappingManager.GetClass(UnobfuscatedName) .OrElse(new ClassObj(UnobfuscatedName, className)); MappingManager.AddClass(@class); @class.AddMethod("GetJoinedMods", method.Name); //Mods mods, bool abreviated, bool displayNone, bool parens, bool ?space? } if (@class == null) { return; } foreach (var method in methodDefs) { if (!ClrHelper.MatchesSig(method, "Mods")) { continue; } if (method.Body.Instructions.Count == 5) { @class.AddMethod("IsModActive", method.Name); //Mods mods } } }
public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs) { var sigCheck = methodDefs.Where(m => ClrHelper.MatchesSig(m, "?", "Double", "Double", "Double", "Vector2", "Int32")).ToList(); if (!sigCheck.Any()) { return; } var clazz = new ClassObj(UnobfuscatedName, className); MappingManager.AddClass(clazz); var callbackSearch = methodDefs .Where(m => ClrHelper.MatchesSig(m, "Object", "EventArgs")).ToList(); if (!callbackSearch.Any()) { return; } foreach (var methodDef in callbackSearch) { var insn = GetOpcodePattern(methodDef, 0, OpCodes.Ldfld, OpCodes.Brfalse_S, OpCodes.Ldarg_0, OpCodes.Ldfld, OpCodes.Ldc_I4_1, OpCodes.Callvirt); if (!insn.IsPresent()) { continue; } var i = insn.Get(); var fieldDef = i.Operand as FieldDef; clazz.AddField("SliderCallbacks", fieldDef.Name); var sliderChangeClass = new ClassObj("SliderChanged", fieldDef.FieldType.FullName); MappingManager.AddClass(sliderChangeClass); } FindSetTooltip(clazz, methodDefs); FindValueField(clazz, methodDefs); }
public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs) { foreach (var method in methodDefs) { if (!method.Name.Equals(".ctor")) { continue; } if (!HasStrings(method, "circle-full") && !ClrHelper.MatchesSig(method, "String", "Single", "Vector2", "Single", "Boolean", "Single")) { continue; } ClrHelper.PrintSig(method); var clazz = new ClassObj("CompCheckbox", className); MappingManager.AddClass(clazz); FindComponentList(clazz, type.Fields); FindAddCallback(clazz, methodDefs); } }
public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs) { var HasCtor = methodDefs.Where(m => ClrHelper.MatchesSig(m, "String", "Single", "Vector2", "Vector2", "Single", "Boolean", "Color", "Boolean")); var ContainsStrings = methodDefs.Where(m => HasStrings(m, "Text: ")); //string text, float textSize, Vector2 startPosition, Vector2 bounds, float drawDepth, bool alwaysDraw, Color colour, bool shadow = true if (!HasCtor.Any() || !ContainsStrings.Any()) { return; } var clazz = new ClassObj("CompLabel", className); MappingManager.AddClass(clazz); var str = methodDefs.First(m => ClrHelper.MatchesSig(m, "String")); clazz.AddMethod("SetText", str.Name); //MethodSig (1): String }
public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs) { ClassObj @class = null; foreach (var method in methodDefs) { if (!HasStrings(method, "SubmissionCache")) { continue; } if (!ClrHelper.MatchesSig(method, "String", "Boolean")) { continue; } @class = MappingManager.GetClass(UnobfuscatedName) .OrElse(new ClassObj(UnobfuscatedName, className)); MappingManager.AddClass(@class); //@class.AddMethod("GetJoinedMods", method.Name); //Mods mods, bool abreviated, bool displayNone, bool parens, bool ?space? } }
private void FindSetTooltip(ClassObj classObj, IList <MethodDef> methodDefs) { var setTooltipMethod = methodDefs.First(m => ClrHelper.MatchesSig(m, "String")); classObj.AddMethod("SetTooltip", setTooltipMethod.Name); }