This is the AMP version of this page.
If you want to load the real page instead, click this text.

Help! How to hook enum function has reference object parameter?

thienha1

Platinian
Original poster
May 25, 2017
30
81
18
26
This is my ex default function:
C#:
public override NPC.Status GetMoveStatus(ref object[] p)
{
    return NPC.Status.Running;
}
I want to return like this:
C#:
public override NPC.Status GetMoveStatus(ref object[] p)
{
    return NPC.Status.Walking;
}
Ex enum function:
C#:
public enum Status
        {
            Running, // 0
            Walking, // 1
            Stopped // 2
        }
So I hook this function as I think it will work:
C++:
bool walk;
int (*old_GetMoveStatus)(void *instance, void p);
int GetMoveStatus(void *instance, void p) {
    if (instance != NULL && walk) {
        return 1;
    }
    return old_GetMoveStatus(instance, p);
}
And a result, it get crash immediately after enable this function.
Can you guys have any idea or solution for this issue?
 

Tiahh

Solid & Active Platinian
Jan 12, 2018
79
46
18
37
C++:
bool walk;
int (*old_GetMoveStatus)(void *instance, void *p);
int GetMoveStatus(void *instance, void *p) {
    if (instance != NULL && walk) {
        return 1;
    }
    return old_GetMoveStatus(instance, p);
}
Try with this code, btw you didn't provide enough info.