Common nn::util: Difference between revisions
Add category. |
Cleanup, add NWPtr<T> and NWString to use as helpers in the other NW file format pages. |
||
| Line 1: | Line 1: | ||
These are file structures common to multiple NintendoWare file formats. Namely the nn::gfx file formats [[Bntx]] and [[Bnsh]], the nn::g3d file formats [[Bfres]], and [[Bfsha]], and the nn::bezel file formats [[Bea]], [[Bnbshpk]], and [[Nbmap]]. | These are file structures common to multiple NintendoWare file formats. Namely the nn::gfx file formats [[Bntx]] and [[Bnsh]], the nn::g3d file formats [[Bfres]], and [[Bfsha]], the nn::vg file format [[Bnvg]], and the nn::bezel file formats [[Bea]], [[Bnbshpk]], and [[Nbmap]]. | ||
== Headers == | |||
=== nn::util::BinaryFileHeader === | |||
The base struct of almost if not every file format using nn::util file structures. | The base struct of almost if not every file format using nn::util file structures. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 72: | Line 72: | ||
|} | |} | ||
=== nn::util::BinaryBlockHeader === | |||
A common base struct of sub sections in nn::util based files. | A common base struct of sub sections in nn::util based files. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 102: | Line 102: | ||
|} | |} | ||
== Relocation Table == | |||
Relocation tables are iterated to relocate pointers all throughout the BinaryFileHeader derived file. Converting the file into just a collection of structs in memory. | Relocation tables are iterated to relocate pointers all throughout the BinaryFileHeader derived file. Converting the file into just a collection of structs in memory. | ||
==== nn::util::RelocationTable | === NWPtr<T> === | ||
A template type to a pointer to type T that is relocatable by the relocation table. The size should match the address size in the file header, in Switch games this is almost always 64-bits. | |||
=== nn::util::RelocationTable === | |||
{| class="wikitable" | {| class="wikitable" | ||
!Offset | !Offset | ||
| Line 167: | Line 170: | ||
|} | |} | ||
==== nn::util::RelocationTable::Entry (unofficial name) ==== | ===== nn::util::RelocationTable::Entry (unofficial name) ===== | ||
Immediately following the Section array is an array of information about relocation entries. Each entry defines a set of continuous pointer arrays with a stride between each array. | Immediately following the Section array is an array of information about relocation entries. Each entry defines a set of continuous pointer arrays with a stride between each array. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 196: | Line 199: | ||
|} | |} | ||
=== | == Dictionary == | ||
=== nn::util::ResDic === | |||
A dictionary, each element must have a unique string key. | |||
{| class="wikitable" | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x0 | |||
|0x4 | |||
|u32 | |||
|Magic ("_DIC" in big-endian or 0x0) | |||
|- | |||
|0x4 | |||
|0x4 | |||
|u32 | |||
|Count (does not count root node, which is part of the header) | |||
|- | |||
|0x8 | |||
|0x10 | |||
|nn::util::ResDic::Node | |||
|Root node (null key) | |||
|- | |||
|0x18 | |||
|0x10 * Count | |||
|nn::util::ResDic::Node[Count] | |||
|Node array | |||
|} | |||
==== nn::util::ResDic:: | ==== nn::util::ResDic::Node (unofficial name) ==== | ||
The ref bit is used for a radix tree style lookup. | |||
{| class="wikitable" | {| class="wikitable" | ||
!Offset | !Offset | ||
| Line 227: | Line 259: | ||
|} | |} | ||
==== | == StringPool == | ||
=== NWString === | |||
NintendoWare file string pointers are preceded by a u16 string length. The strings are also aligned to 2 bytes. | |||
{| class="wikitable" | {| class="wikitable" | ||
|+ | |||
!Offset | !Offset | ||
!Size | !Size | ||
| Line 235: | Line 271: | ||
|- | |- | ||
|0x0 | |0x0 | ||
| | |0x2 | ||
| | |u16 | ||
| | |String Length | ||
|- | |- | ||
| | |0x2 | ||
| | |0x1 * String Length | ||
| | |char[String Length] | ||
| | |String Data | ||
|} | |} | ||
=== nn::util::StringPool === | |||
Header that precedes the deduplicated string table. | |||
Header that precedes | |||
{| class="wikitable" | {| class="wikitable" | ||
!Offset | !Offset | ||
| Line 278: | Line 307: | ||
|0x4 | |0x4 | ||
|u32 | |u32 | ||
|String | |String Count | ||
|- | |- | ||
|0x10 | |0x10 | ||
| Line 284: | Line 313: | ||
|u32 | |u32 | ||
|Empty String entry (0x0000, 0x00) | |Empty String entry (0x0000, 0x00) | ||
|- | |||
|0x14 | |||
| | |||
|NWString[StringCount] | |||
|String region | |||
|} | |} | ||
[[Category:File formats]] | [[Category:File formats]] | ||