Skip to content

EXECUTE_DEX

Cregrant edited this page Jun 10, 2023 · 1 revision

[EXECUTE_DEX]

❓ Problems are possible. Most patches are written by enthusiasts, and the change of Android -> Windows platform or a different decompilation method (a different version of Apktool) can make them non-working

This rule runs code written in Java and compiled into a `.dex' file

  • NAME: the name of the rule (optional)
  • SCRIPT: the path to your .dex script
  • SMALI_NEEDED: true if your script needs .smali files or false if not. If necessary, an attempt will be made to create them.
  • MAIN_CLASS: the path to your entry class in the script
  • ENTRANCE: the name of the method to be called.
  • PARAM: this string will be passed to the method as the fourth parameter

Script creation

Create the file Main.java with the main method. The main method of your class must take 4 lines as arguments:

  1. A path to the .apk file from which your project was decompiled
  2. A path to the `.zip' file of your patch
  3. A path to your project folder
  4. A text in the PARAM field of your rule

Compilation:

javac -source 1.7 -target 1.7 Main.java

dx --dex --output=script.dex Main.class

Where do I find dx? I found it as a .jar file in the JADX project, so my build command starts with java -jar dx-1.16.jar instead of dx

Examples

Run script.dex from your patch:

[EXECUTE_DEX]
SCRIPT:
script.dex
SMALI_NEEDED:
true
MAIN_CLASS:
Main
ENTRANCE:
main
PARAM:
this string will be passed as a method argument
[/EXECUTE_DEX]

Clone this wiki locally