mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
virtmem: Allow rng algorithm override
This commit is contained in:
parent
137f6d1ddc
commit
95fca6753d
@ -32,6 +32,10 @@ static VirtmemReservation *g_Reservations;
|
|||||||
|
|
||||||
static bool g_IsLegacyKernel;
|
static bool g_IsLegacyKernel;
|
||||||
|
|
||||||
|
uintptr_t __attribute__((weak)) __libnx_virtmem_rng(void) {
|
||||||
|
return (uintptr_t)randomGet64();
|
||||||
|
}
|
||||||
|
|
||||||
static Result _memregionInitWithInfo(MemRegion* r, InfoType id0_addr, InfoType id0_sz) {
|
static Result _memregionInitWithInfo(MemRegion* r, InfoType id0_addr, InfoType id0_sz) {
|
||||||
u64 base;
|
u64 base;
|
||||||
Result rc = svcGetInfo(&base, id0_addr, CUR_PROCESS_HANDLE, 0);
|
Result rc = svcGetInfo(&base, id0_addr, CUR_PROCESS_HANDLE, 0);
|
||||||
@ -116,7 +120,7 @@ static void* _memregionFindRandom(MemRegion* r, size_t size, size_t guard_size)
|
|||||||
// Calculate a random memory range outside reserved areas.
|
// Calculate a random memory range outside reserved areas.
|
||||||
uintptr_t cur_addr;
|
uintptr_t cur_addr;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
uintptr_t page_offset = (uintptr_t)randomGet64() % (aslr_max_page_offset + 1);
|
uintptr_t page_offset = __libnx_virtmem_rng() % (aslr_max_page_offset + 1);
|
||||||
cur_addr = (uintptr_t)r->start + (page_offset << 12);
|
cur_addr = (uintptr_t)r->start + (page_offset << 12);
|
||||||
|
|
||||||
// Avoid mapping within the alias region.
|
// Avoid mapping within the alias region.
|
||||||
|
Loading…
Reference in New Issue
Block a user