mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-30 06:30:05 +00:00
Loader: Refactored interface such that data is no longer stored by loader.
NCCH: Removed extra qualification ‘Loader::AppLoader_NCCH::’.
This commit is contained in:
parent
48e39fc992
commit
d8da707bb9
@ -48,60 +48,48 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the code (typically .code section) of the application
|
* Get the code (typically .code section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to code buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
virtual const std::vector<u8>& ReadCode(ResultStatus& error) const {
|
virtual ResultStatus ReadCode(std::vector<u8>& buffer) {
|
||||||
error = ResultStatus::ErrorNotImplemented;
|
return ResultStatus::ErrorNotImplemented;
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the icon (typically icon section) of the application
|
* Get the icon (typically icon section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to icon buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
virtual const std::vector<u8>& ReadIcon(ResultStatus& error) const {
|
virtual ResultStatus ReadIcon(std::vector<u8>& buffer) {
|
||||||
error = ResultStatus::ErrorNotImplemented;
|
return ResultStatus::ErrorNotImplemented;
|
||||||
return icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the banner (typically banner section) of the application
|
* Get the banner (typically banner section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to banner buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
virtual const std::vector<u8>& ReadBanner(ResultStatus& error) const {
|
virtual ResultStatus ReadBanner(std::vector<u8>& buffer) {
|
||||||
error = ResultStatus::ErrorNotImplemented;
|
return ResultStatus::ErrorNotImplemented;
|
||||||
return banner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the logo (typically logo section) of the application
|
* Get the logo (typically logo section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to logo buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
virtual const std::vector<u8>& ReadLogo(ResultStatus& error) const {
|
virtual ResultStatus ReadLogo(std::vector<u8>& buffer) {
|
||||||
error = ResultStatus::ErrorNotImplemented;
|
return ResultStatus::ErrorNotImplemented;
|
||||||
return logo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the RomFs archive of the application
|
* Get the RomFS of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to RomFs archive buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
virtual const std::vector<u8>& ReadRomFS(ResultStatus& error) const {
|
virtual ResultStatus ReadRomFS(std::vector<u8>& buffer) {
|
||||||
error = ResultStatus::ErrorNotImplemented;
|
return ResultStatus::ErrorNotImplemented;
|
||||||
return romfs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
std::vector<u8> code; ///< ExeFS .code section
|
|
||||||
std::vector<u8> icon; ///< ExeFS .icon section
|
|
||||||
std::vector<u8> banner; ///< ExeFS .banner section
|
|
||||||
std::vector<u8> logo; ///< ExeFS .logo section
|
|
||||||
std::vector<u8> romfs; ///< RomFs archive
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,25 +125,22 @@ ResultStatus AppLoader_NCCH::LoadExec() {
|
|||||||
if (!is_loaded)
|
if (!is_loaded)
|
||||||
return ResultStatus::ErrorNotLoaded;
|
return ResultStatus::ErrorNotLoaded;
|
||||||
|
|
||||||
ResultStatus res;
|
std::vector<u8> code;
|
||||||
code = ReadCode(res);
|
if (ResultStatus::Success == ReadCode(code)) {
|
||||||
|
|
||||||
if (ResultStatus::Success == res) {
|
|
||||||
Memory::WriteBlock(entry_point, &code[0], code.size());
|
Memory::WriteBlock(entry_point, &code[0], code.size());
|
||||||
Kernel::LoadExec(entry_point);
|
Kernel::LoadExec(entry_point);
|
||||||
|
return ResultStatus::Success;
|
||||||
}
|
}
|
||||||
return res;
|
return ResultStatus::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
|
* Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
|
||||||
* @param name Name of section to read out of NCCH file
|
* @param name Name of section to read out of NCCH file
|
||||||
* @param buffer Vector to read data into
|
* @param buffer Vector to read data into
|
||||||
* @param error ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
* @return Reference to buffer of data that was read
|
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer,
|
ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer) {
|
||||||
ResultStatus& error) {
|
|
||||||
// Iterate through the ExeFs archive until we find the .code file...
|
// Iterate through the ExeFs archive until we find the .code file...
|
||||||
for (int i = 0; i < kMaxSections; i++) {
|
for (int i = 0; i < kMaxSections; i++) {
|
||||||
// Load the specified section...
|
// Load the specified section...
|
||||||
@ -169,20 +166,17 @@ const std::vector<u8>& AppLoader_NCCH::LoadSectionExeFS(const char* name, std::v
|
|||||||
buffer.resize(decompressed_size);
|
buffer.resize(decompressed_size);
|
||||||
if (!LZSS_Decompress(&temp_buffer[0], exefs_header.section[i].size, &buffer[0],
|
if (!LZSS_Decompress(&temp_buffer[0], exefs_header.section[i].size, &buffer[0],
|
||||||
decompressed_size)) {
|
decompressed_size)) {
|
||||||
error = ResultStatus::ErrorInvalidFormat;
|
return ResultStatus::ErrorInvalidFormat;
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
// Section is uncompressed...
|
// Section is uncompressed...
|
||||||
} else {
|
} else {
|
||||||
buffer.resize(exefs_header.section[i].size);
|
buffer.resize(exefs_header.section[i].size);
|
||||||
file.ReadBytes(&buffer[0], exefs_header.section[i].size);
|
file.ReadBytes(&buffer[0], exefs_header.section[i].size);
|
||||||
}
|
}
|
||||||
error = ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error = ResultStatus::ErrorNotUsed;
|
return ResultStatus::ErrorNotUsed;
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,46 +241,46 @@ ResultStatus AppLoader_NCCH::Load() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the code (typically .code section) of the application
|
* Get the code (typically .code section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to code buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& AppLoader_NCCH::ReadCode(ResultStatus& error) {
|
ResultStatus AppLoader_NCCH::ReadCode(std::vector<u8>& buffer) {
|
||||||
return LoadSectionExeFS(".code", code, error);
|
return LoadSectionExeFS(".code", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the icon (typically icon section) of the application
|
* Get the icon (typically icon section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to icon buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& AppLoader_NCCH::ReadIcon(ResultStatus& error) {
|
ResultStatus AppLoader_NCCH::ReadIcon(std::vector<u8>& buffer) {
|
||||||
return LoadSectionExeFS("icon", icon, error);
|
return LoadSectionExeFS("icon", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the banner (typically banner section) of the application
|
* Get the banner (typically banner section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to banner buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& AppLoader_NCCH::ReadBanner(ResultStatus& error) {
|
ResultStatus AppLoader_NCCH::ReadBanner(std::vector<u8>& buffer) {
|
||||||
return LoadSectionExeFS("banner", banner, error);
|
return LoadSectionExeFS("banner", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the logo (typically logo section) of the application
|
* Get the logo (typically logo section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to logo buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& AppLoader_NCCH::ReadLogo(ResultStatus& error) {
|
ResultStatus AppLoader_NCCH::ReadLogo(std::vector<u8>& buffer) {
|
||||||
return LoadSectionExeFS("logo", logo, error);
|
return LoadSectionExeFS("logo", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the RomFs archive of the application
|
* Get the RomFS of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to RomFs archive buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& AppLoader_NCCH::ReadRomFS(ResultStatus& error) {
|
ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) {
|
||||||
// Check if the NCCH has a RomFS...
|
// Check if the NCCH has a RomFS...
|
||||||
if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
|
if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
|
||||||
u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
|
u32 romfs_offset = ncch_offset + (ncch_header.romfs_offset * kBlockSize) + 0x1000;
|
||||||
@ -295,18 +289,15 @@ const std::vector<u8>& AppLoader_NCCH::ReadRomFS(ResultStatus& error) {
|
|||||||
INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset);
|
INFO_LOG(LOADER, "RomFS offset: 0x%08X", romfs_offset);
|
||||||
INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size);
|
INFO_LOG(LOADER, "RomFS size: 0x%08X", romfs_size);
|
||||||
|
|
||||||
romfs.resize(romfs_size);
|
buffer.resize(romfs_size);
|
||||||
|
|
||||||
file.Seek(romfs_offset, 0);
|
file.Seek(romfs_offset, 0);
|
||||||
file.ReadBytes(&romfs[0], romfs_size);
|
file.ReadBytes(&buffer[0], romfs_size);
|
||||||
|
|
||||||
error = ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
return romfs;
|
|
||||||
} else {
|
|
||||||
NOTICE_LOG(LOADER, "RomFS unused");
|
|
||||||
}
|
}
|
||||||
error = ResultStatus::ErrorNotUsed;
|
NOTICE_LOG(LOADER, "RomFS unused");
|
||||||
return romfs;
|
return ResultStatus::ErrorNotUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Loader
|
} // namespace Loader
|
||||||
|
@ -158,38 +158,38 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the code (typically .code section) of the application
|
* Get the code (typically .code section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to code buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& ReadCode(ResultStatus& error);
|
ResultStatus ReadCode(std::vector<u8>& buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the icon (typically icon section) of the application
|
* Get the icon (typically icon section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to icon buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& ReadIcon(ResultStatus& error);
|
ResultStatus ReadIcon(std::vector<u8>& buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the banner (typically banner section) of the application
|
* Get the banner (typically banner section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to banner buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& ReadBanner(ResultStatus& error);
|
ResultStatus ReadBanner(std::vector<u8>& buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the logo (typically logo section) of the application
|
* Get the logo (typically logo section) of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to logo buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& ReadLogo(ResultStatus& error);
|
ResultStatus ReadLogo(std::vector<u8>& buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the RomFs archive of the application
|
* Get the RomFS of the application
|
||||||
* @param error ResultStatus result of function
|
* @param buffer Reference to buffer to store data
|
||||||
* @return Reference to RomFs archive buffer
|
* @return ResultStatus result of function
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& ReadRomFS(ResultStatus& error);
|
ResultStatus ReadRomFS(std::vector<u8>& buffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -197,11 +197,9 @@ private:
|
|||||||
* Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
|
* Reads an application ExeFS section of an NCCH file into AppLoader (e.g. .code, .logo, etc.)
|
||||||
* @param name Name of section to read out of NCCH file
|
* @param name Name of section to read out of NCCH file
|
||||||
* @param buffer Vector to read data into
|
* @param buffer Vector to read data into
|
||||||
* @param error ResultStatus result of function
|
* @return ResultStatus result of function
|
||||||
* @return Reference to buffer of data that was read
|
|
||||||
*/
|
*/
|
||||||
const std::vector<u8>& LoadSectionExeFS(const char* name, std::vector<u8>& buffer,
|
ResultStatus LoadSectionExeFS(const char* name, std::vector<u8>& buffer);
|
||||||
ResultStatus& error);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads .code section into memory for booting
|
* Loads .code section into memory for booting
|
||||||
|
Loading…
Reference in New Issue
Block a user