Raised This Month: $151 Target: $400
 37% 

CollisionHook


Post New Thread Reply   
 
Thread Tools Display Modes
fbef0102
Member
Join Date: Sep 2017
Location: TW
Old 11-24-2019 , 07:01   Re: CollisionHook
Reply With Quote #101

How can I call pre-hooks or pre-detour please?
__________________
fbef0102 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Black Hole
Old 11-24-2019 , 14:21   Re: CollisionHook
Reply With Quote #102

Okay, I have tried loading this extension for Windows (the one from Spirit's GitHub repo) with the new signature provided in the previous page. It gets loaded but the moment a map is fully loaded, the server crashes. I haven't tried with the one from here but I doubt it will produce a different result.

Last edited by cravenge; 11-24-2019 at 14:22.
cravenge is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 11-24-2019 , 18:00   Re: CollisionHook
Reply With Quote #103

This is my understanding from what I read of Peace-Maker's reply. You are to store the entity data in pre hook phase as opposed to using DHookGetParam in post hook.

I don't have a windows server running, so this is an untested version, but it should work.

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <dhooks>

// Global Variables to store parameters.
int g_iEntityOne;
int g_iEntityTwo;

public 
OnPluginStart()
{
    
// Setup gamedata file
    
GameData hData = new GameData("l4dcollisionhook");

    
Handle hDetour DHookCreateFromConf(hData"PassEntityFilter");
    if( !
hDetour 
        
SetFailState("Failed to find \"PassEntityFilter\" offset.");
    
delete hData;

    
// Setup pre hook to grab parameters
    
if( !DHookEnableDetour(hDetourfalsedetour_pre) ) 
        
SetFailState("Failed to detour \"PassEntityFilter\". pre");
    
    
// Setup post hook
    
if( !DHookEnableDetour(hDetourtruedetour_post) ) 
        
SetFailState("Failed to detour \"PassEntityFilter\". post");
}

public 
MRESReturn detour_pre(Handle hReturnHandle hParams)
{
    
// Store prehook parameters into global variables
    
g_iEntityOne    =    DHookGetParam(hParams1);
    
g_iEntityTwo    =    DHookGetParam(hParams2);
    
    
PrintToServer("Entity 1 %i Entity 2 %i"DHookGetParam(hParams1), DHookGetParam(hParams2));
    return 
MRES_Ignored;


public 
MRESReturn detour_post(Handle hReturnHandle hParams)
{
    
PrintToServer("Entity 1 %i Entity 2 %i"g_iEntityOneg_iEntityTwo);
    return 
MRES_Ignored;

__________________
Spirit_12 is offline
fbef0102
Member
Join Date: Sep 2017
Location: TW
Old 11-25-2019 , 06:51   Re: CollisionHook
Reply With Quote #104

Quote:
Originally Posted by Spirit_12 View Post
This is my understanding from what I read of Peace-Maker's reply. You are to store the entity data in pre hook phase as opposed to using DHookGetParam in post hook.

I don't have a windows server running, so this is an untested version, but it should work.
still crash after few seconds I join the server.

I try to check if a parameter is NULL using the DHookIsNullParam in pre-hook and post-hook, it works without any errors
but still cause windows server crash, I guess windows is pretty complicated
PHP Code:
 if(DHookIsNullParam(hParams1) || DHookIsNullParam(hParams2)) return MRES_Ignored
__________________

Last edited by fbef0102; 11-25-2019 at 06:52.
fbef0102 is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Location: Methamphetamine
Old 11-25-2019 , 07:20   Re: CollisionHook
Reply With Quote #105

Try this gamedata

PHP Code:
"Games"
{
    
"left4dead2"
    
{
        
"Functions"
        
{
            
"PassEntityFilter"
            
{
                
"signature"        "PassEntityFilter"
                "callconv"        "cdecl"
                "return"        "bool"
                "this"            "ignore"
                "arguments"
                
{
                    
"a1"
                    
{
                        
"type"    "cbaseentity"
                    
}
                    
"a2"
                    
{
                        
"type"    "cbaseentity"
                    
}
                }
            }
        }
        
"Signatures"
        
{
            
"PassEntityFilter"
            
{
                
"library" "server"
                "windows"        "\x55\x8B\xEC\x57\x8B\x7D\x0C\x85\xFF\x75"
            
}
        }
    }


If this doesn't help then change the
Code:
"callconv"        "cdecl"
to this
Code:
"callconv"        "thiscall"
__________________
Heart

Last edited by BHaType; 11-25-2019 at 17:50.
BHaType is offline
Send a message via AIM to BHaType
fbef0102
Member
Join Date: Sep 2017
Location: TW
Old 11-26-2019 , 08:35   Re: CollisionHook
Reply With Quote #106

Quote:
Originally Posted by BHaType View Post
Try this gamedata

PHP Code:
[DHOOKSFATALFailed to find return address of original function. Check the arguments and return type of your detour setup
__________________
fbef0102 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 15:18.


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