Raised This Month: $51 Target: $400
 12% 

Solved [H3LP] Hooking CBasePlayer::StartObserver


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 05-07-2019 , 03:37   [H3LP] Hooking CBasePlayer::StartObserver
Reply With Quote #1

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:
#include <amxmodx> #include <okapi> new const g_hObserverSignature[] = {0x53,0x56,0x8B,"𐌻",0x57,0x33,"𐌻",0x8B,"𐌻","𐌻",0x57,0x83,"𐌻","𐌻",0x50,0x6A}; new const g_szObserverSymbol[] = "_ZN11CBasePlayer13StartObserverE6VectorS0_"; new okapi_hook: g_hSpectatorObs; new okapi_func: g_hObserverSetMode; new g_hSpectatorValue; public plugin_precache() {     if(is_linux_server())         g_hSpectatorValue = okapi_mod_get_symbol_ptr(g_szObserverSymbol);     else         g_hSpectatorValue = okapi_mod_find_sig(g_hObserverSignature, sizeof g_hObserverSignature);         g_hObserverSetMode = okapi_build_function(g_hSpectatorValue, arg_void, arg_cbase, arg_vec, arg_vec);     g_hSpectatorObs = okapi_add_hook(g_hObserverSetMode, "OnSpectatorJoin_Post", .post = true); } public plugin_pause() {     okapi_del_hook(g_hSpectatorObs); } public plugin_unpause() {     g_hSpectatorObs = okapi_add_hook(g_hObserverSetMode, "OnSpectatorJoin_Post", .post = true); } public plugin_end() {     okapi_del_hook(g_hSpectatorObs); } public OnSpectatorJoin_Post(const iID, const Float: fVecPos[], const Float: fVecViewAngle[]) {     server_print("Called"); }

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 !

Last edited by DarthMan; 05-07-2019 at 05:03. Reason: Solved
DarthMan is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode