2017-03-01 20:12:47 +00:00
|
|
|
#ifndef _MAGISKBOOT_H_
|
|
|
|
#define _MAGISKBOOT_H_
|
2017-02-27 21:37:47 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "bootimg.h"
|
|
|
|
|
2017-04-28 13:48:38 +00:00
|
|
|
#define KERNEL_FILE "kernel"
|
|
|
|
#define RAMDISK_FILE "ramdisk.cpio"
|
|
|
|
#define SECOND_FILE "second"
|
2017-10-07 14:08:10 +00:00
|
|
|
#define EXTRA_FILE "extra"
|
2017-04-28 13:48:38 +00:00
|
|
|
#define DTB_FILE "dtb"
|
|
|
|
#define NEW_BOOT "new-boot.img"
|
2017-03-04 17:50:36 +00:00
|
|
|
|
2017-04-27 19:15:48 +00:00
|
|
|
#define str(a) #a
|
|
|
|
#define xstr(a) str(a)
|
|
|
|
|
2017-02-27 21:37:47 +00:00
|
|
|
// Main entries
|
|
|
|
void unpack(const char *image);
|
2017-03-07 16:54:23 +00:00
|
|
|
void repack(const char* orig_image, const char* out_image);
|
2017-03-04 13:16:59 +00:00
|
|
|
void hexpatch(const char *image, const char *from, const char *to);
|
2017-09-12 14:09:10 +00:00
|
|
|
int parse_img(void *orig, size_t size, boot_img *boot);
|
2017-03-09 20:08:17 +00:00
|
|
|
int cpio_commands(const char *command, int argc, char *argv[]);
|
2017-09-12 09:00:45 +00:00
|
|
|
void comp_file(const char *method, const char *from, const char *to);
|
|
|
|
void decomp_file(char *from, const char *to);
|
2017-10-07 14:08:10 +00:00
|
|
|
void dtb_print(const char *file);
|
2017-09-14 18:52:27 +00:00
|
|
|
void dtb_patch(const char *file);
|
2017-02-27 21:37:47 +00:00
|
|
|
|
|
|
|
// Compressions
|
2017-09-12 09:00:45 +00:00
|
|
|
size_t gzip(int mode, int fd, const void *buf, size_t size);
|
|
|
|
size_t lzma(int mode, int fd, const void *buf, size_t size);
|
|
|
|
size_t lz4(int mode, int fd, const void *buf, size_t size);
|
|
|
|
size_t bzip2(int mode, int fd, const void *buf, size_t size);
|
|
|
|
size_t lz4_legacy(int mode, int fd, const void *buf, size_t size);
|
|
|
|
long long comp(file_t type, int to, const void *from, size_t size);
|
|
|
|
long long decomp(file_t type, int to, const void *from, size_t size);
|
2017-03-04 13:16:59 +00:00
|
|
|
|
|
|
|
// Utils
|
2017-09-14 15:11:56 +00:00
|
|
|
extern void mmap_ro(const char *filename, void **buf, size_t *size);
|
|
|
|
extern void mmap_rw(const char *filename, void **buf, size_t *size);
|
|
|
|
extern void write_zero(int fd, size_t size);
|
|
|
|
extern void mem_align(size_t *pos, size_t align);
|
|
|
|
extern void file_align(int fd, size_t align, int out);
|
|
|
|
extern int open_new(const char *filename);
|
2017-09-14 17:45:39 +00:00
|
|
|
extern void *patch_init_rc(char *data, uint32_t *size);
|
|
|
|
extern int check_verity_pattern(const char *s);
|
|
|
|
extern int check_encryption_pattern(const char *s);
|
2017-02-27 21:37:47 +00:00
|
|
|
|
|
|
|
#endif
|