3c25647b6e
While Nintendo's own documents claim GameCube and Wii disc file symbol tables only support 7-bit ASCII, this is far from the truth. Indeed, even some first-party Nintendo games shipped with Shift-JIS encoded file symbol tables. My guess? The locale of whatever Windows machine mastered a GameCube or Wii disc influenced how wide character strings (UCS-2) were converted to narrow character strings. To account for all possibilites, this update adds extensible multi-byte character set options to NOD-Tool. A rundown of notable changes: - "-c XXXXX" option added to set the encoding of the GameCube / Wii ISO(s) being processed. - "SystemStringConv" renamed to "DiscLocToSystemConv" - "SystemUTF8Conv" renamed to "SystemToDiscLocConv" - Help message updated with new info. - Bugfix: AddBuildName had a logic error wherein the length of the SystemString was being used instead of length of the disc locale string. This would corrupt the File Symbol Table if the disc locale string's length was greater than the SystemString's length. - Bugfix: recursiveMergeFST was not keeping track of parent indexes at all, meaning nested folders and their contents would be corrupted. I simply copied the way recursiveBuildFST did things to fix this. - Bugfix (Windows): On Windows, for some reason, Sstat was a typedef for _stat (32-bit) instead of _stat64 (64-bit). This is confounding, because untrimmed Wii ISOs will always be larger than the unsigned 32-bit integer limit (4,699,979,776 bytes vs 4,294,967,295 bytes), meaning the MergeWii errand has never worked for untrimmed ISOs on Windows. Was this never tested?? - Bugfix (Windows): Did you know Windows Command Prompt fully supports Unicode? Stdio streams are now in _O_U16TEXT mode for Windows only. Previously, attempting to print any character that could not be narrowed to your locale's encoding would either silently fail (std functions), or throw an exception (fmt functions). As a minor drawback, narrow character print functions can no longer be used when stdio is in _O_U16TEXT mode, necessitating my PR for Logvisor here: (AxioDL/logvisor#7) - ExtractionContext::progressCB now uses SystemStringView because widechar printing works correctly on Windows now. - progFunc lambda no longer throws exceptions when printing unicode because widechar printing works correctly on Windows now. - Top-level constructors and functions with a Codepage_t parameter have also signatures that default to the US-ASCII codepage. - DiscGCN constructor - DiscBuilderGCN constructor - DiscBuilderGCN::CalculateTotalSizeRequired - DiscMergerGCN constructor - DiscMergerGCN::CalculateTotalSizeRequired - DiscWii constructor - DiscBuilderWii constructor - DiscBuilderWii::CalculateTotalSizeRequired - DiscMergerWii constructor - DiscMergerWii::CalculateTotalSizeRequired - OpenDiscFromImage - Conversion between system encoding and disc locale encoding has checks in place to warn the user if string conversion goes awry. |
||
---|---|---|
driver | ||
include/nod | ||
lib | ||
logvisor@274ad5ef07 | ||
.gitignore | ||
.gitmodules | ||
CMakeLists.txt | ||
Config.cmake.in | ||
LICENSE | ||
README.md |
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>]