#[SOLVED] DSR Hook Crashing When Enabled

5 messages · Page 1 of 1 (latest)

turbid ivy
#

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 🫠

turbid ivy
#

update on this: i definitely think this is the wrong function - the delay before the crash is because the function crashes upon calling the original, and the function i'm hooking is invoked somewhere in the startup process. if i wait a few seconds for the game to load the title screen before enabling the hook, nothing crashes
which means i have no idea where the item get function actually is puddingcat

turbid ivy
#

lol

#

so it turns out that this IS the right method, my method signature was just wrong in ghidra. param_3 wasn't a uint32_t, it was an int

#

we're good now!