PDA

View Full Version : CollisionHook


VoiDeD
10-07-2012, 20:18
HEY READ THIS (MARCH 2024)
The notice below still holds. I don't personally use this extension, but contributions on GitHub are welcome.


HEY READ THIS (DEC 2014)
I know you probably really want to use this extension, but here's the fine print: it's now completely unsupported by myself. If you need gamedata updates you're on your own. This extension should be a last resort when you have exhausted all other options for managing collisions: m_nSolidType, m_CollisionGroup, etc

This extension provides a straightforward and easy way to hook and modify collision rules between entities.

You might say "but sdkhooks provides this functionality already!", and you would be partly right. However, I wasn't happy with how sdkhooks ShouldCollide works, and here's why:

If you're familiar with sdkhooks, this code won't be new:

// somewhere in your code
SDKHook( someEntity, SDKHook_ShouldCollide, ShouldCollide );

public bool:ShouldCollide( entity, collisiongroup, contentsmask, bool:result )
{
// modify collision rules
}


As you can see, the hook doesn't provide much information about exactly which entities are colliding; only the collision group and contents mask of the other entity are given to the plugin developer.


To solve this limitation, I wrote CollisionHook.

CollisionHook provides 2 forwards to plugins, both of which can modify the collision rules of certain types of collisions.


forward Action:CH_ShouldCollide( ent1, ent2, &bool:result );

CH_ShouldCollide is called when vphysics is determining whether two vphysics objects (and their associated entities) should collide. Examples of these kinds of collisions include projectiles colliding with the world entity.


forward Action:CH_PassFilter( ent1, ent2, &bool:result );

CH_PassFilter is called when the game is performing a ray/hull trace and is making use of an entity filter. Examples of these kinds of collisions include player-player collisions.

To modify the behavior of the collision check, simply set result to true if you wish for the entities to collide; otherwise false, and return Plugin_Handled or Plugin_Stop in the forward. If you want the game to use default collision rules, simply return Plugin_Continue in the forward.


The benefits of both of these forwards is that you can strictly control which entities can collide, instead of just a specific type of entity.

Installation

Grab the latest release from here (https://github.com/voided/CollisionHook/releases).
Drag & Drop (http://www.youtube.com/watch?v=1Nyn0k1Btns).


Source
The source code is available here (https://github.com/voided/CollisionHook).


Limitations / Known Issues / Notes

Some collisions are not handled by this extension, those include collisions that are checked with traces that don't use an entity filter. Many of these can be handled by sdkhooks' Touch hook.
Modifying collisions that are also performed on the client will lead to prediction errors. This is no different from other server-only methods of overriding collisions.
This extension should work for any OB-based mod (TF2 CS:S, DoD:S), but it's only been tested on TF2.


Thanks

AzuiSleet, for suggesting PassServerEntityFilter for trace based collisions.
psychonic, for providing the linux build, makefile, and generally being the most helpful person on the planet.

GoD-Tony
10-08-2012, 05:04
This is a neat idea! I tried something like this myself a while ago and ran into a few issues with a PassServerEntityFilter detour.

Using this code for example:
public Action:CH_PassFilter( ent1, ent2, &bool:result )
{
// No client-client collisions
if (1 <= ent1 <= MaxClients && 1 <= ent2 <= MaxClients)
{
result = false;
return Plugin_Handled;
}

return Plugin_Continue;
}

This is all on CS:S, and the code above seems to crash when shooting a player.

Normally it would prevent trace weapons from hitting any player target, because the player firing is passed as pPass. So in order to differentiate player collision traces from the rest, I detoured CTraceFilterSimple::ShouldHitEntity instead which provided collisionGroup and contentsMask.

Mine ended up looking like this:
(unreleased because I thought it was an ugly workaround)
DETOUR_DECL_MEMBER2(ShouldHitEntity, bool, IHandleEntity *, pHandleEntity, int, contentsMask)
{
IHandleEntity *m_pPassEnt = *(IHandleEntity **)((intptr_t)this + g_iPassEntOffs);
int m_collisionGroup = *(int *)((intptr_t)this + g_iCollisionOffs);

cell_t result = DETOUR_MEMBER_CALL(ShouldHitEntity)(pHandleEn tity, contentsMask);

if (!pHandleEntity || !m_pPassEnt || pHandleEntity == m_pPassEnt)
return (result != 0);

cell_t touchEnt = gamehelpers->EntityToBCompatRef((CBaseEntity *)pHandleEntity);
cell_t passEnt = gamehelpers->EntityToBCompatRef((CBaseEntity *)m_pPassEnt);

g_pOnShouldCollide->PushCell(touchEnt);
g_pOnShouldCollide->PushCell(passEnt);
g_pOnShouldCollide->PushCell(m_collisionGroup);
g_pOnShouldCollide->PushCell(contentsMask);
g_pOnShouldCollide->PushCellByRef(&result);
g_pOnShouldCollide->Execute(NULL);

return (result != 0);
}

Then in the plugin if you only wanted to work with player collisions, you could check if contentsMask == MASK_PLAYERSOLID.

VoiDeD
10-08-2012, 13:12
Using this code for example:
public Action:CH_PassFilter( ent1, ent2, &bool:result )
{
// No client-client collisions
if (1 <= ent1 <= MaxClients && 1 <= ent2 <= MaxClients)
{
result = false;
return Plugin_Handled;
}

return Plugin_Continue;
}

This is all on CS:S, and the code above seems to crash when shooting a player.


Interesting, in TF2 that code works as expected. The original purpose of the extension was to support a plugin I'm working on that controls precise player-player collision.

I haven't tested CS:S so I'm not sure why that would crash, but I'll check it out and see if anything can be salvaged.


Normally it would prevent trace weapons from hitting any player target, because the player firing is passed as pPass. So in order to differentiate player collision traces from the rest, I detoured CTraceFilterSimple::ShouldHitEntity instead which provided collisionGroup and contentsMask.

Mine ended up looking like this:
(unreleased because I thought it was an ugly workaround)
DETOUR_DECL_MEMBER2(ShouldHitEntity, bool, IHandleEntity *, pHandleEntity, int, contentsMask)
{
IHandleEntity *m_pPassEnt = *(IHandleEntity **)((intptr_t)this + g_iPassEntOffs);
int m_collisionGroup = *(int *)((intptr_t)this + g_iCollisionOffs);

cell_t result = DETOUR_MEMBER_CALL(ShouldHitEntity)(pHandleEn tity, contentsMask);

if (!pHandleEntity || !m_pPassEnt || pHandleEntity == m_pPassEnt)
return (result != 0);

cell_t touchEnt = gamehelpers->EntityToBCompatRef((CBaseEntity *)pHandleEntity);
cell_t passEnt = gamehelpers->EntityToBCompatRef((CBaseEntity *)m_pPassEnt);

g_pOnShouldCollide->PushCell(touchEnt);
g_pOnShouldCollide->PushCell(passEnt);
g_pOnShouldCollide->PushCell(m_collisionGroup);
g_pOnShouldCollide->PushCell(contentsMask);
g_pOnShouldCollide->PushCellByRef(&result);
g_pOnShouldCollide->Execute(NULL);

return (result != 0);
}

Then in the plugin if you only wanted to work with player collisions, you could check if contentsMask == MASK_PLAYERSOLID.

That's a pretty good idea! I may rework the extension hook that function instead, as the extra info during collision checking would definitely be useful. Hooking that function also has the added benefit of handling any checks done in StandardFilterRules as well.

Also I'd make the assumption that most mods won't be touching CTraceFilterSimple, so the offsets to the members would likely be safe to get at.

GoD-Tony
10-10-2012, 03:55
Also I'd make the assumption that most mods won't be touching CTraceFilterSimple, so the offsets to the members would likely be safe to get at.Yea that's true. I can't remember the exact reason for doing that but it probably wasn't important.

I haven't had a chance to play around with the vphysics stuff yet but it looks pretty cool too!

VoiDeD
11-20-2012, 20:25
psychonic has been kind enough to update the extension for the linux changes that broke things a while back. You can get it here (https://bitbucket.org/VoiDeD/collisionhook/src/tip/sourcemod/extensions/collisionhook.ext.so?at=default).

shavit
11-21-2012, 10:20
Wanted to make a new plugin.
No success :(
L 11/21/2012 - 17:18:23: SourceMod error session started
L 11/21/2012 - 17:18:23: Info (map "bhop_arcane_v1") (file "errors_20121121.log")
L 11/21/2012 - 17:18:23: [CLHOOK] Could not locate PassServerEntityFilter - Disabling detour
L 11/21/2012 - 17:18:23: [SM] Unable to load extension "collisionhook.ext": Unable to hook PassServerEntityFilter!
L 11/21/2012 - 17:18:23: [SM] Unable to load plugin "noblock.smx": Required extension "CollisionHook" file("collisionhook.ext") not running

CS:S Windows 7 server.
SM 1.4.7 & MM:S 1.9.0.

VoiDeD
11-21-2012, 13:08
Wanted to make a new plugin.
No success :(
L 11/21/2012 - 17:18:23: SourceMod error session started
L 11/21/2012 - 17:18:23: Info (map "bhop_arcane_v1") (file "errors_20121121.log")
L 11/21/2012 - 17:18:23: [CLHOOK] Could not locate PassServerEntityFilter - Disabling detour
L 11/21/2012 - 17:18:23: [SM] Unable to load extension "collisionhook.ext": Unable to hook PassServerEntityFilter!
L 11/21/2012 - 17:18:23: [SM] Unable to load plugin "noblock.smx": Required extension "CollisionHook" file("collisionhook.ext") not running

CS:S Windows 7 server.
SM 1.4.7 & MM:S 1.9.0.

Whoops! I made a small error in the gamedata file. If you edit it and change "tf" to "#default", it'll work for CS:S.

That being said, I haven't yet investigated the CS:S crashes mentioned in the previous posts. As this extension was originally designed for TF2, your mileage may vary.

shavit
11-23-2012, 06:00
Whoops! I made a small error in the gamedata file. If you edit it and change "tf" to "#default", it'll work for CS:S.

That being said, I haven't yet investigated the CS:S crashes mentioned in the previous posts. As this extension was originally designed for TF2, your mileage may vary.
"Games"
{
"#default"
{
"Signatures"
{
"PassServerEntityFilter"
{
"library" "server"

"windows" "\x55\x8b\xec\x57\x8b\x7d\x0c\x85\xff\x75\x2a\ xb0\x01\x5f\x5d\xc3\x56\x8b\x75"
"linux" "@_Z22PassServerEntityFilterPK13IHandleEntityS 1_"
}
}
}
}


Crashes my server.
I'll try to find the correct signature.

Trotim
03-05-2013, 09:54
Does this still work? Or is there a better way to do this by now?

Peace-Maker
03-06-2013, 18:26
It works perfectly fine! There is no other way to do what this does.

shavit
03-13-2013, 10:42
It works perfectly fine! There is no other way to do what this does.
In CS:S?

VoiDeD
03-13-2013, 18:50
In CS:S?

Should be working fine in CS:S when compiled from tip.

Despirator
03-14-2013, 00:26
but still crashing

VoiDeD
03-14-2013, 13:29
Are you compiling from source?

Mirandor
03-14-2013, 13:51
Works on cs:s but get random crashs...


#include <sourcemod>
#include <collisionhook>


#define VERSION "1.0"

#pragma semicolon 1

public Plugin:myinfo =
{
name = "NoCollide using CollisionHook (with Team Filter)",
author = "",
description = "Players dont collide with team-mates.",
version = VERSION,
url = ""
};

public OnPluginStart()
{
CreateConVar( "sm_nocollideteam_version", VERSION, "Version of NoCollide Team Filter", FCVAR_PLUGIN | FCVAR_REPLICATED | FCVAR_NOTIFY );
}

public Action:CH_PassFilter( ent1, ent2, &bool:result)
{
if ( IsValidClient( ent1 ) && IsValidClient( ent2 ) )
{
if( GetClientTeam( ent1 ) != GetClientTeam( ent2 ) )
{
result = true;
return Plugin_Handled;
}
result = false;
return Plugin_Handled;
}
return Plugin_Continue;
}

stock bool:IsValidClient( client )
{
if ( 0 < client <= MaxClients && IsClientInGame(client) )
return true;

return false;
}


SM 1.5dev MM1.10.0dev - linux

minimoney1
03-14-2013, 18:56
Works on cs:s but get random crashs...


#include <sourcemod>
#include <collisionhook>


#define VERSION "1.0"

#pragma semicolon 1

public Plugin:myinfo =
{
name = "NoCollide using CollisionHook (with Team Filter)",
author = "",
description = "Players dont collide with team-mates.",
version = VERSION,
url = ""
};

public OnPluginStart()
{
CreateConVar( "sm_nocollideteam_version", VERSION, "Version of NoCollide Team Filter", FCVAR_PLUGIN | FCVAR_REPLICATED | FCVAR_NOTIFY );
}

public Action:CH_PassFilter( ent1, ent2, &bool:result)
{
if ( IsValidClient( ent1 ) && IsValidClient( ent2 ) )
{
if( GetClientTeam( ent1 ) != GetClientTeam( ent2 ) )
{
result = true;
return Plugin_Handled;
}
result = false;
return Plugin_Handled;
}
return Plugin_Continue;
}

stock bool:IsValidClient( client )
{
if ( 0 < client <= MaxClients && IsClientInGame(client) )
return true;

return false;
}


SM 1.5dev MM1.10.0dev - linux

Are you compiling from source?

VoiDeD
03-15-2013, 00:54
As is probably evident by now, you need to build from source if you want a working version in CS:S. The latest version on the downloads page (0.1) has a crash issue.

I'd build it myself and upload it, but I've been swamped with class work.

Mirandor
03-15-2013, 03:35
I use the version available on the download page ; i'll try to compile from source...

Despirator
03-15-2013, 03:48
As is probably evident by now, you need to build from source if you want a working version in CS:S. The latest version on the downloads page (0.1) has a crash issue.

I'd build it myself and upload it, but I've been swamped with class work.

oh, didn't know that sorry... getting source to test

Mirandor
03-15-2013, 06:08
oh, didn't know that sorry... getting source to test

Unfortunatly i won't be able to compile it at this time ; if you make it for linux, may you share it please?

Despirator
03-15-2013, 09:58
Unfortunatly i won't be able to compile it at this time ; if you make it for linux, may you share it please?

no, for windows. But failed to compile beacuse it couldn't find IExtensionSys.h... though i have right environment variables

VoiDeD
03-15-2013, 21:46
I've uploaded built versions of 0.2. You can grab it off the downloads page (https://bitbucket.org/VoiDeD/collisionhook/downloads).

Thanks to KyleS for the linux build.

Mirandor
03-16-2013, 07:51
Working and doesn't seem to crash anymore...

Good job!

shavit
03-16-2013, 12:55
Good job at fixing crashing!

Noblock isn't smooth like I thought it going to be.

Despirator
03-16-2013, 16:29
Good job at fixing crashing!

Noblock isn't smooth like I thought it going to be.

hook m_iCollisionGroup with sendproxy and set the value to 2 in the callback

shavit
03-16-2013, 17:08
hook m_iCollisionGroup with sendproxy and set the value to 2 in the callback
Wouldn't be the best because I need it for Trikz partner system and in Trikz, players can toggle noblock on themselves by changing m_iCollisionGroup to 2/5.

Newbie1992
01-12-2014, 14:01
Does this work fine without crash?

I need a function like that to prevent a stuck problem on my saxton hale server.

Thanks!

VoiDeD
01-12-2014, 19:42
Does this work fine without crash?

I need a function like that to prevent a stuck problem on my saxton hale server.

Thanks!

I don't really support this extension anymore. It was created for a niche purpose that I personally don't use anymore, and the problem of correctly hooking collisions isn't perfectly (and can't easily be) addressed by this extension.

In your case, you can likely solve your problem in a more ideal way: collision groups, solid type, etc.

Marcos
05-17-2014, 04:44
It's broken.
L 05/17/2014 - 16:40:07: [CLHOOK] Sigscan for PassServerEntityFilter failed - Disabling detour to prevent crashes

shavit
06-27-2014, 13:52
L 06/27/2014 - 20:52:03: SourceMod error session started
L 06/27/2014 - 20:52:03: Info (map "trikz_advanced") (file "errors_20140627.log")
L 06/27/2014 - 20:52:03: [CLHOOK] Sigscan for PassServerEntityFilter failed - Disabling detour to prevent crashes
L 06/27/2014 - 20:52:03: [SM] Unable to load extension "collisionhook.ext": Unable to hook PassServerEntityFilter!

help plox

Neuro Toxin
07-04-2014, 23:47
Hey,

I get the following error on CS:GO.

[SM] Extension collisionhook.ext.dll failed to load: The specified procedure could not be found.

Is this an outdated gamedata file issue?

TheLaser
10-09-2014, 17:42
Wow what a bummer ,

This was a useful ext.. yet this doesnt surprise me anymore , seems like support for many useful plugins is on the down swing these days and you can wait weeks to years to get a reply and there are many good coders out there who could but just dont want to take the time :cry:

Really sad

skResolver
10-10-2014, 17:24
Thank you! I hope it's working!

TheLaser
10-11-2014, 07:16
skResolver,

Well you can hope but no its not working anymore unless some one fixed it and didnt release it to anyone it no longer works ... I was using this for a good noblock someone made .

TheLaser
10-21-2014, 08:28
Does anyone have this working with new signatures ?
I even tried to PM VoiDeD with no answer so I take it this is a dead extension .
I really need a working noblock for our servers and not one of them work , tested them all and no deal :down:

Neuro Toxin
10-21-2014, 18:31
https://forums.alliedmods.net/showthread.php?p=462813

I ended up using this. Works as expected for csgo

TheLaser
10-21-2014, 19:30
Thank you Neuro Toxin for trying to help but this one does cause the mayhem bug in HL2dm..
and once it does you have to restart the server to get rid of it .
Only Voided's hook ext will do it correctly . also sendproxy works but you cant team it and the bots will run into you attacking while inside you making it hard to kill them .

Neuro Toxin
10-22-2014, 04:27
:(

TheLaser
10-26-2014, 08:44
Well since not enough users have a need for this I dont think we will ever see this ext updated ...
I was hoping someone who had experience in either recompile or signatures would have been nice enough to fix it but nothing :cry:

TheLaser
11-04-2014, 17:18
Still Hoping ,

All things are possible .
Maybe one day some one will be kind enough to repair this and some other great plugins that have been killed off or damaged thanks to Valve :crab:

TheLastRevenge
11-05-2014, 05:03
I only tested this signature at CS:S.
"Games"
{
"#default"
{
"Signatures"
{
"PassServerEntityFilter"
{
"library" "server"
"windows" "\x55\x8B\xEC\x56\x8B\x2A\x2A\x85\x2A\x75\x2A\ xB0\x2A\x5E"
"linux" "@_Z22PassServerEntityFilterPK13IHandleEntityS 1_"
}
}
}
}

TheLaser
11-05-2014, 09:14
TheLastRevenge !!!

Just tested this in " HL2mp / Windows" and its working !!!!!!!!!

Omg you just made a new friend ............

I didnt think anyone was going to do this and you did . I have no clue what it took of your time or knowledge but you so rock ! Thank you Thank you Thank you :up:

There are some people in this world who still care of others needs :wink:

LaserBlast~~~>

SC]-[LONG_{HoF}
12-06-2014, 23:04
@TheLastRevenge

Thank you for fixing this.

API
09-27-2015, 22:08
Recent-ish CSGO sig:
"PassServerEntityFilter"
{
"library" "server"
"windows" "\x56\x8B\xF2\x57\x8B\xF9\x85\xF6\x74\x2A"
"linux" "@_Z22PassServerEntityFilterPK13IHandleEntityS 1_"
}

headline
10-30-2015, 00:11
Can anyone help me with this for sourcemod 1.7 synax?

public Action CH_PassFilter(int ent1, int ent2, &bool passresult)
{
if (!g_bPrepTime)
{
if (GetClientTeam(ent1) == 2 && GetClientTeam(ent2) == 3 || GetClientTeam(ent1) == 3 && GetClientTeam(ent2) == 2)
{
passresult = false;
return Plugin_Handled;
}
}
return Plugin_Continue;
}

Potato Uno
10-30-2015, 00:41
public Action CH_PassFilter(int ent1, int ent2, bool &passresult)

?

keygens
12-15-2015, 21:39
Possible or not make smooth collision, without use sendproxy and switch collisiongroup to 2?

iGANGNAM
04-03-2016, 06:47
Can anyone update this for CS:GO?
[SM] Unable to load extension "collisionhook.ext": libvstdlib_srv.so: cannot open shared object file: No such file or directory

Spirit_12
05-24-2016, 09:39
Can anyone update this for CS:GO?
[SM] Unable to load extension "collisionhook.ext": libvstdlib_srv.so: cannot open shared object file: No such file or directory

I know its a bit late, but try this.

Neuro Toxin
05-24-2016, 18:44
Wheres the source?

Spirit_12
05-24-2016, 22:06
Source in the same as in first post. CSGO library is libvstdlib.so and not libvstdlib_srv.so. I just recompiled it by hooking right library.

joshtrav
06-27-2016, 23:52
Is there a way to accomplish this with virtual offsets instead of signatures by chance?

Powerlord
06-28-2016, 20:23
Is there a way to accomplish this with virtual offsets instead of signatures by chance?

Probably not. offsets only work on functions that are marked virtual in the game's source code.

Nerus
07-24-2016, 18:23
After last update (12 May 2016) my last plugin Block Control (https://forums.alliedmods.net/showthread.php?p=2422426) not working correctly. Entities float on the map like weapons, barrels, etc.

Please try to fix.

Regards,
Nerus.

Spirit_12
07-24-2016, 18:43
What game?

Nerus
07-25-2016, 13:09
What game?

CSS, but problem solved, plugin required sv_turbophysics = 1

Regards,
Nerus.

PUNKSNOTDEAF
03-14-2017, 11:52
anyone got a working linux ext for csgo atm?

cravenge
03-15-2017, 00:14
Oh yeah, can someone good enough to volunteer updating this really outdated extension for l4d2 windows?

Spirit_12
06-18-2017, 19:16
I've recompiled this extension for CSGO on Linux platform, upon LnG's request. Not sure, if this will work on other games or not, but feel free to give it a try.



Credit to LnG for testing the extension.


NOTE: This is not a Windows release and does not contain the updated signatures nor binary for Windows.

Smesh
09-03-2017, 09:03
[CLHOOK] Sigscan for PassServerEntityFilter failed - Disabling detour to prevent crashes
[SM] Unable to load extension "collisionhook.ext": Unable to hook PassServerEntityFilter!
[SM] Unable to load plugin "collisionhooktest.smx": Required extension "CollisionHook" file("collisionhook.ext") not running

SourceMod Version information:
Sourcemod Version: 1.8.0.6025
SourcePawn Engine: SourcePawn 1.8, jit-x86 (build 1.8.0.6025)
SourcePawn API: v1 = 4, v2 = 11
Compiled on: Aug 24 2017 06:27:30
Built from: https://github.com/alliedmodders/sourcemod/commit/494f833
Build ID: 6025:494f833
http://www.sourcemod.net/

[SM] Displaying 11 extensions:
[01] Automatic Updater (1.8.0.6025): Updates SourceMod gamedata files
[02] Webternet (1.8.0.6025): Extension for interacting with URLs
[03] CS Tools (1.8.0.6025): CS extended functionality
[04] BinTools (1.8.0.6025): Low-level C/C++ Calling API
[05] SDK Tols (1.8.0.6025): Source SDK Tools
[06] Top Menus (1.8.0.6025): Creates sorted nested menus
[07] Output Info (1.8.0.6025): Entity output information
[08] SDK Hooks (1.8.0.6025): Source SDK Hooks
[09] Client Preferences (1.8.0.6025): Saves client preference settings
[10] SQLite (1.8.0.6025): SQLite Driver
[11] (FAILED) file "collisionhook.ext.dll": Unable to hook PassServerEntityFilter!

Peace-Maker
09-03-2017, 12:58
Here's the extension including an AMBuild script to ease compiling in the future, updated windows gamedata and some fresh builds as well.

Spirit_12
09-04-2017, 06:07
Still crashes on l4d2 Windows build.

Rale
12-18-2017, 05:11
This extension still crashing server on WINDOWS. Anyone to rewrite it?

Spirit_12
12-19-2017, 17:51
This extension still crashing server on WINDOWS. Anyone to rewrite it?

What game?

Rale
12-20-2017, 02:10
What game?

CS:GO

HarryPotter
03-08-2018, 12:53
Left 4 Dead 1 windows build

....
[CLHOOK] Sigscan for PassServerEntityFilter failed - Disabling detour to prevent crashes
[SM] Unable to load extension "collisionhook.ext": Unable to hook PassServerEntityFilter!
...



any help please :(

zeroibis
03-22-2018, 06:47
CS:GO

It likely needs a game data update and then recompile.

Unfortunately, I do not know how to do the recompile or I would do it and toss the file on here assuming I could find the gamedata.

Does anyone have a link to how to compile this so people can just read the instructions and recompile as needed going forward?

hmmmmm
03-22-2018, 09:45
https://wiki.alliedmods.net/Building_sourcemod
This is closest thing to it, building process for sourcemod itself and extensions is similar since they both use AMBuild

Does Peace-Maker's build a few posts above not work on CS:GO?

Spirit_12
03-23-2018, 09:14
It likely needs a game data update and then recompile.

Unfortunately, I do not know how to do the recompile or I would do it and toss the file on here assuming I could find the gamedata.

Does anyone have a link to how to compile this so people can just read the instructions and recompile as needed going forward?

You would not be required to recompile the extension unless there is a SDK change. Just update the gamedata and it should work again.

IT_KILLER
03-24-2018, 10:16
Crashes on windows. A gamedata update needed.
Works on linux.
Thanks in advance!

GuStAvOS
04-26-2018, 13:24
hello again :v
someone could help me compile the
CollisionHook.ext.so for the SourceMod v1.7.3-dev + 5290
on l4d2 ... thanks in advance :D

Spirit_12
04-26-2018, 22:15
What error do you get? The extension should work on L4D2, unless you get the symbol error.

GuStAvOS
04-27-2018, 08:42
I see this error ... :(

<FAILED> file "collisionhook.ext.so": /home/gustavo/serverfiles/left4dead2/addons/sourcemod/extensions/collisionhook.ext.so: undefined symbol: g_pMemAlloc


[SM] Unable to load plugin "l4d2_collision_adjustments.smx": Required extension "CollisionHook" file("collisionhook.ext") not running

help me please :D

Spirit_12
04-27-2018, 09:38
Haven’t used this in a while, but try the one from my repo.

https://github.com/Satanic-Spirit/Collisionhook/blob/master/build/collisionhook.ext.2.l4d2/collisionhook.ext.2.l4d2.so

Morell
05-15-2018, 16:06
We need a gamedata update.

hmmmmm
05-18-2018, 03:06
I did a bit of investigation on why this doesn't work on CS:GO windows, the gamedata itself is fine but the entity pointer values passed into the detour seem to be messed up.
I noticed that the function is actually a fastcall so the entity pointers are passed in through the ecx/edx registers, I'm guessing thats why the detour "fails".

EDIT: I tested this and that seems to have been the issue. After changing the detour function into a fastcall it all works fine.

Source for the fix: https://github.com/SlidyBat/CollisionHook
Windows binary also attached

Spirit_12
05-18-2018, 14:29
Hmm, interesting! Is the function static on Linux and fastcall on windows? If that's true, then I wonder, if that's the same reason why the extension stopped working on l4d2.

hmmmmm
05-18-2018, 20:03
Yeah it seems like only windows is troublesome with these optimisations, not sure why. Easiest way to check if it's a different calling convention in L4D2 is to crack open the binary in IDA and find the function to see how it works, very likely that it's the same reason (or the gamedata actually changed).

Spirit_12
05-18-2018, 22:07
Yeah it seems like only windows is troublesome with these optimisations, not sure why. Easiest way to check if it's a different calling convention in L4D2 is to crack open the binary in IDA and find the function to see how it works, very likely that it's the same reason (or the gamedata actually changed).

Tried both of them and couldn't figure out the reason. Mind you, the game data is accurate and the extensions works like a charm on Linux. Just Windows is crashing. This is the function from disassembly.


.text:10208280
.text:10208280 ; =============== S U B R O U T I N E =======================================
.text:10208280
.text:10208280 ; Attributes: bp-based frame
.text:10208280
.text:10208280 sub_10208280 proc near ; CODE XREF: sub_1003CC70+28p
.text:10208280 ; sub_1019D5A0+28p ...
.text:10208280
.text:10208280 arg_0 = dword ptr 8
.text:10208280 arg_4 = dword ptr 0Ch
.text:10208280
.text:10208280 push ebp
.text:10208281 mov ebp, esp
.text:10208283 push edi
.text:10208284 mov edi, [ebp+arg_4]
.text:10208287 test edi, edi
.text:10208289 jnz short loc_10208290
.text:1020828B mov al, 1
.text:1020828D pop edi
.text:1020828E pop ebp
.text:1020828F retn
.text:10208290 ; ---------------------------------------------------------------------------
.text:10208290
.text:10208290 loc_10208290: ; CODE XREF: sub_10208280+9j
.text:10208290 push esi
.text:10208291 mov esi, [ebp+arg_0]
.text:10208294 cmp esi, edi
.text:10208296 jnz short loc_1020829E
.text:10208298 pop esi
.text:10208299 xor al, al
.text:1020829B pop edi
.text:1020829C pop ebp
.text:1020829D retn
.text:1020829E ; ---------------------------------------------------------------------------
.text:1020829E
.text:1020829E loc_1020829E: ; CODE XREF: sub_10208280+16j
.text:1020829E mov ecx, dword_107D1C00
.text:102082A4 mov eax, [ecx]
.text:102082A6 mov edx, [eax+0Ch]
.text:102082A9 push ebx
.text:102082AA push esi
.text:102082AB call edx
.text:102082AD test al, al
.text:102082AF jz short loc_102082B5
.text:102082B1 xor ebx, ebx
.text:102082B3 jmp short loc_102082C0
.text:102082B5 ; ---------------------------------------------------------------------------
.text:102082B5
.text:102082B5 loc_102082B5: ; CODE XREF: sub_10208280+2Fj
.text:102082B5 mov eax, [esi]
.text:102082B7 mov edx, [eax+14h]
.text:102082BA mov ecx, esi
.text:102082BC call edx
.text:102082BE mov ebx, eax
.text:102082C0
.text:102082C0 loc_102082C0: ; CODE XREF: sub_10208280+33j
.text:102082C0 mov ecx, dword_107D1C00
.text:102082C6 mov eax, [ecx]
.text:102082C8 mov edx, [eax+0Ch]
.text:102082CB push edi
.text:102082CC call edx
.text:102082CE test al, al
.text:102082D0 jz short loc_102082D6
.text:102082D2 xor esi, esi
.text:102082D4 jmp short loc_102082E1
.text:102082D6 ; ---------------------------------------------------------------------------
.text:102082D6
.text:102082D6 loc_102082D6: ; CODE XREF: sub_10208280+50j
.text:102082D6 mov eax, [edi]
.text:102082D8 mov edx, [eax+14h]
.text:102082DB mov ecx, edi
.text:102082DD call edx
.text:102082DF mov esi, eax
.text:102082E1
.text:102082E1 loc_102082E1: ; CODE XREF: sub_10208280+54j
.text:102082E1 test ebx, ebx
.text:102082E3 jz short loc_1020830C
.text:102082E5 test esi, esi
.text:102082E7 jz short loc_1020830C
.text:102082E9 mov ecx, ebx
.text:102082EB call sub_1003BCE0
.text:102082F0 cmp eax, esi
.text:102082F2 jnz short loc_102082FB
.text:102082F4 pop ebx
.text:102082F5 pop esi
.text:102082F6 xor al, al
.text:102082F8 pop edi
.text:102082F9 pop ebp
.text:102082FA retn
.text:102082FB ; ---------------------------------------------------------------------------
.text:102082FB
.text:102082FB loc_102082FB: ; CODE XREF: sub_10208280+72j
.text:102082FB mov ecx, esi
.text:102082FD call sub_1003BCE0
.text:10208302 cmp eax, ebx
.text:10208304 pop ebx
.text:10208305 pop esi
.text:10208306 setnz al
.text:10208309 pop edi
.text:1020830A pop ebp
.text:1020830B retn
.text:1020830C ; ---------------------------------------------------------------------------
.text:1020830C
.text:1020830C loc_1020830C: ; CODE XREF: sub_10208280+63j
.text:1020830C ; sub_10208280+67j
.text:1020830C pop ebx
.text:1020830D pop esi
.text:1020830E mov al, 1
.text:10208310 pop edi
.text:10208311 pop ebp
.text:10208312 retn
.text:10208312 sub_10208280 endp
.text:10208312

hmmmmm
05-18-2018, 22:32
I don't have the game or the binary myself, but you'll have to attach a debugger to see where its failing. The function assembly looks normal to me, no weird calling convention or anything.

Dr!fter
05-19-2018, 09:53
The weird calling convention is due to LTCG for windows builds on CS:GO. Afaik that is the only game with LTCG enabled (this is why the cstrike extension has blocks of asm for some detours (https://github.com/alliedmodders/sourcemod/blob/master/extensions/cstrike/forwards.cpp#L139) and some calls (https://github.com/alliedmodders/sourcemod/blob/master/extensions/cstrike/natives.cpp#L214))

_GamerX
12-31-2018, 15:33
for CH_PassFilter fuction will be good add mask type becouse i want only remove bullet penetration between teammates if is mp_solid_teammates 1

bebe9b
02-04-2019, 03:09
Hi ,
Pls fix:
Got a presubmit token from server: 062307169f3165ef71e41b51aff16517
Classified module /home/gsp_1998/93.119.27.188-27015/csgo/addons/sourcemod/extensions/collisionhook.ext.2.csgo.so22222 as Extension
Submitting symbols for /home/gsp_1998/93.119.27.188-27015/csgo/addons/sourcemod/extensions/collisionhook.ext.2.csgo.so22222
Symbol upload complete: Stored symbols for collisionhook.ext.2.csgo.so22222/EBB7A0549A8AF4169596C62A8CBE1BC10/Linux/x86
Classified module linux-gate.so as System
Submitting symbols for /home/gsp_1998/93.119.27.188-27015/csgo/addons/sourcemod/data/dumps/linux-gate.so
Failed to process symbol file
Uploaded crash dump: Crash ID: 7B7V-NHWB-BKNF

Thx,

Peace-Maker
02-05-2019, 05:29
That output is from Accelerator and the crash not related to this extension. You might want to open your own thread in the Source Servers section.

_GamerX
02-14-2019, 06:57
Random crash: https://crash.limetech.org/5xiooqysex3n

hoycieto
10-30-2019, 04:22
Any update for CSS Linux? :/

HarryPotter
11-14-2019, 17:03
Haven’t used this in a while, but try the one from my repo.

https://github.com/Satanic-Spirit/Collisionhook/blob/master/build/collisionhook.ext.2.l4d2/collisionhook.ext.2.l4d2.so


collisionhook.ext.2.l4d.dll: Unable to hook PassServerEntityFilter!
collisionhook.ext.2.l4d.so: works!
collisionhook.ext.2.l4d2.dll: Unable to hook PassServerEntityFilter!
collisionhook.ext.2.l4d2.so: works!

it seems that "PassServerEntityFilter" not found?

Spirit_12
11-16-2019, 19:37
collisionhook.ext.2.l4d.dll: Unable to hook PassServerEntityFilter!
collisionhook.ext.2.l4d.so: works!
collisionhook.ext.2.l4d2.dll: Unable to hook PassServerEntityFilter!
collisionhook.ext.2.l4d2.so: works!

it seems that "PassServerEntityFilter" not found?

It is the correct signature, but this extension hasn't worked on windows for the longest time.

HarryPotter
11-17-2019, 12:19
It is the correct signature, but this extension hasn't worked on windows for the longest time.

so the problem is extension, not the signature?
oh great

Spirit_12
11-17-2019, 15:22
so the problem is extension, not the signature?
oh great

I'm certain you can recreate the collisionhooks functionality with Dhooks Detour extension.

HarryPotter
11-18-2019, 00:11
I'm certain you can recreate the collisionhooks functionality with Dhooks Detour extension.

Dhooks 2.2.0-detours9 extension has something or codes related to collision?
That's nice!
have example or scripting tips please?

BHaType
11-18-2019, 17:37
I looked and there the signature is not correct for windows.
Try this one.

\x55\x8B\xEC\x57\x8B\x7D\x0C\x85\xFF\x75

One of the hardest signatures I've been looking for.

Edit: Works without errors


#include <sourcemod>
#include <sdktools>
#include <dhooks>

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

Handle hDetour = DHookCreateFromConf(hData, "PassEntityFilter");
if( !hDetour ) SetFailState("Failed to find \"PassEntityFilter\" offset.");
if( !DHookEnableDetour(hDetour, true, detour) ) SetFailState("Failed to detour \"PassEntityFilter\".");
delete hData;
}


public MRESReturn detour(Handle hReturn, Handle hParams)
{
PrintToServer("Entity 1 %i Entity 2 %i", DHookGetParam(hParams, 1), DHookGetParam(hParams, 2));
return MRES_Ignored;
}

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

HarryPotter
11-20-2019, 07:14
I looked and there the signature is not correct for windows.
Try this one.


I have tested, server crash :(


[DHOOKS] FATAL: Failed to find return address of original function. Check the arguments and return type of your detour setup.

BHaType
11-20-2019, 18:12
I have tested, server crash :(


[DHOOKS] FATAL: Failed to find return address of original function. Check the arguments and return type of your detour setup.


I checked again and everything works so try reinstalling gamedata


https://i.imgur.com/Wpasc0f.png

HarryPotter
11-21-2019, 07:08
I checked again and everything works so try reinstalling gamedata

it does print line on server console, but after few seconds server crash


sm version
SourceMod Version Information:
SourceMod Version: 1.10.0.6456
SourcePawn Engine: 1.10.0.6456, jit-x86 (build 1.10.0.6456)


sm exts list
[SM] Displaying 9 extensions:
[01] Automatic Updater (1.10.0.6456): Updates SourceMod gamedata files
[02] Webternet (1.10.0.6456): Extension for interacting with URLs
[03] Top Menus (1.10.0.6456): Creates sorted nested menus
[04] SDK Tools (1.10.0.6456): Source SDK Tools
[05] BinTools (1.10.0.6456): Low-level C/C++ Calling API
[06] Client Preferences (1.10.0.6456): Saves client preference settings
[07] SQLite (1.10.0.6456): SQLite Driver
[08] DHooks (2.2.0-detours9): Dynamic Hooks
[09] SDK Hooks (1.10.0.6456): Source SDK Hooks


errors_log
L 11/21/2019 - 20:02:41: [SM] Exception reported: Trying to get value for null pointer.
L 11/21/2019 - 20:02:41: [SM] Blaming: test.smx
L 11/21/2019 - 20:02:41: [SM] Call stack trace:
L 11/21/2019 - 20:02:41: [SM] [0] DHookGetParam
L 11/21/2019 - 20:02:41: [SM] [1] Line 19, D:\Program Files (x86)\SteamLibrary\steamapps\common\Left 4 Dead 2 Dedicated Server\left4dead2\addons\sourcemod\scripting\ test.sp::detour
...
...
many lines same errors
...
...
...

cravenge
11-21-2019, 09:13
[...]Looks like a problem in the test plugin you're using.

HarryPotter
11-22-2019, 00:16
Looks like a problem in the test plugin you're using.

test plugin is based on the code he pasted here
https://forums.alliedmods.net/showpost.php?p=2673375&postcount=92

cravenge
11-22-2019, 02:37
Huh, that's strange. There's nothing wrong with how the gamedata is constructed yet the detour is somehow trying to grab something from a pointer that doesn't exist even if it's ignored. It might be a valid entity becoming invalid when that happens. I could be wrong but try adding a validity check for both entities.

Peace-Maker
11-22-2019, 15:01
That's a general problem with post-detours in dhooks. Check the paragraph about "Accessing parameter values in post-hooks" in the release post (https://forums.alliedmods.net/showpost.php?p=2588686&postcount=589).

cravenge
11-22-2019, 19:15
If I can remember properly, getting/changing the parameters should be done in pre-detours right? And it goes for the same for return values in post-detours?

HarryPotter
11-24-2019, 06:01
How can I call pre-hooks or pre-detour please?

cravenge
11-24-2019, 13:21
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.

Spirit_12
11-24-2019, 17:00
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.

#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(hDetour, false, detour_pre) )
SetFailState("Failed to detour \"PassEntityFilter\". pre");

// Setup post hook
if( !DHookEnableDetour(hDetour, true, detour_post) )
SetFailState("Failed to detour \"PassEntityFilter\". post");
}

public MRESReturn detour_pre(Handle hReturn, Handle hParams)
{
// Store prehook parameters into global variables
g_iEntityOne = DHookGetParam(hParams, 1);
g_iEntityTwo = DHookGetParam(hParams, 2);

PrintToServer("Entity 1 %i Entity 2 %i", DHookGetParam(hParams, 1), DHookGetParam(hParams, 2));
return MRES_Ignored;
}

public MRESReturn detour_post(Handle hReturn, Handle hParams)
{
PrintToServer("Entity 1 %i Entity 2 %i", g_iEntityOne, g_iEntityTwo);
return MRES_Ignored;
}

HarryPotter
11-25-2019, 05:51
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

if(DHookIsNullParam(hParams, 1) || DHookIsNullParam(hParams, 2)) return MRES_Ignored;

BHaType
11-25-2019, 06:20
Try this gamedata

"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
"callconv" "cdecl"
to this
"callconv" "thiscall"

HarryPotter
11-26-2019, 07:35
Try this gamedata



[DHOOKS] FATAL: Failed to find return address of original function. Check the arguments and return type of your detour setup.

Nerus
12-28-2019, 11:31
This works for me on Windows and Linux in CSS
"Games"
{
"#default"
{
"Signatures"
{
"PassServerEntityFilter"
{
"library" "server"

"windows" "\x55\x8B\xEC\x56\x8B\x2A\x2A\x85\x2A\x75\x2A\ xB0\x2A\x5E"
"linux" "@_Z22PassServerEntityFilterPK13IHandleEntityS 1_"
}
}
}
}

Kellan123
06-13-2020, 17:19
L 06/14/2020 - 00:19:05: [SM] Unable to load extension "collisionhook.ext": The specified procedure could not be found.

windows ?

using: https://bitbucket.org/VoiDeD/collisionhook/downloads/ 0.2.zip

Spirit_12
06-13-2020, 19:51
L 06/14/2020 - 00:19:05: [SM] Unable to load extension "collisionhook.ext": The specified procedure could not be found.

windows ?

using: https://bitbucket.org/VoiDeD/collisionhook/downloads/ 0.2.zip

You are running the version from 2013, therefore it seems like a linking issue. What game are you running?

Kellan123
06-14-2020, 01:24
You are running the version from 2013, therefore it seems like a linking issue. What game are you running?
CS GO

Peace-Maker one is crashing when i join the server.

Spirit_12
06-15-2020, 00:29
CS GO

Peace-Maker one is crashing when i join the server.

You gotta ask someone to recompile the the extension for the game and then recheck the signature.

Peace-Maker
06-15-2020, 10:26
Have you tried this updated version?
https://forums.alliedmods.net/showthread.php?p=2592634#post2592634

Kellan123
06-15-2020, 11:44
Have you tried this updated version?
https://forums.alliedmods.net/showthread.php?p=2592634#post2592634
Thank you, this one works good (CS GO Only) ;O

vikingo12
02-14-2021, 11:58
Anybody got working version of collisionhook for windows [l4d2]?

Spirit_12
02-14-2021, 19:50
Anybody got working version of collisionhook for windows [l4d2]?

Game?

cravenge
02-15-2021, 03:35
BHaType posted a newer way of recreating this extension for L4D2 in the form of a plugin. The only problem is you have to find the latest offset of the PassServerEntityFilter function in the binary to make it work post-TLS.

Spirit_12
02-15-2021, 17:05
BHaType posted a newer way of recreating this extension for L4D2 in the form of a plugin. The only problem is you have to find the latest offset of the PassServerEntityFilter function in the binary to make it work post-TLS.

Just to add to what cravenge is talking about. I went ahead with BhaType's idea and created this plugin with a forward.

Just grab the right signature for your game and it should work fine. Windows is not tested at all, so you are on your own.

#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(hDetour, true, detour) )
SetFailState("Failed to detour \"PassEntityFilter\".");
delete hData;

g_CHPassEntity = CreateGlobalForward("CH_PassFilter", ET_Event, Param_Cell, Param_Cell , Param_CellByRef);
}


public MRESReturn detour(Handle hReturn, Handle hParams)
{
if(!DHookIsNullParam(hParams, 1) && !DHookIsNullParam(hParams, 2))
{
int iEntity1 = DHookGetParam(hParams, 1);
int iEntity2 = DHookGetParam(hParams, 2);
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(hReturn, funcresult);
return MRES_Supercede;
}
}
}

//PrintToChatAll("Entity 1 %i Entity 2 %i", iEntity1, iEntity2);
return MRES_Ignored;
}

GameData

"Games"
{
"left4dead2"
{
"Functions"
{
"PassEntityFilter"
{
"signature" "PassEntityFilter"
"callconv" "cdecl"
"return" "int"
"this" "ignore"
"arguments"
{
"a1"
{
"type" "cbaseentity"
}
"a2"
{
"type" "cbaseentity"
}
}
}
}
"Signatures"
{
"PassEntityFilter"
{
"library" "server"
"windows" "\x55\x8B\xEC\x57\x8B\x7D\x0C\x85\xFF\x75"
"linux" "@_Z22PassServerEntityFilterPK13IHandleEntityS 1_"
}
}
}
}

cravenge
02-16-2021, 05:33
What's the string to search for in order to find this function? The reason why I'm asking this is cuz I want to get its base address instead since I'm using BHaType's hooking via script manager method.

Psyk0tik
02-16-2021, 09:30
What's the string to search for in order to find this function? The reason why I'm asking this is cuz I want to get its base address instead since I'm using BHaType's hooking via script manager method.

You can find it by searching "RagdollImpact" which will lead you to the "CBaseEntity::FireBullets" function. That function contains other strings you can reference but the "RagdollImpact" is the one closest to the function we'll need. A little below that string, you'll see a function called "Pickup_ForcePlayerToDropThisObject" (the function we need) which will only have two references. The second one will be the function "CTraceFilterMelee::ShouldHitEntity". When you look inside that function, you will see that it calls "PassServerEntityFilter" in the Linux binaries. In the Windows binaries, it'll be the 2nd subroutine that you'll see in an "if" statement.

Linux:
v3 = 0;
if ( (unsigned __int8)StandardFilterRules(a2, a3) )
{
if ( PassServerEntityFilter(a2, *((const IHandleEntity **)this + 1))
&& !(*(unsigned __int8 (__cdecl **)(int, IHandleEntity *))(*(_DWORD *)staticpropmgr + 8))(staticpropmgr, a2) )
{

Windows:
if ( !(unsigned __int8)sub_1020B800(a2, a3)
|| !(unsigned __int8)sub_1020B760(a2, *(_DWORD *)(this + 4))

I ran makesig.idc on "sub_1020B760" and got the same signature (minus the last wildcarded byte) as Spirit_12:
Signature for sub_1020B760:
55 8B EC 57 8B 7D 0C 85 FF 75 ?
\x55\x8B\xEC\x57\x8B\x7D\x0C\x85\xFF\x75\x2A

cravenge
02-16-2021, 09:39
You can find it by searching "RagdollImpact" which will lead you to the "CBaseEntity::FireBullets" function. That function contains other strings you can reference but the "RagdollImpact" is the one closest to the function we'll need. A little below that string, you'll see a function called "Pickup_ForcePlayerToDropThisObject" (the function we need) which will only have two references. The second one will be the function "CTraceFilterMelee::ShouldHitEntity". When you look inside that function, you will see that it calls "PassServerEntityFilter" in the Linux binaries. In the Windows binaries, it'll be the 2nd subroutine that you'll see in an "if" statement.

Linux:
v3 = 0;
if ( (unsigned __int8)StandardFilterRules(a2, a3) )
{
if ( PassServerEntityFilter(a2, *((const IHandleEntity **)this + 1))
&& !(*(unsigned __int8 (__cdecl **)(int, IHandleEntity *))(*(_DWORD *)staticpropmgr + 8))(staticpropmgr, a2) )
{

Windows:
if ( !(unsigned __int8)sub_1020B800(a2, a3)
|| !(unsigned __int8)sub_1020B760(a2, *(_DWORD *)(this + 4))

I ran makesig.idc on "sub_1020B760" and got the same signature (minus the last wildcarded byte) as Spirit_12:
Signature for sub_1020B760:
55 8B EC 57 8B 7D 0C 85 FF 75 ?
\x55\x8B\xEC\x57\x8B\x7D\x0C\x85\xFF\x75\x2AT his really helped me a lot. Thanks! By the way, how did you compare the functions? I'm using IDA and I couldn't see any feature that provided that.

Psyk0tik
02-16-2021, 09:49
This really helped me a lot. Thanks! By the way, how did you compare the functions? I'm using IDA and I couldn't see any feature that provided that.

No problem! I just have two instances of IDA running whenever I'm looking into the binaries, partly because it makes backtracking a lot easier for me.

vikingo12
02-18-2021, 04:00
Game?

it says L4D2

eliteroyal
02-24-2021, 07:36
Links are broken, i need this for css linux

Nerus
04-27-2021, 12:47
Links are broken, I need this for CSS linux

Here you go.

Windroid
05-10-2021, 01:22
My slender fortress server is broken :(
<FAILED> file "collisionhook.ext.dll": Unable to hook PassServerEntityFilter!

Anyone got a fix for tf2(windows)?

FroGeX
05-10-2021, 06:36
My slender fortress server is broken :(
<FAILED> file "collisionhook.ext.dll": Unable to hook PassServerEntityFilter!

Anyone got a fix for tf2(windows)?

Use Linux...

Ejziponken
06-01-2021, 13:49
So is there a way to remove ONLY team bullet collision for CSGO?

FroGeX
06-06-2021, 17:59
So is there a way to remove ONLY team bullet collision for CSGO?

Yes

Ejziponken
06-09-2021, 06:46
Yes

How?

eliteroyal
06-13-2021, 01:58
Here you go.

thanks bro

HarryPotter
09-11-2021, 07:56
l4d1 windows server crash, hope someone can help

sm1.10 + DHooks 2.2.0-detours17

#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(hDetour, true, detour) )
SetFailState("Failed to detour \"PassEntityFilter\".");
delete hData;

g_CHPassEntity = CreateGlobalForward("CH_PassFilter", ET_Event, Param_Cell, Param_Cell , Param_CellByRef);
}


public MRESReturn detour(Handle hReturn, Handle hParams)
{
if(!DHookIsNullParam(hParams, 1) && !DHookIsNullParam(hParams, 2))
{
int iEntity1 = DHookGetParam(hParams, 1);
int iEntity2 = DHookGetParam(hParams, 2);
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(hReturn, funcresult);
return MRES_Supercede;
}
}
}

//PrintToChatAll("Entity 1 %i Entity 2 %i", iEntity1, iEntity2);
return MRES_Ignored;
}



"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" "@_Z22PassServerEntityFilterPK13IHandleEntityS 1_"
}
}
}
}

Psyk0tik
09-11-2021, 16:29
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:
bool PassServerEntityFilter( const IHandleEntity *pTouch, const IHandleEntity *pPass )
{
if ( !pPass )
return true;

if ( pTouch == pPass )
return false;

const CBaseEntity *pEntTouch = EntityFromEntityHandle( pTouch );
const CBaseEntity *pEntPass = EntityFromEntityHandle( pPass );
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:
if ( IsStaticProp( pEntTouch ) || IsStaticProp( pEntPass ) )
return true;

Forgetest
09-15-2021, 01:23
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):
"Games"
{
"left4dead"
{
"Functions"
{
"PassEntityFilter"
{
"signature" "PassEntityFilter"
"callconv" "cdecl"
"return" "bool"
"this" "ignore"
"arguments"
{
"a1"
{
"type" "int"
}
"a2"
{
"type" "int"
}
}
}
}
"Signatures"
{
"PassEntityFilter"
{
"library" "server"
"linux" "@_Z22PassServerEntityFilterPK13IHandleEntityS 1_"
"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:
public void OnPluginStart()
{
Handle hData = LoadGameConfigFile("CollisionHook");

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

if (!DHookEnableDetour(hDetour, false, PassEntityFilter)) // tried both pre and post hook
SetFailState("Failed to detour \"PassEntityFilter\".");

delete hData;
}

public MRESReturn PassEntityFilter(Handle hReturn, Handle hParams)
{
return MRES_Ignored;
}

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

cravenge
09-15-2021, 08:30
Maybe the fault lies within DHooks and how it replaces the first six bytes of the function during the detouring process.

Psyk0tik
09-16-2021, 21:50
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.
"PassServerEntityFilter"
{
"signature" "PassServerEntityFilter"
"callconv" "cdecl"
"return" "bool"
"this" "ignore"
"arguments"
{
"entity1"
{
"type" "int"
}
"entity2"
{
"type" "int"
}
}
}

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.).

AdRiAnIlloO
11-07-2021, 20:00
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?

"\x55\x8b\xec\x57\x8b\x7d\x0c\x85\xff\x75\x2a\ xb0\x01\x5f\x5d\xc3\x56\x8b\x75"

(I guess, CSGO?)

Thanks.

reBane
11-28-2021, 11:06
Tinkered with ghidra over the weekend, PassServerEntityFilter for TF2 in server.dll (win) has the signature
\x55\x8B\xEC\x56\x8B\x75\x0C\x85\xF6\x75\x05
In case anyone is looking for it like I was...

ItsKoenLul
11-28-2021, 16:26
Does anyone happen to have the csgo version of CollisionHook on hand? The DL links are no longer active.

Ejziponken
01-23-2022, 12:33
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?

Ejziponken
01-25-2022, 13:29
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?

"\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

Benito
01-25-2022, 13:32
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

Updated csgo linux signature (Thanks to Konlig) :
\x55\xB8\x01\x00\x00\x00\x89\xE5\x83\xEC\x38\ x89\x5D\xF4

Ejziponken
01-25-2022, 15:26
Updated csgo linux signature (Thanks to Konlig) :

Is that for this version?
https://github.com/Adrianilloo/Collisionhook/releases

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

Benito
01-25-2022, 16:26
Is that for this version?
https://github.com/Adrianilloo/Collisionhook/releases

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

yes, take this gamedata
https://pastebin.com/YhBmxWzH

painkiller
02-21-2022, 10:53
Hi guys,
would this still work in HL2:DM today if there was a download?

Maybe someone could do it again.
I have been looking for something like this for hl2dm for a while now .

Apparently this should have worked in the past

Greetings Painkiller

AdRiAnIlloO
12-18-2022, 15:53
Dear CollisionHook users,

I have recently noticed a serious issue in the extension (which I might have patched successfully). The extension had a memory leak over its internal hooks that arose every map change. The bug causes servers that run for few days without a restart (at minimum) to suffer from high var (CPU) usage, drastically slowing down FPS and thus making the game even unplayable when arbitrary physical/game interaction takes place.

In order to test my patch properly, I ask for your help to try this version. If you have game servers that don't restart often and noticed such bad performance after running without a full restart for few days, the extension could be the culprit. I also ask users to test it to check there are no regression bugs, and it doesn't cause other problems (such as physics bugs).

Source code (patched branch): https://github.com/Adrianilloo/Collisionhook/tree/fix-hooks-memory-leak (note the patched binaries aren't in the Release section yet).

Also, I can't guarantee that the contained gamedata is correct for the game you are using. So I recommend only replacing the files from the extension folder, if you were already using CollisionHook.

Once I can be confident enough that it's stable, I'll push the changes to the main branch.

EDIT: Changes have now been pushed to the master branch. Download updated extension from the ZIP HERE (https://github.com/Adrianilloo/Collisionhook/releases).

Thank you.

Morell
12-19-2022, 05:39
Dear CollisionHook users,

I have recently noticed a serious issue in the extension (which I might have patched successfully). The extension had a memory leak over its internal hooks that arose every map change. The bug causes servers that run for few days without a restart (at minimum) to suffer from high var (CPU) usage, drastically slowing down FPS and thus making the game even unplayable when arbitrary physical/game interaction takes place.

In order to test my patch properly, I ask for your help to try this version. If you have game servers that don't restart often and noticed such bad performance after running without a full restart for few days, the extension could be the culprit. I also ask users to test it to check there are no regression bugs, and it doesn't cause other problems (such as physics bugs).

Source code (patched branch): https://github.com/Adrianilloo/Collisionhook/tree/fix-hooks-memory-leak (note the patched binaries aren't in the Release section yet).

Also, I can't guarantee that the contained gamedata is correct for the game you are using. So I recommend only replacing the files from the extension folder, if you were already using CollisionHook.

Once I can be confident enough that it's stable, I'll push the changes to the main branch.

The patched version is attached below. Thank you.

Hello, thanks for this fix, but I have this error on a CS:GO server using Linux:
<FAILED> file "collisionhook.ext.2.csgo.so": Unable to hook PassServerEntityFilter!

Edit:
Works with the original gamedata file.

xiaoli
12-23-2022, 11:51
Dear CollisionHook users,

I have recently noticed a serious issue in the extension (which I might have patched successfully). The extension had a memory leak over its internal hooks that arose every map change. The bug causes servers that run for few days without a restart (at minimum) to suffer from high var (CPU) usage, drastically slowing down FPS and thus making the game even unplayable when arbitrary physical/game interaction takes place.

In order to test my patch properly, I ask for your help to try this version. If you have game servers that don't restart often and noticed such bad performance after running without a full restart for few days, the extension could be the culprit. I also ask users to test it to check there are no regression bugs, and it doesn't cause other problems (such as physics bugs).

Source code (patched branch): https://github.com/Adrianilloo/Collisionhook/tree/fix-hooks-memory-leak (note the patched binaries aren't in the Release section yet).

Also, I can't guarantee that the contained gamedata is correct for the game you are using. So I recommend only replacing the files from the extension folder, if you were already using CollisionHook.

Once I can be confident enough that it's stable, I'll push the changes to the main branch.

The patched version is attached below. Thank you.

I seem to encounter strange issue with ext.2.tf2.so one on my tf2 server.

There seems to be conflict with accelerator extension somehow
1. replaced old collisionhook with new collisionhook extension
2. make server crash
3. server restarts
4. accelerator tries to upload crash
5. server keeps crashing when that happens and never goes past upload
6. replace collisionhook with old one
7. no more crash, server starts normally

Either it's some rare bug and coincidence or theres conflict with accelerator ext somehow. I didn't change gamedata

AdRiAnIlloO
12-24-2022, 05:51
I seem to encounter strange issue with ext.2.tf2.so one on my tf2 server.

There seems to be conflict with accelerator extension somehow
1. replaced old collisionhook with new collisionhook extension
2. make server crash
3. server restarts
4. accelerator tries to upload crash
5. server keeps crashing when that happens and never goes past upload
6. replace collisionhook with old one
7. no more crash, server starts normally


Previous answer:

Either it's some rare bug and coincidence or theres conflict with accelerator ext somehow. I didn't change gamedata

Crashing when replacing a library in use by a process tends to happen. So let's go by parts.

At step 1, were you already running the server and thus replaced the extension "live"?

At your step 2 ("make server crash"), do you mean server crashed itself? If so, that could be normal due to the above. However, after a restarting the program (step 3) crashes should stop happenning (resuming stability) assuming the extension has no other issues.

After step 6 (downgrading CollisionHook) and before 7, did you restart the server manually?

As you can see, it isn't obvious to me if you tried to fully stop the server, then replace the extension with the patched one and only restart it afterwards. If that isn't the case, please, do that.

I have re-checked the source code changes of the new version and didn't find any mistake, from my knowledge.

Unless you already did, could you also try running my exact "stable" version to check if that already crashes your server? (although it will have the memory leak) -> https://github.com/Adrianilloo/Collisionhook/releases/tag/0.2

Also check your Accelerator dump (if it finally uploaded) for stack calls pointing to CollisionHook.

UPDATE: See my newest post.

AdRiAnIlloO
12-27-2022, 10:53
Important info. to all users of my recent Memory Leak patch (Linux servers only):

As found by @xiaoli, the patched version had an apparent conflict with Accelerator that prevented server from uploading pending minidumps after server start, but it might also cause other random crashes.

The issue wasn't in my CollisionHook source code changes themselves (which I re-checked carefully), but indirectly in the environment I used for the patched version, initially (Ubuntu 22.04 + Clang 14.0) vs the one I had been using previously (Ubuntu 20.04 + Clang 11.0), for some unknown concrete reason (maybe non-straightforward ABI/binary incompatibilities).

After re-compiling the patched version on the lower environment (Ubuntu 22.04) it seems to work fine, at least not exhibiting such concrete Accelerator conflict.

So, anyone using Linux for SRCDS who downloaded the patched version of my other day's post, please, re-download it from the ZIP here (https://github.com/Adrianilloo/Collisionhook/releases/tag/0.2). Otherwise your server might not be safe.

r3v
02-05-2023, 02:43
Need updated linux gamedata for csgo...

Ksenaksis
02-05-2023, 06:21
Please share updated csgo gamedata.

poggu
02-05-2023, 07:41
PassServerEntityFilter


\x55\x89\xE5\x57\x56\x53\x83\xEC\x0C\x8B\x5D\ x0C\x8B\x75\x08\x85\xDB\x0F\x84\x2A\x2A\x2A\x 2A\x39\xF3

3ipKa
06-29-2023, 07:07
Does it still work for l4d2 after last update?

HarryPotter
07-03-2023, 13:14
Does it still work for l4d2 after last update?

This works in L4D2 windows and linux
https://github.com/L4D-Community/Collisionhook/actions

Spirit_12
07-03-2023, 20:23
Why is CollisionHook still an extension? Given the functionality of DHooks Detour this should be a plugin for easier maintenance.

cravenge
07-03-2023, 22:48
Why is CollisionHook still an extension? Given the functionality of DHooks Detour this should be a plugin for easier maintenance.For Linux? Maybe.
For Windows? Nah.

3ipKa
07-11-2023, 05:29
This works in L4D2 windows and linux
https://github.com/L4D-Community/Collisionhook/actions
Could you share windows compiled version please?

HarryPotter
08-02-2023, 09:07
Could you share windows compiled version please?

Files from https://github.com/L4D-Community/Collisionhook

chungocanh12
09-07-2023, 21:49
Files from https://github.com/L4D-Community/Collisionhook

thanks you alot

VoiDeD
03-15-2024, 19:38
Hey all, due to popular demand, I've revived this extension a bit.

The extension now lives on github: https://github.com/voided/CollisionHook

I'm still a little iffy on how much of my own effort I can contribute to keep supporting this, but like most OSS projects: PRs welcome. ;)

Quick hits:

- GH actions are setup to do automated Linux and Windows builds of the extension: https://github.com/voided/CollisionHook/releases
- A few of the community fixes (such as the memory leak issue and a few others) have been included in this repo.
- Both x86 and x64 builds are available for TF2.

Nerus
03-16-2024, 12:36
Hey all, due to popular demand, I've revived this extension a bit.

The extension now lives on github: https://github.com/voided/CollisionHook

I'm still a little iffy on how much of my own effort I can contribute to keep supporting this, but like most OSS projects: PRs welcome. ;)

Quick hits:

- GH actions are setup to do automated Linux and Windows builds of the extension: https://github.com/voided/CollisionHook/releases
- A few of the community fixes (such as the memory leak issue and a few others) have been included in this repo.
- Both x86 and x64 builds are available for TF2.

Thanks, we appreciate your work!

Spirit_12
03-16-2024, 14:38
Is there any advantage of using an extension when the same can be done via plugin and is easier to maintain?