dreamstalker / rehlds

Reverse-engineered HLDS
GNU General Public License v3.0
625 stars 165 forks source link

Add GetDispatch hook #980

Open tmp64 opened 10 months ago

tmp64 commented 10 months ago

This PR adds a hook for GetDispatch function. It is used by WeaponMod.

It additionally bumps the API version to 3.14159265. #951 also bumped the version in rehlds/version/version.h but I didn't. Let me know and I'll fix the commit.

StevenKal commented 10 months ago

Despite having "GetDispatch" hook could be better (since this is the "inside" function), was not the already existing hook "GetEntityInit" not enough for WeaponMod?

tmp64 commented 10 months ago

You're right. I could just hook GetEntityInit since it simply calls GetDispatch. I'll check and report back later

ENTITYINIT GetEntityInit_internal(char *pClassName)
{
    return (ENTITYINIT)GetDispatch(pClassName);
}

ENTITYINIT EXT_FUNC GetEntityInit_api(char *pClassName)
{
    return g_RehldsHookchains.m_GetEntityInit.callChain(GetEntityInit_internal, pClassName);
}

ENTITYINIT GetEntityInit(char *pClassName)
{
    return GetEntityInit_api(pClassName);
}
tmp64 commented 10 months ago

Yep, GetEntityInit hook works just fine. GetDispatch seems to be used as a generic dlsym in the engine. I guess this PR could be left as is in case someone wants to hook GameDLL functions without a hooking library.