Skip to content

Commit

Permalink
Merge pull request #115 from 3DSGuy/ctrtool-detect-compressed-code
Browse files Browse the repository at this point in the history
Fix issue where compressed .code partition wasn't being decompressed.
  • Loading branch information
jakcron authored Mar 30, 2022
2 parents d9f9d4e + ea3b188 commit 8876f0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ctrtool/src/NcchProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,17 @@ void ctrtool::NcchProcess::processRegions()
}
if (mRegionInfo[NcchRegion_ExeFs].size != 0 && mRegionInfo[NcchRegion_ExeFs].ready_stream != nullptr)
{
// prior to reading exefs, check compressed flag in exheader
if (mRegionInfo[NcchRegion_ExHeader].size > 0 && mRegionInfo[NcchRegion_ExHeader].ready_stream != nullptr)
{
// import exheader
ntd::n3ds::ExtendedHeader exheader;
mRegionInfo[NcchRegion_ExHeader].ready_stream->seek(0, tc::io::SeekOrigin::Begin);
mRegionInfo[NcchRegion_ExHeader].ready_stream->read((byte_t*)&exheader, sizeof(ntd::n3ds::ExtendedHeader));

mDecompressExeFsCode = exheader.system_control_info.flags.bitarray.test(ntd::n3ds::SystemControlInfo::Flags_CompressExefsPartition0);
}

ctrtool::ExeFsProcess proc;
proc.setInputStream(mRegionInfo[NcchRegion_ExeFs].ready_stream);
proc.setCliOutputMode(mRegionOpt[NcchRegion_ExeFs].show_info, mRegionOpt[NcchRegion_ExeFs].show_fs);
Expand Down
2 changes: 1 addition & 1 deletion ctrtool/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#define BIN_NAME "ctrtool"
#define VER_MAJOR 1
#define VER_MINOR 0
#define VER_PATCH 2
#define VER_PATCH 3
#define AUTHORS "jakcron"

0 comments on commit 8876f0e

Please sign in to comment.