Hello pRED
Sorry for the late response, I've been pretty busy with moving and school and forgot about your post.
First of all, it's a good thing that you want to try adding detours, I'd probably try it in the (near?) future as well..
- You might want to generate hook functions which look at the registered hooks, call them, and process the META_RES stuff. Most of the time, the SH_DECL_HOOK macros do this. There is also an x86 hook function generator in SVN (although I think that no one ever tried it in production code yet) that (should work)/works for virtual functions. The iteration and META_RES logic should not be too different. The current stuff is in sourcehook_hookmangen* (which basically generates equivalent functions to those created by the DECL_ macros). I guess that going with automatic hook manager generation from the beginning for a new feature might be preferable. Then the macros don't get that big
- In order to generate all that macros in the headers, I used a tool called shworker. It's similar to Don Clugston's "hopter", but a bit more powerful: it supports nested generation loops. I think I had quick "documentation" (hopefully not outdated) in the initial comments in shworker.cpp
- I'm a bit afraid that the sourcehook.h file will grow to bad dimensions when another set of macros is added. I'm not sure what to do about it though (yet)
- In order to be reentrant, SourceHook uses "contexts" which are put on a stack (works for single-threaded stuff at least). All status variables related to the currently active hook are on the top of the stack.
- The NEWPARAMS macros work like this: the function is called AGAIN with new parameters, SourceHook makes sure that the new call proceeds execution where the last left off. Post recalls (NEWPARAMS being called from post functions, ie. after the original function call might have been executed) were a bit trickier, I actually don't remember the exact way they work (and the description at the beginning of sourcehook_impl.h seems to suggest that I was drunk when I wrote them -- though I doubt it
)
- Actually, the whole hooking mechanism might need speeding up, but I'm not sure how to do that either (yet). And how to do that without breaking binary compat.
- I guess there's much more to say, but I haven't looked at the SH code for a long time so I'll have to read it again. If you have AIM/ICQ/google talk/e-mail, send me a PM!
Greetings,
PM
__________________