diff --git a/src/IniProcess.cpp b/src/IniProcess.cpp index 86354f9..38a2222 100644 --- a/src/IniProcess.cpp +++ b/src/IniProcess.cpp @@ -1,20 +1,12 @@ -#include -#include -#include -#include -#include -#include -#include #include "IniProcess.h" -#include "KipProcess.h" +#include "KipProcess.h" nstool::IniProcess::IniProcess() : mModuleName("nstool::IniProcess"), mFile(), mCliOutputMode(true, false, false, false), mVerify(false), - mDoExtractKip(false), mKipExtractPath() { } @@ -84,20 +76,20 @@ void nstool::IniProcess::importHeader() void nstool::IniProcess::importKipList() { // kip pos info - size_t kip_pos = sizeof(nn::hac::sIniHeader); - size_t kip_size = 0; + int64_t kip_pos = sizeof(nn::hac::sIniHeader); + int64_t kip_size = 0; // tmp data to determine size - tc::ByteData hdr_raw; + nn::hac::sKipHeader hdr_raw; nn::hac::KernelInitialProcessHeader hdr; - hdr_raw.alloc(sizeof(nn::hac::sKipHeader)); for (size_t i = 0; i < mHdr.getKipNum(); i++) { - (*mFile)->read(hdr_raw.data(), kip_pos, hdr_raw.size()); - hdr.fromBytes(hdr_raw.data(), hdr_raw.size()); + mFile->seek(kip_pos, tc::io::SeekOrigin::Begin); + mFile->read((byte_t*)&hdr_raw, sizeof(hdr_raw)); + hdr.fromBytes((byte_t*)&hdr_raw, sizeof(hdr_raw)); kip_size = getKipSizeFromHeader(hdr); - mKipList.push_back(new fnd::OffsetAdjustedIFile(mFile, kip_pos, kip_size)); + mKipList.push_back(std::make_shared(tc::io::SubStream(mFile, kip_pos, kip_size))); kip_pos += kip_size; } } @@ -171,7 +163,7 @@ void nstool::IniProcess::extractKipList() } } -size_t nstool::IniProcess::getKipSizeFromHeader(const nn::hac::KernelInitialProcessHeader& hdr) const +int64_t nstool::IniProcess::getKipSizeFromHeader(const nn::hac::KernelInitialProcessHeader& hdr) const { return sizeof(nn::hac::sKipHeader) + hdr.getTextSegmentInfo().file_layout.size + hdr.getRoSegmentInfo().file_layout.size + hdr.getDataSegmentInfo().file_layout.size; } \ No newline at end of file diff --git a/src/IniProcess.h b/src/IniProcess.h index e5ee8a3..747df38 100644 --- a/src/IniProcess.h +++ b/src/IniProcess.h @@ -31,7 +31,12 @@ private: tc::Optional mKipExtractPath; nn::hac::IniHeader mHdr; - std::vector> mKipList; + struct InnerKipInfo + { + nn::hac::KernelInitialProcessHeader hdr; + std::shared_ptr stream; + }; + std::vector mKipList; void importHeader(); void importKipList(); @@ -39,7 +44,7 @@ private: void displayKipList(); void extractKipList(); - size_t getKipSizeFromHeader(const nn::hac::KernelInitialProcessHeader& hdr) const; + int64_t getKipSizeFromHeader(const nn::hac::KernelInitialProcessHeader& hdr) const; }; } \ No newline at end of file