Posted September 20, 20186 yr 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?
September 20, 20186 yr 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, 20186 yr by CodeExplorer
September 20, 20186 yr Author @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, 20186 yr by Modify
Create an account or sign in to comment