[nx] Added nx namespace.

This commit is contained in:
jakcron 2017-07-06 21:17:21 +10:00
parent 01162b8187
commit 7b34bd404d
14 changed files with 450 additions and 420 deletions

View file

@ -1,5 +1,7 @@
#include "AciHeader.h" #include "AciHeader.h"
using namespace nx;
void AciHeader::clearVariables() void AciHeader::clearVariables()
{ {
mType = TYPE_ACI0; mType = TYPE_ACI0;

View file

@ -4,6 +4,8 @@
#include <fnd/memory_blob.h> #include <fnd/memory_blob.h>
#include <nx/ISerialiseableBinary.h> #include <nx/ISerialiseableBinary.h>
namespace nx
{
class AciHeader : public ISerialiseableBinary class AciHeader : public ISerialiseableBinary
{ {
public: public:
@ -106,4 +108,5 @@ private:
bool isEqual(const AciHeader& other) const; bool isEqual(const AciHeader& other) const;
void copyFrom(const AciHeader& other); void copyFrom(const AciHeader& other);
}; };
}

View file

@ -1,6 +1,6 @@
#include "FacBinary.h" #include "FacBinary.h"
using namespace nx;
FacBinary::FacBinary() : FacBinary::FacBinary() :
mHeader() mHeader()

View file

@ -5,6 +5,8 @@
#include <nx/ISerialiseableBinary.h> #include <nx/ISerialiseableBinary.h>
#include <nx/FacHeader.h> #include <nx/FacHeader.h>
namespace nx
{
class FacBinary : class FacBinary :
public ISerialiseableBinary public ISerialiseableBinary
{ {
@ -78,4 +80,5 @@ private:
bool isEqual(const FacBinary& other) const; bool isEqual(const FacBinary& other) const;
void copyFrom(const FacBinary& other); void copyFrom(const FacBinary& other);
}; };
}

View file

@ -1,6 +1,6 @@
#include "FacHeader.h" #include "FacHeader.h"
using namespace nx;
FacHeader::FacHeader() FacHeader::FacHeader()
{ {

View file

@ -3,6 +3,8 @@
#include <fnd/memory_blob.h> #include <fnd/memory_blob.h>
#include <nx/ISerialiseableBinary.h> #include <nx/ISerialiseableBinary.h>
namespace nx
{
class FacHeader : class FacHeader :
public ISerialiseableBinary public ISerialiseableBinary
{ {
@ -80,7 +82,8 @@ private:
// variables // variables
u64 mFsaRights; u64 mFsaRights;
struct sSection { struct sSection
{
size_t offset; size_t offset;
size_t size; size_t size;
} mContentOwnerIdPos, mSaveDataOwnerIdPos; } mContentOwnerIdPos, mSaveDataOwnerIdPos;
@ -90,4 +93,5 @@ private:
bool isEqual(const FacHeader& other) const; bool isEqual(const FacHeader& other) const;
void copyFrom(const FacHeader& other); void copyFrom(const FacHeader& other);
}; };
}

View file

@ -1,6 +1,8 @@
#pragma once #pragma once
#include <fnd/types.h> #include <fnd/types.h>
namespace nx
{
class ISerialiseableBinary class ISerialiseableBinary
{ {
public: public:
@ -14,4 +16,5 @@ public:
virtual void importBinary(const u8* bytes) = 0; virtual void importBinary(const u8* bytes) = 0;
virtual void importBinary(const u8* bytes, size_t len) = 0; virtual void importBinary(const u8* bytes, size_t len) = 0;
}; };
}

View file

@ -1,6 +1,9 @@
#include "NcaHeader.h" #include "NcaHeader.h"
#include <fnd/exception.h> #include <fnd/exception.h>
using namespace nx;
void NcaHeader::exportBinary() void NcaHeader::exportBinary()
{ {
mBinaryBlob.alloc(sizeof(sNcaHeader)); mBinaryBlob.alloc(sizeof(sNcaHeader));

View file

@ -7,6 +7,8 @@
#include <crypto/sha.h> #include <crypto/sha.h>
#include <nx/ISerialiseableBinary.h> #include <nx/ISerialiseableBinary.h>
namespace nx
{
class NcaHeader : public ISerialiseableBinary class NcaHeader : public ISerialiseableBinary
{ {
public: public:
@ -153,3 +155,5 @@ private:
bool isEqual(const NcaHeader& other) const; bool isEqual(const NcaHeader& other) const;
void copyFrom(const NcaHeader& other); void copyFrom(const NcaHeader& other);
}; };
}

View file

@ -1,6 +1,6 @@
#include "SacBinary.h" #include "SacBinary.h"
using namespace nx;
SacBinary::SacBinary() SacBinary::SacBinary()
{ {

View file

@ -6,6 +6,8 @@
#include <nx/ISerialiseableBinary.h> #include <nx/ISerialiseableBinary.h>
#include <nx/SacEntry.h> #include <nx/SacEntry.h>
namespace nx
{
class SacBinary : class SacBinary :
public ISerialiseableBinary public ISerialiseableBinary
{ {
@ -44,3 +46,4 @@ private:
void copyFrom(const SacBinary& other); void copyFrom(const SacBinary& other);
}; };
}

View file

@ -1,5 +1,7 @@
#include "SacEntry.h" #include "SacEntry.h"
using namespace nx;
SacEntry::SacEntry() : SacEntry::SacEntry() :
mIsServer(false), mIsServer(false),
mName("") mName("")

View file

@ -4,6 +4,8 @@
#include <fnd/memory_blob.h> #include <fnd/memory_blob.h>
#include <nx/ISerialiseableBinary.h> #include <nx/ISerialiseableBinary.h>
namespace nx
{
class SacEntry : public ISerialiseableBinary class SacEntry : public ISerialiseableBinary
{ {
public: public:
@ -49,3 +51,4 @@ private:
bool isEqual(const SacEntry& other) const; bool isEqual(const SacEntry& other) const;
void copyFrom(const SacEntry& other); void copyFrom(const SacEntry& other);
}; };
}

View file

@ -6,7 +6,7 @@
#include <nx/NcaHeader.h> #include <nx/NcaHeader.h>
#include <inttypes.h> #include <inttypes.h>
const size_t kNcaSectorSize = NcaHeader::kDefaultBlockSize; const size_t kNcaSectorSize = nx::NcaHeader::kDefaultBlockSize;
void initNcaCtr(u8 ctr[crypto::aes::kAesBlockSize], u32 generation) void initNcaCtr(u8 ctr[crypto::aes::kAesBlockSize], u32 generation)
{ {
@ -69,7 +69,7 @@ int main(int argc, char** argv)
{ {
decryptNcaSectorXts(nca, sector, 1, nx::crypto::aes::nca_header_key[0], nx::crypto::aes::nca_header_key[1]); decryptNcaSectorXts(nca, sector, 1, nx::crypto::aes::nca_header_key[0], nx::crypto::aes::nca_header_key[1]);
NcaHeader hdr; nx::NcaHeader hdr;
hdr.importBinary(sector); hdr.importBinary(sector);
printf("[NCA Header]\n"); printf("[NCA Header]\n");
@ -79,7 +79,7 @@ int main(int argc, char** argv)
printf(" Sections:\n"); printf(" Sections:\n");
for (size_t i = 0; i < hdr.getSections().getSize(); i++) for (size_t i = 0; i < hdr.getSections().getSize(); i++)
{ {
const NcaHeader::sSection& section = hdr.getSections()[i]; const nx::NcaHeader::sSection& section = hdr.getSections()[i];
printf(" %lu:\n", i); printf(" %lu:\n", i);
//printf(" Start Blk: %" PRId32 "\n", section.start_blk); //printf(" Start Blk: %" PRId32 "\n", section.start_blk);
//printf(" End Blk: %" PRId32 "\n", section.end_blk); //printf(" End Blk: %" PRId32 "\n", section.end_blk);