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
1735a713
Unverified
Commit
1735a713
authored
Aug 08, 2022
by
残页
Committed by
GitHub
Aug 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `ANDROID_DLEXT_FORCE_LOAD` to load second stage if possible
Fix #6095
parent
52ba6d11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
entry.cpp
native/src/zygisk/entry.cpp
+20
-10
No files found.
native/src/zygisk/entry.cpp
View file @
1735a713
...
...
@@ -51,16 +51,20 @@ static void *unload_first_stage(void *) {
return
nullptr
;
}
#if defined(__LP64__)
// Use symlink to workaround linker bug on old broken Android
// https://issuetracker.google.com/issues/36914295
#define SECOND_STAGE_PATH "/system/bin/app_process"
#else
#define SECOND_STAGE_PATH "/system/bin/app_process32"
#endif
static
void
second_stage_entry
()
{
zygisk_logging
();
ZLOGD
(
"inject 2nd stage
\n
"
);
MAGISKTMP
=
getenv
(
MAGISKTMP_ENV
);
#if defined(__LP64__)
self_handle
=
dlopen
(
"/system/bin/app_process"
,
RTLD_NOLOAD
);
#else
self_handle
=
dlopen
(
"/system/bin/app_process32"
,
RTLD_NOLOAD
);
#endif
self_handle
=
dlopen
(
SECOND_STAGE_PATH
,
RTLD_NOLOAD
);
dlclose
(
self_handle
);
unsetenv
(
MAGISKTMP_ENV
);
...
...
@@ -81,12 +85,18 @@ static void first_stage_entry() {
}
// Load second stage
android_dlextinfo
info
{
.
flags
=
ANDROID_DLEXT_FORCE_LOAD
};
setenv
(
INJECT_ENV_2
,
"1"
,
1
);
#if defined(__LP64__)
dlopen
(
"/system/bin/app_process"
,
RTLD_LAZY
);
#else
dlopen
(
"/system/bin/app_process32"
,
RTLD_LAZY
);
#endif
if
(
android_dlopen_ext
(
SECOND_STAGE_PATH
,
RTLD_LAZY
,
&
info
)
==
nullptr
)
{
// Android 5.x doesn't support ANDROID_DLEXT_FORCE_LOAD
ZLOGI
(
"ANDROID_DLEXT_FORCE_LOAD is not supported, fallback to dlopen
\n
"
);
if
(
dlopen
(
SECOND_STAGE_PATH
,
RTLD_LAZY
)
==
nullptr
)
{
ZLOGE
(
"Cannot load the second stage
\n
"
);
unsetenv
(
INJECT_ENV_2
);
}
}
}
[[
gnu
::
constructor
]]
[[
maybe_unused
]]
...
...
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