AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Using SourceHook (https://forums.alliedmods.net/showthread.php?t=78669)

BeetleFart 10-09-2008 16:01

Re: Using SourceHook
 
its a vsp..

Im trying to find the lastest single version of sourcehook.
to learn this on.
Ill check out the PLUGIN_SAVEVARS() macro in ISmmPlugin.h

pRED* 10-09-2008 16:03

Re: Using SourceHook
 
PLUGIN_SAVEVARS() relies on the metamod load forward to get all the pointers, which you won't have.

Have you followed the embedding SourceHook bit at the bottom of that wiki page?

BeetleFart 10-09-2008 16:11

Re: Using SourceHook
 
Thats where I'll start ...thanks for the pointer in the right direction.

BeetleFart 10-09-2008 16:32

Re: Using SourceHook
 
where can I download the latest versions of sourcehook...I may have 2 different versions and its not helping matters.

pRED* 10-09-2008 16:40

Re: Using SourceHook
 
http://hg.alliedmods.net/mmsource-ce...35/sourcehook/

Click one of the bz2/zip links or use mercurial to check out a copy.

BAILOPAN 10-09-2008 16:53

Re: Using SourceHook
 
You should really consider using MM:S, conflicting copies of SourceHook in the same address space is really problematic. ESTools does this and it causes conflicts with SourceMod.

One thing to do is what Mani does. VSP version with SourceHook embedded, MM:S version without. This works pretty nicely as the API stays the same.

The whole point of SourceHook is to unify hooking (making it easier through macros is just a side effect). If there's multiple SourceHooks, the original purpose is lost :|

BeetleFart 10-09-2008 18:29

Re: Using SourceHook
 
Id love to be able to do it that way..
Im still learning alot of this stuff and I dont know if the sourcehook files I have are mixed versions or not..
I have ones that Ive downloaded or have bits and pieces of from other plugins..
At the very least it would be great to get sourcehook going...then once thats working and I (hopefully) better understand its use then I can think about going full mm...but for now I having issues just to get the simple logprint hook to work. So until thats working correctly for me.....

BeetleFart 10-10-2008 09:32

Re: Using SourceHook
 
I've had no luck at all getting sourcehook to not crash.

I tried it in both my orangebox version and non orangebox versions.
I followed the embedding portion on http://wiki.alliedmods.net/SourceHook_Development
without any luck.
I included the files ..everything compiles fine.
I try just to hook logprint and as soon as I give it a
int log_hook = SH_ADD_HOOK(IVEngineServer, LogPrint, engine, SH_STATIC(Hook_LogPrint), false);
command it crashs.

PM 10-10-2008 17:14

Re: Using SourceHook
 
With what error? Maybe a call stack would help. Is g_SHPtr valid? Is engine valid? Also make sure g_PLID doesn't change (though that wouldn't crash).

When it crashes on AddHook, it might mean:
1) g_SHPtr is not a valid pointer to a CSourceHookImpl instance
2) Dereferencing the virtual table and the function entry failed. This could be the passed interface pointer not actually being of the same type as the class used for SH_DECL_HOOK
3) If something went wrong it could be a memory access error (vtables are read-only memory, SourceHook uses VirtualProtect to make it read-write, this might fail on some (security) systems).
4) Something I didn't think of at the moment went wrong.

BeetleFart 10-10-2008 21:33

Re: Using SourceHook
 
Thanks ..it was g_SHPtr...I mistakenly defined a local copy so the global didnt get set.
Now back to trying to trap the ivoiceserver.
Thanks


All times are GMT -4. The time now is 18:40.

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