forked from Magisk-Modules-Alt-Repo/magisk_proc_monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynmount.sh
56 lines (43 loc) · 1.46 KB
/
dynmount.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
MODDIR="${0%/*}"
# API_VERSION = 1
STAGE="$1" # prepareEnterMntNs or EnterMntNs
PID="$2" # PID of app process
UID="$3" # UID of app process
PROC="$4" # Process name. Example: com.google.android.gms.unstable
USERID="$5" # USER ID of app
# API_VERSION = 2
# Enable ash standalone
# Enviroment variables: MAGISKTMP, API_VERSION
# API_VERSION = 3
STAGE="$1" # prepareEnterMntNs or EnterMntNs or OnSetUID
# API_VERSION = 4
# Enviroment variables provided by KernelSU:
# KSU_VERSION - KernelSU version, "-1" is not installed
# KSU_ON_UNMOUNT - true if process is on unmount
# KSU_ON_GRANTED - true if process is granted su access
# For Magisk, please use magisk command, example: MAGISKTMP="$(magisk --path)"
RUN_SCRIPT(){
if [ "$STAGE" == "prepareEnterMntNs" ]; then
prepareEnterMntNs
elif [ "$STAGE" == "EnterMntNs" ]; then
EnterMntNs
elif [ "$STAGE" == "OnSetUID" ]; then
OnSetUID
fi
}
prepareEnterMntNs(){
# this function run on app pre-initialize
# su 2000 -c "cmd notification post -S bigtext -t 'Process monitor' 'Tag' 'pid="$PID" uid="$UID" "$PROC"'"
# call exit 0 to let script to be run in EnterMntNs
exit 1 # close script
}
EnterMntNs(){
# this function will be run when mount namespace of app process is unshared
# call exit 0 to let script to be run in OnSetUID
exit 1 # close script
}
OnSetUID(){
# this function will be run when UID is changed from 0 to $UID
exit 1 # close script
}
RUN_SCRIPT