Fixed crashes on the latest ReHLDS (#4)

Fixes #1 by updating the memory pattern for `gMsgBuffer` and `gMsgType` variables.
This commit is contained in:
Artem Golubikhin 2022-02-06 05:11:03 -08:00 committed by GitHub
parent 83fc271222
commit baf100c59d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -355,7 +355,7 @@ void Init() {
} }
if (isReHLDS) { if (isReHLDS) {
uintptr_t addr = FindMemoryByPattern(g_engfuncs.pfnMessageEnd, "F6 05 ?? ?? ?? ?? 02 0F 85 ?? ?? ?? ?? 8B ?? ?? ?? ?? ?? 83 ?? 3A"); uintptr_t addr = FindMemoryByPattern(g_engfuncs.pfnMessageEnd, "F6 05 ?? ?? ?? ?? 02 0F 85 ?? ?? ?? ?? 8B ?? ?? ?? ?? ?? 83");
g_msgBuffer = decltype(g_msgBuffer)(*(uintptr_t *)(addr + 2) - offsetof(remove_pointer_t<decltype(g_msgBuffer)>, flags)); g_msgBuffer = decltype(g_msgBuffer)(*(uintptr_t *)(addr + 2) - offsetof(remove_pointer_t<decltype(g_msgBuffer)>, flags));
g_msgType = *(int **)(addr + 15); g_msgType = *(int **)(addr + 15);
} else { } else {
@ -381,7 +381,7 @@ void Init() {
if (g_msgBuffer != nullptr) { if (g_msgBuffer != nullptr) {
g_msgType = (decltype(g_msgType))dlsym(handle, "gMsgType"); g_msgType = (decltype(g_msgType))dlsym(handle, "gMsgType");
} else { } else {
uintptr_t addr = FindMemoryByPattern(g_engfuncs.pfnMessageEnd, "F6 05 ?? ?? ?? ?? 02 0F 85 ?? ?? ?? ?? 8B ?? ?? ?? ?? ?? 83 ?? 3A"); uintptr_t addr = FindMemoryByPattern(g_engfuncs.pfnMessageEnd, "F6 05 ?? ?? ?? ?? 02 0F 85 ?? ?? ?? ?? 8B ?? ?? ?? ?? ?? 83");
g_msgBuffer = decltype(g_msgBuffer)(*(uintptr_t *)(addr + 2) - offsetof(remove_pointer_t<decltype(g_msgBuffer)>, flags)); g_msgBuffer = decltype(g_msgBuffer)(*(uintptr_t *)(addr + 2) - offsetof(remove_pointer_t<decltype(g_msgBuffer)>, flags));
g_msgType = *(int **)(addr + 15); g_msgType = *(int **)(addr + 15);
} }
@ -1050,4 +1050,4 @@ void PF_MessageEnd_I() {
memcpy((void*)g_engfuncs.pfnMessageEnd, g_patchedBytes, 5); memcpy((void*)g_engfuncs.pfnMessageEnd, g_patchedBytes, 5);
mprotect((void*)(addr/PAGESIZE*PAGESIZE), 5 + addr%PAGESIZE, PROT_EXEC | PROT_READ); mprotect((void*)(addr/PAGESIZE*PAGESIZE), 5 + addr%PAGESIZE, PROT_EXEC | PROT_READ);
#endif #endif
} }