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

Accesing metamod modules by cvar address


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 07-15-2012 , 12:26   Accesing metamod modules by cvar address
Reply With Quote #1

I was trying to hook functions in metamod modules using an amxmodx module and I found that, in linux using dladdr within the cvar pointer registered by the metamod module (even with amxmodx) can't be mapped to an already opened library.

For example

Code:
cvar_t *a = CVAR_GET_POINTER("amx_client_languages");

Dl_info info;
dladdr((void *)a, &info)
Here dladdr returns 0, so it can't find the associated library for that memory address.

Using GDB I found the address is in non-allocated space by any library loaded...
It's really strange. At least should be engine_i686.so.

If I do the same with mp_timelimit or sv_proxies I get the corresponding library (CS or ENGINE).

Some time ago I was trying to do this with orpheu using the included method to define additional libraries and I get the same error.

It's possible that last updates on engine changed something about how cvar pointers works?

Anyone has similar problems?
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
TheAvenger
Junior Member
Join Date: May 2012
Old 07-17-2012 , 10:55   Re: Accesing metamod modules by cvar address
Reply With Quote #2

Metamod does not supply plugin configurable variables directly to the engine to avoid segmentation
faults. Check the 'reg_support.cpp' at line 178, it should explain everything for you.
TheAvenger is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 07-17-2012 , 12:52   Re: Accesing metamod modules by cvar address
Reply With Quote #3

Yes, I found that the correct way is to hook CVarRegister before OnMetaAttach, then at each call check cvar_t pointer passed as parameter and that memory will be for the calling module.

Thanks
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Reply



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 02:09.


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