Magisk/jni/magiskboot/magiskboot.h

64 lines
1.9 KiB
C
Raw Normal View History

2017-03-02 04:12:47 +08:00
#ifndef _MAGISKBOOT_H_
#define _MAGISKBOOT_H_
2017-02-28 05:37:47 +08:00
#include <stdio.h>
#include <stdlib.h>
2017-03-08 00:54:23 +08:00
#include <stdarg.h>
2017-02-28 05:37:47 +08:00
#include <unistd.h>
2017-03-08 00:54:23 +08:00
#include <ctype.h>
2017-02-28 05:37:47 +08:00
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
#include "bootimg.h"
2017-03-10 04:08:17 +08:00
#include "sha1.h"
2017-04-28 21:48:38 +08:00
#include "magisk.h"
#include "utils.h"
2017-09-12 15:27:28 +08:00
#include "magic.h"
2017-02-28 05:37:47 +08:00
2017-04-28 21:48:38 +08:00
#define KERNEL_FILE "kernel"
#define RAMDISK_FILE "ramdisk.cpio"
#define SECOND_FILE "second"
#define DTB_FILE "dtb"
#define NEW_BOOT "new-boot.img"
2017-04-28 03:15:48 +08:00
#define str(a) #a
#define xstr(a) str(a)
extern char *SUP_LIST[];
extern char *SUP_EXT_LIST[];
extern file_t SUP_TYPE_LIST[];
2017-03-08 00:54:23 +08:00
2017-02-28 05:37:47 +08:00
// Main entries
void unpack(const char *image);
2017-03-08 00:54:23 +08:00
void repack(const char* orig_image, const char* out_image);
2017-03-04 21:16:59 +08:00
void hexpatch(const char *image, const char *from, const char *to);
int parse_img(void *orig, size_t size, boot_img *boot);
2017-03-10 04:08:17 +08:00
int cpio_commands(const char *command, int argc, char *argv[]);
void comp_file(const char *method, const char *from, const char *to);
void decomp_file(char *from, const char *to);
void cleanup();
2017-02-28 05:37:47 +08:00
// Compressions
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 21:16:59 +08:00
// Utils
2017-09-12 15:27:28 +08:00
void mmap_ro(const char *filename, void **buf, size_t *size);
void mmap_rw(const char *filename, void **buf, size_t *size);
file_t check_type(const void *buf);
void get_type_name(file_t type, char *name);
void write_zero(int fd, size_t size);
2017-03-04 21:16:59 +08:00
void mem_align(size_t *pos, size_t align);
2017-03-08 00:54:23 +08:00
void file_align(int fd, size_t align, int out);
2017-03-04 21:16:59 +08:00
int open_new(const char *filename);
2017-02-28 05:37:47 +08:00
#endif