aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Murphy <alec@checksum.fail>2021-07-18 16:00:09 -0400
committerAlec Murphy <alec@checksum.fail>2021-07-18 16:00:09 -0400
commit79c95e774cb281404fa8a60f22e0d6c51f7ec96c (patch)
treeb7e04d4342c048cc1ffdfbd43c5c915bf09a219d
parent6d35d42972edbbcc4fc32066017e2145f81780bf (diff)
Remove hard-coded value to patch W_CacheLumpNumHEADmaster
-rw-r--r--Lib/LibC.HC13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/LibC.HC b/Lib/LibC.HC
index 5bb7eee..c75ec51 100644
--- a/Lib/LibC.HC
+++ b/Lib/LibC.HC
@@ -1,7 +1,16 @@
+extern U64 get_symbol_address(U8 *entry_name);
+
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
+U64 find_u32_in_memory(U64 offset, U32 value) {
+ I64 i = 0;
+ while (MemCmp(offset + i, &value, 4))
+ i++;
+ return offset + i;
+}
+
U8 *f_whence[3];
f_whence[0] = "SEEK_SET";
f_whence[1] = "SEEK_CUR";
@@ -396,7 +405,9 @@ U0 lseek() {
U8 *@mmap(I64 fd) {
no_warn fd;
- MemSetU32(0x4136ae, iwad_fp->data, 1);
+ MemSetU32(
+ find_u32_in_memory(get_symbol_address("W_CacheLumpNum"), 0xcafef00d),
+ iwad_fp->data, 1);
return iwad_fp->data;
}