libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
ngcw_junk.h
Go to the documentation of this file.
1/*
2 * This file is part of the Aaru Data Preservation Suite.
3 * Copyright (c) 2019-2026 Natalia Portillo.
4 *
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; version 2.1 of the License.
8 *
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see
16 * <https://www.gnu.org/licenses/>.
17 *
18 * Nintendo GameCube/Wii junk map: serialization, deserialization, regeneration.
19 */
20
21#ifndef LIBAARUFORMAT_NGCW_JUNK_H
22#define LIBAARUFORMAT_NGCW_JUNK_H
23
24#include <stdbool.h>
25#include <stdint.h>
26
27#include "lfg.h"
28
29/* Forward declaration — guard against redefinition when aaruformat.h is also included */
30#ifndef AARUFORMAT_CONTEXT_DECLARED
31#define AARUFORMAT_CONTEXT_DECLARED
33#endif
34
35#ifdef __cplusplus
36extern "C"
37{
38#endif
39
40#define NGCW_JUNK_MAP_VERSION 1
41
47 typedef struct NgcwJunkEntry
48 {
49 uint64_t offset;
50 uint64_t length;
51 uint16_t partition_index;
54
74 int32_t ngcw_serialize_junk_map(const NgcwJunkEntry *entries, uint32_t count, uint8_t **out_data,
75 uint32_t *out_len);
76
87 int32_t ngcw_deserialize_junk_map(const uint8_t *data, uint32_t data_len, NgcwJunkEntry **entries, uint32_t *count,
88 uint16_t *seed_size);
89
104 int ngcw_regenerate_junk_sector(const NgcwJunkEntry *entries, uint32_t entry_count, uint64_t disc_offset,
105 uint8_t *output, uint32_t length);
106
115
116#ifdef __cplusplus
117}
118#endif
119
120#endif /* LIBAARUFORMAT_NGCW_JUNK_H */
#define NGC_LFG_SEED_SIZE
Number of uint32 words needed to seed the LFG.
Definition lfg.h:36
int32_t ngcw_serialize_junk_map(const NgcwJunkEntry *entries, uint32_t count, uint8_t **out_data, uint32_t *out_len)
Serialize a junk map for storage as a media tag.
Definition ngcw_junk.c:75
int32_t ngcw_deserialize_junk_map(const uint8_t *data, uint32_t data_len, NgcwJunkEntry **entries, uint32_t *count, uint16_t *seed_size)
Deserialize a junk map from a media tag buffer.
Definition ngcw_junk.c:104
void ngcw_junk_lazy_init(aaruformat_context *ctx)
Lazy initialization: load junk map from media tags.
Definition ngcw_junk.c:211
int ngcw_regenerate_junk_sector(const NgcwJunkEntry *entries, uint32_t entry_count, uint64_t disc_offset, uint8_t *output, uint32_t length)
Regenerate a junk sector from the junk map.
Definition ngcw_junk.c:154
In-memory junk map entry.
Definition ngcw_junk.h:48
uint64_t length
Length of junk region in bytes.
Definition ngcw_junk.h:50
uint16_t partition_index
Partition index (0xFFFF for GC / inter-partition).
Definition ngcw_junk.h:51
uint64_t offset
Disc byte offset where junk starts.
Definition ngcw_junk.h:49
uint32_t seed[17]
LFG seed (17 words, big-endian).
Definition ngcw_junk.h:52
Master context representing an open or in‑creation Aaru image.
Definition context.h:175