Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[BUG]Wrong Invalid register: v16 error

Open nimamoradi opened this issue 4 years ago • 3 comments

Information

  1. V2.6.2
  2. Mac ARM
  3. Zombie Tusnami -

Steps to Reproduce

  1. decompile app
  2. inject smali
  3. try to recompile

APK

apk the smali file is more useful complete code

hi, I am injecting a piece of code and subverting the program fellow to my own code through smali modification.

Original code


.locals 12  
...
invoke-static {p2}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V
modified code

.locals 13
...
const-class v12, Lclass/code/main;

invoke-static {v12, p2}, Lcom/mypackage/myclass;->mymethod(Ljava/lang/Class;Ljava/lang/String;)V

the new register here 'v12' which is clearly lower than 16 and there is no registers with 16 or more in the file but got this error when I try to build it.

Invalid register: v16. Must be between v0 and v15, inclusive more oddly at places where I made no changes(in the same class file) I used this injection at many apps and they seem to work fine just going this is the only error I got by this sort

here is the gist file for complete code the modification is at line 95

nimamoradi avatar Oct 18 '22 17:10 nimamoradi

I don't think Apktool is at fault here. If you added a local and shifted all items it would increase out of bounds of the registers.

iBotPeaches avatar Oct 18 '22 22:10 iBotPeaches

i did not shift i just added one parameter, even If I add one parameter still it's 12 registers

nimamoradi avatar Oct 18 '22 22:10 nimamoradi

See my response: https://github.com/JesusFreke/smali/issues/858#issuecomment-1287827280

auermich93 avatar Oct 22 '22 15:10 auermich93