rollraw / qo0-csgo

internal cs:go cheat base/template
https://www.unknowncheats.me/forum/cs-go-releases/585900-v2-qo0s-internal-cheat-base-template.html
MIT License
336 stars 101 forks source link

forwarding arguments to hooks original calls #231

Closed mdma0101 closed 1 year ago

mdma0101 commented 1 year ago

hello, i have noticed a weird issue with the hooking method. essentially i have encountered a problem while attempting to hook into the CEngineClient::IsBoxVisible function. it is working perfectly fine on maps like de_mirage and de_overpass. however, as soon as I join de_vertigo, a sudden crash occurs.

inline CHookObject<ROP::ClientGadget_t> hkIsBoxVisible = { };

if (!hkIsBoxVisible.Create(MEM::GetVFunc(I::Engine, 32), reinterpret_cast<void*>(&IsBoxVisible)))
        return false;

int Q_FASTCALL H::IsBoxVisible(IEngineClient* thisptr, int edx, const Vector_t& vecMin, const Vector_t& vecMax)
{
    return hkIsBoxVisible.CallOriginal<int>(thisptr, edx, vecMin, vecMax);
}

the reason i believe minhook causes it is because i have attempted VMT hooking and it worked without any issues.

rollraw commented 1 year ago

you must pass reference arguments by pointer, as the template does not determine this itself

so

int Q_FASTCALL H::IsBoxVisible(IEngineClient* thisptr, int edx, const Vector_t& vecMin, const Vector_t& vecMax)
{
    return hkIsBoxVisible.CallOriginal<int>(thisptr, edx, &vecMin, &vecMax);
}