[H3LP] Hooking CBasePlayer::StartObserver
Hello. I'm having issues hooking CBasePlayer::StartObserver using Okapi. It's my first time using the module, but I'm sure that everything was done correctly. The signature is also correct. In fact, the function is hooked, because, when I join spectator, the server crashes. So it means it hooks the right 1.
Code:
Using Orpheu it would be understandable because it doesn't support vectors as parameters, but, from what I read, Okapi supports them as long as the return function type is not a vector. Looking at the HLSDK to confirm, the function is void, and there are 3 arguments: the player id and 2 vectors to store the position and the view angle. However, if I remember correctly, I read somewhere that the only possible way to hook a function that has Vector and not Vector * or &Vector as a parameter is by using Rage, Okapi and Orpheu being unsupported. Also, I'd like to say that I found this: https://forums.alliedmods.net/showth...t=40164&page=9 . So, the truth lies somewhere else. It means that Okapi is indeed capable of hooking functions that have Vector as parameter. Decompiling the function on Windows TFC I found this: int __thiscall sub_3003E080(_DWORD *this, char a2, int a3, int a4, int a5, int a6, int a7) as opossed to Linux, where it is void __cdecl CBasePlayer::StartObserver(CBasePlayer *const this, Vector *p_vecPosition, Vector *p_vecViewAngle). Thanks ! |
Re: [H3LP] Hooking CBasePlayer::StartObserver
Solved by changing okapi_build_function to okapi_build_method :-)
|
Re: [H3LP] Hooking CBasePlayer::StartObserver
okapi_build_function should be used for functions without a class.
okapi_build_method should be used for functions that are member of a class. orpheu can hook Vector&(IIRC), but not Vector. Okapi can do both. Just take care with okapi, under linux it could crash the server due to some memory bug which wasn't fixed yet. |
Re: [H3LP] Hooking CBasePlayer::StartObserver
Quote:
Also, I noticed a bug with Okapi. If I do new hObserverValue = wl(okapi_mod_find_sig(hObserverSignature, sizeof hObserverSignature), okapi_mod_get_symbol_ptr(szObserverSymbol)); all works fine, but if I hook the same function in another plug-in, then it gives me an error. [OKAPI] Null address provided Same thing happens if I register hObserverValue twice in the plug-in using it, I did that just for testing purposes to see if it causes the error. That means that you can only register a hook once, so, like, it can only be registered in 1 plug-in. Registering it in multiple plug-ins will cause that error. I don't know if that's due to a problem on Okapi itself, but, most likely, it's that. I remember Arkshine saying that he stopped working on Rage/Orpheu/Okapi and he probably won't be touching them anytime in the enar future, since he's focused more on AMX Mod X rather than additional modules right now. And also, considering how slowly AMXX is advancing and 1.9 is still not a stable build, could take a year or a few more before 1.8.2 is finally replaced by 1.9 . Not to mention that there's also AMXX v1.10 available now and I've upgraded to it recently. |
Re: [H3LP] Hooking CBasePlayer::StartObserver
That's not a bug, it is by design(read the okapi topic). You are supposed to build the function in precache and register the hook later(in init for example).
|
Re: [H3LP] Hooking CBasePlayer::StartObserver
So, that's why it happens?
Hook must be registered in init/cfg/etc and the function in precache? So it's like a rule, otherwise will throw the error? Then how come even registering it in init if i do it twice I get that error ? I've been told this: - All hooks registered by the module must be un-hooked - Sig search - All hooks must be repatched to their previous status. |
Re: [H3LP] Hooking CBasePlayer::StartObserver
Quote:
Edit: I had another plug-in calling it and it wasn't done in plugin_precache. Seems to be working fine now. Thanks for the help. Much appreciated ! |
Re: [H3LP] Hooking CBasePlayer::StartObserver
From okapi thread:
Quote:
|
All times are GMT -4. The time now is 15:42. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.