Raised This Month: $12 Target: $400
 3% 

DHooks (Dynamic Hooks - Dev Preview)


Post New Thread Reply   
 
Thread Tools Display Modes
IEcliPsEI95
Junior Member
Join Date: Jul 2011
Location: Romania
Old 10-07-2021 , 02:30   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #851

Quote:
Originally Posted by asherkin View Post
The dhooks-test.smx plugin is an example for plugin developers, you shouldn't have it loaded and it isn't expected to work.
Then how can I hook SetModel or EntitySetModel?
IEcliPsEI95 is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 10-24-2021 , 10:49   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #852

Can somebody help me with extracting ip address from a detoured function?
PHP Code:
int __usercall sub_29AFF0@<eax>(long double a1@<st0>, int a2int a3void *srcint a5int a6// The function from IDA Pseudo (linux)
int NET_SendPacket INetChannel *chanint sock,  const ns_address &to, const  unsigned char *dataint lengthbf_write *pVoicePayload NULLbool bUseCompression falseuint32 unMillisecondsDelay 0u ); // The same function from some old sources 
The ns_address contains netadr_t as the first field, which is technically this:
PHP Code:
struct netadr_t
{
public:
    
netadrtype_t    type//enum
    
unsigned char    ip[4];
    
unsigned short    port;
}; 
Here is what I have at the moment
PHP Code:
public OnPluginStart()
{
    new 
Handle:hGameConf;
    new 
String:error[128];
    
    
hGameConf LoadGameConfigFile("ruleshax.games");
    if(!
hGameConf)
    {
        
Format(errorsizeof(error), "Failed to find ruleshax.games");
        
SetFailState(error);
    }

    
hNetSendPacket DHookCreateDetour(Address_NullCallConv_CDECLReturnType_IntThisPointer_Ignore);
    if (!
hNetSendPacket)
        
SetFailState("Failed to setup detour for NET_SendPacket");
    
    if (!
DHookSetFromConf(hNetSendPackethGameConfSDKConf_Signature"NET_SendPacket"))
        
SetFailState("Failed to load NET_SendPacket signature from gamedata");

    
DHookAddParam(hNetSendPacketHookParamType_ObjectPtr);
    
DHookAddParam(hNetSendPacketHookParamType_Int);
    
DHookAddParam(hNetSendPacketHookParamType_ObjectPtr, -1DHookPass_ByRef);
    
DHookAddParam(hNetSendPacketHookParamType_CharPtr);
    
DHookAddParam(hNetSendPacketHookParamType_Int);
    
//DHookAddParam(hNetSendPacket, HookParamType_ObjectPtr);
    //DHookAddParam(hNetSendPacket, HookParamType_Bool);
    
DHookAddParam(hNetSendPacketHookParamType_Int);

    if (!
DHookEnableDetour(hNetSendPacketfalseDetour_OnNetSendPacket))
        
SetFailState("Failed to detour NET_SendPacket.");

    
PrintToServer("NET_SendPacket detoured!");
}

public 
MRESReturn Detour_OnNetSendPacket(Handle hReturnHandle hParams)
{
    
char addressBuffer[8];
    
DHookGetParamString(hParams3addressBuffersizeof(addressBuffer));

    
PrintToServer("OnNetSendPacket called %x %x %x %x %x %x %x %x"addressBuffer[0], addressBuffer[1], addressBuffer[2], addressBuffer[3], addressBuffer[4], addressBuffer[5], addressBuffer[6], addressBuffer[7]);

    return 
MRES_Ignored;

The hook works, but the result ip address is 0 0 0 0. Also the CC is incorrect, but it crashes if I change it to anything else.
kadet.89 is offline
Send a message via Skype™ to kadet.89
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-24-2021 , 11:00   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #853

extract it as integer, then:
PHP Code:
    octet[0] = (longip >> 24) & 0x000000FF;
    
octet[1] = (longip >> 16) & 0x000000FF
    
octet[2] = (longip >> 8) & 0x000000FF
    
octet[3] = longip 0x000000FF

    
FormatEx(NetIPsizeof(NetIP), "%d.%d.%d.%d"octet[0], octet[1], octet[2], octet[3]); 
Quote:
unsigned char ip[4];
it's not a char, it's array of bytes, or just int.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 10-24-2021 at 11:01.
Dragokas is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 10-24-2021 , 11:22   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #854

Dragokas, thanks, it works.

I have another question.
I read and then change int argument #5:
PHP Code:
            PrintToServer("Old value: %i"indexDHookGetParam(hParams5)); //"Old value: 38"
            
DHookSetParam(hParams542);
            
PrintToServer("New value: %i"indexDHookGetParam(hParams5)); //"New value: 38" 
Why does it show 38 after the value is changed?

Last edited by kadet.89; 10-25-2021 at 18:38.
kadet.89 is offline
Send a message via Skype™ to kadet.89
Schwede
Member
Join Date: Oct 2021
Location: germany
Old 11-07-2021 , 12:11   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #855

hello, I downloaded and instlliert the plugin a few days ago. unfortunately it seems that I can't get it to work. Under the logs I get this message: L 11/04/2021 - 00:01:13: [SM] Unable to load plugin "csgo_nextmapvote_disable.smx": Required extension "dhooks" file ("dhooks.ext") not running

My question, what did I do wrong?
I downloaded that from here 7 and installed it: dhooks-2.2.0-detours17-sm110.zip

I would be happy to answer your questions

Last edited by Schwede; 11-07-2021 at 12:12.
Schwede is offline
paulo_crash
AlliedModders Donor
Join Date: May 2016
Location: Brazil
Old 11-07-2021 , 18:11   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #856

Quote:
Originally Posted by Schwede View Post
hello, I downloaded and instlliert the plugin a few days ago. unfortunately it seems that I can't get it to work. Under the logs I get this message: L 11/04/2021 - 00:01:13: [SM] Unable to load plugin "csgo_nextmapvote_disable.smx": Required extension "dhooks" file ("dhooks.ext") not running

My question, what did I do wrong?
I downloaded that from here 7 and installed it: dhooks-2.2.0-detours17-sm110.zip

I would be happy to answer your questions
Your version of SourceMod? Is your CSGO server hosted on Windows or Linux?
paulo_crash is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 11-07-2021 , 18:16   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #857

Quote:
Originally Posted by kadet.89 View Post
Dragokas, thanks, it works.

I have another question.
I read and then change int argument #5:
PHP Code:
            PrintToServer("Old value: %i"indexDHookGetParam(hParams5)); //"Old value: 38"
            
DHookSetParam(hParams542);
            
PrintToServer("New value: %i"indexDHookGetParam(hParams5)); //"New value: 38" 
Why does it show 38 after the value is changed?
The value is not changed until after the hook, so you can't use this method to retrieve a changed param.
__________________
Silvers is offline
Schwede
Member
Join Date: Oct 2021
Location: germany
Old 11-08-2021 , 04:24   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #858

Quote:
Originally Posted by Silvers View Post
The value is not changed until after the hook, so you can't use this method to retrieve a changed param.
Hello,
the SourceMod version is 2019-9-30 and the server runs on Linux
Schwede is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 11-08-2021 , 07:03   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #859

Quote:
Originally Posted by Schwede View Post
Hello,
the SourceMod version is 2019-9-30 and the server runs on Linux
That doesn't help. Are you using SM 1.10 or what? If you use 1.10 you need to get DHooks that's compiled for 1.10. If 1.11 the DHooks for 1.11 otherwise upgrade your SourceMod.
__________________
Silvers is offline
Schwede
Member
Join Date: Oct 2021
Location: germany
Old 11-08-2021 , 08:35   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #860

Hello again, sorry i assumed that it is the version, but have now found out the version, it is version 1.10
I assume that I will then need the 110 version of dhooks?
The two sourche code will be the same.

Thank you for your patience and help
greeting

PS: I restarted the server and looked in the logs, there is still the error: [SM] Unable to load plugin "csgo_nextmapvote_disable.smx": Required extension "dhooks" file ("dhooks.ext") not running

github Link
Schwede 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 10:28.


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