Raised This Month: $147 Target: $400
 36% 

DHooks (Dynamic Hooks - Dev Preview)


Post New Thread Reply   
 
Thread Tools Display Modes
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-26-2020 , 08:28   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #791

Quote:
Originally Posted by xerox8521 View Post
Would it be possible to add a return type that skips the game function call entirely for void functions ?
Currently it explicity checks when using MRES_Supercede.
That code is just checking for allocating space to store the return value - supercede should work fine for void functions.
__________________
asherkin is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-26-2020 , 08:41   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #792

Quote:
Originally Posted by Accelerator74 View Post
Аfter sourcemod 1.11.6609 and above, dhooks detours causes server crashes on startup. After updating sdkhooks extension (OnEntitySpawned forward)
Code:
---- Host_NewGame ----
maxplayers set to 32
Host_NewGame on map c1m1_hotel
ConVarRef room_type doesn't point to an existing ConVar
Executing dedicated server config file
./srcds_run: line 341:  5383 Segmentation fault      $HL_CMD
Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem
Even the "Accelerator" extension fails to create a crash dump.
This should be fixed in the next-ish SM build, thanks!

In the future, best to file crashes caused by SM upgrades as GitHub issues against SourceMod - they're more likely to be seen quickly.
__________________
asherkin is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 08-26-2020 , 11:58   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #793

Quote:
Originally Posted by asherkin View Post
That code is just checking for allocating space to store the return value - supercede should work fine for void functions.
Yea my bad forgot to switch from post to pre hook where supercede works just fine.
xerox8521 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-26-2020 , 19:09   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #794

So i have a plugin that removes some entities on SDKHook_Spawn and another plugin that dhooks an entity on SDKHook_Spawn. Whenever I kill an entity that is hooked as well, the server crashes.
I changed SDKHook_Spawn to SDKHook_SpawnPost for the dhook thing, and it's fine now. Should i dunhook the entitiy on EntityDestroyed?
I hook AcceptInput and i use AcceptEntityInput to kill entities.

Some info about the crash: https://crash.limetech.org/gd2tysruj7hp
__________________

Last edited by Ilusion9; 08-26-2020 at 19:18.
Ilusion9 is offline
OneMore
Member
Join Date: Feb 2019
Old 09-30-2020 , 09:30   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #795

Hi,

Would you please help me to find a reason why I can't run dhook on my server?
I have the latest metamode and sourcemode. I copied 9, 10, 13 and 14 version of dhooks to sourcemod folder to check. All of them are for sourcemode 1.10 (dhooks-2.2.0-detours14a-sm110).
After server restart I do not see dhooks in the ext lists. I do not see any errors in the console and in sourcemod logs.

Please tell me where to look for...

Code:
hostname: GunGame
version : 1.37.6.8/13768 1181/7929 secure  [G:1:2741606] 
udp/ip  : 195.211.102.52:27510  (public ip: 195.211.102.52)
os      :  Linux

Metamod:Source version 1.10.7-dev
Built from: https://github.com/alliedmodders/metamod-source/commit/6c8495f
Build ID: 971:6c8495f
Loaded As: Valve Server Plugin
Compiled on: Sep  2 2019
Plugin interface version: 15:14
SourceHook version: 5:5
http://www.metamodsource.net/

SourceMod Version: 1.10.0.6497
    SourcePawn Engine: 1.10.0.6497, jit-x86 (build 1.10.0.6497)
    SourcePawn API: v1 = 5, v2 = 12
    Compiled on: Sep 24 2020 19:39:13
    Built from: https://github.com/alliedmodders/sourcemod/commit/39c2dc6
    Build ID: 6497:39c2dc6

Meta list
Listing 5 plugins:
  [01] SourceMod (1.10.0.6497) by AlliedModders LLC
  [02] Query Cache 2 (1.0.0.1) by Hashira
  [03] CS Tools (1.10.0.6497) by AlliedModders LLC
  [04] SDK Tools (1.10.0.6497) by AlliedModders LLC
  [05] SDK Hooks (1.10.0.6497) by AlliedModders LLC

[SM] Displaying 13 extensions:
[01] Automatic Updater (1.10.0.6497): Updates SourceMod gamedata files
[02] Webternet (1.10.0.6497): Extension for interacting with URLs
[03] cURL Extension (1.3.0.0): cURL Extension
[04] CS Tools (1.10.0.6497): CS extended functionality
[05] BinTools (1.10.0.6497): Low-level C/C++ Calling API
[06] SDK Tools (1.10.0.6497): Source SDK Tools
[07] GeoIP (1.10.0.6497): Geographical IP information
[08] Client Preferences (1.10.0.6497): Saves client preference settings
[09] SQLite (1.10.0.6497): SQLite Driver
[10] Top Menus (1.10.0.6497): Creates sorted nested menus
[11] Regex (1.10.0.6497): Provides regex natives for plugins
[12] SDK Hooks (1.10.0.6497): Source SDK Hooks
[13] MySQL-DBI (1.10.0.6497): MySQL driver implementation for DBI
OneMore is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-30-2020 , 09:32   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #796

You do not appear to have anything that requires DHooks, so it won't be loaded.
__________________
asherkin is offline
OneMore
Member
Join Date: Feb 2019
Old 09-30-2020 , 09:49   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #797

Quote:
Originally Posted by asherkin View Post
You do not appear to have anything that requires DHooks, so it won't be loaded.
Do you mean that if I load a plugin which requires DHooks, it will be loaded automatically?

Ok, I'll try, thanks.

Thanks, it works!

Last edited by OneMore; 09-30-2020 at 15:37.
OneMore is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 10-17-2020 , 06:28   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #798

I've put up a new version detours15 which adds a methodmap API for your pleasure. Call arguments are saved before calling the function now by default too, so it's save to access the parameters in a post-hook.

There is a new DynamicHook methodmap for virtual hooks replacing the DHookCreate family and a new DynamicDetour methodmap for the DHookCreateDetour stuff. Return value and parameter handles pushed to the callbacks have new shiny methodmaps too. The old natives haven't been touched and work just as before.

PHP Code:
// Legacy API
Handle hHook DHookCreate(offsetHookType_EntityReturnType_IntThisPointer_CBaseEntity);
DHookAddParam(hHookHookParamType_CharPtr);
DHookEntity(hHooktrueclient, .callback=HookHandler);

public 
MRESReturn HookHandler(int pThisHandle hReturnHandle hParams)
{
    
char sParam[256];
    
DHookGetParamString(hParams1sParamsizeof(sParam));
    
PrintToServer("HookHandler(%d, \"%s\") = %d"pThissParamDHookGetReturn(hReturn));
    return 
MRES_Handled;
}

 
// Methodmap API
DynamicHook hHook = new DynamicHook(offsetHookType_EntityReturnType_IntThisPointer_CBaseEntity);
hHook.AddParam(HookParamType_CharPtr);
hHook.HookEntity(Hook_PostclientHookHandler);

public 
MRESReturn HookHandler(int pThisDHookReturn hReturnDHookParam hParams)
{
    
char sParam[256];
    
hParams.GetString(1sParamsizeof(sParam));
    
PrintToServer("HookHandler(%d, \"%s\") = %d"pThissParamhReturn.Value);
    return 
MRES_Handled;
 } 
The magic bool post parameter during hooking has been replaced with a more readable enum in the methodmap to tell if you want a pre- or post-hook.
PHP Code:
enum HookMode
{
    
Hook_Pre,                   // Callback will be executed BEFORE the original function.
    
Hook_Post                   // Callback will be executed AFTER the original function.
}; 

Methodmap definition:
Spoiler
__________________

Last edited by Peace-Maker; 10-17-2020 at 06:29.
Peace-Maker is online now
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 10-24-2020 , 13:57   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #799

Quote:
Originally Posted by Peace-Maker View Post
...
Whenever I try to compile, I get these errors from the .inc file.

Code:
// C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Source\cstrike\addons\sourcemod\scripting\include\dhooks.inc(414) : error 139: could not find type "GameData"
// C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Source\cstrike\addons\sourcemod\scripting\include\dhooks.inc(455) : error 139: could not find type "GameData"
// C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Source\cstrike\addons\sourcemod\scripting\include\dhooks.inc(551) : error 139: could not find type "GameData"
Shadowysn is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 10-24-2020 , 14:01   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #800

Quote:
Originally Posted by Shadowysn View Post
Whenever I try to compile, I get these errors from the .inc file
You need a newer version of the SourceMod includes.
__________________
asherkin is offline
Reply


Thread Tools
Display Modes

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 13:23.


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