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
30eb4074
Commit
30eb4074
authored
Jun 10, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update binary dump method
parent
9929e7d8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
build.py
build.py
+20
-12
magiskinit.c
native/jni/core/magiskinit.c
+3
-2
No files found.
build.py
View file @
30eb4074
...
...
@@ -42,6 +42,7 @@ else:
ndk_build
=
os
.
path
.
join
(
os
.
environ
[
'ANDROID_HOME'
],
'ndk-bundle'
,
'ndk-build'
)
cpu_count
=
multiprocessing
.
cpu_count
()
archs
=
[
'armeabi-v7a'
,
'x86'
]
def
mv
(
source
,
target
):
try
:
...
...
@@ -79,13 +80,13 @@ def zip_with_msg(zipfile, source, target):
zipfile
.
write
(
source
,
target
)
def
build_all
(
args
):
build_binary
(
args
)
build_apk
(
args
)
build_binary
(
args
)
zip_main
(
args
)
zip_uninstaller
(
args
)
def
collect_binary
():
for
arch
in
[
'armeabi-v7a'
,
'x86'
]
:
for
arch
in
archs
:
mkdir_p
(
os
.
path
.
join
(
'native'
,
'out'
,
arch
))
for
bin
in
[
'magisk'
,
'magiskinit'
,
'magiskboot'
,
'busybox'
,
'b64xz'
]:
source
=
os
.
path
.
join
(
'native'
,
'libs'
,
arch
,
bin
)
...
...
@@ -139,16 +140,13 @@ def build_binary(args):
flags
=
base_flags
if
'magiskinit'
in
targets
:
# We need to create dump.h beforehand
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
'native'
,
'out'
,
'armeabi-v7a'
,
'magisk'
)):
error
(
'Build "magisk" before building "magiskinit"'
)
for
arch
in
[
'armeabi-v7a'
,
'x86'
]:
with
open
(
os
.
path
.
join
(
'native'
,
'out'
,
arch
,
'dump.h'
),
'w'
)
as
dump
:
dump
.
write
(
'#include "stdlib.h"
\n
'
)
with
open
(
os
.
path
.
join
(
'native'
,
'out'
,
arch
,
'magisk'
),
'rb'
)
as
bin
:
dump
.
write
(
'const uint8_t magisk_dump[] = "'
)
dump
.
write
(
''
.
join
(
"
\\
x{:02X}"
.
format
(
c
)
for
c
in
lzma
.
compress
(
bin
.
read
(),
preset
=
9
)))
dump
.
write
(
'";
\n
'
)
for
arch
in
archs
:
bin_file
=
os
.
path
.
join
(
'native'
,
'out'
,
arch
,
'magisk'
)
if
not
os
.
path
.
exists
(
bin_file
):
error
(
'Build "magisk" before building "magiskinit"'
)
with
open
(
os
.
path
.
join
(
'native'
,
'out'
,
arch
,
'binaries_arch_xz.h'
),
'w'
)
as
out
:
with
open
(
bin_file
,
'rb'
)
as
src
:
xz_dump
(
src
,
out
,
'magisk_xz'
)
flags
+=
' B_INIT=1'
other
=
True
...
...
@@ -239,8 +237,18 @@ def build_snet(args):
with
zipfile
.
ZipFile
(
source
)
as
zin
:
for
item
in
zin
.
infolist
():
zout
.
writestr
(
item
.
filename
,
zin
.
read
(
item
))
rm
(
source
)
header
(
'Output: '
+
target
)
def
xz_dump
(
src
,
out
,
var_name
):
out
.
write
(
'const static unsigned char {}[] = {{'
.
format
(
var_name
))
for
i
,
c
in
enumerate
(
lzma
.
compress
(
src
.
read
(),
preset
=
9
)):
if
i
%
16
==
0
:
out
.
write
(
'
\n
'
)
out
.
write
(
'0x{:02X},'
.
format
(
c
))
out
.
write
(
'
\n
};
\n
'
)
out
.
flush
()
def
gen_update_binary
():
update_bin
=
[]
binary
=
os
.
path
.
join
(
'native'
,
'out'
,
'armeabi-v7a'
,
'b64xz'
)
...
...
native/jni/core/magiskinit.c
View file @
30eb4074
...
...
@@ -39,7 +39,8 @@
#include <lzma.h>
#include <cil/cil.h>
#include "dump.h"
#include "binaries_arch_xz.h"
#include "magiskrc.h"
#include "utils.h"
#include "magiskpolicy.h"
...
...
@@ -321,7 +322,7 @@ static int unxz(const void *buf, size_t size, int fd) {
static
int
dump_magisk
(
const
char
*
path
,
mode_t
mode
)
{
unlink
(
path
);
int
fd
=
creat
(
path
,
mode
);
int
ret
=
unxz
(
magisk_
dump
,
sizeof
(
magisk_dump
),
fd
);
int
ret
=
unxz
(
magisk_
xz
,
sizeof
(
magisk_xz
),
fd
);
close
(
fd
);
return
ret
;
}
...
...
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