2 * Copyright (C) 2008 dhewg, #wiidev efnet
4 * this file is part of wiifuse
5 * http://wiibrew.org/index.php?title=Wiifuse
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 void meta_add_part (struct tree
*part_node
, struct partition
*part
, u32 i
) {
29 if (part
->header
.is_gc
)
30 tree_add_filler (i
, part_node
, "gc_image");
31 if (part
->header
.is_wii
)
32 tree_add_filler (i
, part_node
, "wii_image");
34 if (part
->appldr_size
> 0)
35 tree_add_file (i
, part_node
, "appldr.bin",
36 0x2440, part
->appldr_size
);
38 if (part
->header
.dol_offset
> 0 && part
->header
.dol_size
> 0)
39 tree_add_file (i
, part_node
, "main.dol",
40 part
->header
.dol_offset
, part
->header
.dol_size
);
42 if (part
->header
.fst_offset
> 0 && part
->header
.fst_size
> 0)
43 tree_add_file (i
, part_node
, "fst.bin",
44 part
->header
.fst_offset
, part
->header
.fst_size
);
46 node
= tree_add_dir (i
, part_node
, "header");
48 tree_add_char (i
, node
, "console_id", part
->header
.console
);
49 tree_add_string (i
, node
, "gamecode", part
->header
.gamecode
, 2);
50 tree_add_char (i
, node
, "region", part
->header
.region
);
51 tree_add_string (i
, node
, "publisher", part
->header
.publisher
, 2);
53 tree_add_string (i
, node
, "name", part
->header
.name
, 0x60);
54 if (!part
->header
.has_magic
)
55 tree_add_filler (i
, node
, "invalid_magic");
57 if (part
->is_encrypted
) {
58 node
= tree_add_dir (i
, part_node
, "crypto");
60 tree_add_string (i
, node
, "key", part
->key_c
, 32);
61 tree_add_string (i
, node
, "issuer", part
->tmd
->issuer
, 64);
62 tree_add_hex_uint8 (i
, node
, "version", part
->tmd
->version
);
63 tree_add_hex_uint8 (i
, node
, "ca_crl_version",
64 part
->tmd
->ca_crl_version
);
65 tree_add_hex_uint8 (i
, node
, "signer_crl_version",
66 part
->tmd
->signer_crl_version
);
67 tree_add_hex_uint64 (i
, node
, "sys_version",
68 part
->tmd
->sys_version
);
69 tree_add_hex_uint64 (i
, node
, "title_id", part
->tmd
->title_id
);
70 tree_add_hex_uint32 (i
, node
, "title_type",
71 part
->tmd
->title_type
);
72 tree_add_hex_uint16 (i
, node
, "group_id", part
->tmd
->group_id
);
73 tree_add_hex_uint32 (i
, node
, "access_rights",
74 part
->tmd
->access_rights
);
75 tree_add_hex_uint16 (i
, node
, "title_version",
76 part
->tmd
->title_version
);
77 tree_add_uint (i
, node
, "num_contents",
78 part
->tmd
->num_contents
);
79 tree_add_uint (i
, node
, "boot_index", part
->tmd
->boot_index
);
82 node
= tree_add_dir (i
, part_node
, ".internals");
84 tree_add_uint (i
, node
, "partition_offset", part
->offset
);
85 tree_add_uint (i
, node
, "appldr_offset", 0x2440);
86 tree_add_uint (i
, node
, "appldr_size", part
->appldr_size
);
87 tree_add_uint (i
, node
, "dol_offset", part
->header
.dol_offset
);
88 tree_add_uint (i
, node
, "dol_size", part
->header
.dol_size
);
89 tree_add_uint (i
, node
, "fst_offset", part
->header
.fst_offset
);
90 tree_add_uint (i
, node
, "fst_size", part
->header
.fst_size
);
92 if (part
->is_encrypted
) {
93 tree_add_raw_file (i
, node
, "certs",
94 part
->certs_offset
, part
->certs_size
);
96 tree_add_raw_file (i
, node
, "tmd",
97 part
->tmd_offset
, part
->tmd_size
);
99 tree_add_raw_file (i
, node
, "ticket",
100 part
->ticket_offset
, part
->ticket_size
);
102 tree_add_uint (i
, node
, "data_offset", part
->data_offset
);
103 tree_add_uint (i
, node
, "data_size", part
->data_size
);
105 tree_add_file (i
, node
, "decrypted.raw",
108 // tree_add_uint copies an integer, we want the live data
109 tree_add_mem (i
, node
, "cached_block", &part
->cached_block
, 4);
110 tree_add_mem (i
, node
, "cache", part
->cache
, 0x7c00);
114 void meta_add_image (struct tree
*node
, struct image_file
*image
) {
118 for (i
= 0; i
< image
->nparts
; ++i
) {
119 sprintf (str
, "partition%02u", i
);
121 switch (image
->parts
[i
].type
) {
126 tree_add_symlink (i
, node
, "data", str
);
130 tree_add_symlink (i
, node
, "update", str
);
134 tree_add_symlink (i
, node
, "installer", str
);
138 tree_add_symlink (i
, node
, image
->parts
[i
].chan_id
,
143 if (image
->parts
[i
].is_encrypted
)
144 tree_add_symlink (i
, node
, image
->parts
[i
].title_id_str
,