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:
hexkyz
2026-04-02 01:42:53 +01:00
parent 082115187a
commit 93a82c0441
2 changed files with 37 additions and 0 deletions

View File

@@ -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);
}
}
}
}
}
}