Skip to content

Commit

Permalink
Fixes #2\nFixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
j005u committed May 25, 2022
1 parent 2000b2b commit f8240e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ipk/control/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: wtfos-modloader
Version: 0.1.1
Version: 0.1.2
Maintainer: Joonas Trussmann <[email protected]>
Description: Configurable LD_PRELOAD injector for DJI services
Architecture: armv7-3.2
Expand Down
11 changes: 9 additions & 2 deletions modloader
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#!/system/bin/sh

me=$(basename "$0")
MODS=""

if [ -d "/opt/etc/preload.d/${me}" ]
then
MODS="$(find /opt/etc/preload.d/${me}/ -name "*.so" -maxdepth 1 -type l)"
while read lname; do
#check that the link resolves to an actual file
if [ -f $(readlink -f ${lname}) ]; then
MODS="${MODS} ${lname}"
fi
done <<< "$(find /opt/etc/preload.d/${me}/ -name \"*.so\" -maxdepth 1 -type l)"
fi
if [ ! -z "${MODS}" ]
then
#clear LD_PRELOAD in application env so spawns don't get spammed
MODS="${MODS} /opt/lib/libmodloader_final.so"
MODS="${MODS##*( )} /opt/lib/libmodloader_final.so"
echo "modloader starting with: ${MODS}"
LD_PRELOAD="${MODS}" ${me}_original "$@"
else
${me}_original "$@"
Expand Down
11 changes: 9 additions & 2 deletions modmanager
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

PRELOAD_D=/opt/etc/preload.d/

if [ $# -eq 0 ]; then
sh $0 help
exit 1
fi

if [ $1 = "enable" ]; then
if [ $# -ne 3 ]; then
echo "illegal number of parameters"
Expand All @@ -26,7 +31,8 @@ if [ $1 = "enable" ]; then
ln -sf "${PRELOAD_D}${modlib}" "${PRELOAD_D}${target}/${modlib}"

#this will force init to reload the service, which should auto enable it
killall ${target}_original || killall ${target} || true
killall ${target} > /dev/null 2>&1 || true
killall ${target}_original > /dev/null 2>&1 || true

elif [ $1 = "disable" ]; then
if [ $# -ne 3 ]; then
Expand All @@ -46,7 +52,8 @@ elif [ $1 = "disable" ]; then

if [[ -L "${PRELOAD_D}${target}/${modlib}" ]]; then
rm -f "${PRELOAD_D}${target}/${modlib}"
killall ${target}_original || true
killall ${target} > /dev/null 2>&1 || true
killall ${target}_original > /dev/null 2>&1 || true
else
echo "no such mod enabled"
fi
Expand Down

0 comments on commit f8240e9

Please sign in to comment.