View Single Post
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-04-2010 , 03:38   Re: Dynamic detouring library
Reply With Quote #11

Quote:
Originally Posted by DJ Tsunami View Post
I came across Orpheu recently though, which seems to make dynamic hooking possible for AMX Mod X. Unfortunately that code just made my head spin. Now I know Source is not the same as GoldSrc, but it still seems to be possible. Indeed the question remains if that's a sane way of doing it.
Ignore the code, the concept is easy. A base class that defines the virtual functions related to convert "between a C++ type and a pawn type" and vice versa. Implemented in a class per type for types like CBaseEntity, entvars_s, edict, "string", etc. Then, depending on how the function is described in a file, an array of objects of each type is created like:

Code:
[0] = CBaseEntity object
[1] = String object
[2] = Float object
Then, with inline assembly code (so functions can be given a variable number of arguments) the array is iterated to convert from pawn to C++ or vice-versa and pass them from plugin to module or vice-versa.

The bigger problems that I had were creating the code to handle all types because float por example uses different processor registers so I had to do some stuff and strings are returned by reference, etc. But I had no prior assembly and C++ experience (had C experience tough) so I know you can do it with less problems that I had (edit: if you do it, try to use this idea. I wish I had it before making it since now it's a pain to make all over again)

I don't know how sourcepawn or sourcemod works but I guess you can apply the same concept to it.

About what David Bailopan said, don't be scared. What he is saying is that since he produces base tools they have to be under solid grounds (like, when having errors failing the sooner possible) and this concept can never be that solid per se (from the few I know). But in the end a tool like this is for more experienced users so the unsafeness is not a big problem. And since what it let's people do can't be achieved otherwise is nice to have it and the approved plugins using it are the proof of that (And two that bailopan banned ).

To end this post, sorry for making it so long but it's the first time I talked about this with someone that has more knowledge than me with this stuff and I didn't send this as PM because I hope that someone might give me some insight of how I can improve the stuff I did using another concept for example (namely, the thread author).

Note to Bailopan: In the Modules section there are many modules stickied less useful than Orpheu.
__________________

Last edited by joaquimandrade; 05-04-2010 at 03:48.
joaquimandrade is offline