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