2012-01-21 21:57:41 +01:00
|
|
|
#ifndef WIIDISC_H
|
|
|
|
#define WIIDISC_H
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "libwbfs_os.h" // this file is provided by the project wanting to compile libwbfs and wiidisc
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
// callback definition. Return 1 on fatal error (callback is supposed to make retries until no hopes..)
|
|
|
|
// offset points 32bit words, count counts bytes
|
2018-05-08 15:49:43 +02:00
|
|
|
typedef s32 (*read_wiidisc_callback_t)(void *fp, u32 offset, u32 count, void *iobuf);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
UPDATE_PARTITION_TYPE = 0,
|
|
|
|
GAME_PARTITION_TYPE,
|
|
|
|
OTHER_PARTITION_TYPE,
|
|
|
|
// value in between selects partition types of that value
|
|
|
|
ALL_PARTITIONS = 0xffffffff - 3,
|
|
|
|
REMOVE_UPDATE_PARTITION, // keeps game + channel installers
|
|
|
|
ONLY_GAME_PARTITION,
|
|
|
|
} partition_selector_t;
|
|
|
|
|
|
|
|
typedef struct wiidisc_s
|
|
|
|
{
|
|
|
|
read_wiidisc_callback_t read;
|
|
|
|
void *fp;
|
|
|
|
u8 *sector_usage_table;
|
|
|
|
|
|
|
|
// everything points 32bit words.
|
|
|
|
u32 disc_raw_offset;
|
|
|
|
u32 partition_raw_offset;
|
|
|
|
u32 partition_data_offset;
|
|
|
|
u32 partition_data_size;
|
|
|
|
u32 partition_block;
|
|
|
|
|
|
|
|
u8 *tmp_buffer;
|
|
|
|
u8 *tmp_buffer2;
|
|
|
|
u8 disc_key[16];
|
|
|
|
int dont_decrypt;
|
|
|
|
|
|
|
|
partition_selector_t part_sel;
|
|
|
|
|
|
|
|
const char *extract_pathname;
|
|
|
|
u8 *extracted_buffer;
|
|
|
|
u32 extracted_size;
|
|
|
|
void *user_data;
|
|
|
|
} wiidisc_t;
|
|
|
|
|
|
|
|
int wd_get_last_error(void);
|
|
|
|
|
|
|
|
wiidisc_t *wd_open_disc(read_wiidisc_callback_t read, void *fp);
|
|
|
|
void wd_close_disc(wiidisc_t *);
|
|
|
|
// returns a buffer allocated with wbfs_ioalloc() or NULL if not found of alloc error
|
|
|
|
u8 * wd_extract_file(wiidisc_t *d, u32 *size, partition_selector_t partition_type, const char *pathname);
|
|
|
|
void wd_build_disc_usage(wiidisc_t *d, partition_selector_t selector, u8 *usage_table);
|
|
|
|
|
|
|
|
// effectively remove not copied partition from the partition table.
|
2012-05-12 18:03:14 +02:00
|
|
|
void wd_fix_partition_table(partition_selector_t selector, u8 *partition_table);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-07-07 00:35:05 +02:00
|
|
|
// needed for wad decryption
|
|
|
|
void decrypt_title_key(u8 *tik, u8 *title_key);
|
2012-01-21 21:57:41 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif
|