xrock/loader.h

81 lines
1.6 KiB
C
Raw Normal View History

2024-09-04 10:16:24 +08:00
#ifndef __LOADER_H__
#define __LOADER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <x.h>
2024-09-30 16:06:11 +08:00
#include <rc4.h>
#include <crc16.h>
2024-09-04 11:09:55 +08:00
#include <crc32.h>
#include <misc.h>
2024-09-04 10:16:24 +08:00
enum rkloader_entry_type_t {
RKLOADER_ENTRY_471 = (1 << 0),
RKLOADER_ENTRY_472 = (1 << 1),
RKLOADER_ENTRY_LOADER = (1 << 2),
};
2024-09-04 10:16:24 +08:00
struct rkloader_time_t {
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
} __attribute__((packed));
2024-09-04 10:16:24 +08:00
struct rkloader_header_t {
uint32_t tag;
uint16_t size;
uint32_t version;
uint32_t merger_version;
2024-09-04 10:16:24 +08:00
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));
2024-09-04 10:16:24 +08:00
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));
2024-09-04 10:16:24 +08:00
struct rkloader_ctx_t {
void * buffer;
uint64_t length;
2024-09-30 13:42:44 +08:00
int is_newidb;
int is_rc4on;
int is_sign;
2024-09-04 10:16:24 +08:00
struct rkloader_header_t * header;
struct rkloader_entry_t * entry[32];
int nentry;
2024-09-30 16:06:11 +08:00
void * idbbuf;
uint64_t idblen;
};
2024-09-04 10:35:16 +08:00
char * loader_wide2str(char * str, uint8_t * wide, int len);
2024-09-04 11:09:55 +08:00
struct rkloader_ctx_t * rkloader_ctx_alloc(const char * filename);
void rkloader_ctx_free(struct rkloader_ctx_t * ctx);
#ifdef __cplusplus
}
#endif
2024-09-04 10:16:24 +08:00
#endif /* __LOADER_H__ */