wiidisc.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef WIIDISC_H
  2. #define WIIDISC_H
  3. #include <stdio.h>
  4. #include "libwbfs_os.h" // this file is provided by the project wanting to compile libwbfs and wiidisc
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif /* __cplusplus */
  8. #if 0 //removes extra automatic indentation by editors
  9. }
  10. #endif
  11. // callback definition. Return 1 on fatal error (callback is supposed to make retries until no hopes..)
  12. // offset points 32bit words, count counts bytes
  13. typedef int (*read_wiidisc_callback_t)(void*fp,u32 offset,u32 count,void*iobuf);
  14. typedef enum{
  15. UPDATE_PARTITION_TYPE=0,
  16. GAME_PARTITION_TYPE,
  17. OTHER_PARTITION_TYPE,
  18. // value in between selects partition types of that value
  19. ALL_PARTITIONS=0xffffffff-3,
  20. REMOVE_UPDATE_PARTITION, // keeps game + channel installers
  21. ONLY_GAME_PARTITION,
  22. }partition_selector_t;
  23. typedef struct wiidisc_s
  24. {
  25. read_wiidisc_callback_t read;
  26. void *fp;
  27. u8 *sector_usage_table;
  28. // everything points 32bit words.
  29. u32 disc_raw_offset;
  30. u32 partition_raw_offset;
  31. u32 partition_data_offset;
  32. u32 partition_data_size;
  33. u32 partition_block;
  34. u8 *tmp_buffer;
  35. u8 *tmp_buffer2;
  36. u8 disc_key[16];
  37. int dont_decrypt;
  38. partition_selector_t part_sel;
  39. char *extract_pathname;
  40. u8 *extracted_buffer;
  41. }wiidisc_t;
  42. wiidisc_t *wd_open_disc(read_wiidisc_callback_t read,void*fp);
  43. void wd_close_disc(wiidisc_t *);
  44. // returns a buffer allocated with wbfs_ioalloc() or NULL if not found of alloc error
  45. u8 * wd_extract_file(wiidisc_t *d, partition_selector_t partition_type, char *pathname);
  46. int wd_build_disc_usage(wiidisc_t *d, partition_selector_t selector, u8* usage_table);
  47. // effectively remove not copied partition from the partition table.
  48. void wd_fix_partition_table(wiidisc_t *d, partition_selector_t selector, u8* partition_table);
  49. #if 0
  50. {
  51. #endif
  52. #ifdef __cplusplus
  53. }
  54. #endif /* __cplusplus */
  55. #endif