2016-03-05 03:58:16 +00:00
|
|
|
### NOD
|
2016-01-25 20:21:10 +00:00
|
|
|
|
2016-03-05 03:58:16 +00:00
|
|
|
**NOD** is a library and utility (`nodtool`) for traversing, dumping, and authoring
|
2016-01-25 20:21:10 +00:00
|
|
|
*GameCube* and *Wii* optical disc images.
|
|
|
|
|
|
|
|
#### Library
|
|
|
|
|
2016-03-05 03:58:16 +00:00
|
|
|
The primary motivation of NOD is to supply a *uniform C++11 API* for accessing data
|
|
|
|
from image files directly. `nod::DiscBase` provides a common interface for traversing partitions
|
2016-01-25 20:21:10 +00:00
|
|
|
and individual files. Files may be individually streamed, or the whole partition may be extracted
|
2016-01-26 02:01:55 +00:00
|
|
|
to the user's filesystem. Raw *ISO* and *WBFS* images are supported read sources.
|
2016-01-25 20:21:10 +00:00
|
|
|
|
|
|
|
```cpp
|
|
|
|
bool isWii; /* Set by reference next line */
|
2016-03-05 03:58:16 +00:00
|
|
|
std::unique_ptr<nod::DiscBase> disc = nod::OpenDiscFromImage(path, isWii);
|
2016-01-25 20:21:10 +00:00
|
|
|
if (!disc)
|
2016-01-26 02:01:55 +00:00
|
|
|
return FAILURE;
|
2016-01-25 20:21:10 +00:00
|
|
|
|
|
|
|
/* Access first data-partition on Wii, or full GameCube disc */
|
2016-03-05 03:58:16 +00:00
|
|
|
nod::Partition* dataPart = disc->getDataPartition();
|
2016-01-25 20:21:10 +00:00
|
|
|
if (!dataPart)
|
2016-01-26 02:01:55 +00:00
|
|
|
return FAILURE;
|
2016-01-25 20:21:10 +00:00
|
|
|
|
|
|
|
/* One-shot extraction to filesystem */
|
|
|
|
if (!dataPart->extractToDirectory(outDir, ctx))
|
2016-01-26 02:01:55 +00:00
|
|
|
return FAILURE;
|
|
|
|
|
2016-01-25 20:21:10 +00:00
|
|
|
return SUCCESS;
|
|
|
|
```
|
|
|
|
|
2016-01-25 21:41:21 +00:00
|
|
|
*Image authoring* is always done from the user's filesystem and may be integrated into
|
2016-03-05 03:58:16 +00:00
|
|
|
a content pipeline using the `nod::DiscBuilderBase` interface.
|
2016-01-25 20:21:10 +00:00
|
|
|
|
|
|
|
```cpp
|
|
|
|
/* Sample logging lambda for progress feedback */
|
|
|
|
size_t lastIdx = -1;
|
2016-03-05 03:58:16 +00:00
|
|
|
auto progFunc = [&](size_t idx, const nod::SystemString& name, size_t bytes)
|
2016-01-25 20:21:10 +00:00
|
|
|
{
|
2016-01-26 02:01:55 +00:00
|
|
|
if (idx != lastIdx)
|
|
|
|
{
|
|
|
|
lastIdx = idx;
|
|
|
|
/* NOD provides I/O wrappers using wchar_t on Windows;
|
|
|
|
* _S() conditionally makes string-literals wide */
|
2019-07-20 04:21:57 +00:00
|
|
|
fmt::print(_S("\n"));
|
2016-01-26 02:01:55 +00:00
|
|
|
}
|
|
|
|
if (bytes != -1)
|
2019-07-20 04:21:57 +00:00
|
|
|
fmt::print(_S("\r{} {} B"), name, bytes);
|
2016-01-26 02:01:55 +00:00
|
|
|
else
|
2019-07-20 04:21:57 +00:00
|
|
|
fmt::print(_S("\r{}"), name);
|
2016-01-26 02:01:55 +00:00
|
|
|
fflush(stdout);
|
2016-01-25 20:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Making a GCN image */
|
2017-07-01 23:36:16 +00:00
|
|
|
nod::DiscBuilderGCN b(isoOutPath, progFunc);
|
|
|
|
ret = b.buildFromDirectory(fsRootDirPath);
|
2016-01-25 20:21:10 +00:00
|
|
|
|
|
|
|
/* Making a Wii image */
|
2017-07-01 23:36:16 +00:00
|
|
|
nod::DiscBuilderWii b(isoOutPath, dualLayer, progFunc);
|
|
|
|
ret = b.buildFromDirectory(fsRootDirPath);
|
2016-01-25 20:21:10 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Wii images are fakesigned using a commonly-applied [signing bug](http://wiibrew.org/wiki/Signing_bug).
|
|
|
|
|
|
|
|
Additionally, any `*.dol` files added to the disc are patched to bypass the #001 error caused by invalid signature checks.
|
|
|
|
This allows games with multiple .dols to inter-boot without extensive loader-patching.
|
|
|
|
|
|
|
|
#### Tool
|
|
|
|
|
|
|
|
The library usage mentioned above is provided by a command-line tool called `nodtool`.
|
|
|
|
|
|
|
|
An extract/repack works like so:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
>$ nodtool extract <image-in> [<dir-out>]
|
|
|
|
>$ cd <dir-out>
|
|
|
|
|
|
|
|
# Then one of:
|
2017-07-01 23:36:16 +00:00
|
|
|
>$ nodtool makegcn fsroot [<image-out>]
|
|
|
|
>$ nodtool makewii fsroot [<image-out>]
|
2016-01-25 20:21:10 +00:00
|
|
|
```
|