mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-05 13:20:11 +00:00
fix(libs): reject unsupported WebAssembly module unwind queries
This commit is contained in:
1 parent
e427bd0567
commit
2c22b68133
7 files changed
+63
-5
No files matched your search
@@ -0,0 +1,41 @@
|
||||
#include "prx/libkernel/include/Api.hpp"
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
#include "prx/libSceSysmodule/include/Api.hpp"
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
namespace {
|
||||
|
||||
struct UnsupportedPath {
|
||||
const char* function;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* function) {
|
||||
throw UnsupportedPath{function};
|
||||
}
|
||||
|
||||
int main() {
|
||||
for (const auto query : {&sceKernelGetModuleInfoForUnwind, &sceSysmoduleGetModuleInfoForUnwind}) {
|
||||
for (const auto address : {std::uint64_t{0}, std::uint64_t{0x10000}, std::numeric_limits<std::uint64_t>::max()}) {
|
||||
for (const int flags : {0, 1, -1}) {
|
||||
ModuleInfoForUnwind info;
|
||||
std::memset(&info, 0xa5, sizeof(info));
|
||||
std::array<unsigned char, sizeof(info)> before;
|
||||
std::memcpy(before.data(), &info, sizeof(info));
|
||||
try {
|
||||
query(address, flags, &info);
|
||||
std::abort();
|
||||
} catch (const UnsupportedPath& error) {
|
||||
if (std::strcmp(error.function, "sceKernelGetModuleInfoForUnwind") != 0 ||
|
||||
std::memcmp(before.data(), &info, sizeof(info)) != 0) std::abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sceKernelGetModuleInfoForUnwind(0, 0, nullptr) != SCE_KERNEL_ERROR_EFAULT) std::abort();
|
||||
}
|
||||
Reference in new issue
Block a user