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
081074ad
Commit
081074ad
authored
Mar 09, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better zygote process detection
parent
ab0cc78d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
19 deletions
+38
-19
daemon.h
native/jni/include/daemon.h
+0
-1
hide_utils.cpp
native/jni/magiskhide/hide_utils.cpp
+1
-2
magiskhide.h
native/jni/magiskhide/magiskhide.h
+0
-1
proc_monitor.cpp
native/jni/magiskhide/proc_monitor.cpp
+37
-15
No files found.
native/jni/include/daemon.h
View file @
081074ad
...
@@ -79,7 +79,6 @@ void install_apk(const char *apk);
...
@@ -79,7 +79,6 @@ void install_apk(const char *apk);
**************/
**************/
void
magiskhide_handler
(
int
client
);
void
magiskhide_handler
(
int
client
);
void
zygote_notify
(
int
client
,
struct
ucred
*
cred
);
/*************
/*************
* Superuser *
* Superuser *
...
...
native/jni/magiskhide/hide_utils.cpp
View file @
081074ad
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
using
namespace
std
;
using
namespace
std
;
pthread_t
proc_monitor_thread
;
static
pthread_t
proc_monitor_thread
;
static
const
char
*
prop_key
[]
=
static
const
char
*
prop_key
[]
=
{
"ro.boot.vbmeta.device_state"
,
"ro.boot.verifiedbootstate"
,
"ro.boot.flash.locked"
,
{
"ro.boot.vbmeta.device_state"
,
"ro.boot.verifiedbootstate"
,
"ro.boot.flash.locked"
,
...
@@ -327,4 +327,3 @@ void auto_start_magiskhide() {
...
@@ -327,4 +327,3 @@ void auto_start_magiskhide() {
});
});
}
}
}
}
native/jni/magiskhide/magiskhide.h
View file @
081074ad
...
@@ -37,7 +37,6 @@ void clean_magisk_props();
...
@@ -37,7 +37,6 @@ void clean_magisk_props();
void
crawl_procfs
(
const
std
::
function
<
bool
(
int
)
>
&
fn
);
void
crawl_procfs
(
const
std
::
function
<
bool
(
int
)
>
&
fn
);
bool
proc_name_match
(
int
pid
,
const
char
*
name
);
bool
proc_name_match
(
int
pid
,
const
char
*
name
);
extern
pthread_t
proc_monitor_thread
;
extern
bool
hide_enabled
;
extern
bool
hide_enabled
;
extern
pthread_mutex_t
monitor_lock
;
extern
pthread_mutex_t
monitor_lock
;
extern
std
::
set
<
std
::
pair
<
std
::
string
,
std
::
string
>>
hide_set
;
extern
std
::
set
<
std
::
pair
<
std
::
string
,
std
::
string
>>
hide_set
;
...
...
native/jni/magiskhide/proc_monitor.cpp
View file @
081074ad
...
@@ -63,6 +63,22 @@ static inline void lazy_unmount(const char* mountpoint) {
...
@@ -63,6 +63,22 @@ static inline void lazy_unmount(const char* mountpoint) {
LOGD
(
"hide_daemon: Unmounted (%s)
\n
"
,
mountpoint
);
LOGD
(
"hide_daemon: Unmounted (%s)
\n
"
,
mountpoint
);
}
}
static
int
parse_ppid
(
int
pid
)
{
char
path
[
32
];
int
ppid
;
sprintf
(
path
,
"/proc/%d/stat"
,
pid
);
FILE
*
stat
=
fopen
(
path
,
"re"
);
if
(
stat
==
nullptr
)
return
-
1
;
/* PID COMM STATE PPID ..... */
fscanf
(
stat
,
"%*d %*s %*c %d"
,
&
ppid
);
fclose
(
stat
);
return
ppid
;
}
static
long
xptrace
(
bool
log
,
int
request
,
pid_t
pid
,
void
*
addr
,
void
*
data
)
{
static
long
xptrace
(
bool
log
,
int
request
,
pid_t
pid
,
void
*
addr
,
void
*
data
)
{
long
ret
=
ptrace
(
request
,
pid
,
addr
,
data
);
long
ret
=
ptrace
(
request
,
pid
,
addr
,
data
);
if
(
log
&&
ret
==
-
1
)
if
(
log
&&
ret
==
-
1
)
...
@@ -115,18 +131,25 @@ static bool parse_packages_xml(string_view s) {
...
@@ -115,18 +131,25 @@ static bool parse_packages_xml(string_view s) {
}
}
static
void
check_zygote
()
{
static
void
check_zygote
()
{
int
min_zyg
=
1
;
if
(
access
(
"/system/bin/app_process64"
,
R_OK
)
==
0
)
min_zyg
=
2
;
for
(
bool
first
=
true
;
zygote_map
.
size
()
<
min_zyg
;
first
=
false
)
{
if
(
!
first
)
usleep
(
10000
);
crawl_procfs
([](
int
pid
)
->
bool
{
crawl_procfs
([](
int
pid
)
->
bool
{
char
buf
[
512
];
char
buf
[
512
];
snprintf
(
buf
,
sizeof
(
buf
),
"/proc/%d/cmdline"
,
pid
);
snprintf
(
buf
,
sizeof
(
buf
),
"/proc/%d/cmdline"
,
pid
);
FILE
*
f
=
fopen
(
buf
,
"re"
);
FILE
*
f
=
fopen
(
buf
,
"re"
);
if
(
f
)
{
if
(
f
)
{
fgets
(
buf
,
sizeof
(
buf
),
f
);
fgets
(
buf
,
sizeof
(
buf
),
f
);
if
(
strncmp
(
buf
,
"zygote"
,
6
)
==
0
)
if
(
strncmp
(
buf
,
"zygote"
,
6
)
==
0
&&
parse_ppid
(
pid
)
==
1
)
new_zygote
(
pid
);
new_zygote
(
pid
);
fclose
(
f
);
fclose
(
f
);
}
}
return
true
;
return
true
;
});
});
}
}
}
void
*
update_uid_map
(
void
*
)
{
void
*
update_uid_map
(
void
*
)
{
...
@@ -138,7 +161,7 @@ void *update_uid_map(void*) {
...
@@ -138,7 +161,7 @@ void *update_uid_map(void*) {
/*************************
/*************************
* The actual hide daemon
* The actual hide daemon
*************************
*
/
*************************/
static
void
hide_daemon
(
int
pid
)
{
static
void
hide_daemon
(
int
pid
)
{
RunFinally
fin
([
=
]()
->
void
{
RunFinally
fin
([
=
]()
->
void
{
...
@@ -208,8 +231,7 @@ static void inotify_event(int) {
...
@@ -208,8 +231,7 @@ static void inotify_event(int) {
read
(
inotify_fd
,
buf
,
sizeof
(
buf
));
read
(
inotify_fd
,
buf
,
sizeof
(
buf
));
if
((
event
->
mask
&
IN_CLOSE_WRITE
)
&&
strcmp
(
event
->
name
,
"packages.xml"
)
==
0
)
{
if
((
event
->
mask
&
IN_CLOSE_WRITE
)
&&
strcmp
(
event
->
name
,
"packages.xml"
)
==
0
)
{
LOGD
(
"proc_monitor: /data/system/packages.xml updated
\n
"
);
LOGD
(
"proc_monitor: /data/system/packages.xml updated
\n
"
);
check_zygote
();
new_daemon_thread
(
update_uid_map
);
update_uid_map
();
}
}
}
}
...
...
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