// Copyright 2009 Kwiirk based on negentig.c:
// Copyright 2007,2008 Segher Boessenkool
// Licensed under the terms of the GNU GPL, version 2
//
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#include "../memcheck.h"
#include "wiidisc.h"
#include
// Turn upper and lower into a full title ID
#define TITLE_ID(x,y) (((u64)(x) > 32))
// Turn upper and lower into a full title ID
#define TITLE_LOWER(x) ((u32)(x))
...
static void do_partition(wiidisc_t*d)
{
u8 *tik = wbfs_ioalloc(0x2a4);
u8 *b = wbfs_ioalloc(0x1c);
tmd *tmd_data = NULL;
u64 tmd_offset;
u32 tmd_size;
u8 *tmd;
u64 cert_offset;
u32 cert_size;
u8 *cert;
u64 h3_offset;
// read ticket, and read some offsets and sizes
partition_raw_read(d,0, tik, 0x2a4);
partition_raw_read(d,0x2a4>>2, b, 0x1c);
tmd_size = _be32(b);
tmd_offset = _be32(b + 4);
cert_size = _be32(b + 8);
cert_offset = _be32(b + 0x0c);
h3_offset = _be32(b + 0x10);
d->partition_data_offset = _be32(b + 0x14);
d->partition_block = (d->partition_raw_offset+d->partition_data_offset)>>13;
tmd = wbfs_ioalloc(tmd_size);
if (tmd == 0)
wbfs_fatal("malloc tmd");
partition_raw_read(d,tmd_offset, tmd, tmd_size);
cert = wbfs_ioalloc(cert_size);
if (cert == 0)
wbfs_fatal("malloc cert");
partition_raw_read(d,cert_offset, cert, cert_size);
_decrypt_title_key(tik, d->disc_key);
signed_blob *s_tmd = (signed_blob *)tmd;
tmd_data = SIGNATURE_PAYLOAD(s_tmd);
printf("Title IOS: %d", TITLE_LOWER(tmd_data->sys_version));
partition_raw_read(d,h3_offset, 0, 0x18000);
wbfs_iofree(b);
wbfs_iofree(tik);
wbfs_iofree(cert);
wbfs_iofree(tmd);
do_files(d);
}
...