From 362a3fde10a3bb2738fcf30ae2e2eaf4a53df042 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 31 Oct 2023 15:38:31 +0100 Subject: [ELFLOADER] Changed how memory is managed in elfloader --- src/custommem.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/custommem.c') diff --git a/src/custommem.c b/src/custommem.c index 51359bd4..b85b2257 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -85,6 +85,7 @@ static uint64_t memprot_allocated = 0, memprot_max_allocated = 0; #endif static memprot_t memprot[1<0x7fff00000000LL) + have48bits = 1; } } fclose(f); @@ -1570,6 +1573,20 @@ void* find47bitBlockNearHint(void* hint, size_t size) } return NULL; } +void* find47bitBlockElf(size_t size, int mainbin) +{ + static void* startingpoint = NULL; + if(!startingpoint) { + startingpoint = (void*)(have48bits?0x7fff00000000LL:0x7f00000000LL); + } + void* mainaddr = (void*)0x100000000LL; + void* ret = find47bitBlockNearHint(mainbin?mainaddr:startingpoint, size); + if(!ret) + ret = find32bitBlock(size); + if(!mainbin) + startingpoint = (void*)(((uintptr_t)startingpoint+size+0x1000000LL)&~0xffffffLL); + return ret; +} int isBlockFree(void* hint, size_t size) { -- cgit 1.4.1