-
Notifications
You must be signed in to change notification settings - Fork 24
/
loader.h
80 lines (70 loc) · 1.61 KB
/
loader.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef __LOADER_H__
#define __LOADER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <x.h>
#include <rc4.h>
#include <crc16.h>
#include <crc32.h>
#include <misc.h>
enum rkloader_entry_type_t {
RKLOADER_ENTRY_471 = (1 << 0),
RKLOADER_ENTRY_472 = (1 << 1),
RKLOADER_ENTRY_LOADER = (1 << 2),
};
struct rkloader_time_t {
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
} __attribute__((packed));
struct rkloader_header_t {
uint32_t tag;
uint16_t size;
uint32_t version;
uint32_t merger_version;
struct rkloader_time_t release_time;
uint32_t chiptype;
uint8_t code471_num;
uint32_t code471_offset;
uint8_t code471_size;
uint8_t code472_num;
uint32_t code472_offset;
uint8_t code472_size;
uint8_t loader_num;
uint32_t loader_offset;
uint8_t loader_size;
uint8_t sign_flag;
uint8_t rc4_flag;
uint8_t reserved[57];
} __attribute__((packed));
struct rkloader_entry_t {
uint8_t size;
uint32_t type;
uint16_t name[20];
uint32_t data_offset;
uint32_t data_size;
uint32_t data_delay;
} __attribute__((packed));
struct rkloader_ctx_t {
void * buffer;
uint64_t length;
int is_newidb;
int is_rc4on;
int is_sign;
struct rkloader_header_t * header;
struct rkloader_entry_t * entry[32];
int nentry;
void * idbbuf;
uint64_t idblen;
};
char * loader_wide2str(char * str, uint8_t * wide, int len);
struct rkloader_ctx_t * rkloader_ctx_alloc(const char * filename);
void rkloader_ctx_free(struct rkloader_ctx_t * ctx);
#ifdef __cplusplus
}
#endif
#endif /* __LOADER_H__ */