pfs0.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #pragma once
  2. #include <stdio.h>
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #define PFS0_MAGIC 0x30534650
  6. #define PFS0_HEADER_SIZE 0x10
  7. typedef struct
  8. {
  9. uint32_t magic;
  10. uint32_t total_files;
  11. uint32_t string_table_size;
  12. uint32_t padding;
  13. } pfs0_header_t;
  14. typedef struct
  15. {
  16. uint64_t data_offset;
  17. uint64_t data_size;
  18. uint32_t name_offset;
  19. uint32_t padding;
  20. } pfs0_file_table_t;
  21. typedef struct
  22. {
  23. char name[256];
  24. } pfs0_string_table_t;
  25. typedef struct
  26. {
  27. uint8_t hash[0x20];
  28. uint32_t block_size;
  29. uint32_t always_2;
  30. uint64_t hash_table_offset;
  31. uint64_t hash_table_size;
  32. uint64_t pfs0_offset;
  33. uint64_t pfs0_size;
  34. uint8_t _0x48[0xF0];
  35. } Pfs0Superblock_t;
  36. typedef struct
  37. {
  38. FILE *file;
  39. pfs0_header_t header;
  40. pfs0_file_table_t *file_table;
  41. pfs0_string_table_t *string_table;
  42. uint64_t file_table_offset;
  43. size_t file_table_size;
  44. uint64_t string_table_offset;
  45. uint64_t raw_data_offset;
  46. size_t raw_data_size;
  47. } pfs0_struct_ptr;
  48. //
  49. void read_data(void *buf_out, size_t buf_size, uint64_t offset, FILE *f);
  50. //
  51. void pfs0_get_header(pfs0_struct_ptr *ptr, uint64_t offset);
  52. //
  53. void pfs0_populate_file_table(pfs0_struct_ptr *ptr);
  54. //
  55. void pfs0_populate_string_table(pfs0_struct_ptr *ptr);
  56. //
  57. bool pfs0_check_valid_magic(uint32_t magic);
  58. //
  59. void pfs0_populate_table_size_offsets(pfs0_struct_ptr *ptr, uint64_t offset);
  60. //
  61. size_t pfs0_get_total_raw_data_size(pfs0_struct_ptr *ptr);
  62. //
  63. int pfs0_search_string_table(pfs0_struct_ptr *ptr, const char *search_name);
  64. //
  65. bool pfs0_extract_file(pfs0_struct_ptr *ptr, int location);
  66. //
  67. bool pfs0_extract_all(pfs0_struct_ptr *ptr);
  68. //
  69. void pfs0_free_structs(pfs0_struct_ptr *ptr);
  70. //
  71. bool pfs0_process(pfs0_struct_ptr *ptr, uint64_t offset, FILE *fp);
  72. //
  73. bool pfs0_start(FILE *file, uint64_t offset);