1. What is DEX?
Simply put, the optimized Android version of. exe. Each APK installation package is available.
Run with respect to the Java virtual function on the PC. The Davlik virtual function on the class;android runs. Dex.
Why Study dex format? Because Dex contains all the app code, the use of the Anti-compilation tool to get Java source. Understand and modify the Dex file to be able to better apk crack and anti-hack.
2. Dex Benefits
The Dex file has a huge benefit: it can be loaded directly with the Dexclassloader class, which is called dynamic loading. So we can avoid the risk of static decompile by adding Shell to Dex and shelling out when the program is running.
3, the general anti-compilation process is what it looks like.
1. Download the apk file and unzip it to get the Class.dex file
2, use Dex2jar to restore Class.dex to Classes-dex2jar.jar file
3, use Jd-gui.exe to open Classes-dex2jar.jar file, you can see the source code.
4. Why does Android have 65536 limit issues?
In an Android system, all the code for an app is inside a dex file. Dex is a jar-like package that stores many of the archived files for Java-compiled bytecode. Because the Android system uses the Dalvik virtual machine, you need to convert the class file that was compiled with Java compiler into a class file that Dalvik can execute. The point here is that Dex, like the jar, is an archive file, which is still a bytecode file for Java code. When the Android system launches an application, one step is to optimize for Dex, a process that has a dedicated tool to handle, called dexopt. The execution of the dexopt is performed when the Dex file is loaded for the first time. This process generates a Odex file, which is optimised Dex. Executing Odex is much more efficient than directly executing the Dex file. But in the early days of Android, Dexopt had a problem, which is what this article wants to illustrate and solve. Dexopt will retrieve the method ID of each class, and there is a list structure inside. However, the length of the list is saved with a short type, resulting in no more than 65,536 method IDs. When a project is large enough, it is clear that the upper limit of this method is not enough. Although dexopt fixes the problem in the new version of Android, we still need to be compatible with older systems.
Android DEX Basics