kotori2/riru_unity_example

How to hook an enum?

Closed this issue · 5 comments

Hi, I have a problem hooking a enum; here is the enum to hook:
image

And this is the method which use it:
image

And this is the code to hook it:
image

Is this correct? Because my game crash when loading this hook.

I solved it. Just include KittyMemory and patch it manually.
image

Well, for some reason now it doesn't work. When I try to hook the function which return the enum the game crash. Also I tried with KittyMemory and still doesn't work. Is it possible to hook the return of a function which is an enum? In KittyMemory I patched like an Integer.

Yes you should hook the function and return an integer.
Personally I will use Dobby as shown in the example files.
You might gonna check stacktrace from adb.

My best guess is, it is a super simple function, so it must be inlined during compiling. So you might gonna figure out who called get_SkipMode. But I have no idea why it crash.

Thanks for the help but I have finally managed to get it to work. I just hooked the LateUpdate() function and with Ghidra decompiled the lib to know the offset.
image
image