AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   How to hook/call game dll function from module? (https://forums.alliedmods.net/showthread.php?t=300119)

STekLyAToR 08-06-2017 15:55

How to hook/call game dll function from module?
 
I have a name of function and disassembled code, can get a signature and maybe address.
What should I do to call game dll function from my module?

Spirit_12 08-06-2017 15:56

Re: How to hook/call game dll function from module?
 
Use Orpheu.

STekLyAToR 08-06-2017 16:08

Re: How to hook/call game dll function from module?
 
Quote:

Originally Posted by Spirit_12 (Post 2539985)
Use Orpheu.

I don't need to call function from pawn script, and I know what Orphey can do it.
I could see how it is implemented in Orphey, but he contain a lot of code and i can't understand it. :cry:

klippy 08-06-2017 19:20

Re: How to hook/call game dll function from module?
 
Unless you want to use some library, it's really advanced and requires x86 assembly knowledge as well. Search around the forums for "CHooker" or CDetour.

However, if you can't deal with it, better stick to Pawn and Orpheu.

WildCard65 08-07-2017 10:07

Re: How to hook/call game dll function from module?
 
Quote:

Originally Posted by KliPPy (Post 2540024)
Unless you want to use some library, it's really advanced and requires x86 assembly knowledge as well. Search around the forums for "CHooker" or CDetour.

However, if you can't deal with it, better stick to Pawn and Orpheu.

The version of CDetour you linked is coupled to SourceMod, here's the version that should work with AMXX: https://github.com/alliedmodders/amx...mtools/CDetour

STekLyAToR 08-09-2017 16:25

Re: How to hook/call game dll function from module?
 
Where I can find any example or tutorial of CDetour?
I was looking for on this forum, but found nothing. Also, i was reseached source codes of ns, cstrike modules, but that work with pvPrivateData and do not contain any information about calling dll funcs.

klippy 08-09-2017 16:47

Re: How to hook/call game dll function from module?
 
Check amxmodx/meta_api.cpp and search for SV_DropClient.

STekLyAToR 08-10-2017 08:38

Re: How to hook/call game dll function from module?
 
Quote:

Originally Posted by KliPPy (Post 2540609)
Check amxmodx/meta_api.cpp and search for SV_DropClient.

As I understand, to detour function I need to it was declared in my code?
For example, using IDA I found out that exist is that function:
Code:

void AdjustSpecificWeapon(tsweapon_t, float, float, float, float, int)
But that function are not declared in cpp code, because that from game dll.
Will it be enough to declare a func for detour that, or i need initialize func and after detour?

STekLyAToR 08-15-2017 23:40

Re: How to hook/call game dll function from module?
 
I worked my idea without calling any clientside functions. I have more attentively studied the code and find out that target function uses g_engfuncs[47], I started looking for declare of g_engfuncs, and found function g_engfuncs[0], this function took the path to model. And later, exploring AMXX SDK, I noticed that in defines function PrecacheModel is first, and I assumed that PrecacheModel has index 0. Experimentally I scroll through 46 lines down and mark line, this line was define of MessageBegin. I used this method on other functions for convert calling using pointer on instance of array to function names. Using the obtained information, I was able to more detail examine the code of AdjustSpecificWeapon. Examined, I was discovered that this function can be replaced to messages. Thanks to all for the help.

joropito 08-17-2017 15:04

Re: How to hook/call game dll function from module?
 
Quote:

Originally Posted by STekLyAToR (Post 2541870)
I worked my idea without calling any clientside functions. I have more attentively studied the code and find out that target function uses g_engfuncs[47], I started looking for declare of g_engfuncs, and found function g_engfuncs[0], this function took the path to model. And later, exploring AMXX SDK, I noticed that in defines function PrecacheModel is first, and I assumed that PrecacheModel has index 0. Experimentally I scroll through 46 lines down and mark line, this line was define of MessageBegin. I used this method on other functions for convert calling using pointer on instance of array to function names. Using the obtained information, I was able to more detail examine the code of AdjustSpecificWeapon. Examined, I was discovered that this function can be replaced to messages. Thanks to all for the help.

Why so complicated?

Check for enginefuncs_t struct at eiface.h on hlsdk


All times are GMT -4. The time now is 02:06.

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