Solved How to hooking function that has class and enum parameters in LGL mod menu?

Status
Not open for further replies.

thienha1

Platinian
Original poster
May 25, 2017
30
81
18
26
I tried too many times search overall the forum, even Google, but still no hope, so I need modders can analyze this function that how to hook!
Example Code:
C#:
//  Token: 0x06029FCC RID: 171980 RVA: 0x00002050 File Offset: 0x00000250 
        [Token(Token = "0x6029FCC")]
        [Address(RVA = "0x2BC7B2C", Offset = "0x2BC7B2C", VA = "0x2BC7B2C")]
        public float Method(Class1 class1, Enum1 enum1)
        {
            return 0f;
        }
Then I wrote code C++ in Main.cpp and i fixed Class1, Enum1 that added 2 class Class1 and Enum1 C++ in project:
C++:
float (*old_Method)(void *instance, Class1 class1, Enum1 enum1);
float Method(void *instance, Class1 class1, Enum1 enum1) {
    if (instance != NULL && value > 1) {
        return (float) value;
    }
    return old_Method(instance, class1, enum1);
}
And Build and Running App then tried set slider in menu mod and crashed immediately!
Hope you all can help me solve this problem!
 

GNaFF

PMT Modder
Staff member
Modding-Team
Oct 20, 2018
2,802
535,391
1,213
BlackPink❤️️
Ex:
C++:
float (*old_Method)(void *instance, void class1, void enum1);
float Method(void *instance, void class1, void enum1) {
    if (instance != NULL && value > 1) {
        return (float) value;
    }
    return old_Method(instance, class1, enum1);
}
 
Last edited:

thienha1

Platinian
Original poster
May 25, 2017
30
81
18
26
Ex:
C++:
float (*old_Method)(void *instance, void class1, void enum1);
float Method(void *instance, void class1, void enum1) {
    if (instance != NULL && value > 1) {
        return (float) value;
    }
    return old_Method(instance, class1, enum1);
}
It work perfect, thank you for your guide!
 
Status
Not open for further replies.