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

141 lines
2.8 KiB
C
Raw Permalink Normal View History

2018-06-09 15:30:08 +00:00
#pragma once
2018-08-07 09:31:06 +00:00
#include <cstring>
2018-08-07 07:17:51 +00:00
#include <nn/hac/nro.h>
2018-06-24 08:18:54 +00:00
#include <fnd/ISerialisable.h>
2018-06-09 15:30:08 +00:00
#include <fnd/List.h>
2018-08-07 07:17:51 +00:00
namespace nn
{
namespace hac
2018-06-09 15:30:08 +00:00
{
class NroHeader :
2018-06-24 08:18:54 +00:00
public fnd::ISerialisable
2018-06-09 15:30:08 +00:00
{
public:
struct sRoCrt
{
byte_t data[nro::kRoCrtSize];
void operator=(const sRoCrt& other)
{
memcpy(data, other.data, nro::kRoCrtSize);
}
bool operator==(const sRoCrt& other) const
{
return memcmp(data, other.data, nro::kRoCrtSize) == 0;
}
bool operator!=(const sRoCrt& other) const
{
return !(*this == other);
}
};
struct sModuleId
{
byte_t data[nro::kModuleIdSize];
void operator=(const sModuleId& other)
{
memcpy(data, other.data, nro::kModuleIdSize);
}
bool operator==(const sModuleId& other) const
{
return memcmp(data, other.data, nro::kModuleIdSize) == 0;
}
bool operator!=(const sModuleId& other) const
{
return !(*this == other);
}
};
struct sSection
{
uint32_t memory_offset;
uint32_t size;
void operator=(const sSection& other)
{
memory_offset = other.memory_offset;
size = other.size;
}
bool operator==(const sSection& other) const
{
return (memory_offset == other.memory_offset) \
&& (size == other.size);
}
bool operator!=(const sSection& other) const
{
return !(*this == other);
}
};
NroHeader();
NroHeader(const NroHeader& other);
2018-06-24 08:18:54 +00:00
void operator=(const NroHeader& other);
2018-06-09 15:30:08 +00:00
bool operator==(const NroHeader& other) const;
bool operator!=(const NroHeader& other) const;
// export/import binary
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-06-09 15:30:08 +00:00
// variables
void clear();
const sRoCrt& getRoCrt() const;
void setRoCrt(const sRoCrt& ro_crt);
uint32_t getNroSize() const;
void setNroSize(uint32_t size);
const sSection& getTextInfo() const;
void setTextInfo(const sSection& info);
const sSection& getRoInfo() const;
void setRoInfo(const sSection& info);
const sSection& getDataInfo() const;
void setDataInfo(const sSection& info);
uint32_t getBssSize() const;
void setBssSize(uint32_t size);
const sModuleId& getModuleId() const;
void setModuleId(const sModuleId& id);
const sSection& getRoEmbeddedInfo() const;
void setRoEmbeddedInfo(const sSection& info);
const sSection& getRoDynStrInfo() const;
void setRoDynStrInfo(const sSection& info);
const sSection& getRoDynSymInfo() const;
void setRoDynSymInfo(const sSection& info);
private:
const std::string kModuleName = "NRO_HEADER";
// binary
2018-06-24 08:18:54 +00:00
fnd::Vec<byte_t> mRawBinary;
2018-06-09 15:30:08 +00:00
// data
sRoCrt mRoCrt;
uint32_t mNroSize;
sSection mTextInfo;
sSection mRoInfo;
sSection mDataInfo;
uint32_t mBssSize;
sModuleId mModuleId;
sSection mRoEmbeddedInfo;
sSection mRoDynStrInfo;
sSection mRoDynSymInfo;
};
2018-08-07 07:17:51 +00:00
}
2018-06-09 15:30:08 +00:00
}