Comments (5)
Hi, could you share the changes on rewriting that happen between the first and second disassembly attempts? Preferably in a minimal code snippet to try to reproduce the error on our end.
from smali.
There are no changes between loading the file and rewriting it. Simply rewriting a file without changes using DexRewriter and then writing the rewritten file produces the broken dex. The code snippet that does it is listed as the first thing in the issue.
Here are all the files needed to reproduce it locally: smali_repro.zip.
Steps:
- Download and extract smali_repro.zip
Libraries used
- https://maven.google.com/com/android/tools/smali/smali/3.0.7/smali-3.0.7.jar
- https://maven.google.com/com/android/tools/smali/smali-baksmali/3.0.7/smali-baksmali-3.0.7.jar
- https://maven.google.com/com/android/tools/smali/smali-dexlib2/3.0.7/smali-dexlib2-3.0.7.jar
- https://maven.google.com/com/android/tools/smali/smali-util/3.0.7/smali-util-3.0.7.jar
- https://repo1.maven.org/maven2/com/google/guava/guava/33.2.1-jre/guava-33.2.1-jre.jar
- https://repo1.maven.org/maven2/com/beust/jcommander/1.64/jcommander-1.64.jar
-
Compile repro program:
javac -cp ".;lib\*" Main.java
(Windows)
javac -cp ".:lib/*" Main.java
(Linux) -
Run repro program (it reads
classes_original.dex
and writes brokenclasses_rewritten.dex
)
java -cp ".;lib\*" Main
(Windows)
java -cp ".:lib/*" Main
(Linux) -
Disassemble original file
classes_original.dex
(no error):
java -cp ".;lib\*" com.android.tools.smali.baksmali.Main dis -o out_original classes_original.dex
(Windows)
java -cp ".:lib/*" com.android.tools.smali.baksmali.Main dis -o out_original classes_original.dex
(Linux) -
Disassemble broken file
classes_rewritten.dex
(error as the file is broken):
java -cp ".;lib\*" com.android.tools.smali.baksmali.Main dis -o out_rewritten classes_rewritten.dex
(Windows)
java -cp ".:lib/*" com.android.tools.smali.baksmali.Main dis -o out_rewritten classes_rewritten.dex
(Linux)
The classes_rewritten.dex
file is generated by using DexRewriter
and then writing the file with DexFileFactory.writeDexFile
.
from smali.
Actually it looks like DexFileFactory.writeDexFile
is broken.
Repro:
import com.android.tools.smali.dexlib2.DexFileFactory;
import com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile;
public class Main {
public static void main(String[] args) throws Exception {
DexBackedDexFile dexFile = DexFileFactory.loadDexFile("classes_original.dex", null);
DexFileFactory.writeDexFile("classes_writedexfile.dex", dexFile);
}
}
Compile and run:
$ javac -cp ".;lib\*" Main.java
$ java -cp ".;lib\*" Main
$ md5sum classes_original.dex
73d6b886ad21105a077ba4ff8dc70a83 *classes_original.dex
$ md5sum classes_writedexfile.dex
9b638d2cf2e768c87b44a4f7dd3f3e50 *classes_writedexfile.dex
$ stat -c "%s %n" -- *.dex
2938412 classes_original.dex
3172524 classes_writedexfile.dex
$ java -cp ".;lib\*" com.android.tools.smali.baksmali.Main dis -o out classes_writedexfile.dex
Error occurred while disassembling class LFC0; - skipping class
com.android.tools.smali.util.ExceptionWithContext: Invalid uleb128 integer encountered at offset 0x110642
from smali.
Could you test with the changes in the rewriter branch?
https://github.com/google/smali/tree/rewriter
from smali.
It does not compile from command line. I've used both gradlew assemble
and gradlew smali:fatJar
and both fail.
If you can build the jars like the ones I can download from maven then I'll be able to test it.
> Task :smali:generateGrammarSource FAILED
error(10): internal error: : java.lang.Error: Error parsing smaliTreeWalker.g: 'third_party' not expected 'grammar'
org.antlr.tool.GrammarSpelunker.match(GrammarSpelunker.java:70)
org.antlr.tool.GrammarSpelunker.grammarHeader(GrammarSpelunker.java:108)
org.antlr.tool.GrammarSpelunker.parse(GrammarSpelunker.java:80)
org.antlr.Tool.sortGrammarFiles(Tool.java:585)
org.antlr.Tool.process(Tool.java:439)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
> Task :smali:generateGrammarSource FAILED
> Task :dexlib2:compileJava
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':smali:generateGrammarSource'.
> There were 19 errors during grammar generation
from smali.
Related Issues (20)
- gradle 6 is EOL HOT 1
- Request for Dex compilation enhancement HOT 12
- CI builds fails, as it is currently compiling with JDK-8 HOT 1
- java.lang.IllegalArgumentException: bad utf-8 byte dc at offset 000000eb HOT 6
- Can't build in WSL Debian HOT 1
- Build failed HOT 4
- build failed
- Dex - getOpcodes().api returning misleading api version HOT 1
- Smali fails to assemble classes.dex decompiled with baksmali
- DEX version compatibility HOT 2
- Don't emit multiple .line directives before an instruction when disassembling
- assert failed in 3.0.7 HOT 6
- Breaking change introduced with a refactor HOT 3
- Support for rewrite/instrumentation with dexlib2 HOT 2
- [BUG] After smali, Origin method name changes. So runtime error occurs. HOT 1
- 403: Forbidden HOT 9
- Bad index for debug_info_item parameter_name: 2ffffff >= 1e58 HOT 6
- Bad index for debug_info_item parameter_name: HOT 1
- different signature after compilation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smali.