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

Trying to detour IsSpawnPointValid in CSGO


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Effeff
AlliedModders Donor
Join Date: Jan 2019
Location: discord: ff#0533
Old 02-21-2021 , 19:22   Trying to detour IsSpawnPointValid in CSGO
Reply With Quote #1

My goal is to accomplish what this plugin does, but different https://forums.alliedmods.net/showthread.php?t=260532

I see three relevant functions:

CTeamSpawnPoint::IsValid
(I don't think I'm allowed to link the csgo leak, but it's in team_spawnpoint.cpp)

CGameRules::IsSpawnPointValid

CCSGameRules::IsSpawnPointValid

I used IDA Freeware to find the signatures for these three, and I wrote the following code to try it out.

Code:
"Games"
{
	"csgo"
	{
		"Signatures"
		{
			"CTeamSpawnPoint::IsValid"
			{
				"library"	"server"
				"linux"		"\x55\x89\xE5\x57\x56\x53\x81\xEC\x2C\x08\x00\x00\x8B\x5D\x08"
			}
			"CGameRules::IsSpawnPointValid"
			{
				"library"	"server"
				"linux"		"\x55\x89\xE5\x57\x56\x53\x81\xEC\x2C\x08\x00\x00\x8B\x5D\x0C"
			}
			"CCSGameRules::IsSpawnPointValid"
			{
				"library"	"server"
				"linux"		"\x55\x89\xE5\x81\xEC\x88\x00\x00\x00\x89\x5D\xF4\x8B\x5D\x0C\x8B\x55\x10"
			}
		}
		"Functions"
		{
			"CTeamSpawnPoint::IsValid"
			{
				"signature"	"CTeamSpawnPoint::IsValid"
				"callconv"	"thiscall"
				"return"	"bool"
				"this"		"ignore"
			}
			"CGameRules::IsSpawnPointValid"
			{
				"signature"	"CGameRules::IsSpawnPointValid"
				"callconv"	"thiscall"
				"return"	"bool"
				"this"		"ignore"
			}
			"CCSGameRules::IsSpawnPointValid"
			{
				"signature"	"CCSGameRules::IsSpawnPointValid"
				"callconv"	"thiscall"
				"return"	"bool"
				"this"		"ignore"
			}
		}
	}
}
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <dhooks>

ConVar cvar_SolidTeammates;

Handle g_hGameData;

Handle g_dhIsSpawnPointValidDetour;

public 
void OnPluginStart()
{
    
cvar_SolidTeammates FindConVar("mp_solid_teammates");
    
    
g_hGameData LoadGameConfigFile("detour_csgo_spawns.games2");
    
    if (
g_hGameData == null)
    {
        
SetFailState("failed to load game config file");
    }
    else
    {
        
PrintToChatAll("gamedata is not null");
    }
    
    
g_dhIsSpawnPointValidDetour DHookCreateDetour(Address_NullCallConv_THISCALLReturnType_BoolThisPointer_Ignore);
    
    if (
g_dhIsSpawnPointValidDetour == null)
    {
        
SetFailState("failed to setup spawnpoint valid hook");
    }
    else
    {
        
PrintToChatAll("hook setup success");
    }
    
    if (!
DHookSetFromConf(g_dhIsSpawnPointValidDetourg_hGameDataSDKConf_Signature"<insert signature name here>"))
    {
        
SetFailState("failed to load spawnpoint valid signature");
    }
    else
    {
        
PrintToChatAll("hook load success");
    }
    
    if (!
DHookEnableDetour(g_dhIsSpawnPointValidDetourfalseDetour_IsSpawnPointValid))
    {
        
SetFailState("failed to detour spawnpoint valid");
    }
    else
    {
        
PrintToChatAll("detour success");
    }
}

public 
MRESReturn Detour_IsSpawnPointValid(Handle hReturnHandle hParams)
{
    if (!
cvar_SolidTeammates.BoolValue)
    {
        
PrintToChatAll("Detour_IsSpawnPointValid called, changing return value to true");
        
DHookSetReturn(hReturntrue);
        return 
MRES_Override;
    }
    
PrintToChatAll("Detour_IsSpawnPointValid called, not changing return value");
    return 
MRES_Ignored;

There were no errors when I tried the first function. However, the detour never actually "occurs".
The latter two functions resulted in errors in DHookSetFromConf.

I'm not sure how to proceed from here, and am not sure if I am doing something wrong. Never attempted to use dhooks before this.

Last edited by Effeff; 02-21-2021 at 20:07.
Effeff is offline
 



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 23:15.


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