2017-07-06 10:57:33 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
2017-08-05 13:09:50 +00:00
|
|
|
#include <fnd/MemoryBlob.h>
|
2017-07-17 08:21:39 +00:00
|
|
|
#include <fnd/List.h>
|
2017-07-21 10:30:16 +00:00
|
|
|
#include <fnd/ISerialiseableBinary.h>
|
2017-07-06 10:57:33 +00:00
|
|
|
|
2017-07-06 11:17:21 +00:00
|
|
|
namespace nx
|
2017-07-06 10:57:33 +00:00
|
|
|
{
|
2017-07-06 11:17:21 +00:00
|
|
|
class FacHeader :
|
2017-07-21 10:30:16 +00:00
|
|
|
public fnd::ISerialiseableBinary
|
2017-07-06 10:57:33 +00:00
|
|
|
{
|
2017-07-06 11:17:21 +00:00
|
|
|
public:
|
2017-07-17 08:21:39 +00:00
|
|
|
enum FsAccessFlag
|
|
|
|
{
|
|
|
|
FSA_APPLICATION_INFO,
|
|
|
|
FSA_BOOT_MODE_CONTROL,
|
|
|
|
FSA_CALIBRATION,
|
|
|
|
FSA_SYSTEM_SAVE_DATA,
|
|
|
|
FSA_GAME_CARD,
|
|
|
|
FSA_SAVE_DATA_BACKUP,
|
|
|
|
FSA_SAVE_DATA_MANAGEMENT,
|
|
|
|
FSA_BIS_ALL_RAW,
|
|
|
|
FSA_GAME_CARD_RAW,
|
|
|
|
FSA_GAME_CARD_PRIVATE,
|
|
|
|
FSA_SET_TIME,
|
|
|
|
FSA_CONTENT_MANAGER,
|
|
|
|
FSA_IMAGE_MANAGER,
|
|
|
|
FSA_CREATE_SAVE_DATA,
|
|
|
|
FSA_SYSTEM_SAVE_DATA_MANAGEMENT,
|
|
|
|
FSA_BIS_FILE_SYSTEM,
|
|
|
|
FSA_SYSTEM_UPDATE,
|
|
|
|
FSA_SAVE_DATA_META,
|
|
|
|
FSA_DEVICE_SAVE_CONTROL,
|
|
|
|
FSA_SETTINGS_CONTROL,
|
|
|
|
FSA_DEBUG = 62,
|
|
|
|
FSA_FULL_PERMISSION = 63,
|
|
|
|
};
|
|
|
|
|
2017-07-06 11:17:21 +00:00
|
|
|
FacHeader();
|
|
|
|
FacHeader(const FacHeader& other);
|
2018-03-22 05:26:22 +00:00
|
|
|
FacHeader(const byte_t* bytes, size_t len);
|
2017-07-06 11:17:21 +00:00
|
|
|
|
|
|
|
bool operator==(const FacHeader& other) const;
|
|
|
|
bool operator!=(const FacHeader& other) const;
|
|
|
|
void operator=(const FacHeader& 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
|
|
|
|
void exportBinary();
|
2018-03-22 05:26:22 +00:00
|
|
|
void importBinary(const byte_t* bytes, size_t len);
|
2017-07-06 11:17:21 +00:00
|
|
|
|
|
|
|
// variables
|
2017-07-15 08:28:01 +00:00
|
|
|
void clear();
|
|
|
|
size_t getFacSize() const;
|
2017-07-06 11:17:21 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t getFormatVersion() const;
|
|
|
|
void setFormatVersion(uint32_t version);
|
2017-07-17 08:21:39 +00:00
|
|
|
|
|
|
|
const fnd::List<FsAccessFlag>& getFsaRightsList() const;
|
|
|
|
void setFsaRightsList(const fnd::List<FsAccessFlag>& list);
|
2017-07-06 11:17:21 +00:00
|
|
|
|
|
|
|
size_t getContentOwnerIdOffset() const;
|
|
|
|
size_t getContentOwnerIdSize() const;
|
|
|
|
void setContentOwnerIdSize(size_t size);
|
|
|
|
|
|
|
|
size_t getSaveDataOwnerIdOffset() const;
|
|
|
|
size_t getSaveDataOwnerIdSize() const;
|
|
|
|
void setSaveDataOwnerIdSize(size_t size);
|
|
|
|
|
2017-07-06 10:57:33 +00:00
|
|
|
private:
|
2017-07-06 11:17:21 +00:00
|
|
|
const std::string kModuleName = "FAC_HEADER";
|
2018-03-22 05:26:22 +00:00
|
|
|
static const uint32_t kFacFormatVersion = 1;
|
2017-07-06 11:17:21 +00:00
|
|
|
|
|
|
|
#pragma pack (push, 1)
|
|
|
|
struct sFacHeader
|
2017-07-06 10:57:33 +00:00
|
|
|
{
|
2018-03-22 05:26:22 +00:00
|
|
|
le_uint32_t version; // default 1
|
|
|
|
le_uint64_t fac_flags;
|
2017-07-06 11:17:21 +00:00
|
|
|
struct sFacSection
|
|
|
|
{
|
2018-03-22 05:26:22 +00:00
|
|
|
le_uint32_t start;
|
|
|
|
le_uint32_t end;
|
|
|
|
} content_owner_ids, save_data_owner_ids; // the data for these follow later in binary. start/end relative to base of FacData instance
|
2017-07-06 11:17:21 +00:00
|
|
|
};
|
2017-07-06 10:57:33 +00:00
|
|
|
#pragma pack (pop)
|
|
|
|
|
2017-07-06 11:17:21 +00:00
|
|
|
// raw binary
|
|
|
|
fnd::MemoryBlob mBinaryBlob;
|
|
|
|
|
|
|
|
// variables
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t mVersion;
|
2017-07-17 08:21:39 +00:00
|
|
|
fnd::List<FsAccessFlag> mFsaRights;
|
2017-07-06 11:17:21 +00:00
|
|
|
struct sSection
|
|
|
|
{
|
|
|
|
size_t offset;
|
|
|
|
size_t size;
|
|
|
|
} mContentOwnerIdPos, mSaveDataOwnerIdPos;
|
|
|
|
|
|
|
|
void calculateOffsets();
|
|
|
|
bool isEqual(const FacHeader& other) const;
|
|
|
|
void copyFrom(const FacHeader& other);
|
|
|
|
};
|
|
|
|
}
|
2017-07-06 10:57:33 +00:00
|
|
|
|