mirror of https://github.com/AxioDL/nod.git
Humungous refactor
This commit is contained in:
parent
7320b76ff4
commit
556a5868bb
|
@ -1,3 +1,3 @@
|
|||
[submodule "log-visor"]
|
||||
path = log-visor
|
||||
url = https://github.com/AxioDL/log-visor.git
|
||||
[submodule "logvisor"]
|
||||
path = logvisor
|
||||
url = https://github.com/AxioDL/logvisor.git
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(NODLib)
|
||||
project(nod)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
endif()
|
||||
|
||||
if (NOT TARGET LogVisor)
|
||||
add_subdirectory(LogVisor)
|
||||
set(LOG_VISOR_INCLUDE_DIR LogVisor/include)
|
||||
if (NOT TARGET logvisor)
|
||||
add_subdirectory(logvisor)
|
||||
set(LOGVISOR_INCLUDE_DIR logvisor/include)
|
||||
endif()
|
||||
|
||||
include_directories(include ${LOG_VISOR_INCLUDE_DIR})
|
||||
file(GLOB NOD_HEADERS include/NOD/*.h*)
|
||||
include_directories(include ${LOGVISOR_INCLUDE_DIR})
|
||||
file(GLOB NOD_HEADERS include/nod/*.h*)
|
||||
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(driver)
|
||||
install(DIRECTORY include/NOD DESTINATION include/NOD)
|
||||
install(DIRECTORY include/nod DESTINATION include/nod)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
add_executable(nodtool
|
||||
main.cpp)
|
||||
add_executable(nodtool main.cpp)
|
||||
|
||||
target_link_libraries(nodtool NOD LogVisor)
|
||||
target_link_libraries(nodtool nod logvisor)
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(nodtool pthread)
|
||||
endif()
|
||||
|
|
102
driver/main.cpp
102
driver/main.cpp
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <LogVisor/LogVisor.hpp>
|
||||
#include "NOD/NOD.hpp"
|
||||
#include "logvisor/logvisor.hpp"
|
||||
#include "nod/nod.hpp"
|
||||
|
||||
static void printHelp()
|
||||
{
|
||||
|
@ -33,13 +33,13 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
/* Enable logging to console */
|
||||
LogVisor::RegisterConsoleLogger();
|
||||
logvisor::RegisterConsoleLogger();
|
||||
|
||||
NOD::ExtractionContext ctx = { true, true, [&](const std::string& str){
|
||||
nod::ExtractionContext ctx = { true, true, [&](const std::string& str){
|
||||
fprintf(stderr, "%s\n", str.c_str());
|
||||
}};
|
||||
const NOD::SystemChar* inDir = nullptr;
|
||||
const NOD::SystemChar* outDir = _S(".");
|
||||
const nod::SystemChar* inDir = nullptr;
|
||||
const nod::SystemChar* outDir = _S(".");
|
||||
|
||||
for (int a=2 ; a<argc ; ++a)
|
||||
{
|
||||
|
@ -57,17 +57,17 @@ int main(int argc, char* argv[])
|
|||
if (!strcasecmp(argv[1], _S("extract")))
|
||||
{
|
||||
bool isWii;
|
||||
std::unique_ptr<NOD::DiscBase> disc = NOD::OpenDiscFromImage(inDir, isWii);
|
||||
std::unique_ptr<nod::DiscBase> disc = nod::OpenDiscFromImage(inDir, isWii);
|
||||
if (!disc)
|
||||
return 1;
|
||||
|
||||
NOD::Mkdir(outDir, 0755);
|
||||
nod::Mkdir(outDir, 0755);
|
||||
|
||||
if (isWii)
|
||||
static_cast<NOD::DiscWii&>(*disc).writeOutDataPartitionHeader(
|
||||
(NOD::SystemString(outDir) + _S("/partition_head.bin")).c_str());
|
||||
static_cast<nod::DiscWii&>(*disc).writeOutDataPartitionHeader(
|
||||
(nod::SystemString(outDir) + _S("/partition_head.bin")).c_str());
|
||||
|
||||
NOD::Partition* dataPart = disc->getDataPartition();
|
||||
nod::Partition* dataPart = disc->getDataPartition();
|
||||
if (!dataPart)
|
||||
return 1;
|
||||
|
||||
|
@ -78,27 +78,27 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
#if NOD_UCS2
|
||||
if (wcslen(argv[2]) < 6)
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("game-id is not at least 6 characters"));
|
||||
nod::LogModule.report(logvisor::Fatal, _S("game-id is not at least 6 characters"));
|
||||
#else
|
||||
if (strlen(argv[2]) < 6)
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("game-id is not at least 6 characters"));
|
||||
nod::LogModule.report(logvisor::Fatal, _S("game-id is not at least 6 characters"));
|
||||
#endif
|
||||
|
||||
/* Pre-validate paths */
|
||||
NOD::Sstat theStat;
|
||||
if (NOD::Stat(argv[4], &theStat) || !S_ISDIR(theStat.st_mode))
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("unable to stat %s as directory"), argv[4]);
|
||||
if (NOD::Stat(argv[5], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("unable to stat %s as file"), argv[5]);
|
||||
if (NOD::Stat(argv[6], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
NOD::LogModule.report(LogVisor::FatalError, "unable to stat %s as file", argv[6]);
|
||||
nod::Sstat theStat;
|
||||
if (nod::Stat(argv[4], &theStat) || !S_ISDIR(theStat.st_mode))
|
||||
nod::LogModule.report(logvisor::Fatal, _S("unable to stat %s as directory"), argv[4]);
|
||||
if (nod::Stat(argv[5], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
nod::LogModule.report(logvisor::Fatal, _S("unable to stat %s as file"), argv[5]);
|
||||
if (nod::Stat(argv[6], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
nod::LogModule.report(logvisor::Fatal, "unable to stat %s as file", argv[6]);
|
||||
|
||||
NOD::SystemString gameIdSys(argv[2]);
|
||||
NOD::SystemUTF8View gameId(gameIdSys);
|
||||
NOD::SystemString gameTitleSys(argv[3]);
|
||||
NOD::SystemUTF8View gameTitle(gameTitleSys);
|
||||
nod::SystemString gameIdSys(argv[2]);
|
||||
nod::SystemUTF8View gameId(gameIdSys);
|
||||
nod::SystemString gameTitleSys(argv[3]);
|
||||
nod::SystemUTF8View gameTitle(gameTitleSys);
|
||||
size_t lastIdx = -1;
|
||||
auto progFunc = [&](size_t idx, const NOD::SystemString& name, size_t bytes)
|
||||
auto progFunc = [&](size_t idx, const nod::SystemString& name, size_t bytes)
|
||||
{
|
||||
if (idx != lastIdx)
|
||||
{
|
||||
|
@ -106,9 +106,9 @@ int main(int argc, char* argv[])
|
|||
printf("\n");
|
||||
}
|
||||
if (bytes != -1)
|
||||
NOD::Printf(_S("\r%s %" PRISize " B"), name.c_str(), bytes);
|
||||
nod::Printf(_S("\r%s %" PRISize " B"), name.c_str(), bytes);
|
||||
else
|
||||
NOD::Printf(_S("\r%s"), name.c_str());
|
||||
nod::Printf(_S("\r%s"), name.c_str());
|
||||
fflush(stdout);
|
||||
};
|
||||
|
||||
|
@ -116,14 +116,14 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (argc < 8)
|
||||
{
|
||||
NOD::SystemString outPath(argv[4]);
|
||||
nod::SystemString outPath(argv[4]);
|
||||
outPath.append(_S(".iso"));
|
||||
NOD::DiscBuilderGCN b(outPath.c_str(), gameId.utf8_str().c_str(), gameTitle.utf8_str().c_str(), 0x0003EB60, progFunc);
|
||||
nod::DiscBuilderGCN b(outPath.c_str(), gameId.utf8_str().c_str(), gameTitle.utf8_str().c_str(), 0x0003EB60, progFunc);
|
||||
ret = b.buildFromDirectory(argv[4], argv[5], argv[6]);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOD::DiscBuilderGCN b(argv[7], gameId.utf8_str().c_str(), gameTitle.utf8_str().c_str(), 0x0003EB60, progFunc);
|
||||
nod::DiscBuilderGCN b(argv[7], gameId.utf8_str().c_str(), gameTitle.utf8_str().c_str(), 0x0003EB60, progFunc);
|
||||
ret = b.buildFromDirectory(argv[4], argv[5], argv[6]);
|
||||
}
|
||||
|
||||
|
@ -135,29 +135,29 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
#if NOD_UCS2
|
||||
if (wcslen(argv[2]) < 6)
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("game-id is not at least 6 characters"));
|
||||
nod::LogModule.report(logvisor::Fatal, _S("game-id is not at least 6 characters"));
|
||||
#else
|
||||
if (strlen(argv[2]) < 6)
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("game-id is not at least 6 characters"));
|
||||
nod::LogModule.report(logvisor::Fatal, _S("game-id is not at least 6 characters"));
|
||||
#endif
|
||||
|
||||
/* Pre-validate paths */
|
||||
NOD::Sstat theStat;
|
||||
if (NOD::Stat(argv[4], &theStat) || !S_ISDIR(theStat.st_mode))
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("unable to stat %s as directory"), argv[4]);
|
||||
if (NOD::Stat(argv[5], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("unable to stat %s as file"), argv[5]);
|
||||
if (NOD::Stat(argv[6], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("unable to stat %s as file"), argv[6]);
|
||||
if (NOD::Stat(argv[7], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
NOD::LogModule.report(LogVisor::FatalError, _S("unable to stat %s as file"), argv[7]);
|
||||
nod::Sstat theStat;
|
||||
if (nod::Stat(argv[4], &theStat) || !S_ISDIR(theStat.st_mode))
|
||||
nod::LogModule.report(logvisor::Fatal, _S("unable to stat %s as directory"), argv[4]);
|
||||
if (nod::Stat(argv[5], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
nod::LogModule.report(logvisor::Fatal, _S("unable to stat %s as file"), argv[5]);
|
||||
if (nod::Stat(argv[6], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
nod::LogModule.report(logvisor::Fatal, _S("unable to stat %s as file"), argv[6]);
|
||||
if (nod::Stat(argv[7], &theStat) || !S_ISREG(theStat.st_mode))
|
||||
nod::LogModule.report(logvisor::Fatal, _S("unable to stat %s as file"), argv[7]);
|
||||
|
||||
NOD::SystemString gameIdSys(argv[2]);
|
||||
NOD::SystemUTF8View gameId(gameIdSys);
|
||||
NOD::SystemString gameTitleSys(argv[3]);
|
||||
NOD::SystemUTF8View gameTitle(gameTitleSys);
|
||||
nod::SystemString gameIdSys(argv[2]);
|
||||
nod::SystemUTF8View gameId(gameIdSys);
|
||||
nod::SystemString gameTitleSys(argv[3]);
|
||||
nod::SystemUTF8View gameTitle(gameTitleSys);
|
||||
size_t lastIdx = -1;
|
||||
auto progFunc = [&](size_t idx, const NOD::SystemString& name, size_t bytes)
|
||||
auto progFunc = [&](size_t idx, const nod::SystemString& name, size_t bytes)
|
||||
{
|
||||
if (idx != lastIdx)
|
||||
{
|
||||
|
@ -165,9 +165,9 @@ int main(int argc, char* argv[])
|
|||
printf("\n");
|
||||
}
|
||||
if (bytes != -1)
|
||||
NOD::Printf(_S("\r%s %" PRISize " B"), name.c_str(), bytes);
|
||||
nod::Printf(_S("\r%s %" PRISize " B"), name.c_str(), bytes);
|
||||
else
|
||||
NOD::Printf(_S("\r%s"), name.c_str());
|
||||
nod::Printf(_S("\r%s"), name.c_str());
|
||||
fflush(stdout);
|
||||
};
|
||||
|
||||
|
@ -176,14 +176,14 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (argc < 9)
|
||||
{
|
||||
NOD::SystemString outPath(argv[4]);
|
||||
nod::SystemString outPath(argv[4]);
|
||||
outPath.append(_S(".iso"));
|
||||
NOD::DiscBuilderWii b(outPath.c_str(), gameId.utf8_str().c_str(), gameTitle.utf8_str().c_str(), dual, progFunc);
|
||||
nod::DiscBuilderWii b(outPath.c_str(), gameId.utf8_str().c_str(), gameTitle.utf8_str().c_str(), dual, progFunc);
|
||||
ret = b.buildFromDirectory(argv[4], argv[5], argv[6], argv[7]);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOD::DiscBuilderWii b(argv[8], gameId.utf8_str().c_str(), gameTitle.utf8_str().c_str(), dual, progFunc);
|
||||
nod::DiscBuilderWii b(argv[8], gameId.utf8_str().c_str(), gameTitle.utf8_str().c_str(), dual, progFunc);
|
||||
ret = b.buildFromDirectory(argv[4], argv[5], argv[6], argv[7]);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "Util.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
struct CaseInsensitiveCompare
|
|
@ -12,7 +12,7 @@
|
|||
#include "IDiscIO.hpp"
|
||||
#include "IFileIO.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class FSTNode
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
{
|
||||
if (m_kind != Kind::File)
|
||||
{
|
||||
LogModule.report(LogVisor::Error, "unable to stream a non-file %s", m_name.c_str());
|
||||
LogModule.report(logvisor::Error, "unable to stream a non-file %s", m_name.c_str());
|
||||
return std::unique_ptr<IPartReadStream>();
|
||||
}
|
||||
return m_parent.beginReadStream(m_discOffset + offset);
|
||||
|
@ -159,7 +159,7 @@ public:
|
|||
{
|
||||
if (m_kind != Kind::File)
|
||||
{
|
||||
LogModule.report(LogVisor::Error, "unable to buffer a non-file %s", m_name.c_str());
|
||||
LogModule.report(logvisor::Error, "unable to buffer a non-file %s", m_name.c_str());
|
||||
return std::unique_ptr<uint8_t[]>();
|
||||
}
|
||||
uint8_t* buf = new uint8_t[m_discLength];
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "DiscBase.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class DiscGCN : public DiscBase
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "DiscBase.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class DiscWii : public DiscBase
|
|
@ -7,11 +7,11 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#if NOD_ATHENA
|
||||
#include <Athena/IStreamReader.hpp>
|
||||
#include <Athena/IStreamWriter.hpp>
|
||||
#include <athena/IStreamReader.hpp>
|
||||
#include <athena/IStreamWriter.hpp>
|
||||
#endif
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class IDiscIO
|
||||
|
@ -54,17 +54,17 @@ struct IPartWriteStream
|
|||
|
||||
#if NOD_ATHENA
|
||||
|
||||
class AthenaPartReadStream : public Athena::io::IStreamReader
|
||||
class AthenaPartReadStream : public athena::io::IStreamReader
|
||||
{
|
||||
std::unique_ptr<IPartReadStream> m_rs;
|
||||
public:
|
||||
AthenaPartReadStream(std::unique_ptr<IPartReadStream>&& rs) : m_rs(std::move(rs)) {}
|
||||
|
||||
inline void seek(atInt64 off, Athena::SeekOrigin origin)
|
||||
inline void seek(atInt64 off, athena::SeekOrigin origin)
|
||||
{
|
||||
if (origin == Athena::Begin)
|
||||
if (origin == athena::Begin)
|
||||
m_rs->seek(off, SEEK_SET);
|
||||
else if (origin == Athena::Current)
|
||||
else if (origin == athena::Current)
|
||||
m_rs->seek(off, SEEK_CUR);
|
||||
}
|
||||
inline atUint64 position() const {return m_rs->position();}
|
|
@ -6,7 +6,7 @@
|
|||
#include "IDiscIO.hpp"
|
||||
#include "Util.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class IFileIO
|
|
@ -25,7 +25,7 @@
|
|||
#include <string>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <LogVisor/LogVisor.hpp>
|
||||
#include "logvisor/logvisor.hpp"
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4996)
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
|||
#undef min
|
||||
#undef max
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
/* define our own min/max to avoid MSVC BS */
|
||||
template<typename T>
|
||||
|
@ -56,7 +56,7 @@ template<typename T>
|
|||
inline T max(T a, T b) { return a > b ? a : b; }
|
||||
|
||||
/* Log Module */
|
||||
extern LogVisor::LogModule LogModule;
|
||||
extern logvisor::Module LogModule;
|
||||
|
||||
/* filesystem char type */
|
||||
#if _WIN32 && UNICODE
|
||||
|
@ -272,7 +272,7 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo
|
|||
LockFileEx((HANDLE)(uintptr_t)_fileno(fp), (lock == FileLockType::Write) ? LOCKFILE_EXCLUSIVE_LOCK : 0, 0, 0, 1, &ov);
|
||||
#else
|
||||
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
|
||||
LogModule.report(LogVisor::Error, "flock %s: %s", path, strerror(errno));
|
||||
LogModule.report(logvisor::Error, "flock %s: %s", path, strerror(errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -309,16 +309,16 @@ static inline bool CheckFreeSpace(const SystemChar* path, size_t reqSz)
|
|||
wchar_t* end;
|
||||
DWORD ret = GetFullPathNameW(path, 1024, buf, &end);
|
||||
if (!ret || ret > 1024)
|
||||
LogModule.report(LogVisor::FatalError, _S("GetFullPathNameW %s"), path);
|
||||
LogModule.report(logvisor::Fatal, _S("GetFullPathNameW %s"), path);
|
||||
if (end)
|
||||
end[0] = L'\0';
|
||||
if (!GetDiskFreeSpaceExW(buf, &freeBytes, nullptr, nullptr))
|
||||
LogModule.report(LogVisor::FatalError, _S("GetDiskFreeSpaceExW %s: %d"), path, GetLastError());
|
||||
LogModule.report(logvisor::Fatal, _S("GetDiskFreeSpaceExW %s: %d"), path, GetLastError());
|
||||
return reqSz < freeBytes.QuadPart;
|
||||
#else
|
||||
struct statvfs svfs;
|
||||
if (statvfs(path, &svfs))
|
||||
LogModule.report(LogVisor::FatalError, "statvfs %s: %s", path, strerror(errno));
|
||||
LogModule.report(logvisor::Fatal, "statvfs %s: %s", path, strerror(errno));
|
||||
return reqSz < svfs.f_frsize * svfs.f_bavail;
|
||||
#endif
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <memory>
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class IAES
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <LogVisor/LogVisor.hpp>
|
||||
#include "logvisor/logvisor.hpp"
|
||||
#include "Util.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class DiscBase;
|
|
@ -4,7 +4,7 @@ set(PLAT_SRCS FileIOFILE.cpp)
|
|||
else()
|
||||
set(PLAT_SRCS FileIOWin32.cpp)
|
||||
endif()
|
||||
add_library(NOD
|
||||
add_library(nod
|
||||
aes.cpp
|
||||
sha1.c
|
||||
DiscBase.cpp
|
||||
|
@ -13,9 +13,9 @@ add_library(NOD
|
|||
DiscIOWBFS.cpp
|
||||
DiscWii.cpp
|
||||
DirectoryEnumerator.cpp
|
||||
NOD.cpp
|
||||
nod.cpp
|
||||
${PLAT_SRCS}
|
||||
${NOD_HEADERS})
|
||||
if(NOT WIN32)
|
||||
if(NOT MSVC)
|
||||
set_source_files_properties(aes.cpp PROPERTIES COMPILE_FLAGS -maes)
|
||||
endif()
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
#include "NOD/DirectoryEnumerator.hpp"
|
||||
#include "nod/DirectoryEnumerator.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "NOD/DiscBase.hpp"
|
||||
#include "NOD/IFileIO.hpp"
|
||||
#include "NOD/DirectoryEnumerator.hpp"
|
||||
#include "NOD/NOD.hpp"
|
||||
#include "nod/DiscBase.hpp"
|
||||
#include "nod/IFileIO.hpp"
|
||||
#include "nod/DirectoryEnumerator.hpp"
|
||||
#include "nod/nod.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
@ -35,7 +35,7 @@ static void* memmem(const void *haystack, size_t hlen, const void *needle, size_
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
void DiscBase::IPartition::parseFST(IPartReadStream& s)
|
||||
|
@ -101,7 +101,7 @@ bool DiscBase::IPartition::Node::extractToDirectory(const SystemString& basePath
|
|||
ctx.progressCB(getName());
|
||||
if (Mkdir(path.c_str(), 0755) && errno != EEXIST)
|
||||
{
|
||||
LogModule.report(LogVisor::Error, _S("unable to mkdir '%s'"), path.c_str());
|
||||
LogModule.report(logvisor::Error, _S("unable to mkdir '%s'"), path.c_str());
|
||||
return false;
|
||||
}
|
||||
for (Node& subnode : *this)
|
||||
|
@ -130,7 +130,7 @@ bool DiscBase::IPartition::extractToDirectory(const SystemString& path,
|
|||
Sstat theStat;
|
||||
if (Mkdir(path.c_str(), 0755) && errno != EEXIST)
|
||||
{
|
||||
LogModule.report(LogVisor::Error, _S("unable to mkdir '%s'"), path.c_str());
|
||||
LogModule.report(logvisor::Error, _S("unable to mkdir '%s'"), path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ bool DiscBase::IPartition::extractToDirectory(const SystemString& path,
|
|||
SystemString fsPath = path + _S("/fsroot");
|
||||
if (Mkdir(fsPath.c_str(), 0755) && errno != EEXIST)
|
||||
{
|
||||
LogModule.report(LogVisor::Error, _S("unable to mkdir '%s'"), fsPath.c_str());
|
||||
LogModule.report(logvisor::Error, _S("unable to mkdir '%s'"), fsPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -177,17 +177,17 @@ static uint64_t GetInode(const SystemChar* path)
|
|||
FILE_ATTRIBUTE_NORMAL,
|
||||
nullptr);
|
||||
if (!fp)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to open %s"), path);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to open %s"), path);
|
||||
BY_HANDLE_FILE_INFORMATION info;
|
||||
if (!GetFileInformationByHandle(fp, &info))
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to GetFileInformationByHandle %s"), path);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to GetFileInformationByHandle %s"), path);
|
||||
inode = uint64_t(info.nFileIndexHigh) << 32;
|
||||
inode |= uint64_t(info.nFileIndexLow);
|
||||
CloseHandle(fp);
|
||||
#else
|
||||
struct stat st;
|
||||
if (stat(path, &st))
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to stat %s"), path);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to stat %s"), path);
|
||||
inode = uint64_t(st.st_ino);
|
||||
#endif
|
||||
return inode;
|
||||
|
@ -277,7 +277,7 @@ void DiscBuilderBase::PartitionBuilderBase::recursiveBuildNodes(IPartWriteStream
|
|||
++m_parent.m_progressIdx;
|
||||
while (xferSz < e.m_fileSz)
|
||||
{
|
||||
size_t rdSz = rs->read(buf, NOD::min(size_t(0x8000ul), e.m_fileSz - xferSz));
|
||||
size_t rdSz = rs->read(buf, nod::min(size_t(0x8000ul), e.m_fileSz - xferSz));
|
||||
if (!rdSz)
|
||||
break;
|
||||
ws.write(buf, rdSz);
|
||||
|
@ -329,7 +329,7 @@ bool DiscBuilderBase::PartitionBuilderBase::buildFromDirectory(IPartWriteStream&
|
|||
const SystemChar* apploaderIn)
|
||||
{
|
||||
if (!dirIn || !dolIn || !apploaderIn)
|
||||
LogModule.report(LogVisor::FatalError, _S("all arguments must be supplied to buildFromDirectory()"));
|
||||
LogModule.report(logvisor::Fatal, _S("all arguments must be supplied to buildFromDirectory()"));
|
||||
|
||||
/* Clear file */
|
||||
++m_parent.m_progressIdx;
|
||||
|
@ -343,7 +343,7 @@ bool DiscBuilderBase::PartitionBuilderBase::buildFromDirectory(IPartWriteStream&
|
|||
{
|
||||
Sstat dolStat;
|
||||
if (Stat(dolIn, &dolStat))
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to stat %s"), dolIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to stat %s"), dolIn);
|
||||
size_t fileSz = ROUND_UP_32(dolStat.st_size);
|
||||
uint64_t fileOff = userAllocate(fileSz, ws);
|
||||
m_dolOffset = fileOff;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "NOD/DiscGCN.hpp"
|
||||
#include "nod/DiscGCN.hpp"
|
||||
#define BUFFER_SZ 0x8000
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class PartitionGCN : public DiscBase::IPartition
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
m_curUser &= 0xfffffffffffffff0;
|
||||
if (m_curUser < 0x30000)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "user area low mark reached");
|
||||
LogModule.report(logvisor::Fatal, "user area low mark reached");
|
||||
return -1;
|
||||
}
|
||||
static_cast<PartWriteStream&>(ws).seek(m_curUser);
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
ws->write(buf, rdSz);
|
||||
xferSz += rdSz;
|
||||
if (0x2440 + xferSz >= m_curUser)
|
||||
LogModule.report(LogVisor::FatalError,
|
||||
LogModule.report(logvisor::Fatal,
|
||||
"apploader flows into user area (one or the other is too big)");
|
||||
m_parent.m_progressCB(m_parent.m_progressIdx, apploaderName, xferSz);
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ public:
|
|||
fstSz = ROUND_UP_32(fstSz);
|
||||
|
||||
if (fstOff + fstSz >= m_curUser)
|
||||
LogModule.report(LogVisor::FatalError,
|
||||
LogModule.report(logvisor::Fatal,
|
||||
"FST flows into user area (one or the other is too big)");
|
||||
|
||||
ws = beginWriteStream(0x420);
|
||||
|
@ -236,7 +236,7 @@ bool DiscBuilderGCN::buildFromDirectory(const SystemChar* dirIn, const SystemCha
|
|||
|
||||
if (!CheckFreeSpace(m_outPath, 0x57058000))
|
||||
{
|
||||
LogModule.report(LogVisor::Error, _S("not enough free disk space for %s"), m_outPath);
|
||||
LogModule.report(logvisor::Error, _S("not enough free disk space for %s"), m_outPath);
|
||||
return false;
|
||||
}
|
||||
++m_progressIdx;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include "NOD/Util.hpp"
|
||||
#include "NOD/IDiscIO.hpp"
|
||||
#include "NOD/IFileIO.hpp"
|
||||
#include "nod/Util.hpp"
|
||||
#include "nod/IDiscIO.hpp"
|
||||
#include "nod/IFileIO.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class DiscIOISO : public IDiscIO
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "NOD/Util.hpp"
|
||||
#include "NOD/IDiscIO.hpp"
|
||||
#include "NOD/IFileIO.hpp"
|
||||
#include "nod/Util.hpp"
|
||||
#include "nod/IDiscIO.hpp"
|
||||
#include "nod/IFileIO.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
#define ALIGN_LBA(x) (((x)+p->hd_sec_sz-1)&(~(p->hd_sec_sz-1)))
|
||||
|
@ -80,7 +80,7 @@ class DiscIOWBFS : public IDiscIO
|
|||
rs.seek(off, SEEK_SET);
|
||||
if (rs.read(buf, count*512ULL) != count*512ULL)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "error reading disc");
|
||||
LogModule.report(logvisor::Fatal, "error reading disc");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
WBFS* p = &wbfs;
|
||||
WBFSHead tmpHead;
|
||||
if (rs->read(&tmpHead, sizeof(tmpHead)) != sizeof(tmpHead))
|
||||
LogModule.report(LogVisor::FatalError, "unable to read WBFS head");
|
||||
LogModule.report(logvisor::Fatal, "unable to read WBFS head");
|
||||
unsigned hd_sector_size = 1 << tmpHead.hd_sec_sz_s;
|
||||
unsigned num_hd_sector = SBig(tmpHead.n_hd_sec);
|
||||
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
WBFSHead* head = (WBFSHead*)wbfsHead.get();
|
||||
rs->seek(0, SEEK_SET);
|
||||
if (rs->read(head, hd_sector_size) != hd_sector_size)
|
||||
LogModule.report(LogVisor::FatalError, "unable to read WBFS head");
|
||||
LogModule.report(logvisor::Fatal, "unable to read WBFS head");
|
||||
|
||||
//constants, but put here for consistancy
|
||||
p->wii_sec_sz = 0x8000;
|
||||
|
@ -115,10 +115,10 @@ public:
|
|||
p->part_lba = 0;
|
||||
_wbfsReadSector(*rs, p->part_lba, 1, head);
|
||||
if (hd_sector_size && head->hd_sec_sz_s != size_to_shift(hd_sector_size)) {
|
||||
LogModule.report(LogVisor::FatalError, "hd sector size doesn't match");
|
||||
LogModule.report(logvisor::Fatal, "hd sector size doesn't match");
|
||||
}
|
||||
if (num_hd_sector && head->n_hd_sec != SBig(num_hd_sector)) {
|
||||
LogModule.report(LogVisor::FatalError, "hd num sector doesn't match");
|
||||
LogModule.report(logvisor::Fatal, "hd num sector doesn't match");
|
||||
}
|
||||
p->hd_sec_sz = 1<<head->hd_sec_sz_s;
|
||||
p->hd_sec_sz_s = head->hd_sec_sz_s;
|
||||
|
@ -146,7 +146,7 @@ public:
|
|||
{
|
||||
wbfsDiscInfo.reset(new uint8_t[p->disc_info_sz]);
|
||||
if (!wbfsDiscInfo)
|
||||
LogModule.report(LogVisor::FatalError, "allocating memory");
|
||||
LogModule.report(logvisor::Fatal, "allocating memory");
|
||||
_wbfsReadSector(*rs, p->part_lba+1, disc_info_sz_lba, wbfsDiscInfo.get());
|
||||
p->n_disc_open++;
|
||||
//for(i=0;i<p->n_wbfs_sec_per_disc;i++)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "NOD/DiscWii.hpp"
|
||||
#include "NOD/aes.hpp"
|
||||
#include "NOD/sha1.h"
|
||||
#include "nod/DiscWii.hpp"
|
||||
#include "nod/aes.hpp"
|
||||
#include "nod/sha1.h"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
static const uint8_t COMMON_KEYS[2][16] =
|
||||
|
@ -348,7 +348,7 @@ public:
|
|||
std::unique_ptr<IDiscIO::IReadStream> rs = m_parent.getDiscIO().beginReadStream(m_offset + 0x2B4);
|
||||
uint32_t h3;
|
||||
if (rs->read(&h3, 4) != 4)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to read H3 offset from %s"), pathOut);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to read H3 offset from %s"), pathOut);
|
||||
h3 = SBig(h3);
|
||||
h3Off = uint64_t(h3) << 2;
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ public:
|
|||
std::unique_ptr<IDiscIO::IReadStream> rs = m_parent.getDiscIO().beginReadStream(m_offset);
|
||||
while (rem)
|
||||
{
|
||||
size_t rdSz = NOD::min(rem, size_t(8192ul));
|
||||
size_t rdSz = nod::min(rem, size_t(8192ul));
|
||||
rs->read(buf, rdSz);
|
||||
ws->write(buf, rdSz);
|
||||
rem -= rdSz;
|
||||
|
@ -410,7 +410,7 @@ DiscWii::DiscWii(std::unique_ptr<IDiscIO>&& dio)
|
|||
kind = part.partType;
|
||||
break;
|
||||
default:
|
||||
LogModule.report(LogVisor::FatalError, "invalid partition type %d", part.partType);
|
||||
LogModule.report(logvisor::Fatal, "invalid partition type %d", part.partType);
|
||||
}
|
||||
m_partitions.emplace_back(new PartitionWii(*this, kind, part.partDataOff << 2));
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ public:
|
|||
}
|
||||
|
||||
if (m_fio->write(m_buf, 0x200000) != 0x200000)
|
||||
LogModule.report(LogVisor::FatalError, "unable to write full disc group");
|
||||
LogModule.report(logvisor::Fatal, "unable to write full disc group");
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -520,7 +520,7 @@ public:
|
|||
: m_parent(parent), m_baseOffset(baseOffset), m_offset(offset)
|
||||
{
|
||||
if (offset % 0x1F0000)
|
||||
LogModule.report(LogVisor::FatalError, "partition write stream MUST begin on 0x1F0000-aligned boundary");
|
||||
LogModule.report(logvisor::Fatal, "partition write stream MUST begin on 0x1F0000-aligned boundary");
|
||||
size_t group = m_offset / 0x1F0000;
|
||||
m_fio = m_parent.m_parent.getFileIO().beginWriteStream(m_baseOffset + group * 0x200000);
|
||||
m_curGroup = group;
|
||||
|
@ -597,14 +597,14 @@ public:
|
|||
reqSz = ROUND_UP_32(reqSz);
|
||||
if (m_curUser + reqSz >= 0x1FB450000)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "partition exceeds maximum single-partition capacity");
|
||||
LogModule.report(logvisor::Fatal, "partition exceeds maximum single-partition capacity");
|
||||
return -1;
|
||||
}
|
||||
uint64_t ret = m_curUser;
|
||||
PartWriteStream& cws = static_cast<PartWriteStream&>(ws);
|
||||
if (cws.m_offset > ret)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "partition overwrite error");
|
||||
LogModule.report(logvisor::Fatal, "partition overwrite error");
|
||||
return -1;
|
||||
}
|
||||
while (cws.m_offset < ret)
|
||||
|
@ -634,27 +634,27 @@ public:
|
|||
uint8_t tkey[16];
|
||||
{
|
||||
if (ph->beginReadStream(0x1BF)->read(tkey, 16) != 16)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to read title key from %s"), partHeadIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to read title key from %s"), partHeadIn);
|
||||
}
|
||||
|
||||
uint8_t tkeyiv[16] = {};
|
||||
{
|
||||
if (ph->beginReadStream(0x1DC)->read(tkeyiv, 8) != 8)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to read title key IV from %s"), partHeadIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to read title key IV from %s"), partHeadIn);
|
||||
}
|
||||
|
||||
uint8_t ccIdx;
|
||||
{
|
||||
if (ph->beginReadStream(0x1F1)->read(&ccIdx, 1) != 1)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to read common key index from %s"), partHeadIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to read common key index from %s"), partHeadIn);
|
||||
if (ccIdx > 1)
|
||||
LogModule.report(LogVisor::FatalError, _S("common key index may only be 0 or 1"));
|
||||
LogModule.report(logvisor::Fatal, _S("common key index may only be 0 or 1"));
|
||||
}
|
||||
|
||||
uint32_t tmdSz;
|
||||
{
|
||||
if (ph->beginReadStream(0x2A4)->read(&tmdSz, 4) != 4)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to read TMD size from %s"), partHeadIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to read TMD size from %s"), partHeadIn);
|
||||
tmdSz = SBig(tmdSz);
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,7 @@ public:
|
|||
{
|
||||
uint32_t h3Ptr;
|
||||
if (ph->beginReadStream(0x2B4)->read(&h3Ptr, 4) != 4)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to read H3 pointer from %s"), partHeadIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to read H3 pointer from %s"), partHeadIn);
|
||||
h3Off = uint64_t(SBig(h3Ptr)) << 2;
|
||||
}
|
||||
|
||||
|
@ -670,14 +670,14 @@ public:
|
|||
{
|
||||
uint32_t dataPtr;
|
||||
if (ph->beginReadStream(0x2B8)->read(&dataPtr, 4) != 4)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to read data pointer from %s"), partHeadIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to read data pointer from %s"), partHeadIn);
|
||||
dataOff = uint64_t(SBig(dataPtr)) << 2;
|
||||
}
|
||||
m_userOffset = dataOff;
|
||||
|
||||
std::unique_ptr<uint8_t[]> tmdData(new uint8_t[tmdSz]);
|
||||
if (ph->beginReadStream(0x2C0)->read(tmdData.get(), tmdSz) != tmdSz)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to read TMD from %s"), partHeadIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to read TMD from %s"), partHeadIn);
|
||||
|
||||
/* Copy partition head up to H3 table */
|
||||
std::unique_ptr<IFileIO::IWriteStream> ws = m_parent.getFileIO().beginWriteStream(m_baseOffset);
|
||||
|
@ -732,7 +732,7 @@ public:
|
|||
/* Get Apploader Size */
|
||||
Sstat theStat;
|
||||
if (Stat(apploaderIn, &theStat))
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to stat %s"), apploaderIn);
|
||||
LogModule.report(logvisor::Fatal, _S("unable to stat %s"), apploaderIn);
|
||||
|
||||
/* Compute boot table members and write */
|
||||
size_t fstOff = 0x2440 + ROUND_UP_32(theStat.st_size);
|
||||
|
@ -741,7 +741,7 @@ public:
|
|||
fstSz = ROUND_UP_32(fstSz);
|
||||
|
||||
if (fstOff + fstSz >= 0x1F0000)
|
||||
LogModule.report(LogVisor::FatalError,
|
||||
LogModule.report(logvisor::Fatal,
|
||||
"FST flows into user area (one or the other is too big)");
|
||||
|
||||
cws->write(nullptr, 0x420 - sizeof(Header));
|
||||
|
@ -767,14 +767,14 @@ public:
|
|||
cws->write(buf, rdSz);
|
||||
xferSz += rdSz;
|
||||
if (0x2440 + xferSz >= 0x1F0000)
|
||||
LogModule.report(LogVisor::FatalError,
|
||||
LogModule.report(logvisor::Fatal,
|
||||
"apploader flows into user area (one or the other is too big)");
|
||||
m_parent.m_progressCB(m_parent.m_progressIdx, apploaderName, xferSz);
|
||||
}
|
||||
|
||||
size_t fstOffRel = fstOff - 0x2440;
|
||||
if (xferSz > fstOffRel)
|
||||
LogModule.report(LogVisor::FatalError, "apploader unexpectedly flows into FST");
|
||||
LogModule.report(logvisor::Fatal, "apploader unexpectedly flows into FST");
|
||||
for (size_t i=0 ; i<fstOffRel-xferSz ; ++i)
|
||||
cws->write("\xff", 1);
|
||||
|
||||
|
@ -856,7 +856,7 @@ bool DiscBuilderWii::buildFromDirectory(const SystemChar* dirIn, const SystemCha
|
|||
|
||||
if (!CheckFreeSpace(m_outPath, m_discCapacity))
|
||||
{
|
||||
LogModule.report(LogVisor::Error, _S("not enough free disk space for %s"), m_outPath);
|
||||
LogModule.report(logvisor::Error, _S("not enough free disk space for %s"), m_outPath);
|
||||
return false;
|
||||
}
|
||||
++m_progressIdx;
|
||||
|
@ -867,7 +867,7 @@ bool DiscBuilderWii::buildFromDirectory(const SystemChar* dirIn, const SystemCha
|
|||
filledSz = pb.buildFromDirectory(dirIn, dolIn, apploaderIn, partHeadIn);
|
||||
if (filledSz >= m_discCapacity)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "data partition exceeds disc capacity");
|
||||
LogModule.report(logvisor::Fatal, "data partition exceeds disc capacity");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include "NOD/Util.hpp"
|
||||
#include "NOD/IFileIO.hpp"
|
||||
#include "nod/Util.hpp"
|
||||
#include "nod/IFileIO.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class FileIOFILE : public IFileIO
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
{
|
||||
fp = fopen(path.c_str(), "wb");
|
||||
if (!fp)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for writing"), path.c_str());
|
||||
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for writing"), path.c_str());
|
||||
}
|
||||
WriteStream(const SystemString& path, uint64_t offset, int64_t maxWriteSize)
|
||||
: m_maxWriteSize(maxWriteSize)
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
FSeek(fp, offset, SEEK_SET);
|
||||
return;
|
||||
FailLoc:
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for writing"), path.c_str());
|
||||
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for writing"), path.c_str());
|
||||
}
|
||||
~WriteStream()
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
if (m_maxWriteSize >= 0)
|
||||
{
|
||||
if (FTell(fp) + length > m_maxWriteSize)
|
||||
LogModule.report(LogVisor::FatalError, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
|
||||
LogModule.report(logvisor::Fatal, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
|
||||
}
|
||||
return fwrite(buf, 1, length, fp);
|
||||
}
|
||||
|
@ -82,16 +82,16 @@ public:
|
|||
uint8_t buf[0x7c00];
|
||||
while (length)
|
||||
{
|
||||
uint64_t thisSz = NOD::min(uint64_t(0x7c00), length);
|
||||
uint64_t thisSz = nod::min(uint64_t(0x7c00), length);
|
||||
uint64_t readSz = discio.read(buf, thisSz);
|
||||
if (thisSz != readSz)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "unable to read enough from disc");
|
||||
LogModule.report(logvisor::Fatal, "unable to read enough from disc");
|
||||
return read;
|
||||
}
|
||||
if (write(buf, readSz) != readSz)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "unable to write in file");
|
||||
LogModule.report(logvisor::Fatal, "unable to write in file");
|
||||
return read;
|
||||
}
|
||||
length -= thisSz;
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
{
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (!fp)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for reading"), path.c_str());
|
||||
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for reading"), path.c_str());
|
||||
}
|
||||
ReadStream(const SystemString& path, uint64_t offset)
|
||||
: ReadStream(path)
|
||||
|
@ -145,15 +145,15 @@ public:
|
|||
uint8_t buf[0x7c00];
|
||||
while (length)
|
||||
{
|
||||
uint64_t thisSz = NOD::min(uint64_t(0x7c00), length);
|
||||
uint64_t thisSz = nod::min(uint64_t(0x7c00), length);
|
||||
if (read(buf, thisSz) != thisSz)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "unable to read enough from file");
|
||||
LogModule.report(logvisor::Fatal, "unable to read enough from file");
|
||||
return written;
|
||||
}
|
||||
if (discio.write(buf, thisSz) != thisSz)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "unable to write enough to disc");
|
||||
LogModule.report(logvisor::Fatal, "unable to write enough to disc");
|
||||
return written;
|
||||
}
|
||||
length -= thisSz;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include "NOD/Util.hpp"
|
||||
#include "NOD/IFileIO.hpp"
|
||||
#include "nod/Util.hpp"
|
||||
#include "nod/IFileIO.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
class FileIOWin32 : public IFileIO
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
fp = CreateFileW(path.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||
nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (fp == INVALID_HANDLE_VALUE)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for writing"), path.c_str());
|
||||
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for writing"), path.c_str());
|
||||
}
|
||||
WriteStream(const SystemString& path, uint64_t offset, int64_t maxWriteSize)
|
||||
: m_maxWriteSize(maxWriteSize)
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
fp = CreateFileW(path.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||
nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (fp == INVALID_HANDLE_VALUE)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for writing"), path.c_str());
|
||||
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for writing"), path.c_str());
|
||||
LARGE_INTEGER lioffset;
|
||||
lioffset.QuadPart = offset;
|
||||
SetFilePointerEx(fp, lioffset, nullptr, FILE_BEGIN);
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
LARGE_INTEGER res;
|
||||
SetFilePointerEx(fp, li, &res, FILE_CURRENT);
|
||||
if (res.QuadPart + int64_t(length) > m_maxWriteSize)
|
||||
LogModule.report(LogVisor::FatalError, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
|
||||
LogModule.report(logvisor::Fatal, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
|
||||
}
|
||||
|
||||
DWORD ret = 0;
|
||||
|
@ -91,16 +91,16 @@ public:
|
|||
uint8_t buf[0x7c00];
|
||||
while (length)
|
||||
{
|
||||
uint64_t thisSz = NOD::min(uint64_t(0x7c00), length);
|
||||
uint64_t thisSz = nod::min(uint64_t(0x7c00), length);
|
||||
uint64_t readSz = discio.read(buf, thisSz);
|
||||
if (thisSz != readSz)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "unable to read enough from disc");
|
||||
LogModule.report(logvisor::Fatal, "unable to read enough from disc");
|
||||
return read;
|
||||
}
|
||||
if (write(buf, readSz) != readSz)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "unable to write in file");
|
||||
LogModule.report(logvisor::Fatal, "unable to write in file");
|
||||
return read;
|
||||
}
|
||||
length -= thisSz;
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
fp = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (fp == INVALID_HANDLE_VALUE)
|
||||
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for reading"), path.c_str());
|
||||
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for reading"), path.c_str());
|
||||
}
|
||||
ReadStream(const SystemString& path, uint64_t offset)
|
||||
: ReadStream(path)
|
||||
|
@ -164,15 +164,15 @@ public:
|
|||
uint8_t buf[0x7c00];
|
||||
while (length)
|
||||
{
|
||||
uint64_t thisSz = NOD::min(uint64_t(0x7c00), length);
|
||||
uint64_t thisSz = nod::min(uint64_t(0x7c00), length);
|
||||
if (read(buf, thisSz) != thisSz)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "unable to read enough from file");
|
||||
LogModule.report(logvisor::Fatal, "unable to read enough from file");
|
||||
return written;
|
||||
}
|
||||
if (discio.write(buf, thisSz) != thisSz)
|
||||
{
|
||||
LogModule.report(LogVisor::FatalError, "unable to write enough to disc");
|
||||
LogModule.report(logvisor::Fatal, "unable to write enough to disc");
|
||||
return written;
|
||||
}
|
||||
length -= thisSz;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "NOD/aes.hpp"
|
||||
#include "nod/aes.hpp"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
|||
#include <cpuid.h>
|
||||
#endif
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
/* rotates x one bit to the left */
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include "NOD/NOD.hpp"
|
||||
#include "NOD/DiscBase.hpp"
|
||||
#include "nod/nod.hpp"
|
||||
#include "nod/DiscBase.hpp"
|
||||
|
||||
namespace NOD
|
||||
namespace nod
|
||||
{
|
||||
|
||||
LogVisor::LogModule LogModule("NODLib");
|
||||
logvisor::Module LogModule("nod");
|
||||
|
||||
std::unique_ptr<IDiscIO> NewDiscIOISO(const SystemChar* path);
|
||||
std::unique_ptr<IDiscIO> NewDiscIOWBFS(const SystemChar* path);
|
||||
|
@ -16,7 +16,7 @@ std::unique_ptr<DiscBase> OpenDiscFromImage(const SystemChar* path, bool& isWii)
|
|||
std::unique_ptr<IFileIO> fio = NewFileIO(path);
|
||||
if (!fio->exists())
|
||||
{
|
||||
LogModule.report(LogVisor::Error, _S("Unable to open '%s'"), path);
|
||||
LogModule.report(logvisor::Error, _S("Unable to open '%s'"), path);
|
||||
return std::unique_ptr<DiscBase>();
|
||||
}
|
||||
std::unique_ptr<IFileIO::IReadStream> rs = fio->beginReadStream();
|
||||
|
@ -25,9 +25,9 @@ std::unique_ptr<DiscBase> OpenDiscFromImage(const SystemChar* path, bool& isWii)
|
|||
std::unique_ptr<IDiscIO> discIO;
|
||||
uint32_t magic = 0;
|
||||
if (rs->read(&magic, 4) != 4)
|
||||
LogModule.report(LogVisor::FatalError, _S("Unable to read magic from '%s'"), path);
|
||||
LogModule.report(logvisor::Fatal, _S("Unable to read magic from '%s'"), path);
|
||||
|
||||
if (magic == NOD::SBig((uint32_t)'WBFS'))
|
||||
if (magic == nod::SBig((uint32_t)'WBFS'))
|
||||
{
|
||||
discIO = NewDiscIOWBFS(path);
|
||||
isWii = true;
|
||||
|
@ -36,7 +36,7 @@ std::unique_ptr<DiscBase> OpenDiscFromImage(const SystemChar* path, bool& isWii)
|
|||
{
|
||||
rs->seek(0x18, SEEK_SET);
|
||||
rs->read(&magic, 4);
|
||||
magic = NOD::SBig(magic);
|
||||
magic = nod::SBig(magic);
|
||||
if (magic == 0x5D1C9EA3)
|
||||
{
|
||||