|
| 1 | +Setting up an environment for the client decompilation |
| 2 | +======================================================== |
| 3 | + |
| 4 | +.. important:: |
| 5 | + |
| 6 | + Building under Windows is not possible (as viking doesn't work on Windows), if you are under Windows, |
| 7 | + please use a Windows Subsystem for Linux (WSL) Ubuntu instance. |
| 8 | + |
| 9 | +.. important:: |
| 10 | + All commands here are executed trough a Bash shell. |
| 11 | + |
| 12 | +Requirements |
| 13 | +-------------- |
| 14 | + |
| 15 | +* Python 3.6 or newer with pip (or a virtual env with pipx) |
| 16 | +* Ninja |
| 17 | +* CMake 3.30+ |
| 18 | +* A C++ toolchain (for compiling the Rust tools) |
| 19 | +* `A Rust toolchain <https://www.rust-lang.org/tools/install>`_ |
| 20 | +* wget and p7zip |
| 21 | +* The following Python modules (you can install them with pip install ..): |
| 22 | + |
| 23 | + capstone colorama cxxfilt pyelftools ansiwrap watchdog python-Levenshtein toml |
| 24 | + |
| 25 | +* A Java runtime (like OpenJDK 21) |
| 26 | +* `APKTool <https://apktool.org/docs/install>`_ |
| 27 | + |
| 28 | +.. note:: |
| 29 | + |
| 30 | + On Ubuntu, you can install everything except the Rust toolchain and apktool by running the following commands:: |
| 31 | + |
| 32 | + sudo apt install python3 ninja-build cmake clang libssl-dev pkg-config build-essential openjdk-21-jre wget p7zip |
| 33 | + pip install capstone colorama cxxfilt pyelftools ansiwrap watchdog python-Levenshtein toml |
| 34 | + |
| 35 | +Clong the repository |
| 36 | +--------------------- |
| 37 | + |
| 38 | +Using git, clone the `client <https://github.com/decompfrontier/client>`_ repository with the following command:: |
| 39 | + |
| 40 | + git clone --recurse-submodules https://github.com/decompfrontier/client |
| 41 | + |
| 42 | + |
| 43 | +Dumping the executable and data files |
| 44 | +---------------------------------------- |
| 45 | + |
| 46 | +You will first need to get an original copy of Brave Frontier for Android (sg.gumi.bravefrontier) for ARM version 2.19.6.0. If you have |
| 47 | +Brave Frontier installed on your phone, you can use apps like APK Manager to get the APK file. |
| 48 | + |
| 49 | +The SHA256 of the file should match: `BFE8D2141280AC51DEBDD819EC0BEBBC6844BF8249474D9FBDF361F8192B8241`. |
| 50 | + |
| 51 | +Run the following command to extract the APK file:: |
| 52 | + |
| 53 | + java -jar apktool.jar d -o apkunpack -s -r "brave frontier apk.apk" |
| 54 | + |
| 55 | +You should see a directory called "apkunpack" in the same directory where you have run apktool, your apkunpack directory should look something like this: |
| 56 | + |
| 57 | +.. image:: |
| 58 | + ../../images/decomp-setup/apkunpack.png |
| 59 | + |
| 60 | +From this directory, only two directories are important for this tutorial, "assets" and "lib". |
| 61 | + |
| 62 | +Copy the whole content of the "assets" directory inside the "data" directory of the decompfrontier client. |
| 63 | + |
| 64 | +Your data directory should look like so: |
| 65 | + |
| 66 | +.. image:: |
| 67 | + ../../images/decomp-setup/datadir.png |
| 68 | + |
| 69 | +Next, copy the "libgame.so" file from the apkunpack/lib/arm64-v8a directory to the replika/romset/android/global/arm64-v8a directory. |
| 70 | + |
| 71 | +The SHA256 of libgame.so **MUST BE** `076C8ED12E84D122938255C1530A4D4B1853D876B5928DD0C2389538FC4CAD95`. |
| 72 | + |
| 73 | +Setting up the repository |
| 74 | +---------------------------- |
| 75 | + |
| 76 | +Go to the client directory that we cloned previously and type: |
| 77 | + |
| 78 | + ./setup.sh |
| 79 | + |
| 80 | +The following command will download the Android NDK r21e required for building brave frontier, if everything has gone successfully |
| 81 | +you should see an `OK`. (Altrought sometimes you might see `Error: found at least one error` which is ok as well). |
| 82 | + |
| 83 | +If you never installed any Android SDK (the script will check for the existance of the environment variable |
| 84 | +`ANDROID_SDK`), if will default the installation to `~/android-sdk` |
| 85 | + |
| 86 | +Make sure to update your `~/.bashrc` to add the following line if you have never setted up an android SDK: |
| 87 | + |
| 88 | + export ANDROID_SDK=~/android-sdk |
| 89 | + |
| 90 | +Next steps |
| 91 | +--------------- |
| 92 | + |
| 93 | +You are now ready to start decompiling, you can modify the files in the src directory and type `./make.sh` to compile the client |
| 94 | +and `./diff.sh (your function)` to check if a function matches or not. |
0 commit comments