From a930e0e04c453a6be57e070867acdbe32a876897 Mon Sep 17 00:00:00 2001 From: jakcron Date: Sun, 27 May 2018 19:25:28 +0800 Subject: [PATCH] [nx] Add nx/nso.h --- lib/libnx/include/nx/nso.h | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lib/libnx/include/nx/nso.h diff --git a/lib/libnx/include/nx/nso.h b/lib/libnx/include/nx/nso.h new file mode 100644 index 0000000..f0462cf --- /dev/null +++ b/lib/libnx/include/nx/nso.h @@ -0,0 +1,69 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include + +namespace nx +{ + namespace nso + { + const std::string kNsoSig = "NSO0"; + + enum HeaderFlags + { + FLAG_TEXT_COMPRESS, + FLAG_RO_COMPRESS, + FLAG_DATA_COMPRESS, + FLAG_TEXT_HASH, + FLAG_RO_HASH, + FLAG_DATA_HASH + } + + static const size_t kModuleIdLen = 32; + } + +#pragma pack(push,1) + struct sNsoCodeSegment + { + le_uint32_t file_offset; + le_uint32_t memory_offset; + le_uint32_t size; + }; + + struct sNsoSection + { + le_uint32_t offset; + le_uint32_t size; + } + + struct sNsoHeader + { + char signature[4]; + le_uint32_t version; + byte_t reserved_1[4]; + le_uint32_t flags; + sNsoCodeSegment text; + le_uint32_t module_name_offset; + sNsoCodeSegment ro; + le_uint32_t module_name_size; + sNsoCodeSegment data; + le_uint32_t bss_size; + byte_t module_id[nso::kModuleIdLen]; + le_uint32_t text_file_size; + le_uint32_t ro_file_size; + le_uint32_t data_file_size; + byte_t reserved_2[28]; + sNsoSection embedded; + sNsoSection dyn_str; + sNsoSection dyn_sym; + byte_t text_hash[crypto::sha::kSha256HashLen]; + byte_t ro_hash[crypto::sha::kSha256HashLen]; + byte_t data_hash[crypto::sha::kSha256HashLen]; + }; + +#pragma pack(pop) +}