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

110 lines
2.5 KiB
C
Raw Normal View History

2017-07-07 00:18:33 +00:00
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/MemoryBlob.h>
#include <fnd/ISerialiseableBinary.h>
#include <nx/npdm.h>
2017-07-07 00:18:33 +00:00
namespace nx
{
class NpdmHeader :
public fnd::ISerialiseableBinary
2017-07-07 00:18:33 +00:00
{
public:
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);
}
};
NpdmHeader();
NpdmHeader(const NpdmHeader& other);
2018-03-22 05:26:22 +00:00
NpdmHeader(const byte_t* bytes, size_t len);
2017-07-07 00:18:33 +00:00
bool operator==(const NpdmHeader& other) const;
bool operator!=(const NpdmHeader& other) const;
void operator=(const NpdmHeader& other);
// to be used after export
2018-03-22 05:26:22 +00:00
const byte_t* getBytes() const;
2017-07-07 00:18:33 +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-07 00:18:33 +00:00
// variables
void clear();
2017-07-07 00:18:33 +00:00
size_t getNpdmSize() const;
npdm::InstructionType getInstructionType() const;
void setInstructionType(npdm::InstructionType type);
2017-07-07 00:18:33 +00:00
npdm::ProcAddrSpaceType getProcAddressSpaceType() const;
void setProcAddressSpaceType(npdm::ProcAddrSpaceType type);
2017-07-07 00:18:33 +00:00
2018-03-22 05:26:22 +00:00
byte_t getMainThreadPriority() const;
void setMainThreadPriority(byte_t priority);
2017-07-07 00:18:33 +00:00
2018-03-22 05:26:22 +00:00
byte_t getMainThreadCpuId() const;
void setMainThreadCpuId(byte_t cpu_id);
2017-07-07 00:18:33 +00:00
2018-03-22 05:26:22 +00:00
uint32_t getVersion() const;
void setVersion(uint32_t version);
2017-07-07 00:18:33 +00:00
2018-03-22 05:26:22 +00:00
uint32_t getMainThreadStackSize() const;
void setMainThreadStackSize(uint32_t size);
2017-07-07 00:18:33 +00:00
const std::string& getName() const;
void setName(const std::string& name);
const std::string& getProductCode() const;
void setProductCode(const std::string& product_code);
const sSection& getAciPos() const;
void setAciSize(size_t size);
2017-07-07 00:18:33 +00:00
const sSection& getAcidPos() const;
void setAcidSize(size_t size);
2017-07-07 00:18:33 +00:00
private:
const std::string kModuleName = "NPDM_HEADER";
2017-07-07 00:18:33 +00:00
// raw binary
fnd::MemoryBlob mBinaryBlob;
// variables
npdm::InstructionType mInstructionType;
npdm::ProcAddrSpaceType mProcAddressSpaceType;
2018-03-22 05:26:22 +00:00
byte_t mMainThreadPriority;
byte_t mMainThreadCpuId;
uint32_t mVersion;
uint32_t mMainThreadStackSize;
2017-07-07 00:18:33 +00:00
std::string mName;
std::string mProductCode;
sSection mAciPos;
sSection mAcidPos;
void calculateOffsets();
bool isEqual(const NpdmHeader& other) const;
void copyFrom(const NpdmHeader& other);
};
}