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
983b74be
Commit
983b74be
authored
Oct 27, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass MAGISKTMP over to zygote
parent
a3eafdd2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
entry.cpp
native/jni/zygisk/entry.cpp
+7
-3
main.cpp
native/jni/zygisk/main.cpp
+7
-2
No files found.
native/jni/zygisk/entry.cpp
View file @
983b74be
...
...
@@ -70,8 +70,9 @@ static void zygisk_cleanup_wait() {
#define SECOND_STAGE_PTR "ZYGISK_PTR"
static
void
second_stage_entry
(
void
*
handle
,
char
*
path
)
{
static
void
second_stage_entry
(
void
*
handle
,
c
onst
char
*
tmp
,
c
har
*
path
)
{
self_handle
=
handle
;
MAGISKTMP
=
tmp
;
unsetenv
(
INJECT_ENV_2
);
unsetenv
(
SECOND_STAGE_PTR
);
...
...
@@ -101,6 +102,8 @@ static void first_stage_entry() {
ZLOGD
(
"inject 1st stage
\n
"
);
char
*
ld
=
getenv
(
"LD_PRELOAD"
);
char
tmp
[
128
];
strlcpy
(
tmp
,
getenv
(
"MAGISKTMP"
),
sizeof
(
tmp
));
char
*
path
;
if
(
char
*
c
=
strrchr
(
ld
,
':'
))
{
*
c
=
'\0'
;
...
...
@@ -111,6 +114,7 @@ static void first_stage_entry() {
path
=
strdup
(
ld
);
}
unsetenv
(
INJECT_ENV_1
);
unsetenv
(
"MAGISKTMP"
);
sanitize_environ
();
// Update path to 2nd stage lib
...
...
@@ -128,7 +132,7 @@ static void first_stage_entry() {
char
*
env
=
getenv
(
SECOND_STAGE_PTR
);
decltype
(
&
second_stage_entry
)
second_stage
;
sscanf
(
env
,
"%p"
,
&
second_stage
);
second_stage
(
handle
,
path
);
second_stage
(
handle
,
tmp
,
path
);
}
__attribute__
((
constructor
))
...
...
@@ -308,7 +312,7 @@ static void setup_files(int client, const sock_cred *cred) {
string
path
=
MAGISKTMP
+
"/"
ZYGISKBIN
"/zygisk."
+
basename
(
buf
);
cp_afc
(
buf
,
(
path
+
".1.so"
).
data
());
cp_afc
(
buf
,
(
path
+
".2.so"
).
data
());
write_string
(
client
,
path
);
write_string
(
client
,
MAGISKTMP
);
}
static
void
magiskd_passthrough
(
int
client
)
{
...
...
native/jni/zygisk/main.cpp
View file @
983b74be
...
...
@@ -69,8 +69,12 @@ int app_process_main(int argc, char *argv[]) {
if
(
app_proc_fd
<
0
)
break
;
string
path
=
read_string
(
socket
);
string
lib
=
path
+
".1.so"
;
string
tmp
=
read_string
(
socket
);
#if defined(__LP64__)
string
lib
=
tmp
+
"/"
ZYGISKBIN
"/zygisk.app_process64.1.so"
;
#else
string
lib
=
tmp
+
"/"
ZYGISKBIN
"/zygisk.app_process32.1.so"
;
#endif
if
(
char
*
ld
=
getenv
(
"LD_PRELOAD"
))
{
char
env
[
256
];
sprintf
(
env
,
"%s:%s"
,
ld
,
lib
.
data
());
...
...
@@ -79,6 +83,7 @@ int app_process_main(int argc, char *argv[]) {
setenv
(
"LD_PRELOAD"
,
lib
.
data
(),
1
);
}
setenv
(
INJECT_ENV_1
,
"1"
,
1
);
setenv
(
"MAGISKTMP"
,
tmp
.
data
(),
1
);
close
(
socket
);
...
...
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