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

Creating threads


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Miu
Veteran Member
Join Date: Nov 2013
Old 03-22-2015 , 19:48   Creating threads
Reply With Quote #1

I'm trying to make a sourcemod extension to create a thread to execute any given plugin function with the simple code:

Code:
DWORD WINAPI thr(LPVOID param)
{
	((IPluginFunction *)param)->CallFunction(0, 0, 0);
	return 0;
}

cell_t CreateThreadNative(IPluginContext *pContext, const cell_t *params)
{
	IPluginFunction *pfn = pContext->GetFunctionById(params[1]);
	CreateThread(0, 0, thr, pfn, 0, 0);
	return 0;
}
Testing this on arbitrary functions in a plugin seemingly works fine on some functions, gives the unclear "Plugin encountered error 17: Stack memory leaked by native" other times, and completely crashes the server other times again. Sourcemod can also no longer unload the plugin.

I'm not sure why the code I wrote causes this erratic behavior. Any help?
Miu 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 07:34.


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