-
Notifications
You must be signed in to change notification settings - Fork 11
/
pfs0.h
48 lines (41 loc) · 1.29 KB
/
pfs0.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef HACBREWPACK_PFS0_H
#define HACBREWPACK_PFS0_H
#include <stdint.h>
#include "types.h"
#include "utils.h"
#include "filepath.h"
#define MAGIC_PFS0 0x30534650
#define PFS0_HASH_BLOCK_SIZE 0x8000;
#define PFS0_PADDING_SIZE 0x4000;
#pragma pack(push, 1)
typedef struct {
uint32_t magic;
uint32_t num_files;
uint32_t string_table_size;
uint32_t reserved;
} pfs0_header_t;
#pragma pack(pop)
#pragma pack(push, 1)
typedef struct {
uint64_t offset;
uint64_t size;
uint32_t string_table_offset;
uint32_t reserved;
} pfs0_file_entry_t;
#pragma pack(pop)
#pragma pack(push, 1)
typedef struct {
uint8_t master_hash[0x20]; /* SHA-256 hash of the hash table. */
uint32_t block_size; /* In bytes. */
uint32_t always_2;
uint64_t hash_table_offset; /* Normally zero. */
uint64_t hash_table_size;
uint64_t pfs0_offset;
uint64_t pfs0_size;
uint8_t _0x48[0xF0];
} pfs0_superblock_t;
#pragma pack(pop)
int pfs0_build(filepath_t *in_dirpath, filepath_t *out_pfs0_filepath, uint64_t *out_pfs0_size);
void pfs0_create_hashtable(filepath_t *pfs0_path, filepath_t *pfs0_hashtable_path, uint64_t *out_hashtable_size, uint64_t *out_pfs0_offset);
void pfs0_calculate_master_hash(filepath_t *pfs0_hashtable_filepath, uint64_t hash_table_size, uint8_t *out_master_hash);
#endif