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
f24a5dfd
Commit
f24a5dfd
authored
Mar 09, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More efficient xml parsing
parent
081074ad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
16 deletions
+19
-16
proc_monitor.cpp
native/jni/magiskhide/proc_monitor.cpp
+16
-14
file.cpp
native/jni/utils/file.cpp
+3
-2
No files found.
native/jni/magiskhide/proc_monitor.cpp
View file @
f24a5dfd
...
...
@@ -99,27 +99,29 @@ static bool parse_packages_xml(string_view s) {
return
true
;
/* <package key1="value1" key2="value2"....> */
char
*
start
=
(
char
*
)
s
.
data
();
start
[
s
.
length
()
-
2
]
=
'\0'
;
/* Remove trailing '>' */
start
[
s
.
length
()
-
1
]
=
'\0'
;
/* Remove trailing '>' */
start
+=
9
;
/* Skip '<package ' */
char
key
[
32
],
value
[
1024
];
const
char
*
pkg
=
nullptr
;
char
*
tok
;
while
((
tok
=
strtok_r
(
nullptr
,
" "
,
&
start
)))
{
sscanf
(
tok
,
"%[^=]=
\"
%[^
\"
]"
,
key
,
value
);
string_view
key_view
(
key
);
string_view
value_view
(
value
);
if
(
key_view
==
"name"
)
{
string_view
pkg
;
for
(
char
*
tok
=
start
;
*
tok
;)
{
char
*
eql
=
strchr
(
tok
,
'='
);
*
eql
=
'\0'
;
/* Terminate '=' */
string_view
key
(
tok
,
eql
-
tok
);
eql
+=
2
;
/* Skip '="' */
tok
=
strchr
(
eql
,
'\"'
);
/* Find closing '"' */
*
tok
=
'\0'
;
string_view
value
(
eql
,
tok
-
eql
);
tok
+=
2
;
if
(
key
==
"name"
)
{
for
(
auto
&
hide
:
hide_set
)
{
if
(
hide
.
first
==
value
_view
)
{
pkg
=
hide
.
first
.
data
()
;
if
(
hide
.
first
==
value
)
{
pkg
=
hide
.
first
;
break
;
}
}
if
(
!
pkg
)
if
(
pkg
.
empty
()
)
return
true
;
}
else
if
(
key
_view
==
"userId"
||
key_view
==
"sharedUserId"
)
{
}
else
if
(
key
==
"userId"
||
key
==
"sharedUserId"
)
{
int
uid
=
parse_int
(
value
);
for
(
auto
&
hide
:
hide_set
)
{
if
(
hide
.
first
==
pkg
)
...
...
native/jni/utils/file.cpp
View file @
f24a5dfd
...
...
@@ -378,8 +378,9 @@ void file_readline(const char *file, const function<bool (string_view)> &fn, boo
while
((
read
=
getline
(
&
buf
,
&
len
,
fp
))
>=
0
)
{
start
=
buf
;
if
(
trim
)
{
while
(
buf
[
read
-
1
]
==
'\n'
||
buf
[
read
-
1
]
==
' '
)
buf
[
read
--
-
1
]
=
'\0'
;
while
(
read
&&
(
buf
[
read
-
1
]
==
'\n'
||
buf
[
read
-
1
]
==
' '
))
--
read
;
buf
[
read
]
=
'\0'
;
while
(
*
start
==
' '
)
++
start
;
}
...
...
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