public override void Process(Instrumentor instrumentor, AssemblyDefinition assdef) { var referenceStart = GetPolymorphReferenceStart(); _referencedToStart = SetImports(assdef, referenceStart); if (RequiresEnd) { var referenceEnd = GetPolymorphReferenceEnd(); _referencedToEnd = SetImports(assdef, referenceEnd); } foreach (TypeDefinition typedef in assdef.MainModule.Types) { if (typedef.Name != "<Module>") { if (typedef.Name == TargetType) { _baseType = typedef.BaseType; foreach (MethodDefinition methoddef in typedef.Methods) { if (methoddef.Name == TargetMethod) { ModifyMethod(methoddef); break; } } break; } } } }
public override void Process(Instrumentor instrumentor, Mono.Cecil.AssemblyDefinition assdef) { //Lets find some stuff var module = assdef.MainModule; //Stage 1: Acquiring vanilla enum index foreach (var typedef in module.Types) { if (typedef.Name == "StaticPrefabType") { foreach (var fieldef in typedef.Fields) { if (fieldef.Name == "value__") { continue; } string val = fieldef.Name.Replace("_", "").ToUpperInvariant(); int key = (int)fieldef.Constant;//No idea if this will work, derp ^_^ _enumIndex.Add(key, val); } } } //Stage 2: Collecting index foreach (var typedef in module.Types) { if (typedef.Name == "StaticPrefab") { var instantiator = FindEntryToInstantiator(typedef); List <String> typelist = CollectAllCTORCalls(instantiator); instrumentor.Workspace.SaveAllLines(typelist.ToArray(), "vanillaprojects"); return;//No need to look for others } } throw new InstrumentationFailureException("SP Registry type is unreachable!"); }
public override void Process(Instrumentor instrumentor, AssemblyDefinition assdef) { foreach (var typedef in assdef.MainModule.Types) { if (typedef.Name == _typeName) { foreach (var metdef in typedef.Methods) { if (metdef.Name == _methodName) { foreach (Instruction ins in metdef.Body.Instructions) { if (ins.OpCode == OpCodes.Ldstr) { String operand = ins.Operand as String; if (operand != null) { if (Compare(operand, _oldValue)) { ins.Operand = GetNewValue(operand); return; } } } } } } } } throw new InstrumentationFailureException("It was impossible to find replacement point for Loadstring redefinition!"); }
public override void Process(Instrumentor instrumentor, AssemblyDefinition assdef) { var module = assdef.MainModule; foreach (var type in module.Types) { type.IsPublic = true; } }
public override void Process(Instrumentor instrumentor, AssemblyDefinition assdef) { var module = assdef.MainModule; TypeDefinition inventoryItemType = null; inventoryItemType = PickBaseMethod(module); if (inventoryItemType == null) { throw new BadImageFormatException("Unable to obtain: " + BaseMethodName); } else { var list = CollectDerrived(inventoryItemType, module.Types.ToArray()); int before = list.Count; list = SelectWithArgumentlessCTOR(list); var idlist = TryExtractIdsFromCTOR(list); int after = list.Count; int abstr = before - after; Console.WriteLine("Items identified: " + before + "[" + "Concrete: " + after + ", Abstract: " + abstr + "]"); DumpAsCache(list, idlist, instrumentor.Workspace); } }
public override void Process(Instrumentor instrumentor, AssemblyDefinition assdef) { GetPolymorphReference(); SetImports(assdef); foreach (TypeDefinition typedef in assdef.MainModule.Types) { if (typedef.Name != "<Module>") { if (typedef.Name == TargetType) { foreach (MethodDefinition methoddef in typedef.Methods) { if (methoddef.Name == TargetMethod) { ModifyMethod(methoddef); break; } } break; } } } }
public override void Process(Instrumentor instrumentor, AssemblyDefinition assdef) { var referenceStart = GetPolymorphReferenceStart(); _referencedToStart = SetImports(assdef, referenceStart); foreach (TypeDefinition typedef in assdef.MainModule.Types) { if (typedef.Name != "<Module>") { if (typedef.Name == TargetType) { foreach (MethodDefinition methoddef in typedef.Methods) { if (methoddef.Name == TargetMethod && methoddef.Parameters[0].ParameterType.Name == "InventoryItemType") { ModifyMethod(methoddef); break; } } break; } } } }