Static Analysis & Reverse Engineering
Systematic dissection of APK Java bytecode with jadx, headless Ghidra pseudo-C extraction, dynamic symbol auditing, and Thumb-2 disassembly to discover entry points and data structures.
☕ Phase 1: Java Decompilation with jadx¶
Run jadx to decompile the APK's Dalvik bytecode into readable Java:
1. Locate the Main Activity¶
Open decompiled_apk/resources/AndroidManifest.xml and identify the launch activity:
<activity android:name="com.gameloft.android.GAND.GloftSPAW.ML.HeroOfSparta">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
2. Identify native Entry Points¶
Inspect the Activity and rendering loops (GameRenderer, GLSurfaceView, NativeApp). Look for methods declared with the native modifier:
package com.gameloft.android;
public class GameRenderer implements GLSurfaceView.Renderer {
// Core lifecycle hooks
public static native void nativeInit(int width, int height);
public static native void nativeRender();
public static native void nativeResize(int width, int height);
public static native void nativeDone();
// Input dispatchers
public static native boolean nativeOnTouch(int action, float x, float y, int pointerId);
public static native boolean nativeOnKeyDown(int keyCode);
}
// Function pointer types matching Java native signatures
typedef void (*nativeInit_t)(int width, int height);
typedef void (*nativeRender_t)(void);
typedef int (*nativeOnTouch_t)(int action, float x, float y, int pointerId);
nativeInit_t game_nativeInit;
nativeRender_t game_nativeRender;
nativeOnTouch_t game_nativeOnTouch;
void resolve_game_entrypoints(so_module *mod) {
game_nativeInit = (nativeInit_t)so_resolve(mod, "Java_com_gameloft_android_GameRenderer_nativeInit");
game_nativeRender = (nativeRender_t)so_resolve(mod, "Java_com_gameloft_android_GameRenderer_nativeRender");
game_nativeOnTouch = (nativeOnTouch_t)so_resolve(mod, "Java_com_gameloft_android_GameRenderer_nativeOnTouch");
if (!game_nativeInit || !game_nativeRender) {
fatal_error("Could not resolve essential game entry points!");
}
}
[!IMPORTANT] These
nativedeclarations are the exact entry points your Vita loader will invoke inmain.cto drive game initialization, input polling, and frame rendering.
🧩 Phase 2: Dynamic Symbol Extraction (.so)¶
Use binary utilities to inspect exported functions in the .so:
1. List Exported JNI Functions¶
Standard JNI C naming conventions replace Java package dots . with underscores _:
Example output:
00045a10 g DF .text 00000034 Java_com_gameloft_android_GameRenderer_nativeInit
00045a50 g DF .text 00000120 Java_com_gameloft_android_GameRenderer_nativeRender
00045b80 g DF .text 00000088 Java_com_gameloft_android_HeroOfSparta_nativeOnTouch
2. Check for JNI_OnLoad¶
- If JNI_OnLoad is present: The game registers its native methods dynamically via RegisterNatives(). Your loader must call JNI_OnLoad(&jvm, NULL) during startup.
- If JNI_OnLoad is absent: Sockets and methods are statically mapped to Java_package_class_method exports. You can resolve their addresses directly with so_resolve(&so_mod, "Java_...").
🧠 Phase 3: Headless Ghidra Decompilation with Docker¶
To analyze function logic and struct definitions without running a heavy GUI, use devrvk/so-decompiler:
mkdir -p decompiled_so/libgame_armv7
docker run --rm --platform linux/amd64 \
-v "$(pwd)/lib/armeabi-v7a:/input" \
-v "$(pwd)/decompiled_so/libgame_armv7:/output" \
devrvk/so-decompiler decompile /input/libgame.so /output
This outputs:
1. out_ghidra.c: The entire binary reconstructed in pseudo-C.
2. out_ghidra.h: Inferred types, struct layouts, and prototypes.
// Decompiled pseudo-C from headless Ghidra
undefined4 Java_com_gameloft_android_GameRenderer_nativeInit(int param_1, undefined4 param_2, int width, int height) {
g_ScreenWidth = width;
g_ScreenHeight = height;
InitGraphicsEngine(width, height);
LoadGameAssets("/sdcard/gameloft/games/hos");
return 1;
}
Search out_ghidra.c for key paths, strings, and hardcoded asset directories:
grep -n "sdcard" decompiled_so/libgame_armv7/out_ghidra.c
grep -n "nativeRender" decompiled_so/libgame_armv7/out_ghidra.c
⚡ Phase 4: Disassembly with -M force-thumb¶
Over 95% of Android ARMv7 game binaries use the Thumb-2 instruction set (mixed 16-bit and 32-bit opcodes) for code density.
[!CAUTION] If you disassemble Thumb-2 code with standard host
objdump, it defaults to 32-bit ARM mode and decodes corrupt, nonsensical instructions.
Always disassemble using the VitaSDK toolchain with -M force-thumb:
📝 Documenting Findings in PORTING_PLAN.md¶
Summarize all findings in PORTING_PLAN.md at your project root:
- Identified Java package names and Title ID (e.g. HOSP00001).
- Selected .so binary path and memory footprint.
- Exported JNI methods and unresolved imports (so_resolve).
- Lifecycle methods (init, render, pause, resume, touch).