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
3b8ce850
Commit
3b8ce850
authored
Sep 15, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Zygisk
parent
b6298f86
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
6 deletions
+26
-6
module.cpp
native/jni/core/module.cpp
+20
-1
magisk.hpp
native/jni/include/magisk.hpp
+1
-0
files.cpp
native/jni/utils/files.cpp
+2
-2
files.hpp
native/jni/utils/files.hpp
+1
-1
xwrap.cpp
native/jni/utils/xwrap.cpp
+1
-1
entry.cpp
native/jni/zygisk/entry.cpp
+1
-1
No files found.
native/jni/core/module.cpp
View file @
3b8ce850
...
...
@@ -542,6 +542,19 @@ static void inject_magisk_bins(root_node *system) {
delete
bin
->
extract
(
init_applet
[
i
]);
}
#define mount_zygisk(bit) \
if (access("/system/bin/app_process" #bit, F_OK) == 0) { \
string zbin = zygisk_bin + "/app_process" #bit; \
string mbin = MAGISKTMP + "/magisk" #bit; \
int src = xopen(mbin.data(), O_RDONLY); \
int out = xopen(zbin.data(), O_CREAT | O_WRONLY, 0); \
xsendfile(out, src, nullptr, INT_MAX); \
close(src); \
close(out); \
clone_attr("/system/bin/app_process" #bit, zbin.data()); \
bind_mount(zbin.data(), "/system/bin/app_process" #bit); \
}
void
magic_mount
()
{
node_entry
::
mirror_dir
=
MAGISKTMP
+
"/"
MIRRDIR
;
node_entry
::
module_mnt
=
MAGISKTMP
+
"/"
MODULEMNT
"/"
;
...
...
@@ -592,7 +605,7 @@ void magic_mount() {
for
(
const
char
*
part
:
{
"/vendor"
,
"/product"
,
"/system_ext"
})
{
struct
stat
st
;
if
(
lstat
(
part
,
&
st
)
==
0
&&
S_ISDIR
(
st
.
st_mode
))
{
if
(
auto
old
=
system
->
extract
(
part
+
1
)
;
old
)
{
if
(
auto
old
=
system
->
extract
(
part
+
1
))
{
auto
new_node
=
new
root_node
(
old
);
root
->
insert
(
new_node
);
}
...
...
@@ -601,6 +614,12 @@ void magic_mount() {
root
->
prepare
();
root
->
mount
();
// Mount on top of modules to enable zygisk
string
zygisk_bin
=
MAGISKTMP
+
"/"
ZYGISKBIN
;
mkdir
(
zygisk_bin
.
data
(),
0
);
mount_zygisk
(
32
)
mount_zygisk
(
64
)
}
static
void
prepare_modules
()
{
...
...
native/jni/include/magisk.hpp
View file @
3b8ce850
...
...
@@ -26,6 +26,7 @@ extern std::string MAGISKTMP;
#define ROOTOVL INTLROOT "/rootdir"
#define SHELLPTS INTLROOT "/pts"
#define ROOTMNT ROOTOVL "/.mount_list"
#define ZYGISKBIN INTLROOT "/zygisk"
constexpr
const
char
*
applet_names
[]
=
{
"su"
,
"resetprop"
,
nullptr
};
constexpr
const
char
*
init_applet
[]
=
{
"magiskpolicy"
,
"supolicy"
,
nullptr
};
...
...
native/jni/utils/files.cpp
View file @
3b8ce850
...
...
@@ -26,7 +26,7 @@ int fd_pathat(int dirfd, const char *name, char *path, size_t size) {
return
0
;
}
int
mkdirs
(
string
path
,
mode_t
mode
)
{
int
mkdirs
(
string
_view
path
,
mode_t
mode
)
{
errno
=
0
;
for
(
char
*
p
=
path
.
data
()
+
1
;
*
p
;
++
p
)
{
if
(
*
p
==
'/'
)
{
...
...
@@ -420,7 +420,7 @@ void restore_folder(const char *dir, vector<raw_file> &files) {
for
(
raw_file
&
file
:
files
)
{
string
path
=
base
+
"/"
+
file
.
path
;
if
(
S_ISDIR
(
file
.
attr
.
st
.
st_mode
))
{
mkdirs
(
path
.
data
()
,
0
);
mkdirs
(
path
,
0
);
}
else
if
(
S_ISREG
(
file
.
attr
.
st
.
st_mode
))
{
auto
fp
=
xopen_file
(
path
.
data
(),
"we"
);
if
(
fp
)
fwrite
(
file
.
buf
,
1
,
file
.
sz
,
fp
.
get
());
...
...
native/jni/utils/files.hpp
View file @
3b8ce850
...
...
@@ -32,7 +32,7 @@ struct raw_file {
ssize_t
fd_path
(
int
fd
,
char
*
path
,
size_t
size
);
int
fd_pathat
(
int
dirfd
,
const
char
*
name
,
char
*
path
,
size_t
size
);
int
mkdirs
(
std
::
string
path
,
mode_t
mode
);
int
mkdirs
(
std
::
string
_view
path
,
mode_t
mode
);
void
rm_rf
(
const
char
*
path
);
void
mv_path
(
const
char
*
src
,
const
char
*
dest
);
void
mv_dir
(
int
src
,
int
dest
);
...
...
native/jni/utils/xwrap.cpp
View file @
3b8ce850
...
...
@@ -466,7 +466,7 @@ void *xmmap(void *addr, size_t length, int prot, int flags,
ssize_t
xsendfile
(
int
out_fd
,
int
in_fd
,
off_t
*
offset
,
size_t
count
)
{
ssize_t
ret
=
sendfile
(
out_fd
,
in_fd
,
offset
,
count
);
if
(
count
!=
ret
)
{
if
(
ret
<
0
)
{
PLOGE
(
"sendfile"
);
}
return
ret
;
...
...
native/jni/zygisk/entry.cpp
View file @
3b8ce850
...
...
@@ -247,7 +247,7 @@ static void setup_files(int client, ucred *cred) {
write_int
(
client
,
0
);
string
path
=
MAGISKTMP
+
"/zygisk."
+
basename
(
buf
);
string
path
=
MAGISKTMP
+
"/
"
ZYGISKBIN
"/
zygisk."
+
basename
(
buf
);
cp_afc
(
buf
,
(
path
+
".1.so"
).
data
());
cp_afc
(
buf
,
(
path
+
".2.so"
).
data
());
...
...
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