mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
Add support to remove avb verity
This commit is contained in:
parent
811489f157
commit
2487ec94e6
@ -208,8 +208,13 @@ static void cpio_test(struct vector *v) {
|
|||||||
int check_verity_pattern(const char *s) {
|
int check_verity_pattern(const char *s) {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
if (s[0] == ',') ++pos;
|
if (s[0] == ',') ++pos;
|
||||||
if (strncmp(s + pos, "verify", 6) != 0) return -1;
|
if (strncmp(s + pos, "verify", 6) == 0)
|
||||||
pos += 6;
|
pos += 6;
|
||||||
|
else if (strncmp(s + pos, "avb", 3) == 0)
|
||||||
|
pos += 3;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (s[pos] == '=') {
|
if (s[pos] == '=') {
|
||||||
while (s[pos] != '\0' && s[pos] != ' ' && s[pos] != '\n' && s[pos] != ',') ++pos;
|
while (s[pos] != '\0' && s[pos] != ' ' && s[pos] != '\n' && s[pos] != ',') ++pos;
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,24 @@
|
|||||||
|
|
||||||
extern int check_verity_pattern(const char *s);
|
extern int check_verity_pattern(const char *s);
|
||||||
|
|
||||||
|
static void print_props(const void *fdt, int node, int depth) {
|
||||||
|
int prop;
|
||||||
|
fdt_for_each_property_offset(prop, fdt, node) {
|
||||||
|
for (int i = 0; i < depth; ++i) printf(" ");
|
||||||
|
printf(" ");
|
||||||
|
int size;
|
||||||
|
const char *name;
|
||||||
|
const char *value = fdt_getprop_by_offset(fdt, prop, &name, &size);
|
||||||
|
printf("[%s]: [%s]\n", name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void print_subnode(const void *fdt, int parent, int depth) {
|
static void print_subnode(const void *fdt, int parent, int depth) {
|
||||||
int node;
|
int node;
|
||||||
fdt_for_each_subnode(node, fdt, parent) {
|
fdt_for_each_subnode(node, fdt, parent) {
|
||||||
for (int i = 0; i < depth; ++i) printf(" ");
|
for (int i = 0; i < depth; ++i) printf(" ");
|
||||||
printf("%d: %s\n", node, fdt_get_name(fdt, node, NULL));
|
printf("#%d: %s\n", node, fdt_get_name(fdt, node, NULL));
|
||||||
|
print_props(fdt, node, depth);
|
||||||
print_subnode(fdt, node, depth + 1);
|
print_subnode(fdt, node, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -28,7 +41,7 @@ static int find_fstab(const void *fdt, int parent) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dtb_print(const char *file) {
|
void dtb_dump(const char *file) {
|
||||||
size_t size ;
|
size_t size ;
|
||||||
void *dtb, *fdt;
|
void *dtb, *fdt;
|
||||||
fprintf(stderr, "Loading dtbs from [%s]\n", file);
|
fprintf(stderr, "Loading dtbs from [%s]\n", file);
|
||||||
@ -38,7 +51,7 @@ void dtb_print(const char *file) {
|
|||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
if (memcmp(dtb + i, DTB_MAGIC, 4) == 0) {
|
if (memcmp(dtb + i, DTB_MAGIC, 4) == 0) {
|
||||||
fdt = dtb + i;
|
fdt = dtb + i;
|
||||||
fprintf(stderr, "\nPrinting dtb.%04d\n\n", dtb_num++);
|
fprintf(stderr, "Dumping dtb.%04d\n\n", dtb_num++);
|
||||||
print_subnode(fdt, 0, 0);
|
print_subnode(fdt, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ int parse_img(void *orig, size_t size, boot_img *boot);
|
|||||||
int cpio_commands(const char *command, int argc, char *argv[]);
|
int cpio_commands(const char *command, int argc, char *argv[]);
|
||||||
void comp_file(const char *method, const char *from, const char *to);
|
void comp_file(const char *method, const char *from, const char *to);
|
||||||
void decomp_file(char *from, const char *to);
|
void decomp_file(char *from, const char *to);
|
||||||
void dtb_print(const char *file);
|
void dtb_dump(const char *file);
|
||||||
void dtb_patch(const char *file);
|
void dtb_patch(const char *file);
|
||||||
|
|
||||||
// Compressions
|
// Compressions
|
||||||
|
@ -45,7 +45,7 @@ static void usage(char *arg0) {
|
|||||||
" -extract <entry> <outfile>\n"
|
" -extract <entry> <outfile>\n"
|
||||||
" Extract <entry> to <outfile>\n"
|
" Extract <entry> to <outfile>\n"
|
||||||
" -test\n"
|
" -test\n"
|
||||||
" Return value: 0/stock 1/Magisk 2/other (e.g. phh, SuperSU)\n"
|
" Return value: 0/stock 1/Magisk 2/other (phh, SuperSU, Xposed)\n"
|
||||||
" -patch <KEEPVERITY> <KEEPFORCEENCRYPT>\n"
|
" -patch <KEEPVERITY> <KEEPFORCEENCRYPT>\n"
|
||||||
" Patch cpio for Magisk. KEEP**** are true/false values\n"
|
" Patch cpio for Magisk. KEEP**** are true/false values\n"
|
||||||
" -backup <origcpio> [SHA1]\n"
|
" -backup <origcpio> [SHA1]\n"
|
||||||
@ -56,11 +56,13 @@ static void usage(char *arg0) {
|
|||||||
" -stocksha1\n"
|
" -stocksha1\n"
|
||||||
" Get stock boot SHA1 recorded within <incpio>\n"
|
" Get stock boot SHA1 recorded within <incpio>\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --dtb-print <dtb>\n"
|
" --dtb-<cmd> <dtb>\n"
|
||||||
" Print all nodes in <dtb>, for debugging\n"
|
" Do dtb related cmds to <dtb> (modifications are done directly)\n"
|
||||||
"\n"
|
" Supported commands:\n"
|
||||||
" --dtb-patch <dtb>\n"
|
" -dump\n"
|
||||||
" Search for fstab in <dtb> and remove verity checks\n"
|
" Dump all contents from dtb for debugging\n"
|
||||||
|
" -patch\n"
|
||||||
|
" Search for fstab and remove verity/avb\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --compress[=method] <infile> [outfile]\n"
|
" --compress[=method] <infile> [outfile]\n"
|
||||||
" Compress <infile> with [method] (default: gzip), optionally to [outfile]\n"
|
" Compress <infile> with [method] (default: gzip), optionally to [outfile]\n"
|
||||||
@ -119,8 +121,8 @@ int main(int argc, char *argv[]) {
|
|||||||
repack(argv[2], argc > 3 ? argv[3] : NEW_BOOT);
|
repack(argv[2], argc > 3 ? argv[3] : NEW_BOOT);
|
||||||
} else if (argc > 2 && strcmp(argv[1], "--decompress") == 0) {
|
} else if (argc > 2 && strcmp(argv[1], "--decompress") == 0) {
|
||||||
decomp_file(argv[2], argc > 3 ? argv[3] : NULL);
|
decomp_file(argv[2], argc > 3 ? argv[3] : NULL);
|
||||||
} else if (argc > 2 && strcmp(argv[1], "--dtb-print") == 0) {
|
} else if (argc > 2 && strcmp(argv[1], "--dtb-dump") == 0) {
|
||||||
dtb_print(argv[2]);
|
dtb_dump(argv[2]);
|
||||||
} else if (argc > 2 && strcmp(argv[1], "--dtb-patch") == 0) {
|
} else if (argc > 2 && strcmp(argv[1], "--dtb-patch") == 0) {
|
||||||
dtb_patch(argv[2]);
|
dtb_patch(argv[2]);
|
||||||
} else if (argc > 2 && strncmp(argv[1], "--compress", 10) == 0) {
|
} else if (argc > 2 && strncmp(argv[1], "--compress", 10) == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user