mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	Merge pull request #3120 from shinyquagsire23/ncch-container-offsets
file_sys/ncch_container: Expose ncch_offset during instantiation and in OpenFile
This commit is contained in:
		
						commit
						dc5d7a802f
					
				
					 2 changed files with 9 additions and 7 deletions
				
			
		|  | @ -95,12 +95,14 @@ static bool LZSS_Decompress(const u8* compressed, u32 compressed_size, u8* decom | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| NCCHContainer::NCCHContainer(const std::string& filepath) : filepath(filepath) { | ||||
| NCCHContainer::NCCHContainer(const std::string& filepath, u32 ncch_offset) | ||||
|     : filepath(filepath), ncch_offset(ncch_offset) { | ||||
|     file = FileUtil::IOFile(filepath, "rb"); | ||||
| } | ||||
| 
 | ||||
| Loader::ResultStatus NCCHContainer::OpenFile(const std::string& filepath) { | ||||
| Loader::ResultStatus NCCHContainer::OpenFile(const std::string& filepath, u32 ncch_offset) { | ||||
|     this->filepath = filepath; | ||||
|     this->ncch_offset = ncch_offset; | ||||
|     file = FileUtil::IOFile(filepath, "rb"); | ||||
| 
 | ||||
|     if (!file.IsOpen()) { | ||||
|  | @ -118,7 +120,7 @@ Loader::ResultStatus NCCHContainer::Load() { | |||
| 
 | ||||
|     if (file.IsOpen()) { | ||||
|         // Reset read pointer in case this file has been read before.
 | ||||
|         file.Seek(0, SEEK_SET); | ||||
|         file.Seek(ncch_offset, SEEK_SET); | ||||
| 
 | ||||
|         if (file.ReadBytes(&ncch_header, sizeof(NCCH_Header)) != sizeof(NCCH_Header)) | ||||
|             return Loader::ResultStatus::Error; | ||||
|  | @ -126,7 +128,7 @@ Loader::ResultStatus NCCHContainer::Load() { | |||
|         // Skip NCSD header and load first NCCH (NCSD is just a container of NCCH files)...
 | ||||
|         if (Loader::MakeMagic('N', 'C', 'S', 'D') == ncch_header.magic) { | ||||
|             LOG_DEBUG(Service_FS, "Only loading the first (bootable) NCCH within the NCSD file!"); | ||||
|             ncch_offset = 0x4000; | ||||
|             ncch_offset += 0x4000; | ||||
|             file.Seek(ncch_offset, SEEK_SET); | ||||
|             file.ReadBytes(&ncch_header, sizeof(NCCH_Header)); | ||||
|         } | ||||
|  |  | |||
|  | @ -168,10 +168,10 @@ namespace FileSys { | |||
|  */ | ||||
| class NCCHContainer { | ||||
| public: | ||||
|     NCCHContainer(const std::string& filepath); | ||||
|     NCCHContainer(const std::string& filepath, u32 ncch_offset = 0); | ||||
|     NCCHContainer() {} | ||||
| 
 | ||||
|     Loader::ResultStatus OpenFile(const std::string& filepath); | ||||
|     Loader::ResultStatus OpenFile(const std::string& filepath, u32 ncch_offset = 0); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Ensure ExeFS and exheader is loaded and ready for reading sections | ||||
|  | @ -263,7 +263,7 @@ private: | |||
|     bool is_loaded = false; | ||||
|     bool is_compressed = false; | ||||
| 
 | ||||
|     u32 ncch_offset = 0; // Offset to NCCH header, can be 0 or after NCSD header
 | ||||
|     u32 ncch_offset = 0; // Offset to NCCH header, can be 0 for NCCHs or non-zero for CIAs/NCSDs
 | ||||
|     u32 exefs_offset = 0; | ||||
| 
 | ||||
|     std::string filepath; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue