Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 9e32cb3

Browse files
authored
De-inlines DelDatum
1 parent ace01c1 commit 9e32cb3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

byond-extools/src/core/find_functions.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#define IMPORT_OR_DIE(name, sig) name = (name##Ptr)dlsym(dlopen(BYONDCORE, 0), sig); if(!name) { Core::Alert("Failed to locate " #name " via " #sig); return false; }
1414
#endif
1515

16+
extern "C" void *subhook_unprotect(void *address, size_t size);
17+
1618
bool Core::verify_compat()
1719
{
1820
#ifdef _WIN32
@@ -141,6 +143,19 @@ bool Core::find_functions()
141143
FIND_OR_DIE(SetVariable, "55 89 E5 81 EC A8 00 00 00 8B 55 ?? 89 5D ?? 8B 4D ?? 89 7D ?? 8B 5D ??");
142144
FIND_OR_DIE(GetStringTableIndexUTF8, "55 89 E5 57 56 89 CE 53 89 D3 83 EC ?? 8B 55 ?? 85 C0") // regparm3
143145
if(failed) return false;
146+
147+
// De-inlines DelDatum, very hackily.
148+
char *datum_dec_function_deinline = (char *)Pocket::Sigscan::FindPattern(BYONDCORE, "55 89 e5 53 83 ec 44 8b 45 08 3b 05 ?? ?? ?? ?? 72 46", 114);
149+
subhook_unprotect(datum_dec_function_deinline, 3+5+2);
150+
// mov [esp], eax
151+
datum_dec_function_deinline[0] = 0x89;
152+
datum_dec_function_deinline[1] = 0x04;
153+
datum_dec_function_deinline[2] = 0x24;
154+
// call DelDatum
155+
datum_dec_function_deinline[3] = 0xe8;
156+
*((int*)(datum_dec_function_deinline+4)) = ((int)(void*)DelDatum) - ((int)(void*)datum_dec_function_deinline + 8);
157+
datum_dec_function_deinline[8] = 0xeb;
158+
datum_dec_function_deinline[9] = 0xd4;
144159

145160
datum_pointer_table_length = *(unsigned int**)((char*)DelDatum + 12);
146161
datum_pointer_table = *(RawDatum****)((char*)DelDatum + 20);

0 commit comments

Comments
 (0)