-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpatch.h
More file actions
67 lines (58 loc) · 1.55 KB
/
patch.h
File metadata and controls
67 lines (58 loc) · 1.55 KB
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
struct hImg3
{
unsigned int magic;
unsigned int size;
unsigned int imageSize;
unsigned int shshOffset;
unsigned int name;
};
struct hImg3Element
{
unsigned int magic;
unsigned int size;
unsigned int dataSize;
};
struct hKernel
{
unsigned int magic;
unsigned int compress_type;
unsigned int adler32;
unsigned int uncompressed_size;
unsigned int compressed_size;
unsigned int reserved[11];
char platform_name[64];
char root_path[256];
unsigned char data[0];
};
typedef struct hImg3 hImg3;
typedef struct hImg3Element hImg3Element;
typedef struct hKernel hKernel;
struct Img3Element
{
hImg3Element header;
unsigned char* data;
void* nextElement;
};
typedef struct Img3Element Img3Element;
typedef enum
{
kvUndefined = 0,
kv202 = 1,
kv210 = 2,
kv220 = 3,
kv221 = 4
} KernelVersion;
int patch(const char* filename, const char* output);
Img3Element* getDataElement(Img3Element* pElement);
unsigned int getElementsSize(Img3Element* pElement);
unsigned int getSHSHOffset(Img3Element* pElement);
Img3Element* removeElement(Img3Element* pElement, unsigned int magic);
void freeElements(Img3Element* pElement);
void aes_decrypt(void* p, unsigned int size, const char* key, const char* iv);
void aes_encrypt(void* p, unsigned int size, const char* key, const char* iv);
void sha1(void* p, unsigned int size, char** buf);
void convert_hex(const char* str, unsigned char* bytes, int len);
unsigned int swap32(unsigned int x);
unsigned short swap16(unsigned short x);
unsigned int endian_swap(unsigned int x);
unsigned short endian_swap16(unsigned short x);