document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using Dexer.Core;
  3. using Dexer.Instructions;
  4.  
  5. namespace Dexer.Debug
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Dex dex = Dex.Load("classes.dex");
  12.             MethodDefinition method = dex.GetClass("dexer.poc.MainActivity").GetMethod("onCreate");
  13.  
  14.             method.Body.Instructions[5].OpCode = OpCodes.Add_int;
  15.             method.Body.Instructions[7].Operand = "Dexer rocks! ";
  16.  
  17.             int color; unchecked { color = (int)0xFFFF00FF; }
  18.  
  19.             // Declare a new method reference with prototype
  20.             Prototype prototype = new Prototype(PrimitiveType.Void, new Parameter(PrimitiveType.Int));
  21.             MethodReference setTitleColor = dex.Import(new MethodReference(method.Owner, "setTitleColor", prototype));
  22.  
  23.             // Load the color in a register (n°1) then invoke the method (register n°5 is \'this\' in our case)
  24.             var regs = method.Body.Registers;
  25.             Instruction iconst = new Instruction(OpCodes.Const, color, regs[1]);
  26.             method.Body.Instructions.Insert(14, iconst);
  27.  
  28.             Instruction iinvoke = new Instruction(OpCodes.Invoke_virtual, setTitleColor, regs[5], regs[1]);
  29.             method.Body.Instructions.Insert(15, iinvoke);
  30.  
  31.             dex.Write("output.dex");
  32.             Console.ReadLine();
  33.         }
  34.     }
  35. }
');