forked from djrbliss/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
56 lines (51 loc) · 1.67 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* loki_patch
*
* A utility to patch unsigned boot and recovery images to make
* them suitable for booting on the AT&T/Verizon Samsung
* Galaxy S4, Galaxy Stellar, and various locked LG devices
*
* by Dan Rosenberg (@djrbliss)
*
*/
#include <stdio.h>
#include <string.h>
#include "loki.h"
static int print_help(const char* cmd) {
printf("Usage\n");
printf("> Patch partition file image:\n");
printf("%s [patch] [boot|recovery] [aboot.img] [in.img] [out.lok]\n", cmd);
printf("\n");
printf("> Flash loki image to boot|recovery:\n");
printf("%s [flash] [boot|recovery] [in.lok]\n", cmd);
printf("\n");
printf("> Find offset from aboot image:\n");
printf("%s [find] [aboot.img]\n", cmd);
printf("\n");
printf("> Revert Loki patching:\n");
printf("%s [unlok] [in.lok] [out.img]\n", cmd);
printf("\n");
return 1;
}
int main(int argc, char **argv) {
printf("Loki tool v%s\n", VERSION);
if (argc == 6 && strcmp(argv[1], "patch") == 0) {
// argv[2]: partition_label
// argv[3]: aboot_image
// argv[4]: in_image
// argv[5]: out_image
return loki_patch(argv[2], argv[3], argv[4], argv[5]);
} else if (argc == 4 && strcmp(argv[1], "flash") == 0) {
// argv[2]: partition_label
// argv[3]: loki_image
return loki_flash(argv[2], argv[3]);
} else if (argc == 3 && strcmp(argv[1], "find") == 0) {
// argv[2]: aboot_image
return loki_find(argv[2]);
} else if (argc == 4 && strcmp(argv[1], "unlok") == 0) {
// argv[2]: in_image
// argv[3]: out_image
return loki_unlok(argv[2], argv[3]);
}
return print_help(argv[0]);
}