Compare commits

3 Commits
Author SHA1 Message Date
tobid7 0ab0929746 started some work on cia/ncch 2025-11-28 17:49:05 +01:00
tobid7 8c1a48a527 updated to newer palladium 2025-11-28 17:48:54 +01:00
tobid7 6242a7565e fixes 2025-11-28 17:48:27 +01:00
6 changed files with 74 additions and 5 deletions
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#include <ctrff/helper.hpp>
#include <ctrff/pd_p_api.hpp>
#include <ctrff/smdh.hpp>
#include <pd.hpp>
namespace ctrff {
class Cia : public BinFile {
public:
Cia() {}
~Cia() {}
PD::u32 HeaderSize;
PD::u16 Type;
PD::u16 Version;
PD::u32 CertChainSize;
PD::u32 TikSize;
PD::u32 TmdFileSize;
PD::u32 MetaSize;
PD::u64 ContentSize;
PD::u8 ContentIndex[0x2000];
};
} // namespace ctrff
+44
View File
@@ -0,0 +1,44 @@
#pragma once
#include <ctrff/helper.hpp>
#include <ctrff/pd_p_api.hpp>
#include <ctrff/smdh.hpp>
#include <pd.hpp>
namespace ctrff {
class NCCH : public BinFile {
public:
NCCH() {}
~NCCH() {}
PD::u8 Sig[0x100];
PD::u32 Magic;
PD::u32 ContentLen; // 1 (Media Unit) = 0x200 bytes
PD::u64 PartitionID;
PD::u16 MarkerCode;
PD::u16 Version;
PD::u32 Wtf;
PD::u64 ProgramID;
PD::u8 Reserved[0x10];
PD::u8 LogoHash[0x20]; // Firm 5.0.0-11+
PD::u8 ProdCode[0x10];
PD::u8 ExHeaderHash[0x20];
PD::u32 ExHeaderLen;
PD::u32 Reserved1;
PD::u64 Flags;
PD::u32 PlainRegionOff; // In Media Units
PD::u32 PlainRegionSize;
PD::u32 LogoRegionOff;
PD::u32 LogoRegionSize;
PD::u32 ExeFsOff;
PD::u32 ExeFsSize;
PD::u32 ExeFsHashRegionSize;
PD::u32 Reserved2;
PD::u32 RomFsOff;
PD::u32 RomFsSize;
PD::u32 RomFsHashRegionSize;
PD::u32 Reserved;
PD::u8 ExeFsSuperBlockHash[0x20];
PD::u8 RomFsSuperBlockHash[0x20];
};
} // namespace ctrff
+2 -1
View File
@@ -163,7 +163,8 @@ CTRFF_API void BCSTM::ReadGotoBeginning(bool use_loop_beg) {
CTRFF_API void BCSTM::ReadBlock(PD::u32 block, PD::u8* ref) {
if (pFile.tellg() > pHeader.FileSize || block >= GetNumBlocks()) {
throw std::runtime_error("BCSTM: Decode block Out of range!");
throw std::runtime_error(std::format(
"BCSTM: Decode block Out of range! ({} > {})", block, GetNumBlocks()));
}
pFile.read(
reinterpret_cast<char*>(ref),
+1 -1
View File
@@ -38,4 +38,4 @@ void BinUtil::Write(const T& v) {
// Write buffer into file
m_file.write(reinterpret_cast<const char*>(buf.data()), sizeof(T));
}
} // namespace ctrff
} // namespace ctrff
+2 -2
View File
@@ -148,7 +148,7 @@ CTRFF_API std::string ctrff::U16toU8(PD::u16 *in, size_t max) {
result.push_back(static_cast<char>(0x80 | (c & 0x3F)));
} else if (c < 0x10000) {
result.push_back(static_cast<char>(0xE0 | (c >> 12)));
result.push_back(static_cast<char>(0x80 | ((c >> 6) & 0x3F)));
result.push_back(static_cast<char>(0x80 | ((c >> 6) & 0x3F)));
result.push_back(static_cast<char>(0x80 | (c & 0x3F)));
} else {
continue;
@@ -156,4 +156,4 @@ result.push_back(static_cast<char>(0x80 | ((c >> 6) & 0x3F)));
}
return result;
}
}