about summary refs log tree commit diff stats
path: root/src/custommem.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-05-03 18:42:03 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-05-03 18:42:03 +0200
commit12467916a4ce5bf8042324f0dbb10a93da41d834 (patch)
treeb617fe857d5aff21c4df1404c19dba1dcb7be452 /src/custommem.c
parent6f0eb5662177f83458a8ad6db29501851f5d66b8 (diff)
downloadbox64-12467916a4ce5bf8042324f0dbb10a93da41d834.tar.gz
box64-12467916a4ce5bf8042324f0dbb10a93da41d834.zip
[DYNAREC] Re-introduce a simple HotPage handling, to speedup heavily obfuscated program loading
Diffstat (limited to 'src/custommem.c')
-rw-r--r--src/custommem.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/custommem.c b/src/custommem.c
index 6a56c641..476a6837 100644
--- a/src/custommem.c
+++ b/src/custommem.c
@@ -1190,6 +1190,27 @@ int isprotectedDB(uintptr_t addr, size_t size)
     return 1;
 }
 
+uintptr_t hotpage = 0;
+int hotpage_cnt = 0;
+#define HOTPAGE_MARK 64
+void SetHotPage(uintptr_t addr)
+{
+    hotpage = addr&~(box64_pagesize-1);
+    hotpage_cnt = HOTPAGE_MARK;
+}
+int isInHotPage(uintptr_t addr)
+{
+    if(!hotpage_cnt)
+        return 0;
+    --hotpage_cnt;
+    return (addr>=hotpage) && (addr<hotpage+box64_pagesize);
+}
+int checkInHotPage(uintptr_t addr)
+{
+    return hotpage_cnt && (addr>=hotpage) && (addr<hotpage+box64_pagesize);
+}
+
+
 #endif
 
 void updateProtection(uintptr_t addr, size_t size, uint32_t prot)