about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-08-18 10:16:38 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-08-18 10:46:15 +0200
commitdead2003fa59cbfa6a2fd8ba285bdf28aac953f3 (patch)
treed4af9e5a45fa84fed460b33127dc67725a54547f /src
parent44dfa53d4578c66b2e90290da96f8b88fb34fd13 (diff)
downloadbox64-dead2003fa59cbfa6a2fd8ba285bdf28aac953f3.tar.gz
box64-dead2003fa59cbfa6a2fd8ba285bdf28aac953f3.zip
[HACK] Patch Heroic 2.15.1 to avoid some internal memory manager test, until a better solution is found (heroic is still a bit unstable)
Diffstat (limited to 'src')
-rw-r--r--src/core.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index eae05d67..3283a6c2 100644
--- a/src/core.c
+++ b/src/core.c
@@ -2145,6 +2145,18 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf
         FreeCollection(&ld_preload);
         return -1;
     }
+    if(!strcmp(prgname, "heroic")) {
+        // check if heroic needs patching (for the 2.15.1 version)
+        uint8_t* address = GetBaseAddress(elf_header);
+        if(address[0x422f6e1]==0x72 && address[0x422f6e2]==0x44 && address[0x422f6e0]==0xF8 && address[0x422f727]==0xcc) {
+            printf_log(LOG_INFO, "Patched heroic!\n");
+            uintptr_t page = ((uintptr_t)&address[0x422f6e1])&~(box64_pagesize-1);
+            int prot = getProtection(page);
+            mprotect((void*)page, box64_pagesize, PROT_READ|PROT_WRITE|PROT_EXEC);
+            address[0x422f6e1]=0x90; address[0x422f6e2]=0x90;
+            mprotect((void*)page, box64_pagesize, prot);
+        }
+    }
     if(ElfCheckIfUseTCMallocMinimal(elf_header)) {
         if(!box64_tcmalloc_minimal) {
             // need to reload with tcmalloc_minimal as a LD_PRELOAD!