zivlhoo / smali

Automatically exported from code.google.com/p/smali
0 stars 0 forks source link

Lots of errors during recompilation: This method requries at least... registers, for the method parameters #212

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What seems to be the problem?
I was successfully able to decompile a dex file with baksmali-2.0.3. But when I 
tried to recompile it without any changes using smali-2.0.3, I got lots of 
errors similar to this:
out/cn/waps/m.smali[18,4] This method requires at least 4 registers, for the 
method parameters

What is the exact smali/baksmali command that you ran?
java -jar baksmali-2.0.3.jar <apk>
java -jar smali-2.0.3.jar out

What version of smali/baksmali are you using? What rom are you working
from?
2.0.3

What is the airspeed velocity of an unladen swallow?

Please provide any additional information below: error messages, symptoms,
etc.
Error message while recompiling with smali-2.0.3: (the error message is a lot 
longer but I truncated it because it's the same type of errors)
out/cn/waps/m.smali[18,4] This method requires at least 4 registers, for the 
method parameters
out/cn/waps/m.smali[28,4] This method requires at least 1 registers, for the 
method parameters
out/cn/waps/cq.smali[14,4] This method requires at least 2 registers, for the 
method parameters
out/cn/waps/v.smali[11,4] This method requires at least 2 registers, for the 
method parameters
out/cn/waps/v.smali[19,4] This method requires at least 3 registers, for the 
method parameters

Decompiling with baksmali-1.3.3 or 1.4.1 fails with the error message:
UNEXPECTED TOP-LEVEL EXCEPTION:
org.jf.dexlib.Util.ExceptionWithContext: Index: 13932, Size: 8585
        at org.jf.dexlib.Util.ExceptionWithContext.withContext(ExceptionWithContext.java:54)
        at org.jf.dexlib.IndexedSection.getItemByIndex(IndexedSection.java:77)
        at org.jf.dexlib.Code.InstructionWithReference.<init>(InstructionWithReference.java:57)
        at org.jf.dexlib.Code.Format.Instruction21c.<init>(Instruction21c.java:63)
        at org.jf.dexlib.Code.Format.Instruction21c.<init>(Instruction21c.java:40)
        at org.jf.dexlib.Code.Format.Instruction21c$Factory.makeInstruction(Instruction21c.java:112)
        at org.jf.dexlib.Code.InstructionIterator.IterateInstructions(InstructionIterator.java:84)
        at org.jf.dexlib.CodeItem.readItem(CodeItem.java:154)
        at org.jf.dexlib.Item.readFrom(Item.java:77)
        at org.jf.dexlib.OffsettedSection.readItems(OffsettedSection.java:48)
        at org.jf.dexlib.Section.readFrom(Section.java:143)
        at org.jf.dexlib.DexFile.<init>(DexFile.java:431)
        at org.jf.baksmali.main.main(main.java:269)
Caused by: java.lang.IndexOutOfBoundsException: Index: 13932, Size: 8585
        at java.util.ArrayList.RangeCheck(Unknown Source)
        at java.util.ArrayList.get(Unknown Source)
        at org.jf.dexlib.IndexedSection.getItemByIndex(IndexedSection.java:75)
        ... 11 more
Error occured while retrieving the field_id_item item at index 13932
Error occured at code address 12
code_item @0x66260

Original issue reported on code.google.com by dongjuna...@gmail.com on 5 May 2014 at 6:25

GoogleCodeExporter commented 9 years ago
This problem is caused when 360 security software (used by a lot of Chinese 
developers) is applied to the apk. 

Original comment by dongjuna...@gmail.com on 24 Jul 2014 at 6:43

GoogleCodeExporter commented 9 years ago
These are mostly-invalid dex files, that are fixed up in-memory at runtime. You 
would need to extract the fixed-up dex file from memory and then run baksmali 
on that. Or write a separate deobfuscator for this particular style of 
obfuscation/packing.

Original comment by jesusfreke@jesusfreke.com on 28 Dec 2014 at 8:53