Nintendo Optical Disc traversal and generation
Go to file
Lioncash 221bc7c7f2 General: Be explicit about athena's SeekOrigin type
Allows this code to function if the enum is turned into an enum class.
2019-09-08 17:29:38 -04:00
driver Use std::optional for CalculateTotalSizeBuild 2019-09-06 22:17:06 +02:00
include/nod General: Be explicit about athena's SeekOrigin type 2019-09-08 17:29:38 -04:00
lib Use std::optional for CalculateTotalSizeBuild 2019-09-06 22:17:06 +02:00
logvisor@8c2e711362 Update athena 2019-09-06 23:31:44 -07:00
.gitignore Add .gitignore 2017-05-29 09:55:27 -10:00
.gitmodules Minor .gitmodules change 2019-05-22 16:04:33 -10:00
CMakeLists.txt CMakeLists: Move lib-specific CMake commands into the lib folder 2019-08-30 04:53:05 -04:00
Config.cmake.in Cmake config support 2019-01-27 21:35:03 -08:00
LICENSE Update LICENSE date 2016-03-06 17:12:22 -10:00
README.md Massive libfmt refactor 2019-07-19 18:21:57 -10:00

README.md

NOD

NOD is a library and utility (nodtool) for traversing, dumping, and authoring GameCube and Wii optical disc images.

Library

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 and individual files. Files may be individually streamed, or the whole partition may be extracted to the user's filesystem. Raw ISO and WBFS images are supported read sources.

bool isWii; /* Set by reference next line */
std::unique_ptr<nod::DiscBase> disc = nod::OpenDiscFromImage(path, isWii);
if (!disc)
    return FAILURE;

/* Access first data-partition on Wii, or full GameCube disc */
nod::Partition* dataPart = disc->getDataPartition();
if (!dataPart)
    return FAILURE;

/* One-shot extraction to filesystem */
if (!dataPart->extractToDirectory(outDir, ctx))
    return FAILURE;

return SUCCESS;

Image authoring is always done from the user's filesystem and may be integrated into a content pipeline using the nod::DiscBuilderBase interface.

/* Sample logging lambda for progress feedback */
size_t lastIdx = -1;
auto progFunc = [&](size_t idx, const nod::SystemString& name, size_t bytes)
{
    if (idx != lastIdx)
    {
        lastIdx = idx;
        /* NOD provides I/O wrappers using wchar_t on Windows;
         * _S() conditionally makes string-literals wide */
        fmt::print(_S("\n"));
    }
    if (bytes != -1)
        fmt::print(_S("\r{} {} B"), name, bytes);
    else
        fmt::print(_S("\r{}"), name);
    fflush(stdout);
};

/* Making a GCN image */
nod::DiscBuilderGCN b(isoOutPath, progFunc);
ret = b.buildFromDirectory(fsRootDirPath);

/* Making a Wii image */
nod::DiscBuilderWii b(isoOutPath, dualLayer, progFunc);
ret = b.buildFromDirectory(fsRootDirPath);

Wii images are fakesigned using a commonly-applied 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:

>$ nodtool extract <image-in> [<dir-out>]
>$ cd <dir-out>

# Then one of:
>$ nodtool makegcn fsroot [<image-out>]
>$ nodtool makewii fsroot [<image-out>]