Minor style changes and use memcpy
This commit is contained in:
parent
2496ecbaf6
commit
bf50bb06f1
|
@ -486,7 +486,7 @@ Loader::ResultStatus NCCHContainer::LoadSectionExeFS(const char* name, std::vect
|
||||||
|
|
||||||
if (FileUtil::Exists(override_ips) && strcmp(name, ".code") == 0) {
|
if (FileUtil::Exists(override_ips) && strcmp(name, ".code") == 0) {
|
||||||
FileUtil::IOFile ips_file(override_ips, "rb");
|
FileUtil::IOFile ips_file(override_ips, "rb");
|
||||||
size_t ips_file_size = ips_file.GetSize();
|
std::size_t ips_file_size = ips_file.GetSize();
|
||||||
std::vector<u8> ips(ips_file_size);
|
std::vector<u8> ips(ips_file_size);
|
||||||
|
|
||||||
if (ips_file.IsOpen() &&
|
if (ips_file.IsOpen() &&
|
||||||
|
@ -543,15 +543,11 @@ Loader::ResultStatus NCCHContainer::ApplyIPS(std::vector<u8>& ips, std::vector<u
|
||||||
return Loader::ResultStatus::Error;
|
return Loader::ResultStatus::Error;
|
||||||
|
|
||||||
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];
|
||||||
u32 length = (ips[cursor + 3]) << 8 | (ips[cursor + 4]);
|
std::size_t length = ips[cursor + 3] << 8 | ips[cursor + 4];
|
||||||
cursor += 5;
|
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
std::memcpy(&buffer[offset], &ips[cursor + 5], length);
|
||||||
buffer[offset + i] = ips[cursor + i];
|
cursor += length + 5;
|
||||||
}
|
|
||||||
|
|
||||||
cursor += length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Loader::ResultStatus::Success;
|
return Loader::ResultStatus::Success;
|
||||||
|
|
Reference in New Issue