mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 10:45:28 +00:00
[nx] Added nx namespace.
This commit is contained in:
parent
01162b8187
commit
7b34bd404d
|
@ -1,5 +1,7 @@
|
|||
#include "AciHeader.h"
|
||||
|
||||
using namespace nx;
|
||||
|
||||
void AciHeader::clearVariables()
|
||||
{
|
||||
mType = TYPE_ACI0;
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
#include <fnd/memory_blob.h>
|
||||
#include <nx/ISerialiseableBinary.h>
|
||||
|
||||
class AciHeader : public ISerialiseableBinary
|
||||
namespace nx
|
||||
{
|
||||
public:
|
||||
class AciHeader : public ISerialiseableBinary
|
||||
{
|
||||
public:
|
||||
enum AciType
|
||||
{
|
||||
TYPE_ACI0, // for Access Control Info
|
||||
|
@ -48,7 +50,7 @@ public:
|
|||
const sSection& getKernelCapabilities() const;
|
||||
void setKernelCapabilities(u32 size);
|
||||
|
||||
private:
|
||||
private:
|
||||
const std::string kModuleName = "ACI_HEADER";
|
||||
const std::string kAciStructSig = "ACI0";
|
||||
const std::string kAciDescStructSig = "ACID";
|
||||
|
@ -105,5 +107,6 @@ private:
|
|||
void calculateSectionOffsets();
|
||||
bool isEqual(const AciHeader& other) const;
|
||||
void copyFrom(const AciHeader& other);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "FacBinary.h"
|
||||
|
||||
|
||||
using namespace nx;
|
||||
|
||||
FacBinary::FacBinary() :
|
||||
mHeader()
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
#include <nx/ISerialiseableBinary.h>
|
||||
#include <nx/FacHeader.h>
|
||||
|
||||
class FacBinary :
|
||||
public ISerialiseableBinary
|
||||
namespace nx
|
||||
{
|
||||
public:
|
||||
class FacBinary :
|
||||
public ISerialiseableBinary
|
||||
{
|
||||
public:
|
||||
enum FsAccessFlag
|
||||
{
|
||||
FSA_APPLICATION_INFO = BIT(0),
|
||||
|
@ -62,7 +64,7 @@ public:
|
|||
|
||||
const fnd::List<u32>& getSaveDataOwnerIds() const;
|
||||
void addSaveDataOwnerId(u32 id);
|
||||
private:
|
||||
private:
|
||||
const std::string kModuleName = "FAC_BINARY";
|
||||
|
||||
// raw binary
|
||||
|
@ -77,5 +79,6 @@ private:
|
|||
void clearVariables();
|
||||
bool isEqual(const FacBinary& other) const;
|
||||
void copyFrom(const FacBinary& other);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "FacHeader.h"
|
||||
|
||||
|
||||
using namespace nx;
|
||||
|
||||
FacHeader::FacHeader()
|
||||
{
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
#include <fnd/memory_blob.h>
|
||||
#include <nx/ISerialiseableBinary.h>
|
||||
|
||||
class FacHeader :
|
||||
public ISerialiseableBinary
|
||||
namespace nx
|
||||
{
|
||||
public:
|
||||
class FacHeader :
|
||||
public ISerialiseableBinary
|
||||
{
|
||||
public:
|
||||
FacHeader();
|
||||
FacHeader(const FacHeader& other);
|
||||
FacHeader(const u8* bytes);
|
||||
|
@ -38,7 +40,7 @@ public:
|
|||
size_t getSaveDataOwnerIdSize() const;
|
||||
void setSaveDataOwnerIdSize(size_t size);
|
||||
|
||||
private:
|
||||
private:
|
||||
const std::string kModuleName = "FAC_HEADER";
|
||||
static const u32 kFacFormatVersion = 1;
|
||||
|
||||
|
@ -80,7 +82,8 @@ private:
|
|||
|
||||
// variables
|
||||
u64 mFsaRights;
|
||||
struct sSection {
|
||||
struct sSection
|
||||
{
|
||||
size_t offset;
|
||||
size_t size;
|
||||
} mContentOwnerIdPos, mSaveDataOwnerIdPos;
|
||||
|
@ -89,5 +92,6 @@ private:
|
|||
void calculateOffsets();
|
||||
bool isEqual(const FacHeader& other) const;
|
||||
void copyFrom(const FacHeader& other);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
|
||||
class ISerialiseableBinary
|
||||
namespace nx
|
||||
{
|
||||
public:
|
||||
class ISerialiseableBinary
|
||||
{
|
||||
public:
|
||||
//virtual bool operator==(const ISerialiseableBinary& other) = 0;
|
||||
//virtual void operator=(const ISerialiseableBinary& other) = 0;
|
||||
|
||||
|
@ -13,5 +15,6 @@ public:
|
|||
virtual void exportBinary() = 0;
|
||||
virtual void importBinary(const u8* bytes) = 0;
|
||||
virtual void importBinary(const u8* bytes, size_t len) = 0;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#include "NcaHeader.h"
|
||||
#include <fnd/exception.h>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
|
||||
void NcaHeader::exportBinary()
|
||||
{
|
||||
mBinaryBlob.alloc(sizeof(sNcaHeader));
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
#include <crypto/sha.h>
|
||||
#include <nx/ISerialiseableBinary.h>
|
||||
|
||||
class NcaHeader : public ISerialiseableBinary
|
||||
namespace nx
|
||||
{
|
||||
public:
|
||||
class NcaHeader : public ISerialiseableBinary
|
||||
{
|
||||
public:
|
||||
struct sSection
|
||||
{
|
||||
u64 offset;
|
||||
|
@ -71,7 +73,7 @@ public:
|
|||
const fnd::List<crypto::aes::sAes128Key>& getAesKeys() const;
|
||||
void addKey(const crypto::aes::sAes128Key& key);
|
||||
|
||||
private:
|
||||
private:
|
||||
const std::string kModuleName = "NCA_HEADER";
|
||||
const std::string kNcaSig = "NCA2";
|
||||
static const size_t kSectionNum = 4;
|
||||
|
@ -152,4 +154,6 @@ private:
|
|||
u32 sizeToBlockNum(u64 real_size) const;
|
||||
bool isEqual(const NcaHeader& other) const;
|
||||
void copyFrom(const NcaHeader& other);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#include "SacBinary.h"
|
||||
|
||||
|
||||
using namespace nx;
|
||||
|
||||
SacBinary::SacBinary()
|
||||
{
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
#include <nx/ISerialiseableBinary.h>
|
||||
#include <nx/SacEntry.h>
|
||||
|
||||
class SacBinary :
|
||||
public ISerialiseableBinary
|
||||
namespace nx
|
||||
{
|
||||
public:
|
||||
class SacBinary :
|
||||
public ISerialiseableBinary
|
||||
{
|
||||
public:
|
||||
SacBinary();
|
||||
SacBinary(const SacBinary& other);
|
||||
SacBinary(const u8* bytes, size_t len);
|
||||
|
@ -30,7 +32,7 @@ public:
|
|||
// variables
|
||||
const fnd::List<SacEntry>& getServiceList() const;
|
||||
void addService(const SacEntry& service);
|
||||
private:
|
||||
private:
|
||||
const std::string kModuleName = "SAC_BINARY";
|
||||
|
||||
// raw binary
|
||||
|
@ -42,5 +44,6 @@ private:
|
|||
void clearVariables();
|
||||
bool isEqual(const SacBinary& other) const;
|
||||
void copyFrom(const SacBinary& other);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "SacEntry.h"
|
||||
|
||||
using namespace nx;
|
||||
|
||||
SacEntry::SacEntry() :
|
||||
mIsServer(false),
|
||||
mName("")
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
#include <fnd/memory_blob.h>
|
||||
#include <nx/ISerialiseableBinary.h>
|
||||
|
||||
class SacEntry : public ISerialiseableBinary
|
||||
namespace nx
|
||||
{
|
||||
public:
|
||||
class SacEntry : public ISerialiseableBinary
|
||||
{
|
||||
public:
|
||||
SacEntry();
|
||||
SacEntry(const std::string& name, bool isServer);
|
||||
SacEntry(const SacEntry& other);
|
||||
|
@ -29,14 +31,14 @@ public:
|
|||
void setIsServer(bool isServer);
|
||||
const std::string& getName() const;
|
||||
void setName(const std::string& name);
|
||||
private:
|
||||
private:
|
||||
const std::string kModuleName = "SAC_ENTRY";
|
||||
static const size_t kMaxServiceNameLen = 8;
|
||||
|
||||
enum SacEntryFlag
|
||||
{
|
||||
SAC_IS_SERVER = BIT(7),
|
||||
SAC_NAME_LEN_MASK = BIT(7)-1
|
||||
SAC_NAME_LEN_MASK = BIT(7) - 1
|
||||
};
|
||||
|
||||
// raw binary
|
||||
|
@ -48,4 +50,5 @@ private:
|
|||
|
||||
bool isEqual(const SacEntry& other) const;
|
||||
void copyFrom(const SacEntry& other);
|
||||
};
|
||||
};
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
#include <nx/NcaHeader.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)
|
||||
{
|
||||
|
@ -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]);
|
||||
|
||||
NcaHeader hdr;
|
||||
nx::NcaHeader hdr;
|
||||
hdr.importBinary(sector);
|
||||
|
||||
printf("[NCA Header]\n");
|
||||
|
@ -79,7 +79,7 @@ int main(int argc, char** argv)
|
|||
printf(" Sections:\n");
|
||||
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(" Start Blk: %" PRId32 "\n", section.start_blk);
|
||||
//printf(" End Blk: %" PRId32 "\n", section.end_blk);
|
||||
|
|
Loading…
Reference in a new issue