Skip to content

Commit 9d8a95a

Browse files
committed
Initial commit
0 parents  commit 9d8a95a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+418686
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.vscode/
2+
gamefiles/*
3+
!gamefiles/support_files
4+
build/
5+
libjnivm/build/

CMakeLists.txt

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
if(COMMAND cmake_policy)
3+
cmake_policy(SET CMP0003 NEW)
4+
endif(COMMAND cmake_policy)
5+
6+
if (NOT DEFINED PROJ)
7+
project(unityloader)
8+
else()
9+
project(PROJ)
10+
endif()
11+
12+
13+
set(CMAKE_BUILD_TYPE Debug)
14+
15+
set(PROJ_SOURCE_DIR ${CMAKE_SOURCE_DIR}/projects/${CMAKE_PROJECT_NAME})
16+
file(GLOB_RECURSE PROJ_SOURCES ${PROJ_SOURCE_DIR}/*.c ${PROJ_SOURCE_DIR}/*.cc ${PROJ_SOURCE_DIR}/*.cpp)
17+
18+
add_executable(${CMAKE_PROJECT_NAME}
19+
${PROJ_SOURCES}
20+
javastubs/android.cpp
21+
javastubs/javac.cpp
22+
platform/common/so_util.c
23+
platform/linux/so_util_linux.c
24+
platform/linux/physram.c
25+
bridges/pthread_bridge.c
26+
bridges/misc_bridges.c
27+
bridges/stdio_bridge.c
28+
bridges/gles2_bridge.c
29+
bridges/fcntl_bridge.c
30+
bridges/ctype_bridge.c
31+
bridges/math_bridge.c
32+
bridges/gles2_bridge.c
33+
)
34+
35+
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
36+
${CMAKE_SOURCE_DIR}/libjnivm/include
37+
${CMAKE_SOURCE_DIR}/platform/common
38+
${CMAKE_SOURCE_DIR}/bridges
39+
${CMAKE_SOURCE_DIR}/javastubs
40+
${PROJ_SOURCE_DIR}/javastubs
41+
)
42+
43+
#file(COPY ${CMAKE_SOURCE_DIR}/support_files DESTINATION ${CMAKE_BINARY_DIR})
44+
45+
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC EnableJNIVMGC)
46+
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC JNIVM_FAKE_JNI_SYNTAX=1)
47+
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC JNI_DEBUG)
48+
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC VERBOSE_LOG)
49+
50+
target_link_libraries(${CMAKE_PROJECT_NAME} dl pthread ${CMAKE_SOURCE_DIR}/libjnivm/build/libfake-jni.a ${CMAKE_SOURCE_DIR}/libjnivm/build/libbaron.a ${CMAKE_SOURCE_DIR}/libjnivm/build/libjnivm.a)
51+
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)

LICENSE.md

+595
Large diffs are not rendered by default.

README.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Bogodroid
2+
3+
### **WARNING: VERY EARLY IN DEVELOPMENT, VERY NON-FUNCTIONAL, CODE QUALITY QUESTIONABLE**
4+
5+
This is an experimental project attempting to create a wrapper environment around native libraries (armeabi) from Android Apps, with the intent of running the libraries (or entire apps and games) on ARM Linux (armhf and arm64) handhelds.
6+
7+
The project is heavily based on [JohnnyOnFlame/droidports](https://github.com/JohnnyonFlame/droidports) and [ChristopherHX/libjnivm](https://github.com/ChristopherHX/libjnivm).
8+
9+
The idea is to:
10+
- load the libraries, patch them at runtime
11+
- wrap, bridge or stub any required symbols from Android system libraries
12+
- Provide a JNI interface for communication with placeholder "java" classes
13+
- Provide implementations and stubs for common java and android classes
14+
- Ultimately wrap Audio, GLES and Input to host interfaces and libraries.
15+
16+
This project does not aim to be able to run your App out of the box. It is meant as a framework or starting point for your own porting project. For existing porting projects, check the "Ports in progress" table and the projects folder.
17+
18+
# How to Build (Debug)
19+
20+
(This process will be simplified later on)
21+
22+
1. Create a armhf chroot environment for building and testing. I recommend [this VM](https://forum.odroid.com/viewtopic.php?p=306185#p306185) image as a starting point.
23+
2. Clone the repository into your chroot
24+
3. Create the folder "./libjnivm/build" inside the repository and enter it
25+
4. `cmake .. --build -DJNIVM_ENABLE_TRACE=ON -DJNIVM_ENABLE_GC=ON -DJNIVM_ENABLE_DEBUG=ON -DJNIVM_USE_FAKE_JNI_CODEGEN=ON `
26+
5. Create the folder "./build" inside the repository and enter it
27+
6. `cmake .. --build`
28+
29+
By default this will build the `unityloader` project. If you want to build a different project, you can specify the project in step 6 with `cmake .. --build -DPROJ=<project name>`
30+
31+
# Running
32+
33+
Currently, the `unityloader` and `hexagonloader` expect a commandline argument to a folder where you extracted the apk of your target. one folder above that should contain the folder `support_files` from the `gamefiles` directory. The easiest way is to extract your apk in the `gamefiles` folder, and run directly from the build directory, like this:
34+
35+
`./unityloader ../gamefiles/testgame/`
36+
37+
# Debugging with QEMU and GDB-multiarch
38+
39+
(This expects the chroot environment as provided by [this VM](https://forum.odroid.com/viewtopic.php?p=306185#p306185))
40+
41+
1. Exit your chroot, we will call the binary directly
42+
2. Enter the build directory
43+
3. Start the binary with:
44+
`QEMU_LD_PREFIX=/mnt/data/armhf/ qemu-arm-static -g 5 ./unityloader ../gamefiles/testgame/`
45+
4. Open another terminal and type in `gdb-multiarch`
46+
5. Enter the location of your chroot: `set sysroot /mnt/data/armhf`
47+
6. Enter the location of your binary: `file /mnt/data/armhf/root/bogodroid/build/unityloader`
48+
7. Connect to the open GDB session in QEMU: `target remote :5`
49+
6. "c" to run the program, "si" to step a single instruction, "bt" to read stack trace, "break" to set breakpoint. ***Refer to the GDB manpage and internet resources on how to debug***
50+
51+
# JNI Tracing your App
52+
53+
(This requires a rooted Android device and a computer with ADB and Python installed)
54+
55+
1. [Install a Frida server on your Android device](https://frida.re/docs/android/)
56+
2. Install jnitrace on your computer: `pip install jnitrace`
57+
3. Run the trace: `jnitrace -o jnitrace.json com.example.myapplication`
58+
4. Press CTRL-C to finish aquiring data
59+
5. `jnitrace.json` will contain all JNI calls made by the application
60+
6. `python tools/jnitrace_parse.py <input_json_file> <output_json_file>` will give you a consolidated tree of all classes, methods and fields (and their signatures) accessed during the tracing period.
61+
62+
See `tools/unity_traces` for a trace of a minimal Unity game starting up
63+
64+
65+
66+
67+
68+
# Ports in Progress
69+
70+
| Name | Arch | Status | Notes |
71+
|-----------------------------------|-------|---------------|--------------------------------------------------------------------------------------------------------------------|
72+
| Unity (Mono) | ARMv7 | Not Booting | Makes it 70% through initialization. Crashes when Mono creates first thread. Pthread bridge needs to be reworked. |
73+
| Super Hexagon | ARMv7 | Not Booting | Crashes very early during init while writing first log message. Issue with libc++_shared.so |
74+
| Crazy Taxi Classic | ARMv7 | Investigated | Requires better file handling for loading the big OBB files, before it can be attempted. |
75+
| Limbo | ARMv7 | Not attempted | |
76+
| Terraria | ARMv7 | Not attempted | (Engine: FNA, Monogame port might be easier) |
77+
| Baba is you | ARMv7 | Not attempted | |
78+
| Super Meat Boy Forever | ARMv7 | Not attempted | |
79+
| Streets of rage 4 | ARMv7 | Not attempted | (Engine: FNA, Monogame port might be easier) |
80+
| Chrono Trigger | ARMv7 | Not attempted | (Engine: cocos2d-x) |
81+
| Dead Cells | ARMv7 | Not attempted | |
82+
| Brotato | ARMv7 | Not attempted | |
83+
| Castlevania Symphony of the Night | ARMv7 | Not attempted | |
84+
| Five Nights At Freddy | ARMv7 | Not attempted | |
85+
| Gris | ARMv7 | Not attempted | |
86+
| The way home | ARMv7 | Not attempted | |
87+
| Vampire Survivors | ARMv7 | Not attempted | |
88+
| Scourgebringer | ARMv7 | Not attempted | |
89+
| Haak | ARMv7 | Not attempted | |
90+
91+
92+

0 commit comments

Comments
 (0)