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
9e821808
Commit
9e821808
authored
Mar 22, 2022
by
LoveSy
Committed by
John Wu
Mar 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only dlopen valid fd
parent
3f660a39
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
hook.cpp
native/jni/zygisk/hook.cpp
+5
-0
main.cpp
native/jni/zygisk/main.cpp
+11
-8
No files found.
native/jni/zygisk/hook.cpp
View file @
9e821808
...
...
@@ -359,6 +359,11 @@ void HookContext::run_modules_pre(const vector<int> &fds) {
modules
.
reserve
(
fds
.
size
());
for
(
int
i
=
0
;
i
<
fds
.
size
();
++
i
)
{
struct
stat
s
{};
if
(
fstat
(
fds
[
i
],
&
s
)
!=
0
||
!
S_ISREG
(
s
.
st_mode
))
{
close
(
fds
[
i
]);
continue
;
}
android_dlextinfo
info
{
.
flags
=
ANDROID_DLEXT_USE_LIBRARY_FD
,
.
library_fd
=
fds
[
i
],
...
...
native/jni/zygisk/main.cpp
View file @
9e821808
...
...
@@ -114,14 +114,17 @@ static void zygiskd(int socket) {
vector
<
int
>
module_fds
=
recv_fds
(
socket
);
for
(
int
fd
:
module_fds
)
{
comp_entry
entry
=
nullptr
;
android_dlextinfo
info
{
.
flags
=
ANDROID_DLEXT_USE_LIBRARY_FD
,
.
library_fd
=
fd
,
};
if
(
void
*
h
=
android_dlopen_ext
(
"/jit-cache"
,
RTLD_LAZY
,
&
info
))
{
*
(
void
**
)
&
entry
=
dlsym
(
h
,
"zygisk_companion_entry"
);
}
else
{
LOGW
(
"Failed to dlopen zygisk module: %s
\n
"
,
dlerror
());
struct
stat
s
{};
if
(
fstat
(
fd
,
&
s
)
==
0
&&
S_ISREG
(
s
.
st_mode
))
{
android_dlextinfo
info
{
.
flags
=
ANDROID_DLEXT_USE_LIBRARY_FD
,
.
library_fd
=
fd
,
};
if
(
void
*
h
=
android_dlopen_ext
(
"/jit-cache"
,
RTLD_LAZY
,
&
info
))
{
*
(
void
**
)
&
entry
=
dlsym
(
h
,
"zygisk_companion_entry"
);
}
else
{
LOGW
(
"Failed to dlopen zygisk module: %s
\n
"
,
dlerror
());
}
}
modules
.
push_back
(
entry
);
close
(
fd
);
...
...
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