Raised This Month: $32 Target: $400
 8% 

Detours


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pRED*
Join Date: Dec 2006
Old 09-19-2008 , 18:58   Detours
Reply With Quote #1

Hello PM.

I hear that you were originally (or maybe still) planning to include a detours component in SourceHook.

I've been working on my own detours implementation: http://users.svn.alliedmods.net/view...est/?root=pred

And was considering playing with a sourcehook version.

Do you have any ideas/suggestions/news/abuse/wise advice you are willing to share.

I've had a quick read of the SH source and have a general understanding of what's happening. Do need to spend some time getting to fully understand it.

<-- crab
pRED* is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 10-18-2008 , 04:32   Re: Detours
Reply With Quote #2

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
__________________
hello, i am pm

Last edited by PM; 10-18-2008 at 04:37.
PM is offline
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 00:40.


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