-
Notifications
You must be signed in to change notification settings - Fork 5
/
image.h
62 lines (49 loc) · 1.39 KB
/
image.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
#if !defined(UNIMGC_H_IMAGE)
#define UNIMGC_H_IMAGE
#include <stdint.h>
struct pascal_str {
unsigned char length;
char data[0xFF];
};
#define IMGC_HEADER_SIZE 0x1000
struct imgc_header {
/* creator software metadata */
struct {
/* "HDD Raw Copy Tool" */
struct pascal_str name;
/* "1.10" */
struct pascal_str version;
} software;
/* original volume metadata */
struct {
/* "SMI USB DISK" */
struct pascal_str model;
/* "0CB0" */
struct pascal_str revision;
/* "624811604181" */
struct pascal_str serial;
} volume;
/* image properties */
struct {
uint64_t sector_count; /* ? */
uint64_t sector_size; /* ? */
uint64_t unk1;
uint64_t unk2;
uint8_t unk3;
} image;
};
enum imgc_block_type {
IMGC_BLOCK_COMPRESSED = 1,
IMGC_BLOCK_ZERO
};
#define IMGC_BLOCK_HEADER_SIZE 8
struct imgc_block_header {
enum imgc_block_type type;
uint32_t size;
};
char *pascal_to_cstr(struct pascal_str *p);
int pascal_from_cstr(struct pascal_str *p, const char *s);
int imgc_parse(const uint8_t *buf, size_t len, struct imgc_header *hdr);
int imgc_parse_block(const uint8_t *buf, size_t len, struct imgc_block_header *hdr);
size_t imgc_decompress_block(const uint8_t *buf, size_t len, uint8_t *out, size_t outlen);
#endif /* !defined(UNIMGC_H_IMAGE) */