mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-24 02:29:20 +01:00
Updated based on review
This commit is contained in:
parent
2a5b56bb1d
commit
2778801dc5
@ -491,7 +491,7 @@ Loader::ResultStatus NCCHContainer::LoadSectionExeFS(const char* name, std::vect
|
|||||||
|
|
||||||
if (ips_file.IsOpen() &&
|
if (ips_file.IsOpen() &&
|
||||||
ips_file.ReadBytes(&ips[0], ips_file_size) == ips_file_size) {
|
ips_file.ReadBytes(&ips[0], ips_file_size) == ips_file_size) {
|
||||||
LOG_WARNING(Service_FS, "File {} patching code.bin", override_ips);
|
LOG_INFO(Service_FS, "File {} patching code.bin", override_ips);
|
||||||
ApplyIPS(ips, buffer);
|
ApplyIPS(ips, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,13 +534,13 @@ Loader::ResultStatus NCCHContainer::LoadOverrideExeFSSection(const char* name,
|
|||||||
return Loader::ResultStatus::ErrorNotUsed;
|
return Loader::ResultStatus::ErrorNotUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader::ResultStatus NCCHContainer::ApplyIPS(std::vector<u8>& ips, std::vector<u8>& buffer) {
|
void NCCHContainer::ApplyIPS(std::vector<u8>& ips, std::vector<u8>& buffer) {
|
||||||
u32 cursor = 5;
|
u32 cursor = 5;
|
||||||
u32 patch_length = ips.size() - 3;
|
u32 patch_length = ips.size() - 3;
|
||||||
std::string ips_header(ips.begin(), ips.begin() + 5);
|
std::string ips_header(ips.begin(), ips.begin() + 5);
|
||||||
|
|
||||||
if (strcmp(ips_header.c_str(), "PATCH") != 0)
|
if (ips_header != "PATCH")
|
||||||
return Loader::ResultStatus::Error;
|
return;
|
||||||
|
|
||||||
while (cursor < patch_length) {
|
while (cursor < patch_length) {
|
||||||
u32 offset = ips[cursor] << 16 | ips[cursor + 1] << 8 | ips[cursor + 2];
|
u32 offset = ips[cursor] << 16 | ips[cursor + 1] << 8 | ips[cursor + 2];
|
||||||
@ -549,8 +549,6 @@ Loader::ResultStatus NCCHContainer::ApplyIPS(std::vector<u8>& ips, std::vector<u
|
|||||||
std::memcpy(&buffer[offset], &ips[cursor + 5], length);
|
std::memcpy(&buffer[offset], &ips[cursor + 5], length);
|
||||||
cursor += length + 5;
|
cursor += length + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Loader::ResultStatus::Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader::ResultStatus NCCHContainer::ReadRomFS(std::shared_ptr<RomFSReader>& romfs_file) {
|
Loader::ResultStatus NCCHContainer::ReadRomFS(std::shared_ptr<RomFSReader>& romfs_file) {
|
||||||
|
@ -253,9 +253,9 @@ public:
|
|||||||
* Attempts to patch a buffer using an IPS
|
* Attempts to patch a buffer using an IPS
|
||||||
* @param ips Vector of the patches to apply
|
* @param ips Vector of the patches to apply
|
||||||
* @param buffer Vector to patch data into
|
* @param buffer Vector to patch data into
|
||||||
* @return ResultStatus result of function
|
* @return Void
|
||||||
*/
|
*/
|
||||||
Loader::ResultStatus ApplyIPS(std::vector<u8>& ips, std::vector<u8>& buffer);
|
void ApplyIPS(std::vector<u8>& ips, std::vector<u8>& buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the override RomFS of the NCCH container
|
* Get the override RomFS of the NCCH container
|
||||||
|
Loading…
Reference in New Issue
Block a user