Humungous refactor

This commit is contained in:
Jack Andersen
2016-03-04 13:04:30 -10:00
parent 7320b76ff4
commit 556a5868bb
28 changed files with 191 additions and 192 deletions

View File

@@ -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()

View File

@@ -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,

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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++)

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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)
{
discIO = NewDiscIOISO(path);
@@ -45,7 +45,7 @@ std::unique_ptr<DiscBase> OpenDiscFromImage(const SystemChar* path, bool& isWii)
else
{
rs->read(&magic, 4);
magic = NOD::SBig(magic);
magic = nod::SBig(magic);
if (magic == 0xC2339F3D)
discIO = NewDiscIOISO(path);
}
@@ -53,7 +53,7 @@ std::unique_ptr<DiscBase> OpenDiscFromImage(const SystemChar* path, bool& isWii)
if (!discIO)
{
LogModule.report(LogVisor::Error, _S("'%s' is not a valid image"), path);
LogModule.report(logvisor::Error, _S("'%s' is not a valid image"), path);
return std::unique_ptr<DiscBase>();
}

View File

@@ -5,7 +5,7 @@
#include <stdint.h>
#include <string.h>
#include "NOD/sha1.h"
#include "nod/sha1.h"
#ifdef __BIG_ENDIAN__
# define SHA_BIG_ENDIAN