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
9e737df5
Commit
9e737df5
authored
Mar 10, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update high compression mode detection logic
parent
0b3192c4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
13 deletions
+30
-13
ramdisk.c
native/jni/magiskboot/ramdisk.c
+7
-3
boot_patch.sh
scripts/boot_patch.sh
+21
-8
magisk_uninstaller.sh
scripts/magisk_uninstaller.sh
+2
-2
No files found.
native/jni/magiskboot/ramdisk.c
View file @
9e737df5
...
...
@@ -34,18 +34,22 @@ static void cpio_patch(struct vector *v, int keepverity, int keepforceencrypt) {
#define STOCK_BOOT 0x0
#define MAGISK_PATCH 0x1
#define OTHER_PATCH 0x2
#define HIGH_COMPRESS 0x2
#define OTHER_PATCH 0x3
static
int
cpio_test
(
struct
vector
*
v
)
{
const
char
*
OTHER_LIST
[]
=
{
"sbin/launch_daemonsu.sh"
,
"sbin/su"
,
"init.xposed.rc"
,
"boot/sbin/launch_daemonsu.sh"
,
NULL
};
const
char
*
MAGISK_LIST
[]
=
{
".backup/.magisk"
,
"init.magisk.rc"
,
"overlay/init.magisk.rc"
,
NULL
};
for
(
int
i
=
0
;
OTHER_LIST
[
i
];
++
i
)
if
(
cpio_find
(
v
,
OTHER_LIST
[
i
])
>
0
)
if
(
cpio_find
(
v
,
OTHER_LIST
[
i
])
>
=
0
)
return
OTHER_PATCH
;
if
(
cpio_find
(
v
,
"ramdisk.cpio.xz"
)
>=
0
)
return
HIGH_COMPRESS
;
for
(
int
i
=
0
;
MAGISK_LIST
[
i
];
++
i
)
if
(
cpio_find
(
v
,
MAGISK_LIST
[
i
])
>
0
)
if
(
cpio_find
(
v
,
MAGISK_LIST
[
i
])
>
=
0
)
return
MAGISK_PATCH
;
return
STOCK_BOOT
;
...
...
scripts/boot_patch.sh
View file @
9e737df5
...
...
@@ -91,9 +91,7 @@ case $? in
abort
"! Unable to unpack boot image"
;;
2
)
ui_print
"! Insufficient boot partition size detected"
HIGHCOMP
=
true
ui_print
"- Enable high compression mode"
;;
3
)
ui_print
"- ChromeOS boot image detected"
...
...
@@ -114,6 +112,7 @@ esac
# Test patch status and do restore, after this section, ramdisk.cpio.orig is guaranteed to exist
ui_print
"- Checking ramdisk status"
MAGISK_PATCHED
=
false
./magiskboot
--cpio
ramdisk.cpio
test
case
$?
in
0
)
# Stock boot
...
...
@@ -125,18 +124,32 @@ case $? in
cp
-af
ramdisk.cpio ramdisk.cpio.orig
;;
1
)
# Magisk patched
ui_print
"- Magisk patched image detected"
# Find SHA1 of stock boot image
[
-z
$SHA1
]
&&
SHA1
=
`
./magiskboot
--cpio
ramdisk.cpio sha1 2>/dev/null
`
./magiskboot
--cpio
ramdisk.cpio restore
cp
-af
ramdisk.cpio ramdisk.cpio.orig
MAGISK_PATCHED
=
true
HIGHCOMP
=
false
;;
2
)
# Other patched
2
)
# High compression mode
MAGISK_PATCHED
=
true
HIGHCOMP
=
true
;;
3
)
# Other patched
ui_print
"! Boot image patched by other programs"
abort
"! Please restore stock boot image"
;;
esac
if
$MAGISK_PATCHED
;
then
ui_print
"- Magisk patched image detected"
# Find SHA1 of stock boot image
[
-z
$SHA1
]
&&
SHA1
=
`
./magiskboot
--cpio
ramdisk.cpio sha1 2>/dev/null
`
./magiskboot
--cpio
ramdisk.cpio restore
cp
-af
ramdisk.cpio ramdisk.cpio.orig
fi
if
$HIGHCOMP
;
then
ui_print
"! Insufficient boot partition size detected"
ui_print
"- Enable high compression mode"
fi
##########################################################################################
# Ramdisk patches
##########################################################################################
...
...
scripts/magisk_uninstaller.sh
View file @
9e737df5
...
...
@@ -73,7 +73,7 @@ case $? in
ui_print
"- Stock boot image detected"
abort
"! Magisk is not installed!"
;;
1
)
# Magisk patched
1
|2
)
# Magisk patched
ui_print
"- Magisk patched image detected"
# Find SHA1 of stock boot image
[
-z
$SHA1
]
&&
SHA1
=
`
./magiskboot
--cpio
ramdisk.cpio sha1 2>/dev/null
`
...
...
@@ -89,7 +89,7 @@ case $? in
flash_boot_image new-boot.img
"
$BOOTIMAGE
"
fi
;;
2
)
# Other patched
3
)
# Other patched
ui_print
"! Boot image patched by other programs"
abort
"! Cannot uninstall"
;;
...
...
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