Magisk/native/jni/magiskboot/format.h

67 lines
1.5 KiB
C
Raw Normal View History

#pragma once
2017-09-12 07:27:28 +00:00
2019-02-21 01:49:26 +00:00
#include <map>
#include <string_view>
2017-09-12 07:27:28 +00:00
typedef enum {
2018-01-29 14:16:02 +00:00
UNKNOWN,
2019-02-21 01:49:26 +00:00
/* Boot formats */
2018-01-29 14:16:02 +00:00
CHROMEOS,
AOSP,
ELF32,
ELF64,
2019-02-21 01:49:26 +00:00
DHTB,
BLOB,
/* Compression formats */
2018-01-29 14:16:02 +00:00
GZIP,
XZ,
LZMA,
BZIP2,
LZ4,
LZ4_LEGACY,
2019-02-21 01:49:26 +00:00
/* Misc */
LZOP,
2018-01-29 14:16:02 +00:00
MTK,
DTB,
2018-01-28 19:12:35 +00:00
} format_t;
2017-09-12 07:27:28 +00:00
2019-02-21 01:49:26 +00:00
#define COMPRESSED(fmt) ((fmt) >= GZIP && (fmt) <= LZ4_LEGACY)
2017-10-07 14:08:10 +00:00
2018-01-28 19:12:35 +00:00
#define BOOT_MAGIC "ANDROID!"
2017-09-12 07:27:28 +00:00
#define CHROMEOS_MAGIC "CHROMEOS"
#define ELF32_MAGIC "\x7f""ELF\x01"
#define ELF64_MAGIC "\x7f""ELF\x02"
#define GZIP_MAGIC "\x1f\x8b\x08"
2017-09-12 07:27:28 +00:00
#define LZOP_MAGIC "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a"
#define XZ_MAGIC "\xfd""7zXZ\x00"
#define BZIP_MAGIC "BZh"
#define LZ4_MAGIC "\x04\x22\x4d\x18"
#define LZ4_LEG_MAGIC "\x02\x21\x4c\x18"
#define MTK_MAGIC "\x88\x16\x88\x58"
#define DTB_MAGIC "\xd0\x0d\xfe\xed"
#define LG_BUMP_MAGIC "\x41\xa9\xe4\x67\x74\x4d\x1d\x1b\xa4\x29\xf2\xec\xea\x65\x52\x79"
2018-01-29 14:16:02 +00:00
#define DHTB_MAGIC "\x44\x48\x54\x42\x01\x00\x00\x00"
#define SEANDROID_MAGIC "SEANDROIDENFORCE"
2018-01-29 21:20:18 +00:00
#define TEGRABLOB_MAGIC "-SIGNED-BY-SIGNBLOB-"
#define NOOKHD_MAGIC "Green Loader"
#define NOOKHD_NEW_MAGIC "eMMC boot.img+secondloader"
#define NOOKHD_PRE_HEADER_SZ 1048576
#define ACCLAIM_MAGIC "BauwksBoot"
#define ACCLAIM_PRE_HEADER_SZ 262144
2017-09-12 07:27:28 +00:00
2019-02-21 01:49:26 +00:00
class Fmt2Name {
public:
const char *operator[](format_t fmt);
};
class Fmt2Ext {
public:
const char *operator[](format_t fmt);
};
2018-02-09 19:34:13 +00:00
format_t check_fmt(const void *buf, size_t len);
2019-02-21 01:49:26 +00:00
extern std::map<std::string_view, format_t> name2fmt;
extern Fmt2Name fmt2name;
extern Fmt2Ext fmt2ext;