View Single Post
ekshon
Junior Member
Join Date: Nov 2020
Old 12-05-2020 , 03:51   Re: [ANY/CSGO] cutlrbtree overflow, memory access
Reply With Quote #6

Alright. Thank you guys in helipng me with this investigation!
Here's conclusion that might be helpful for anyone who's facing same problem:

Calling "FreeAll()" in round runtime wasn't a good idea, because you're losing map's logic. Every output stops working. Also, server crashes when you mp_restartgame 1. Maybe you should call it in pre-event of "round_restart"? I didn't try this. Forget about "FreeAll" then.

Call "void Remove( const char *pszValue )" instead. It allows you to remove a string by it's name, but here's another problem:

Every time you create an entity in runtime with VSCRIPT attached to it, it creates a wierd string with some unique ID and classname / targetname. Good thing you can get this unique ID and remove string in "OnEntityDestroyed" very easily.


Here's the code:

Code:
Handle sdkcall;

public void OnPluginStart()
{
	StartPrepSDKCall(SDKCall_Static);
        //signature is for windows
	PrepSDKCall_SetSignature(SDKLibrary_Server, "\x55\x8B\xEC\x56\x8D\x45\x08\xB9",8);
	PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
	sdkcall = EndPrepSDKCall();
}

public void OnEntityDestroyed(int entity)
{
	char buffer[128];
	GetEntPropString(entity, Prop_Data, "m_iszScriptId", buffer, sizeof(buffer));	

	if (strlen(buffer) <= 0) return;
	
	SDKCall(sdkcall,buffer);
}
Credits to anarh1st47 for finding the signatures.

YOU CAN USE THIS METHOD TO REMOVE ANY UNWATNED STRING

Here's another solution, just 3 lines of code, that will remove only "m_iszScriptId" strings from stringpool.

Code:
public void OnEntityCreated(entity, const char[] classname)
{
    SetEntProp(entity,Prop_Data,"m_bForcePurgeFixedupStrings",true);
}
SOLVED

Last edited by ekshon; 12-05-2020 at 09:28. Reason: +image
ekshon is offline