i'm trying to use minhook to hook into what i think is the get item function for dsr based on searching for some matching assembly in ghidra, but i'm running into an issue where the hook is created and enabled successfully, but then crashes the game after about a second.
here's the function signature in the ghidra decompiler:
int FUN_1403f8780(int param_1,uint param_2,uint param_3,int param_4)
and here's how i've defined the original function and hook (which right now is just returning the original stuff - i had some log statements here but given where the game crashes they never actually execute anyway):
using getItemDef = int(_fastcall*)(int param_1, uint32_t param_2, uint32_t param_3, int param_4);
getItemDef originalGetItem;
int __fastcall getItemOverride(int param_1, uint32_t param_2, uint32_t param_3, int param_4) {
return originalGetItem(param_1, param_2, param_3, param_4);
}
and here's where i'm hooking - note that the address i'm hooking at is 0x1403F8780, same as the original function:
MH_STATUS status = MH_CreateHook((LPVOID)0x1403F8780, &getItemOverride, (LPVOID*)&originalGetItem);
if (status != MH_OK) {
logger->log("Couldn't create hook!");
return false;
}
if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) {
logger->log("Couldn't enable hook!");
return false;
}
logger->log("Hooked successfully!");
return true;
the "Hooked successfully!" log is executing, but like i mentioned the whole game crashes after about a second. this doesn't happen if i don't enable the hook though.
it's also extremely possible that this is the wrong function entirely, but it's hard to tell while the game is just straight up crashing before the main window even appears 🫠
