* fix(native): programs started through the rootfs loader show their own command line Without proot every dynamic guest program runs as "ld.so --preload <hook> --library-path <dirs> --argv0 <name> <program> <args>", and the kernel's /proc/<pid>/cmdline kept all of it. Launchers and the session match programs by their command line, and Wine only moves its Windows command line over its loader's name when its arguments follow each other, so the Battle.net launcher never saw Battle.net.exe, gave up after five minutes and ended the session with the game still running. The hook now moves the program's own arguments to the front of that area at start, as an exec of the program would have laid them out. * fix(native): programs the app starts natively keep their path for /proc/<pid>/exe * fix(native): the rewritten command line keeps AT_EXECFN naming the program --------- Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
Native userland (no proot)
libddnatv-hook.so is an LD_PRELOAD library that lets the glibc rootfs run directly on Android:
it maps the guest's absolute paths into the rootfs (plus the mounts proot used to provide, from
DDNATV_BINDS), starts every program through the rootfs's ld.so, and answers the system calls
Android's seccomp policy kills a process for (SIGSYS handler). There is no tracer. The app side
is runtime/NativeGuest.kt; the setting is Performance > "Run without proot (experimental)".
The hook is derived from the Apache-2.0 libcortex-hook of
ssfuisu/cortex (see LICENSE), renamed (cortex -> ddnatv,
same length: the code compares environment names by length) and extended with:
DDNATV_BINDSmounts,DDNATV_PRELOAD(what/etc/ld.so.preloaddoes for proot), and mapping of guest paths insideLD_PRELOAD;- POSIX
shm_open/shm_unlinkthrough/dev/shm; - starting Wine without its static preloader, which opens files with raw system calls.
Build: tools/nativeguest/build.sh out.so with an aarch64 glibc cross compiler.
Testing under Android's seccomp filter
Some devices (eng builds, setenforce 0 ROMs) run apps with no seccomp filter, so a hook that
passes there can still die with SIGSYS on a stock phone (GUEST_EXIT 159). seccomp-sim.c applies
a filter that answers the calls Android blocks with SIGSYS, then runs the program:
aarch64-linux-gnu-gcc -static -O2 -o seccomp-sim tools/nativeguest/seccomp-sim.c
# copy it into the rootfs, then name it for every native launch:
echo /usr/local/bin/seccomp-sim > <rootfs>/etc/droiddeck/seccomp-sim
grep Seccomp: /proc/<pid>/status should then show 2 for the session's processes. Empty the file
to turn it off. seccomp-sim -a NR,NR PROGRAM leaves the listed calls allowed, to find which one
kills a program.