mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-07 13:39:55 +00:00
sceKernelGetSanitizerMallocReplaceExternal and sceKernelGetSanitizerNewReplaceExternal are imported by the libc.prx nine titles ship, and the libkernel debt entry describes what they return: a static table whose first field is its size, 0x70 for malloc and 0x68 for new, with every function pointer null. Nothing tested that. The test checks both tables' sizes, that every entry after the size is zero and that a second call returns the same table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
27 lines
936 B
C++
27 lines
936 B
C++
#include "prx/libkernel/include/Api.hpp"
|
|
#include "SceTypes.hpp"
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
|
|
static void Require(bool value) {
|
|
if (!value) std::abort();
|
|
}
|
|
|
|
template <typename Table>
|
|
static void RequireEmpty(const Table* table, std::uint64_t size) {
|
|
Require(table != nullptr);
|
|
Require(table->size == size);
|
|
const auto* entries = reinterpret_cast<const unsigned char*>(table) + sizeof(table->size);
|
|
for (std::size_t index = 0; index < sizeof(Table) - sizeof(table->size); index++) Require(entries[index] == 0);
|
|
}
|
|
|
|
int main() {
|
|
const auto* mallocTable = sceKernelGetSanitizerMallocReplaceExternal();
|
|
RequireEmpty(mallocTable, 0x70);
|
|
Require(sceKernelGetSanitizerMallocReplaceExternal() == mallocTable);
|
|
const auto* newTable = sceKernelGetSanitizerNewReplaceExternal();
|
|
RequireEmpty(newTable, 0x68);
|
|
Require(sceKernelGetSanitizerNewReplaceExternal() == newTable);
|
|
}
|