Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
21984fac
Commit
21984fac
authored
May 25, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API for running independent proc_monitor test
parent
75405b2b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
22 deletions
+26
-22
hide_utils.cpp
native/jni/magiskhide/hide_utils.cpp
+7
-0
magiskhide.cpp
native/jni/magiskhide/magiskhide.cpp
+11
-6
magiskhide.h
native/jni/magiskhide/magiskhide.h
+1
-0
proc_monitor.cpp
native/jni/magiskhide/proc_monitor.cpp
+7
-16
No files found.
native/jni/magiskhide/hide_utils.cpp
View file @
21984fac
...
...
@@ -328,3 +328,10 @@ void auto_start_magiskhide() {
});
}
}
void
test_proc_monitor
()
{
if
(
procfp
==
nullptr
&&
(
procfp
=
opendir
(
"/proc"
))
==
nullptr
)
exit
(
1
);
proc_monitor
();
exit
(
0
);
}
native/jni/magiskhide/magiskhide.cpp
View file @
21984fac
...
...
@@ -13,6 +13,8 @@
#include "magiskhide.h"
using
namespace
std
::
literals
;
bool
hide_enabled
=
false
;
[[
noreturn
]]
static
void
usage
(
char
*
arg0
)
{
...
...
@@ -26,6 +28,7 @@ bool hide_enabled = false;
" --add PKG [PROC] Add a new target to the hide list
\n
"
" --rm PKG [PROC] Remove from the hide list
\n
"
" --ls List the current hide list
\n
"
" --test Run process monitor test
\n
"
,
arg0
);
exit
(
1
);
}
...
...
@@ -77,18 +80,20 @@ int magiskhide_main(int argc, char *argv[]) {
usage
(
argv
[
0
]);
int
req
;
if
(
strcmp
(
argv
[
1
],
"--enable"
)
==
0
)
if
(
argv
[
1
]
==
"--enable"
sv
)
req
=
LAUNCH_MAGISKHIDE
;
else
if
(
strcmp
(
argv
[
1
],
"--disable"
)
==
0
)
else
if
(
argv
[
1
]
==
"--disable"
sv
)
req
=
STOP_MAGISKHIDE
;
else
if
(
strcmp
(
argv
[
1
],
"--add"
)
==
0
&&
argc
>
2
)
else
if
(
argv
[
1
]
==
"--add"
sv
)
req
=
ADD_HIDELIST
;
else
if
(
strcmp
(
argv
[
1
],
"--rm"
)
==
0
&&
argc
>
2
)
else
if
(
argv
[
1
]
==
"--rm"
sv
)
req
=
RM_HIDELIST
;
else
if
(
strcmp
(
argv
[
1
],
"--ls"
)
==
0
)
else
if
(
argv
[
1
]
==
"--ls"
sv
)
req
=
LS_HIDELIST
;
else
if
(
strcmp
(
argv
[
1
],
"--status"
)
==
0
)
else
if
(
argv
[
1
]
==
"--status"
sv
)
req
=
HIDE_STATUS
;
else
if
(
argv
[
1
]
==
"--test"
sv
)
test_proc_monitor
();
else
usage
(
argv
[
0
]);
...
...
native/jni/magiskhide/magiskhide.h
View file @
21984fac
...
...
@@ -25,6 +25,7 @@ int stop_magiskhide();
int
add_list
(
int
client
);
int
rm_list
(
int
client
);
void
ls_list
(
int
client
);
[[
noreturn
]]
void
test_proc_monitor
();
// Process monitoring
void
proc_monitor
();
...
...
native/jni/magiskhide/proc_monitor.cpp
View file @
21984fac
/* proc_monitor.cpp - Monitor am_proc_start events and unmount
*
* We monitor the listed APK files from /data/app until they get opened
* via inotify to detect a new app launch.
*
* If it's a target we pause it ASAP, and fork a new process to join
* its mount namespace and do all the unmounting/mocking.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
...
...
@@ -188,9 +179,6 @@ static void setup_inotify() {
}
else
{
inotify_add_watch
(
inotify_fd
,
APP_PROC
,
IN_ACCESS
);
}
// First find existing zygotes
check_zygote
();
}
/*************************
...
...
@@ -291,12 +279,12 @@ static void term_thread(int) {
* Ptrace Madness
******************/
/* Ptrace is super tricky, preserve all excessive
debu
g in code
/* Ptrace is super tricky, preserve all excessive
loggin
g in code
* but disable when actually building for usage (you won't want
* your logcat spammed with new thread events from all apps) */
//
#define PTRACE_LOG(fmt, args...) LOGD("PID=[%d] " fmt, pid, ##args)
#define PTRACE_LOG(...)
#define PTRACE_LOG(fmt, args...) LOGD("PID=[%d] " fmt, pid, ##args)
//
#define PTRACE_LOG(...)
static
void
detach_pid
(
int
pid
,
int
signal
=
0
)
{
char
path
[
128
];
...
...
@@ -371,7 +359,7 @@ static bool check_pid(int pid) {
}
}
}
PTRACE_LOG
(
"
not our target
\n
"
);
PTRACE_LOG
(
"
[%s] not our target
\n
"
,
cmdline
);
detach_pid
(
pid
);
return
true
;
}
...
...
@@ -414,6 +402,9 @@ void proc_monitor() {
setup_inotify
();
// First find existing zygotes
check_zygote
();
int
status
;
for
(;;)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment