Modify Posted September 20, 2018 Posted September 20, 2018 I try to add new instruction, // old const/v4 v?, 0x0 // new const/v4 v?, 0x0 const-string v?, "Hello" // new instruction can someone help me, adding instruction without duplicate register number?
CodeExplorer Posted September 20, 2018 Posted September 20, 2018 (edited) Look to these sample I've created DEXPatcher: https://gitlab.com/CodeCracker/DEXPatcher https://github.com/CodeCrackerSND/DEXPatcher https://bitbucket.org/CodeCrackerSND/dexpatcher More exactly look here: https://gitlab.com/CodeCracker/DEXPatcher/blob/master/dexpatcher/DEXPatcher.java Edited September 20, 2018 by CodeExplorer 1
Modify Posted September 20, 2018 Author Posted September 20, 2018 (edited) @CodeExplorer I try with this code: private static MethodImplementation addNewInstructions(@Nonnull MethodImplementation implementation) { MutableMethodImplementation mutableImplementation = new MutableMethodImplementation(implementation); List<BuilderInstruction> instructions = mutableImplementation.getInstructions(); for (int i = 0; i < instructions.size(); i++) { Instruction instruction = instructions.get(i); if (instruction instanceof ReferenceInstruction) { if (((ReferenceInstruction) instruction).getReferenceType() == ReferenceType.METHOD) { Opcode opcode = instruction.getOpcode(); if (!opcode.name.endsWith("range")) { mutableImplementation.addInstruction(i++, new BuilderInstruction21c(Opcode.CONST_STRING, 0, new ImmutableStringReference("Hello World"))); // look } } } } return mutableImplementation; } after : // before .line 54 iget-object v0, p0, Lapp/test/MainActivity;->ed:Landroid/widget/TextView; // after .line 54 iget-object v0, p0, Lapp/test/MainActivity;->ed:Landroid/widget/TextView; // v0 already register const-string v0, "Hello World" // v0 duplicate register If i storing a new value in it, I'll be clobbering any value that was already there, and later code that expects the previous value will likely fail. Edited September 20, 2018 by Modify
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now