summaryrefslogtreecommitdiffstats
path: root/wii_tmd.h
blob: 498b96d6b23198ac56c4e94c13b30f158cfded2f (plain)
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
/**
 * wii_tmd.h
 */

#ifndef __WII_TMD_H__
#define __WII_TMD_H__

#include <stdio.h>
#include <stdlib.h>
#include "types.h"

#define	OFFSET_TMD		(0xd00)
#define	OFFSET_TITLE_ID		(0x18c)
#define	OFFSET_REGION		(0x19d)
#define	OFFSET_BF		(0x1c1)

extern const char *region_names[];

typedef struct {
	u32 cid;		/* content id */
	u16 index;		/* # number of the file */
	u16 type;
	u64 size;
	u8 hash[20];		/* SHA1 hash content */
} tmd_content_record;		/* size: 0x24 bytes */

typedef struct {
	u32 sig_type;
	u8 sig[256];
	u8 fill1[60];
	char issuer[64];	/* Root-CA%08x-CP%08x */
	u8 version;
	u8 ca_crl_version;
	u8 signer_crl_version;
	u8 fill2;
	u64 sys_version;
	u32 title_category;
	u32 title_id;
	u32 title_type;
	u16 group_id;		/* Publisher ID */
	u16 fill4;
	u16 region_code;
	u8 reserved[58];
	u32 access_rights;
	u16 title_version;
	u16 num_contents;
	u16 boot_index;
	u16 fill6;
} ATTRIBUTE_PACKED tmd_header;

void dump_tmd_raw(u8 *tmd);
void print_tmd(tmd_header *tmd);
void print_tmd_content_records(tmd_header *tmd, tmd_content_record *tmd_content);

void tmd_read(FILE *f, tmd_header *tmd);
void tmd_read_content_records(FILE *f, tmd_header *tmd, tmd_content_record *tmd_content);
 u32 tmd_get_block_size(tmd_header *tmd, tmd_content_record *tmd_content);

char*tmd_lookup_group_name(u16 group_id);
char*tmd_lookup_title_category_name(u32 category);
char*tmd_lookup_system_code_name(u32 title_id);
 int tmd_get_system_title_name(u32 title_id, char *name);

#endif