loader: patch am to recover homebrew compatibility
This patch is to be removed if/once hbmenu/libnx re-designs the exiting logic
This commit is contained in:
24
stratosphere/loader/source/ldr_embedded_am_patches.inc
Normal file
24
stratosphere/loader/source/ldr_embedded_am_patches.inc
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Patch teardown function call to NOP. */
|
||||
constexpr inline const EmbeddedPatchEntry AmDisableTeardownPatches_22_0_0[] = {
|
||||
{ 0x5CC4C, "\x1F\x20\x03\xD5", 4 },
|
||||
};
|
||||
|
||||
constexpr inline const EmbeddedPatch AmDisableTeardownPatches[] = {
|
||||
{ ParseModuleId("B337F7C5AD53E55F3D920FCD394B4DE7C3B7D606"), util::size(AmDisableTeardownPatches_22_0_0), AmDisableTeardownPatches_22_0_0 }, /* 22.0.0 */
|
||||
};
|
||||
@@ -108,6 +108,7 @@ namespace ams::ldr {
|
||||
};
|
||||
|
||||
#include "ldr_embedded_usb_patches.inc"
|
||||
#include "ldr_embedded_am_patches.inc"
|
||||
|
||||
}
|
||||
|
||||
@@ -140,6 +141,18 @@ namespace ams::ldr {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Remove this if/when a cleaner solution is implemented by hbmenu/libnx. */
|
||||
for (const auto &patch : AmDisableTeardownPatches) {
|
||||
if (std::memcmp(std::addressof(patch.module_id), std::addressof(module_id), sizeof(module_id)) == 0) {
|
||||
for (size_t i = 0; i < patch.num_entries; ++i) {
|
||||
const auto &entry = patch.entries[i];
|
||||
if (entry.offset + entry.size <= mapped_size) {
|
||||
std::memcpy(reinterpret_cast<void *>(mapped_nso + entry.offset), entry.data, entry.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user