Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import DHooks as first-party extension #1629

Merged
merged 6 commits into from
Nov 17, 2021
Merged

Import DHooks as first-party extension #1629

merged 6 commits into from
Nov 17, 2021

Conversation

peace-maker
Copy link
Member

Since DHooks with dynamic detouring is widely used by plugin developers nowadays, we decided to adopt the extension as a base feature of SourceMod. #981 made a first proposal of importing the original DHooks extension, but since most users switched to the fork which adds detouring support in addition to dynamic vtable hooking, it seemed better to import the forked version.

This is the latest DHooks version from https://github.com/peace-maker/DHooks2/tree/1314f2d1b4d870677a1b9f628c770f2799878f9b

@Drifter321 and I both agreed to transfer the copyright of the code to Alliedmodders LLC. To implement dynamic detouring for plugins the DynamicHooks library by @Ayuto was adopted. Thank you again!

This is a straight import of the latest version including the fixes and enhancements that didn't make it into a new release yet. There was no effort made to streamline the implementation with other code inside SourceMod.

Supercedes #981

This helped catch a bug in DHooks before, so it's worth adding it in here as well.
I frequently have one like `buildwin` and `buildlin` for the different OS in WSL.
@Drifter321
Copy link
Member

I have a few questions (I probably looked at but forgot now…)

What happens if two plugins detour the same function? Does one clobber the other?

I think it’s still better to add a detour library to MM:S (along the lines of sourcehook) so we don’t have plugins/extensions clobbering each other.

Also, I can’t remember this. Is it possible to access object param address to get data? I know it’s possible to get object values.

Example object->object->thisval ?

If not, we should consider adding this probably?

on another note, thanks for all your hard work on dhooks over the years!

@peace-maker
Copy link
Member Author

What happens if two plugins detour the same function? Does one clobber the other?

They are added to the plugin callback list of the same detour and get their callbacks called in sequence. The highest MRES return value is used. This only works for detours done through DHooks though. Detours through an extension or other server plugin could still cause problems during unloading/reloading similar to the problems with CDetour.

I think it’s still better to add a detour library to MM:S (along the lines of sourcehook) so we don’t have plugins/extensions clobbering each other.

Yes, very true. It just needs someone to do it and DHooks can be moved to that other library when it's available.

Also, I can’t remember this. Is it possible to access object param address to get data? I know it’s possible to get object values.

Example object->object->thisval ?

DHookParam.GetAddress was added recently if that's what you're after. I don't think it's possible to nest object parameters though?

🎉

Copy link
Member

@asherkin asherkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - would definitely like the sigscan cache in before 1.11 is branched though.

@peace-maker peace-maker merged commit 9cb693d into master Nov 17, 2021
@peace-maker peace-maker deleted the dhooks2 branch November 17, 2021 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants