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
cd5384f1
Commit
cd5384f1
authored
Nov 22, 2022
by
LoveSy
Committed by
John Wu
Nov 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crashes whenever a zygisk module has ver > 4
parent
11b2ddba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
hook.cpp
native/src/zygisk/hook.cpp
+11
-6
module.hpp
native/src/zygisk/module.hpp
+3
-0
No files found.
native/src/zygisk/hook.cpp
View file @
cd5384f1
...
...
@@ -2,6 +2,7 @@
#include <sys/mount.h>
#include <dlfcn.h>
#include <bitset>
#include <list>
#include <xhook.h>
...
...
@@ -54,7 +55,7 @@ struct HookContext {
}
args
;
const
char
*
process
;
vector
<
ZygiskModule
>
modules
;
list
<
ZygiskModule
>
modules
;
int
pid
;
bitset
<
FLAG_MAX
>
flags
;
...
...
@@ -485,10 +486,6 @@ void HookContext::fork_post() {
}
void
HookContext
::
run_modules_pre
(
const
vector
<
int
>
&
fds
)
{
// Because the data structure stored in the vector is self referencing, in order to prevent
// dangling pointers, the vector has to be pre-allocated to ensure reallocation does not occur
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
))
{
...
...
@@ -509,8 +506,16 @@ void HookContext::run_modules_pre(const vector<int> &fds) {
close
(
fds
[
i
]);
}
for
(
auto
it
=
modules
.
begin
();
it
!=
modules
.
end
();)
{
it
->
onLoad
(
env
);
if
(
it
->
valid
())
{
++
it
;
}
else
{
it
=
modules
.
erase
(
it
);
}
}
for
(
auto
&
m
:
modules
)
{
m
.
onLoad
(
env
);
if
(
flags
[
APP_SPECIALIZE
])
{
m
.
preAppSpecialize
(
args
.
app
);
}
else
if
(
flags
[
SERVER_FORK_AND_SPECIALIZE
])
{
...
...
native/src/zygisk/module.hpp
View file @
cd5384f1
...
...
@@ -180,6 +180,9 @@ struct ZygiskModule {
void
postServerSpecialize
(
const
ServerSpecializeArgs_v1
*
args
)
const
{
mod
.
v1
->
postServerSpecialize
(
mod
.
v1
->
impl
,
args
);
}
bool
valid
()
const
{
return
entry
.
fn
&&
mod
.
api_version
;
}
int
connectCompanion
()
const
;
int
getModuleDir
()
const
;
...
...
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