AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Accesing metamod modules by cvar address (https://forums.alliedmods.net/showthread.php?t=190160)

joropito 07-15-2012 12:26

Accesing metamod modules by cvar address
 
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?

TheAvenger 07-17-2012 10:55

Re: Accesing metamod modules by cvar address
 
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.

joropito 07-17-2012 12:52

Re: Accesing metamod modules by cvar address
 
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


All times are GMT -4. The time now is 17:39.

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