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
4fcdcd9a
Commit
4fcdcd9a
authored
Jun 04, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect UID from data directories
parent
80d834fb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
44 deletions
+15
-44
db.cpp
native/jni/core/db.cpp
+2
-3
daemon.h
native/jni/include/daemon.h
+2
-0
proc_monitor.cpp
native/jni/magiskhide/proc_monitor.cpp
+11
-41
No files found.
native/jni/core/db.cpp
View file @
4fcdcd9a
...
@@ -254,12 +254,11 @@ int validate_manager(string &alt_pkg, int userid, struct stat *st) {
...
@@ -254,12 +254,11 @@ int validate_manager(string &alt_pkg, int userid, struct stat *st) {
st
=
&
tmp_st
;
st
=
&
tmp_st
;
// Prefer DE storage
// Prefer DE storage
const
char
*
base
=
access
(
"/data/user_de"
,
F_OK
)
==
0
?
"/data/user_de"
:
"/data/user"
;
char
app_path
[
128
];
char
app_path
[
128
];
sprintf
(
app_path
,
"%s/%d/%s"
,
base
,
userid
,
alt_pkg
.
empty
()
?
"xxx"
:
alt_pkg
.
data
());
sprintf
(
app_path
,
"%s/%d/%s"
,
APP_DATA_DIR
,
userid
,
alt_pkg
.
empty
()
?
"xxx"
:
alt_pkg
.
data
());
if
(
stat
(
app_path
,
st
))
{
if
(
stat
(
app_path
,
st
))
{
// Check the official package name
// Check the official package name
sprintf
(
app_path
,
"%s/%d/"
JAVA_PACKAGE_NAME
,
base
,
userid
);
sprintf
(
app_path
,
"%s/%d/"
JAVA_PACKAGE_NAME
,
APP_DATA_DIR
,
userid
);
if
(
stat
(
app_path
,
st
))
{
if
(
stat
(
app_path
,
st
))
{
LOGE
(
"su: cannot find manager"
);
LOGE
(
"su: cannot find manager"
);
memset
(
st
,
0
,
sizeof
(
*
st
));
memset
(
st
,
0
,
sizeof
(
*
st
));
...
...
native/jni/include/daemon.h
View file @
4fcdcd9a
...
@@ -87,3 +87,5 @@ void broadcast_test();
...
@@ -87,3 +87,5 @@ void broadcast_test();
extern
int
SDK_INT
;
extern
int
SDK_INT
;
extern
bool
RECOVERY_MODE
;
extern
bool
RECOVERY_MODE
;
extern
bool
CONNECT_BROADCAST
;
extern
bool
CONNECT_BROADCAST
;
#define APP_DATA_DIR (SDK_INT >= 24 ? "/data/user_de" : "/data/user")
native/jni/magiskhide/proc_monitor.cpp
View file @
4fcdcd9a
...
@@ -76,50 +76,20 @@ static inline long xptrace(int request, pid_t pid, void *addr = nullptr, intptr_
...
@@ -76,50 +76,20 @@ static inline long xptrace(int request, pid_t pid, void *addr = nullptr, intptr_
return
xptrace
(
request
,
pid
,
addr
,
reinterpret_cast
<
void
*>
(
data
));
return
xptrace
(
request
,
pid
,
addr
,
reinterpret_cast
<
void
*>
(
data
));
}
}
static
bool
parse_packages_xml
(
string_view
s
)
{
if
(
!
str_starts
(
s
,
"<package "
))
return
true
;
/* <package key1="value1" key2="value2"....> */
char
*
start
=
(
char
*
)
s
.
data
();
start
[
s
.
length
()
-
1
]
=
'\0'
;
/* Remove trailing '>' */
start
+=
9
;
/* Skip '<package ' */
string_view
pkg
;
for
(
char
*
tok
=
start
;
*
tok
;)
{
char
*
eql
=
strchr
(
tok
,
'='
);
if
(
eql
==
nullptr
)
break
;
*
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
)
{
pkg
=
hide
.
first
;
break
;
}
}
if
(
pkg
.
empty
())
return
true
;
}
else
if
(
key
==
"userId"
||
key
==
"sharedUserId"
)
{
int
uid
=
parse_int
(
value
);
for
(
auto
&
hide
:
hide_set
)
{
if
(
hide
.
first
==
pkg
)
uid_proc_map
[
uid
].
emplace_back
(
hide
.
second
);
}
}
}
return
true
;
}
void
update_uid_map
()
{
void
update_uid_map
()
{
MutexGuard
lock
(
monitor_lock
);
MutexGuard
lock
(
monitor_lock
);
uid_proc_map
.
clear
();
uid_proc_map
.
clear
();
file_readline
(
"/data/system/packages.xml"
,
parse_packages_xml
,
true
);
string
data_path
(
APP_DATA_DIR
);
data_path
+=
"/0/"
;
size_t
len
=
data_path
.
length
();
struct
stat
st
;
for
(
auto
&
hide
:
hide_set
)
{
data_path
.
erase
(
data_path
.
begin
()
+
len
,
data_path
.
end
());
data_path
+=
hide
.
first
;
if
(
stat
(
data_path
.
data
(),
&
st
))
continue
;
uid_proc_map
[
st
.
st_uid
].
emplace_back
(
hide
.
second
);
}
}
}
static
void
check_zygote
()
{
static
void
check_zygote
()
{
...
...
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