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

Call Signature


Post New Thread Reply   
 
Thread Tools Display Modes
Accelerator
Senior Member
Join Date: Dec 2010
Location: Russia
Old 06-01-2017 , 03:14   Re: Call Signature
Reply With Quote #11

Quote:
Originally Posted by asherkin View Post
The type of a pointer doesn't matter, your problem is calling conventions.
If you look at the source for my Connect extension there are some examples in there you can copy.
I would be glad, but Server not avalible (http://hg.limetech.org/projects/connect)

Last edited by Accelerator; 06-01-2017 at 03:18.
Accelerator is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-01-2017 , 03:29   Re: Call Signature
Reply With Quote #12

Quote:
Originally Posted by Accelerator74 View Post
I would be glad, but Server not avalible (http://hg.limetech.org/projects/connect)
Whoops.

https://github.com/nikkiii/sourcemod.../extension.cpp

Search for SetSteamID.
__________________
asherkin is offline
Accelerator
Senior Member
Join Date: Dec 2010
Location: Russia
Old 06-01-2017 , 03:48   Re: Call Signature
Reply With Quote #13

I did it this way:
Code:
typedef int (*GetVersusCompletionFunc)(void *pGameRules, CBaseEntity* pPlayer);
GetVersusCompletionFunc g_pGetVersusCompletion = NULL;

int VersusCompletion::GetVersusCompletion(int client)
{
	void *pGameRules;
	if (!g_pSDKTools || !(pGameRules = g_pSDKTools->GetGameRules()))
	{
		g_pSM->LogError(myself, "Failed to find GameRules");
		return 0;
	}

	if(!g_pGetVersusCompletion) 
	{
		if( !g_pGameConf->GetMemSig("CTerrorGameRules_GetVersusCompletion", (void**)&g_pGetVersusCompletion) || !g_pGetVersusCompletion ) 
		{
			g_pSM->LogError(myself, "Can't resolve CTerrorGameRules_GetVersusCompletion signature");
			return 0;
		}
	}
	CBaseEntity *pPlayer = gamehelpers->ReferenceToEntity(client);
	if(!pPlayer) return 0;

	return g_pGetVersusCompletion(pGameRules, pPlayer);
}
==>> Crash

Tried to even use BinTools:
Code:
int VersusCompletion::GetVersusCompletion(int client)
{
	void *pGameRules;
	if (!g_pSDKTools || !(pGameRules = g_pSDKTools->GetGameRules()))
	{
		g_pSM->LogError(myself, "Failed to find GameRules");
		return 0;
	}

	CBaseEntity *pPlayer = gamehelpers->ReferenceToEntity(client);
	if(!pPlayer) return 0;
	
	static ICallWrapper *pWrapper = NULL;
	
	if (!pWrapper)
	{
		void *addr; 
		if( !g_pGameConf->GetMemSig("CTerrorGameRules_GetVersusCompletion", (void**)&addr) || !addr ) 
		{
			g_pSM->LogError(myself, "Can't resolve CTerrorGameRules_GetVersusCompletion signature");
			return 0;
		}
		
		PassInfo ret;
		ret.flags = PASSFLAG_BYVAL;
		ret.size = sizeof(int);
		ret.type = PassType_Basic;

		PassInfo pass[1];
		pass[0].flags = PASSFLAG_BYVAL;
		pass[0].size = sizeof(CBaseEntity *);
		pass[0].type = PassType_Basic;
		pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, &ret, pass, 1);
	}

	unsigned char vstk[sizeof(void *) + sizeof(CBaseEntity *)];
	unsigned char *vptr = vstk;

	*(void **)vptr = pGameRules;
	vptr += sizeof(void *);
	*(CBaseEntity **)vptr = pPlayer;

	cell_t retbuffer;
	pWrapper->Execute(vstk, &retbuffer);

	return retbuffer;
}
==>> Already crash...

Last edited by Accelerator; 06-01-2017 at 04:09.
Accelerator is offline
Accelerator
Senior Member
Join Date: Dec 2010
Location: Russia
Old 06-01-2017 , 04:59   Re: Call Signature
Reply With Quote #14

I found the reason. All because of the Left4Fix extension https://forums.alliedmods.net/showthread.php?t=219774.

Due to incorrect change of memory locations: https://github.com/spumer/Left4Fix/b...code_linux.cpp
Accelerator is offline
Reply


Thread Tools
Display Modes

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 09:17.


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