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

CollisionHook


Post New Thread Reply   
 
Thread Tools Display Modes
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 09-11-2021 , 07:56   Re: CollisionHook
Reply With Quote #131

l4d1 windows server crash, hope someone can help

sm1.10 + DHooks 2.2.0-detours17
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <dhooks>

Handle g_CHPassEntity;

public 
Plugin myinfo =
{
    
name "CollisionHook Dhooks",
    
author "$atanic $pirit, BHaType",
    
description "Hook on entity collision",
    
version "1.0",
    
url ""
}

public 
OnPluginStart()
{
    
GameData hData = new GameData("CollisionHook");

    
Handle hDetour DHookCreateFromConf(hData"PassEntityFilter");
    if( !
hDetour 
        
SetFailState("Failed to find \"PassEntityFilter\" offset.");
        
    if( !
DHookEnableDetour(hDetourtruedetour) ) 
        
SetFailState("Failed to detour \"PassEntityFilter\".");
    
delete hData;
    
    
g_CHPassEntity CreateGlobalForward("CH_PassFilter"ET_EventParam_CellParam_Cell Param_CellByRef);
}


public 
MRESReturn detour(Handle hReturnHandle hParams)
{
    if(!
DHookIsNullParam(hParams1) && !DHookIsNullParam(hParams2))
    {
        
int iEntity1    DHookGetParam(hParams1);
        
int iEntity2    DHookGetParam(hParams2);
        
int funcresult    DHookGetReturn(hReturn);
        
        if(
g_CHPassEntity)
        {
            
Action result Plugin_Continue;
            
            
/* Start function call */
            
Call_StartForward(g_CHPassEntity);

            
/* Push parameters one at a time */
            
Call_PushCell(iEntity1);
            
Call_PushCell(iEntity2);
            
Call_PushCellRef(funcresult);

            
/* Finish the call, get the result */
            
Call_Finish(result);
            
            if (
result == Plugin_Handled)
            {
                
DHookSetReturn(hReturnfuncresult);
                return 
MRES_Supercede;
            }
        }
    }
    
    
//PrintToChatAll("Entity 1 %i Entity 2 %i", iEntity1, iEntity2);
    
return MRES_Ignored;

Code:
"Games"
{
    "left4dead"
    {
        "Functions"
        {
            "PassEntityFilter"
            {
                "signature"            "PassEntityFilter"
                "callconv"            "cdecl"
                "return"            "int"
                "this"                "ignore"
                "arguments"
                {
                    "a1"
                    {
                        "type"    "cbaseentity"
                    }
                    "a2"
                    {
                        "type"    "cbaseentity"
                    }
                }
            }
        }
        "Signatures"
        {
            "PassEntityFilter"
            {
                "library" "server"
                "windows"        "\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x75\x2A\xB0\x2A\x5F\xC3\x56"
                "linux"        "@_Z22PassServerEntityFilterPK13IHandleEntityS1_"
            }
        }
    }
}
Attached Files
File Type: txt CollisionHook.txt (973 Bytes, 110 views)
File Type: sp Get Plugin or Get Source (l4d_collision_hook_test.sp - 94 views - 1.8 KB)
__________________

Last edited by HarryPotter; 09-11-2021 at 07:57.
HarryPotter is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 09-11-2021 , 16:29   Re: CollisionHook
Reply With Quote #132

Quote:
Originally Posted by HarryPotter View Post
l4d1 windows server crash, hope someone can help

sm1.10 + DHooks 2.2.0-detours17
Your setup is wrong. You need to understand that not every entity handle pointer passed to the two params will be a CBaseEntity pointer. You'll have to figure out a way to check if they are static props or not. When one of the params is a static prop, you'll want to return early to avoid crashes. You'll also want to change the param types from "cbaseentity" to "int" so DHooks doesn't convert them to entity indexes, which is also why you're getting crashes.

This is the code in the SDK:
PHP Code:
bool PassServerEntityFilter( const IHandleEntity *pTouch, const IHandleEntity *pPass 
{
    if ( !
pPass )
        return 
true;

    if ( 
pTouch == pPass )
        return 
false;

    const 
CBaseEntity *pEntTouch EntityFromEntityHandlepTouch );
    const 
CBaseEntity *pEntPass EntityFromEntityHandlepPass );
    if ( !
pEntTouch || !pEntPass )
        return 
true;

    
// don't clip against own missiles
    
if ( pEntTouch->GetOwnerEntity() == pEntPass )
        return 
false;
    
    
// don't clip against owner
    
if ( pEntPass->GetOwnerEntity() == pEntTouch )
        return 
false;    


    return 
true;

You'll want to check for something like this in your detour:
PHP Code:
if ( IsStaticProppEntTouch ) || IsStaticProppEntPass ) )
    return 
true
__________________

Last edited by Psyk0tik; 09-12-2021 at 02:42.
Psyk0tik is offline
Forgetest
Member
Join Date: Aug 2020
Old 09-15-2021 , 01:23   Re: CollisionHook
Reply With Quote #133

Quote:
Originally Posted by Psyk0tik View Post
Your setup is wrong. You need to understand that not every entity handle pointer passed to the two params will be a CBaseEntity pointer. You'll have to figure out a way to check if they are static props or not. When one of the params is a static prop, you'll want to return early to avoid crashes. You'll also want to change the param types from "cbaseentity" to "int" so DHooks doesn't convert them to entity indexes, which is also why you're getting crashes.
Thanks for your information, but nonetheless it's still crashing on Windows in my attempts.

Current setup (works on Linux L4D1):
Code:
"Games"
{
    "left4dead"
    {
        "Functions"
        {
            "PassEntityFilter"
            {
                "signature"			"PassEntityFilter"
                "callconv"			"cdecl"
                "return"			"bool"
                "this"				"ignore"
                "arguments"
                {
                    "a1"
                    {
                        "type"		"int"
                    }
                    "a2"
                    {
                        "type"		"int"
                    }
                }
            }
        }
        "Signatures"
        {
            "PassEntityFilter"
            {
                "library"		"server"
                "linux"			"@_Z22PassServerEntityFilterPK13IHandleEntityS1_"
                "windows"		"\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x75\x2A\xB0\x2A\x5F\xC3\x56"
				/* ? ? ? ? ? ? ? 75 ? B0 ? 5F C3 56 */
            }
	}
    }
}
Tried a few possible setups before I gave up on this, which includes adding an argument whilist setting "a1" to be passed in "ebx".
Given it's always a crash regardless of what's in the detour callback (empty callback included), I started to dig out a few hints from crash logs, until I met with multiple ones labelled unique signature crash.

Plugin setup:
PHP Code:
public void OnPluginStart()
{
    
Handle hData LoadGameConfigFile("CollisionHook");
    
    
Handle hDetour DHookCreateFromConf(hData"PassEntityFilter");
    if (!
hDetour
        
SetFailState("Failed to find \"PassEntityFilter\" offset.");
        
    if (!
DHookEnableDetour(hDetourfalsePassEntityFilter)) // tried both pre and post hook
        
SetFailState("Failed to detour \"PassEntityFilter\".");

    
delete hData;
}

public 
MRESReturn PassEntityFilter(Handle hReturnHandle hParams)
{
    return 
MRES_Ignored;

Several crash IDs:
Code:
XCOI-K4MM-OETP
YKWD-K76T-OXYS
A2Y6-CIZK-VEW4

Last edited by Forgetest; 09-15-2021 at 01:23.
Forgetest is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 09-15-2021 , 08:30   Re: CollisionHook
Reply With Quote #134

Maybe the fault lies within DHooks and how it replaces the first six bytes of the function during the detouring process.
cravenge is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 09-16-2021 , 21:50   Re: CollisionHook
Reply With Quote #135

Quote:
Originally Posted by Forgetest View Post
Thanks for your information, but nonetheless it's still crashing on Windows in my attempts.

Current setup (works on Linux L4D1):
...

Tried a few possible setups before I gave up on this, which includes adding an argument whilist setting "a1" to be passed in "ebx".
Given it's always a crash regardless of what's in the detour callback (empty callback included), I started to dig out a few hints from crash logs, until I met with multiple ones labelled unique signature crash.

Plugin setup:
...

Several crash IDs:
...
The function seems to be setup differently on Windows for both games. I can't say anything definite yet since I'm looking more into this, but so far, it seems that the function may not be "detour-able" on Windows because of its non-standard calling convention.

I haven't tested Linux but the following setup should work fine on both games without needing any extra params. You'll still need to convert the IHandleEntities though.
PHP Code:
"PassServerEntityFilter"
{
    
"signature"    "PassServerEntityFilter"
    "callconv"    "cdecl"
    "return"    "bool"
    "this"        "ignore"
    "arguments"
    
{
        
"entity1"
        
{
            
"type"        "int"
        
}
        
"entity2"
        
{
            
"type"        "int"
        
}
    }

Quote:
Originally Posted by cravenge View Post
Maybe the fault lies within DHooks and how it replaces the first six bytes of the function during the detouring process.
The first few bytes are just relocated since all DHooks does is replace them with a jump instruction to use its function instead. Those bytes only matter when DHooks accesses them (i.e. creating a detour to send a forward to all plugins detouring the function, restoring the original bytes when no plugin is detouring the function anymore, etc.).
__________________
Psyk0tik is offline
AdRiAnIlloO
Member
Join Date: Jul 2015
Location: Spain
Old 11-07-2021 , 20:00   Re: CollisionHook
Reply With Quote #136

Hi,

I created an automatic CollisionHook build pipeline on the cloud (DevOps). Anyone can download automated, multi-platform binaries here: https://github.com/Adrianilloo/Collisionhook/releases

Can anyone confirm on what updated Steam server apps the following Windows signature for PassServerEntityFilter works, if any? (which I see it's currently used in some CollisionHook repos) Or is it outdated?

Code:
"\x55\x8b\xec\x57\x8b\x7d\x0c\x85\xff\x75\x2a\xb0\x01\x5f\x5d\xc3\x56\x8b\x75"
(I guess, CSGO?)

Thanks.

Last edited by AdRiAnIlloO; 11-07-2021 at 20:01.
AdRiAnIlloO is offline
reBane
Senior Member
Join Date: May 2020
Old 11-28-2021 , 11:06   Re: CollisionHook
Reply With Quote #137

Tinkered with ghidra over the weekend, PassServerEntityFilter for TF2 in server.dll (win) has the signature
Code:
\x55\x8B\xEC\x56\x8B\x75\x0C\x85\xF6\x75\x05
In case anyone is looking for it like I was...
reBane is offline
ItsKoenLul
Junior Member
Join Date: May 2020
Location: Suicide @ Dust2
Old 11-28-2021 , 16:26   Re: CollisionHook
Reply With Quote #138

Does anyone happen to have the csgo version of CollisionHook on hand? The DL links are no longer active.
ItsKoenLul is offline
Ejziponken
AlliedModders Donor
Join Date: Apr 2008
Old 01-23-2022 , 12:33   Re: CollisionHook
Reply With Quote #139

Soo ive been reading the comments and some say you can remove bullet collision with teammates. How is that possible if bullets are not an entity?

Last edited by Ejziponken; 01-23-2022 at 14:09.
Ejziponken is offline
Ejziponken
AlliedModders Donor
Join Date: Apr 2008
Old 01-25-2022 , 13:29   Re: CollisionHook
Reply With Quote #140

Quote:
Originally Posted by AdRiAnIlloO View Post
Hi,

I created an automatic CollisionHook build pipeline on the cloud (DevOps). Anyone can download automated, multi-platform binaries here: https://github.com/Adrianilloo/Collisionhook/releases

Can anyone confirm on what updated Steam server apps the following Windows signature for PassServerEntityFilter works, if any? (which I see it's currently used in some CollisionHook repos) Or is it outdated?

Code:
"\x55\x8b\xec\x57\x8b\x7d\x0c\x85\xff\x75\x2a\xb0\x01\x5f\x5d\xc3\x56\x8b\x75"
(I guess, CSGO?)

Thanks.
Im on linux. Using latest from your link.

[15] <FAILED> file "collisionhook.ext.2.csgo.so": Unable to hook PassServerEntityFilter!

SourceMod Version: 1.11.0.6844
Metamod:Source version 1.11.0-dev+1145
Ejziponken 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 12:02.


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