Coder Social home page Coder Social logo

dhooks2's People

Contributors

drifter321 avatar powerlord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dhooks2's Issues

Server crash on removal callback called on unloaded plugin

Tested in TF2 windows and linux with 2.2.0-detours7, i couldn't get to test whenever non-detour version would still crash but im pretty sure it does as i haven't seen any related changes between it.

I'm getting a lot of these crashes, but this one caught my eyes on how it happened, which it seems like it crashed here.

I have a plugin with several hook removal callback, and another plugin that automatically unloads plugin on map end. From what i can see it crashes when dhook tries to call a removal callback while plugin is being unloaded.

Smallest reproduce i can make:

  • Load below plugin named disabled/42test.smx
  • Join server
  • Change map
    This will unload plugin and dhook attempting to call OnHookRemoved, leading to a crash.
#include <sdktools>
#include <dhooks>

Handle g_hHookGetMaxHealth;

public void OnPluginStart()
{
	GameData hGameData = new GameData("sdkhooks.games");
	if (hGameData == null)
		SetFailState("Could not find sdkhooks.games gamedata");
	
	int iOffset = hGameData.GetOffset("GetMaxHealth");
	g_hHookGetMaxHealth = DHookCreate(iOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity);
	if (g_hHookGetMaxHealth == null)
		LogMessage("Failed to create hook: CTFPlayer::GetMaxHealth");
	
	delete hGameData;
	
	//Lateload
	for (int iClient = 1; iClient <= MaxClients; iClient++)
		if (IsClientInGame(iClient))
			OnClientPutInServer(iClient);
}

public void OnMapEnd()
{
	ServerCommand("sm plugins unload disabled/42test");
}

public void OnClientPutInServer(int iClient)
{
	DHookEntity(g_hHookGetMaxHealth, true, iClient, OnHookRemoved, GetMaxHealth);
}

public void OnHookRemoved(int iHookId)
{
}

public MRESReturn GetMaxHealth(int iClient, Handle hReturn)
{
	return MRES_Ignored;
}

Superceding in one function prevents execution of post-callbacks up the call chain

ℹī¸ This should no longer be an issue if you're using @peace-maker's version with detour support, but the issue will remain open as long as the issue is valid upstream.


Versions installed:

  • SourceMod version: 1.10.0.6452
  • Metamod:Source version: 1.11.0-dev+1127
  • DHooks version: 2.2.0-detours7 (does affect mainline dhooks iirc)
  • Platform: Linux

Hard to explain, so here's an example case.

Attached below is a plugin that uses a virtual hook on CBaseCombatWeapon::PrimaryAttack() and a post-hook on PostThink via SDKHooks. If the hook on ::PrimaryAttack() returns MRES_Supercede, the PostThinkPost callback never executes.

To reproduce, install the plugin, set test_supercede_bug to 1, and shoot gun. The expected result is that the SourceMod continues to call PostThink with the latest game time while attacking; the current behavior is that no messages are displayed.

Only TF2 gamedata is provided, but the calls aren't specific to TF2.

test_dhook_think_func.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.