nstool/lib/libhac/include/nn/hac/ContentMeta.h

113 lines
4.2 KiB
C
Raw Normal View History

2018-05-12 09:36:50 +00:00
#pragma once
#include <string>
2018-08-07 09:31:06 +00:00
#include <cstring>
#include <fnd/IByteModel.h>
2018-05-12 09:36:50 +00:00
#include <fnd/List.h>
#include <nn/hac/define/cnmt.h>
#include <nn/hac/ContentInfo.h>
#include <nn/hac/ContentMetaInfo.h>
#include <nn/hac/ApplicationMetaExtendedHeader.h>
#include <nn/hac/PatchMetaExtendedHeader.h>
#include <nn/hac/AddOnContentMetaExtendedHeader.h>
#include <nn/hac/DeltaMetaExtendedHeader.h>
2018-05-12 09:36:50 +00:00
2018-08-07 07:17:51 +00:00
namespace nn
{
namespace hac
2018-05-12 09:36:50 +00:00
{
class ContentMeta :
public fnd::IByteModel
2018-05-12 09:36:50 +00:00
{
public:
ContentMeta();
ContentMeta(const ContentMeta& other);
2018-05-12 09:36:50 +00:00
void operator=(const ContentMeta& other);
bool operator==(const ContentMeta& other) const;
bool operator!=(const ContentMeta& other) const;
2018-05-12 09:36:50 +00:00
// IByteModel
2018-06-24 08:18:54 +00:00
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
2018-05-12 09:36:50 +00:00
// variables
void clear();
uint64_t getTitleId() const;
void setTitleId(uint64_t title_id);
uint32_t getTitleVersion() const;
void setTitleVersion(uint32_t version);
cnmt::ContentMetaType getContentMetaType() const;
void setContentMetaType(cnmt::ContentMetaType type);
2018-05-12 09:36:50 +00:00
byte_t getAttributes() const;
void setAttributes(byte_t attributes);
uint32_t getRequiredDownloadSystemVersion() const;
void setRequiredDownloadSystemVersion(uint32_t version);
const ApplicationMetaExtendedHeader& getApplicationMetaExtendedHeader() const;
void setApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& exhdr);
const PatchMetaExtendedHeader& getPatchMetaExtendedHeader() const;
void setPatchMetaExtendedHeader(const PatchMetaExtendedHeader& exhdr);
const AddOnContentMetaExtendedHeader& getAddOnContentMetaExtendedHeader() const;
void setAddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& exhdr);
const DeltaMetaExtendedHeader& getDeltaMetaExtendedHeader() const;
void setDeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& exhdr);
2018-05-12 09:36:50 +00:00
const fnd::List<nn::hac::ContentInfo>& getContentInfo() const;
void setContentInfo(const fnd::List<nn::hac::ContentInfo>& info);
2018-05-12 09:36:50 +00:00
const fnd::List<nn::hac::ContentMetaInfo>& getContentMetaInfo() const;
void setContentMetaInfo(const fnd::List<nn::hac::ContentMetaInfo>& info);
2018-05-12 09:36:50 +00:00
2018-06-24 08:18:54 +00:00
const fnd::Vec<byte_t>& getExtendedData() const;
void setExtendedData(const fnd::Vec<byte_t>& data);
2018-05-12 09:36:50 +00:00
const cnmt::sDigest& getDigest() const;
void setDigest(const cnmt::sDigest& digest);
2018-05-12 09:36:50 +00:00
private:
const std::string kModuleName = "CONTENT_META";
2018-05-12 09:36:50 +00:00
// binary blob
2018-06-24 08:18:54 +00:00
fnd::Vec<byte_t> mRawBinary;
2018-05-12 09:36:50 +00:00
// variables
uint64_t mTitleId;
uint32_t mTitleVersion;
cnmt::ContentMetaType mType;
2018-05-12 09:36:50 +00:00
byte_t mAttributes;
uint32_t mRequiredDownloadSystemVersion;
2018-06-24 08:18:54 +00:00
fnd::Vec<byte_t> mExtendedHeader;
ApplicationMetaExtendedHeader mApplicationMetaExtendedHeader;
PatchMetaExtendedHeader mPatchMetaExtendedHeader;
AddOnContentMetaExtendedHeader mAddOnContentMetaExtendedHeader;
DeltaMetaExtendedHeader mDeltaMetaExtendedHeader;
fnd::List<ContentInfo> mContentInfo;
fnd::List<ContentMetaInfo> mContentMetaInfo;
2018-06-24 08:18:54 +00:00
fnd::Vec<byte_t> mExtendedData;
cnmt::sDigest mDigest;
2018-05-12 09:36:50 +00:00
inline size_t getExtendedHeaderOffset() const { return sizeof(sContentMetaHeader); }
inline size_t getContentInfoOffset(size_t exhdrSize) const { return getExtendedHeaderOffset() + exhdrSize; }
inline size_t getContentMetaInfoOffset(size_t exhdrSize, size_t contentInfoNum) const { return getContentInfoOffset(exhdrSize) + contentInfoNum * sizeof(sContentInfo); }
inline size_t getExtendedDataOffset(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum) const { return getContentMetaInfoOffset(exhdrSize, contentInfoNum) + contentMetaNum * sizeof(sContentMetaInfo); }
inline size_t getDigestOffset(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum, size_t exdataSize) const { return getExtendedDataOffset(exhdrSize, contentInfoNum, contentMetaNum) + exdataSize; }
inline size_t getTotalSize(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum, size_t exdataSize) const { return getDigestOffset(exhdrSize, contentInfoNum, contentMetaNum, exdataSize) + cnmt::kDigestLen; }
2018-05-12 09:36:50 +00:00
bool validateExtendedHeaderSize(cnmt::ContentMetaType type, size_t exhdrSize) const;
size_t getExtendedDataSize(cnmt::ContentMetaType type, const byte_t* data) const;
void validateBinary(const byte_t* bytes, size_t len) const;
2018-05-12 09:36:50 +00:00
};
2018-08-07 07:17:51 +00:00
}
2018-05-12 09:36:50 +00:00
}