add kip detection

This commit is contained in:
Lightos1
2026-06-27 19:47:00 +02:00
parent cd9d494de9
commit f3886c60b0
8 changed files with 71 additions and 7 deletions

View File

@@ -24,10 +24,7 @@
#define CRASH(msg, ...) { ams::diag::AbortImpl(msg, __PRETTY_FUNCTION__, "", 0); __builtin_unreachable(); }
#include "customize.hpp"
#if defined(AMS_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING)
#include "oc_log.hpp"
#endif
#include "oc_log.hpp"
#define PATCH_OFFSET(offset, value) \
static_assert(sizeof(__typeof__(offset)) <= sizeof(u64)); \

View File

@@ -21,6 +21,7 @@
namespace ams::ldr::hoc {
Result SmcCopyToIram(uintptr_t dest, const void *src, u32 size);
void Log(const char *data, ...);
void ViewLog();

View File

@@ -170,6 +170,12 @@ namespace ams::ldr::hoc::pcv {
}
}
void WriteKipLoadToIram() {
const u32 hocMagic = 0x686F634D;
constexpr uintptr_t LoadMagicAddress = 0x4003DC00 ; /* Should be a pretty safe address. */
R_DISCARD(SmcCopyToIram(LoadMagicAddress, &hocMagic, sizeof(hocMagic)));
}
void Patch(uintptr_t mapped_nso, size_t nso_size) {
SafetyCheck();
@@ -179,6 +185,8 @@ namespace ams::ldr::hoc::pcv {
} else {
erista::Patch(mapped_nso, nso_size);
}
WriteKipLoadToIram();
}
}