-
Notifications
You must be signed in to change notification settings - Fork 340
Gracefully handle dex file decompilation errors, skip problematic dex #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…dex files Some protectors/packers intentionally add useless/unwanted dex files under apk to hinder tools like apktool/apkeditor to fail during decompilation as they're not correct pure dex files(classes0.dex, there's no such thing as `classes0` in an apk file, generally dex files start with `classes.dex`, `classes2.dex` and so on..) which leads to the tools being not able to complete apk decompilation. This commit enhances the `SmaliDecompiler` to gracefully handle errors encountered during the decompilation of individual dex files. Previously, encountering a malformed or invalid dex file would halt the entire decompilation process. Upon encountering an error, instead of halting, it now logs the error and skips the problematic dex file, continuing the decompilation process with the other files.
|
We could think about adding a flag for this in the decompile options, it might give more flexibility. For now, I stuck with the simpler solution since it works without adding complexity. P.S.: Another reason being naming stuff is hard! :haha: I couldn't settle on a good name for the flag. |
|
Edit: Okay that was wrong assumption, built baksmali from source and verified on the same file on which APKEditor throws P.S: Consider merging PR with squash & merge to avoid wrong commit going to HEAD :) |
|
Thank you, |
|
Check this commit |
Awesome, that will suffice as well. |
Some protectors/packers intentionally add useless/unwanted dex files under apk to hinder tools like apktool/apkeditor to fail during decompilation as they're not correct pure dex files(classes0.dex, there's no such thing as
classes0in an apk file, generally dex files start withclasses.dex,classes2.dexand so on..) which leads to the tools being not able to complete apk decompilation.I: [DECOMPILE] Baksmali: classes0.dex ERROR: org.jf.util.ExceptionWithContext: Encountered small uint that is out of range at offset 0x70 at org.jf.dexlib2.dexbacked.DexBuffer.readSmallUint(DexBuffer.java:59) at org.jf.dexlib2.dexbacked.model.DexStringSection.load(DexStringSection.java:44) at org.jf.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:98) at org.jf.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:204) at com.reandroid.apkeditor.smali.SmaliDecompiler.getInputDexFile(SmaliDecompiler.java:179) at com.reandroid.apkeditor.smali.SmaliDecompiler.disassembleWithJesusFrekeLib(SmaliDecompiler.java:119) at com.reandroid.apkeditor.smali.SmaliDecompiler.decodeDex(SmaliDecompiler.java:64) at com.reandroid.apk.DexDecoder.decodeDex(DexDecoder.java:29) at com.reandroid.apkeditor.smali.SmaliDecompiler.decodeDex(SmaliDecompiler.java:71) at com.reandroid.apk.ApkModuleDecoder.decodeDexFiles(ApkModuleDecoder.java:113) at com.reandroid.apk.ApkModuleDecoder.decode(ApkModuleDecoder.java:58) at com.reandroid.apkeditor.decompile.Decompiler.runCommand(Decompiler.java:62) at com.reandroid.apkeditor.Options.runCommand(Options.java:59) at com.reandroid.apkeditor.Main.run(Main.java:136) at com.reandroid.apkeditor.Main.execute(Main.java:72) at com.reandroid.apkeditor.Main.main(Main.java:57)This commit enhances the
SmaliDecompilerto gracefully handle errors encountered during the decompilation of individual dex files. Previously, encountering a malformed or invalid dex file would halt the entire decompilation process.Upon encountering an error, instead of halting, it now logs the error and skips the problematic dex file, continuing the decompilation process with the other files.
After: