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
50ff1140
Commit
50ff1140
authored
Feb 18, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap out inotify fd before adding watch targets
parent
31a27838
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
proc_monitor.cpp
native/jni/magiskhide/proc_monitor.cpp
+9
-5
No files found.
native/jni/magiskhide/proc_monitor.cpp
View file @
50ff1140
...
@@ -193,6 +193,7 @@ static int xinotify_add_watch(int fd, const char* path, uint32_t mask) {
...
@@ -193,6 +193,7 @@ static int xinotify_add_watch(int fd, const char* path, uint32_t mask) {
static
int
new_inotify
;
static
int
new_inotify
;
static
const
string_view
APK_EXT
(
".apk"
);
static
const
string_view
APK_EXT
(
".apk"
);
static
vector
<
string
>
hide_apks
;
static
bool
parse_packages_xml
(
string_view
&
s
)
{
static
bool
parse_packages_xml
(
string_view
&
s
)
{
if
(
!
str_starts
(
s
,
"<package "
))
if
(
!
str_starts
(
s
,
"<package "
))
...
@@ -212,7 +213,7 @@ static bool parse_packages_xml(string_view &s) {
...
@@ -212,7 +213,7 @@ static bool parse_packages_xml(string_view &s) {
}
else
if
(
strcmp
(
key
,
"codePath"
)
==
0
)
{
}
else
if
(
strcmp
(
key
,
"codePath"
)
==
0
)
{
if
(
ends_with
(
value_view
,
APK_EXT
))
{
if
(
ends_with
(
value_view
,
APK_EXT
))
{
// Directly add to inotify list
// Directly add to inotify list
xinotify_add_watch
(
new_inotify
,
value
,
IN_OPEN
);
hide_apks
.
emplace_back
(
value
);
}
else
{
}
else
{
DIR
*
dir
=
opendir
(
value
);
DIR
*
dir
=
opendir
(
value
);
if
(
dir
==
nullptr
)
if
(
dir
==
nullptr
)
...
@@ -222,7 +223,7 @@ static bool parse_packages_xml(string_view &s) {
...
@@ -222,7 +223,7 @@ static bool parse_packages_xml(string_view &s) {
if
(
ends_with
(
entry
->
d_name
,
APK_EXT
))
{
if
(
ends_with
(
entry
->
d_name
,
APK_EXT
))
{
strcpy
(
value
+
value_view
.
length
(),
"/"
);
strcpy
(
value
+
value_view
.
length
(),
"/"
);
strcpy
(
value
+
value_view
.
length
()
+
1
,
entry
->
d_name
);
strcpy
(
value
+
value_view
.
length
()
+
1
,
entry
->
d_name
);
xinotify_add_watch
(
new_inotify
,
value
,
IN_OPEN
);
hide_apks
.
emplace_back
(
value
);
break
;
break
;
}
}
}
}
...
@@ -244,19 +245,22 @@ void update_inotify_mask() {
...
@@ -244,19 +245,22 @@ void update_inotify_mask() {
fcntl
(
new_inotify
,
F_SETFD
,
FD_CLOEXEC
);
fcntl
(
new_inotify
,
F_SETFD
,
FD_CLOEXEC
);
LOGD
(
"proc_monitor: Updating inotify list
\n
"
);
LOGD
(
"proc_monitor: Updating inotify list
\n
"
);
hide_apks
.
clear
();
{
{
MutexGuard
lock
(
list_lock
);
MutexGuard
lock
(
list_lock
);
hide_uid
.
clear
();
hide_uid
.
clear
();
file_readline
(
"/data/system/packages.xml"
,
parse_packages_xml
,
true
);
file_readline
(
"/data/system/packages.xml"
,
parse_packages_xml
,
true
);
}
}
// Add /data/system to monitor /data/system/packages.xml
// Swap out and close old inotify_fd
xinotify_add_watch
(
new_inotify
,
"/data/system"
,
IN_CLOSE_WRITE
);
int
tmp
=
inotify_fd
;
int
tmp
=
inotify_fd
;
inotify_fd
=
new_inotify
;
inotify_fd
=
new_inotify
;
if
(
tmp
>=
0
)
if
(
tmp
>=
0
)
close
(
tmp
);
close
(
tmp
);
for
(
auto
apk
:
hide_apks
)
xinotify_add_watch
(
inotify_fd
,
apk
.
data
(),
IN_OPEN
);
xinotify_add_watch
(
inotify_fd
,
"/data/system"
,
IN_CLOSE_WRITE
);
}
}
void
proc_monitor
()
{
void
proc_monitor
()
{
...
...
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