nstool/lib/libnx/include/nx/AciHeader.h

114 lines
2.4 KiB
C
Raw Normal View History

2017-07-05 15:39:41 +00:00
#pragma once
#include <string>
2017-07-05 15:39:41 +00:00
#include <fnd/types.h>
#include <fnd/MemoryBlob.h>
#include <fnd/ISerialiseableBinary.h>
#include <nx/aci.h>
2017-07-05 15:39:41 +00:00
2017-07-06 11:17:21 +00:00
namespace nx
2017-07-05 15:39:41 +00:00
{
class AciHeader :
public fnd::ISerialiseableBinary
2017-07-05 15:39:41 +00:00
{
2017-07-06 11:17:21 +00:00
public:
enum AciType
{
TYPE_ACI0, // for Access Control Info
TYPE_ACID // for Access Control Info Desc
};
2017-07-05 15:39:41 +00:00
2017-07-06 11:17:21 +00:00
struct sSection
{
size_t offset;
size_t size;
void operator=(const sSection& other)
{
offset = other.offset;
size = other.size;
}
bool operator==(const sSection& other) const
{
return (offset == other.offset) \
&& (size == other.size);
}
bool operator!=(const sSection& other) const
{
return !operator==(other);
}
2017-07-06 11:17:21 +00:00
};
AciHeader();
AciHeader(const AciHeader& other);
2018-03-22 05:26:22 +00:00
AciHeader(const byte_t* bytes, size_t len);
2017-07-06 11:17:21 +00:00
bool operator==(const AciHeader& other) const;
bool operator!=(const AciHeader& other) const;
void operator=(const AciHeader& other);
// to be used after export
2018-03-22 05:26:22 +00:00
const byte_t* getBytes() const;
2017-07-06 11:17:21 +00:00
size_t getSize() const;
// export/import binary
virtual void exportBinary();
2018-03-22 05:26:22 +00:00
virtual void importBinary(const byte_t* bytes, size_t len);
2017-07-06 11:17:21 +00:00
// variables
virtual void clear();
size_t getAciSize() const;
// ACI0 only
2018-03-22 05:26:22 +00:00
uint64_t getProgramId() const;
void setProgramId(uint64_t program_id);
// ACID only
size_t getAcidSize() const;
//void setAcidSize(size_t size);
2018-03-22 05:26:22 +00:00
uint64_t getProgramIdMin() const;
void setProgramIdMin(uint64_t program_id);
uint64_t getProgramIdMax() const;
void setProgramIdMax(uint64_t program_id);
// ACID & ACI0
void setHeaderOffset(size_t offset);
AciType getAciType() const;
void setAciType(AciType type);
bool isProduction() const;
void setIsProduction(bool isProduction);
const sSection& getFacPos() const;
void setFacSize(size_t size);
const sSection& getSacPos() const;
void setSacSize(size_t size);
const sSection& getKcPos() const;
void setKcSize(size_t size);
2017-07-05 15:39:41 +00:00
2017-07-06 11:17:21 +00:00
private:
const std::string kModuleName = "ACI_HEADER";
2017-07-05 15:39:41 +00:00
2017-07-06 11:17:21 +00:00
// raw data
fnd::MemoryBlob mBinaryBlob;
2017-07-05 15:39:41 +00:00
// ACI variables
2018-03-22 05:26:22 +00:00
uint64_t mProgramId;
// ACID variables
size_t mAcidSize;
2018-03-22 05:26:22 +00:00
uint64_t mProgramIdMin;
uint64_t mProgramIdMax;
// ACI(D) variables
size_t mHeaderOffset;
AciType mType;
bool mIsProduction;
2017-07-06 11:17:21 +00:00
sSection mFac, mSac, mKc;
2017-07-06 11:17:21 +00:00
void calculateSectionOffsets();
bool isEqual(const AciHeader& other) const;
void copyFrom(const AciHeader& other);
};
}
2017-07-05 15:39:41 +00:00