2017-07-05 15:39:41 +00:00
|
|
|
#pragma once
|
2017-07-06 03:30:27 +00:00
|
|
|
#include <string>
|
2017-07-05 15:39:41 +00:00
|
|
|
#include <fnd/types.h>
|
2018-06-24 08:18:54 +00:00
|
|
|
#include <fnd/ISerialisable.h>
|
2018-04-21 09:20:37 +00:00
|
|
|
#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
|
|
|
{
|
2017-07-21 10:30:16 +00:00
|
|
|
class AciHeader :
|
2018-06-24 08:18:54 +00:00
|
|
|
public fnd::ISerialisable
|
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;
|
2017-07-06 23:56:49 +00:00
|
|
|
|
|
|
|
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-06-24 08:18:54 +00:00
|
|
|
void operator=(const AciHeader& other);
|
2017-07-06 11:17:21 +00:00
|
|
|
bool operator==(const AciHeader& other) const;
|
|
|
|
bool operator!=(const AciHeader& other) const;
|
|
|
|
|
|
|
|
// export/import binary
|
2018-06-24 08:18:54 +00:00
|
|
|
virtual void toBytes();
|
|
|
|
virtual void fromBytes(const byte_t* bytes, size_t len);
|
|
|
|
const fnd::Vec<byte_t>& getBytes() const;
|
2017-07-06 11:17:21 +00:00
|
|
|
|
|
|
|
// variables
|
2017-07-15 08:28:01 +00:00
|
|
|
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);
|
2017-07-15 08:28:01 +00:00
|
|
|
|
|
|
|
// ACID only
|
|
|
|
size_t getAcidSize() const;
|
2017-07-17 08:21:39 +00:00
|
|
|
//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);
|
2017-07-15 08:28:01 +00:00
|
|
|
|
|
|
|
// ACID & ACI0
|
2017-07-17 08:21:39 +00:00
|
|
|
void setHeaderOffset(size_t offset);
|
2017-07-15 08:28:01 +00:00
|
|
|
AciType getAciType() const;
|
|
|
|
void setAciType(AciType type);
|
2017-07-21 10:30:16 +00:00
|
|
|
bool isProduction() const;
|
|
|
|
void setIsProduction(bool isProduction);
|
2018-04-27 16:13:35 +00:00
|
|
|
bool isUnqualifiedApproval() const;
|
|
|
|
void setIsUnqualifiedApproval(bool isUnqualifiedApproval);
|
2017-07-15 08:28:01 +00:00
|
|
|
const sSection& getFacPos() const;
|
2017-07-17 08:21:39 +00:00
|
|
|
void setFacSize(size_t size);
|
2017-07-15 08:28:01 +00:00
|
|
|
const sSection& getSacPos() const;
|
2017-07-17 08:21:39 +00:00
|
|
|
void setSacSize(size_t size);
|
2017-07-15 08:28:01 +00:00
|
|
|
const sSection& getKcPos() const;
|
2017-07-17 08:21:39 +00:00
|
|
|
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
|
2018-06-24 08:18:54 +00:00
|
|
|
fnd::Vec<byte_t> mRawBinary;
|
2017-07-05 15:39:41 +00:00
|
|
|
|
2017-07-15 08:28:01 +00:00
|
|
|
// ACI variables
|
2018-03-22 05:26:22 +00:00
|
|
|
uint64_t mProgramId;
|
2017-07-15 08:28:01 +00:00
|
|
|
|
|
|
|
// ACID variables
|
|
|
|
size_t mAcidSize;
|
2018-03-22 05:26:22 +00:00
|
|
|
uint64_t mProgramIdMin;
|
|
|
|
uint64_t mProgramIdMax;
|
2017-07-15 08:28:01 +00:00
|
|
|
|
|
|
|
// ACI(D) variables
|
2017-07-17 08:21:39 +00:00
|
|
|
size_t mHeaderOffset;
|
2017-07-15 08:28:01 +00:00
|
|
|
AciType mType;
|
2017-07-21 10:30:16 +00:00
|
|
|
bool mIsProduction;
|
2018-04-27 16:13:35 +00:00
|
|
|
bool mIsUnqualifiedApproval;
|
2017-07-06 11:17:21 +00:00
|
|
|
sSection mFac, mSac, mKc;
|
2017-07-21 10:30:16 +00:00
|
|
|
|
2017-07-06 11:17:21 +00:00
|
|
|
void calculateSectionOffsets();
|
|
|
|
};
|
|
|
|
}
|
2017-07-05 15:39:41 +00:00
|
|
|
|