Ir para conteúdo
Fórum Script Brasil
  • 0

Ajuda implementação Xtrap no meu primeiro Jogo.


KevinDavid

Pergunta

Olá pessoal !

Estou a tentar implantar um AntiCheat de nome Xtrap no meu primeiro jogo, porém, estou encontrando dificuldades na execução do mesmo sob o Xtrap.

Tenho o projeto do meu primeiro jogo, onde haveria o GameClientLauncher e o GameClientMain principais para a implementação, sendo assim, incluo o arquivo com o código do XtrapLauncher no meu GameClientLauncher e o mesmo não é iniciado após a inicialização do meu primeiro jogo após compilação. Meu código está escrito em VS90.

Ao iniciar o GameJoin.exe o jogo carrega normalmente, sem a atualização do Xtrap antes da execução real do GameJoin.exe

Quem puder contribuir a nível de informação e complemento dos meus estudos ficarei grato.

* Lembrando que os exemplos segue somente a linha do GameClientLauncher.

Segue o código do meu GameClientLauncher.cpp

#include "Xtrap4_Launcher.h"
#include "GameClientMain.h"
#include "GameClientPCH.h"
#include "GameClientLauncher.h"
#include "shlwapi.h"

namespace	NLauncher
{
	#define	TSTR_CMDARG_GIDX			_T("/gidx:")
	#define	TSTR_CMDARG_STRID			_T("/strid:")
	#define	TSTR_CMDARG_KEY				_T("/key:")
	#define TSTR_CMDARG_CONNECT_IP		_T("/connetip:")
	#define TSTR_CMDARG_CONNECT_PORT	_T("/connetport:")
	#define TSTR_CMDARG_CHANNEL_INDEX	_T("@")
	#define	TSTR_LAUNCHER_SETUP			_T("LauncherSetup.exe")
	#define	TSTR_LAUNCHER_EXE			_T("LaunchLinker.exe")
	#define	TSTR_SETUP_TEST_SERVER		_T("SetupTestServer.exe")

	#if	defined( _DEBUG )
		#define	_TSTR_GAMEJOIN_EXE	_T("GameJoin.exe")
	#else
		#define	_TSTR_GAMEJOIN_EXE	_T("GameJoin.exe")
	#endif


	void SetCmdLine( LPTSTR lpCmdLine )
	{
		size_t nSize = 0;
		TCHAR  szTemp[MAX_PATH] = _T("");
		TCHAR* lpNextToken = NULL;
		TCHAR* lpNextToken1 = NULL;

		lpCmdLine = ::_tcstok_s( lpCmdLine, _T(" "), &lpNextToken );

		do 
		{
			std::tstring strCmd = lpCmdLine;

			if( strCmd.find( TSTR_CMDARG_GIDX ) != std::tstring::npos )
			{
				nSize = _tcslen( TSTR_CMDARG_GIDX );
				_tcscpy_s( szTemp, _countof( szTemp ), &lpCmdLine[nSize] );
				m_stCmdArgs.nGameIdx = _ttoi( szTemp );
			}
			else if( strCmd.find( TSTR_CMDARG_STRID ) != std::tstring::npos )
			{
				nSize = _tcslen( TSTR_CMDARG_STRID );
				_tcscpy_s( m_stCmdArgs.szUserID, _countof( m_stCmdArgs.szUserID ), &lpCmdLine[nSize] );

				std::tstring strChannelIndex = m_stCmdArgs.szUserID;
				size_t nPos = strChannelIndex.find_first_of( TSTR_CMDARG_CHANNEL_INDEX );
				if( nPos == std::tstring::npos )
				{
					
					m_stCmdArgs.nChannelIdx = CT_GAMECLUB;
				}
				else
				{
					TCHAR szTemp[MAX_PATH] = _T("");
					_tcscpy_s( szTemp, _countof( szTemp ), &strChannelIndex.c_str()[nPos+1] );

					
					m_stCmdArgs.nChannelIdx = static_cast< EChannelType >( _ttoi( szTemp ) );
				}
			}
			else if( strCmd.find( TSTR_CMDARG_KEY ) != std::tstring::npos )
			{
				nSize = _tcslen( TSTR_CMDARG_KEY );
				_tcscpy_s( m_stCmdArgs.szKey, _countof( m_stCmdArgs.szKey ), &lpCmdLine[nSize] );
			}
			else if( strCmd.find( TSTR_CMDARG_CONNECT_IP ) != std::tstring::npos )
			{
				nSize = _tcslen( TSTR_CMDARG_CONNECT_IP );
				_tcscpy_s( m_stCmdArgs.szServerIp, _countof( m_stCmdArgs.szServerIp ), &lpCmdLine[nSize] );
			}
			else if( strCmd.find( TSTR_CMDARG_CONNECT_PORT ) != std::tstring::npos )
			{
				nSize = _tcslen( TSTR_CMDARG_CONNECT_PORT );
				_tcscpy_s( szTemp, _countof( szTemp ), &lpCmdLine[nSize] );
				m_stCmdArgs.nServerPort = _ttoi( szTemp );
			}
		} while ( ( lpCmdLine = ::_tcstok_s( NULL, _T(" "), &lpNextToken ) ) != NULL );

		m_eConnectType = _tcslen( m_stCmdArgs.szKey ) > 0 ? CT_WEB : CT_LAUNCHER;
	}

	WORD GetGameIdx()				{ return m_stCmdArgs.nGameIdx; }
	WORD GetServerPort()			{ return m_stCmdArgs.nServerPort; }
	LPCTSTR GetKey()				{ return m_stCmdArgs.szKey; }
	LPCTSTR GetUserID()				{ return m_stCmdArgs.szUserID; }
	LPCTSTR GetServerIp()			{ return m_stCmdArgs.szServerIp; }
	EConnectType GetConnectType()	{ return m_eConnectType; }
	EChannelType GetChannelType()	{ return m_stCmdArgs.nChannelIdx; }
	
	void CheckGUITextureOfLowLevelUse()		{ m_bUseGUITextureOfLowLevel = NUtil::CheckGUITextureOfLowLevelUse(); }
	bool GetGUITextureOfLowLevelUseFlag()	{ return false;}
	
	
	bool IsGameClientLaunching( LPTSTR lpCmdLine )
	{
		if ( lpCmdLine )
		{
			

			std::tstring strCmdLine = lpCmdLine;
			
			if ( strCmdLine.find( TSTR_CMDARG_GIDX ) == std::tstring::npos ) return false;
			if ( strCmdLine.find( TSTR_CMDARG_STRID) == std::tstring::npos ) return false;
			if ( strCmdLine.find( TSTR_CMDARG_KEY  ) == std::tstring::npos ) return false;

			return true;
		}

		return false;
	}

	
	bool IsLauncherInstalled()
	{
		DWORD dwType = 0;
		TCHAR achData[MAX_PATH] = { 0, };
		DWORD dwDataSize = MAX_PATH;

		LONG lReturn = SHGetValue(	HKEY_LOCAL_MACHINE,
									_T("SOFTWARE\\GameJoin\\Launcher"),
									_T("ProgramName"),
									&dwType,
									achData,
									&dwDataSize );
		if ( lReturn != ERROR_SUCCESS )
		{
			return false;
		}

		lReturn = SHGetValue(	HKEY_LOCAL_MACHINE,
								_T("SOFTWARE\\GameJoin\\Launcher"),
								_T("ProgramPath"),
								&dwType,
								achData,
								&dwDataSize );
		if ( lReturn != ERROR_SUCCESS )
		{
			return false;
		}

		return true;
	}

	//----------------------------------------------------------------------------
	/**
		@note
	 */
	//----------------------------------------------------------------------------
	bool IsSetupDevTestServer()
	{
		DWORD dwType = 0;
		DWORD dwData = 0;
		DWORD dwDataSize = sizeof( DWORD );

		LONG lReturn = SHGetValue(	HKEY_LOCAL_MACHINE,
									_T("SOFTWARE\\GameJoin\\GameJoin"),
									_T("SetupDevTestServer"),
									&dwType,
									&dwData,
									&dwDataSize );
		if ( lReturn != ERROR_SUCCESS )
		{
			return false;
		}

		if ( dwType != REG_DWORD )
		{
			return false;
		}

		return ( dwData == 1 );	
	}

	
	bool SetupDevTestServerKey()
	{
		DWORD dwType = REG_DWORD;
		DWORD dwData = 1;
		DWORD dwDataSize = sizeof( DWORD );

		LONG lReturn = SHSetValue(	HKEY_LOCAL_MACHINE,
									_T("SOFTWARE\\GameJoin\\GameJoin"),
									_T("SetupDevTestServer"),
									dwType,
									&dwData,
									dwDataSize );
		if ( lReturn != ERROR_SUCCESS )
		{
			return false;
		}

		return true;
	}

	
	bool ExecuteProcess( const TCHAR* pchFileName, const TCHAR* pchSubDir )
	{
		TCHAR chPathName[MAX_PATH] = { 0, };
		TCHAR* pchFileNamePos = 0;
		if ( GetFullPathName( pchFileName, MAX_PATH, chPathName, &pchFileNamePos ) )
		{
			*pchFileNamePos = 0;
			std::tstring strExecFile = chPathName;
			if ( pchSubDir )
			{
				strExecFile += pchSubDir;
				strExecFile += _T("\\");
			}
			strExecFile += pchFileName;

			HINSTANCE hInstance = ShellExecute( 0, _T("open"), strExecFile.c_str(), NULL, NULL, 0 );
			return ( int(hInstance) > 32 );
		}

		return false;
	}

	
	bool WaitExitForProcess( const TCHAR* pchFileName, const TCHAR* pchSubDir )
	{
		TCHAR chPathName[MAX_PATH] = { 0, };
		TCHAR* pchFileNamePos = 0;
		if ( GetFullPathName( pchFileName, MAX_PATH, chPathName, &pchFileNamePos ) )
		{
			*pchFileNamePos = 0;
			std::tstring strExecFile = chPathName;
			if ( pchSubDir )
			{
				strExecFile += pchSubDir;
				strExecFile += _T("\\");
			}
			strExecFile += pchFileName;

			_tcscpy( chPathName, strExecFile.c_str() );
			STARTUPINFO			si = { 0, };
			PROCESS_INFORMATION	pi = { 0, };
			BOOL bRet = CreateProcess(	NULL,
										chPathName,
										NULL,
										NULL,
										TRUE,
										0,
										NULL,
										NULL,
										&si,
										&pi );
			if ( bRet )
			{
				Sleep( 200 );
				WaitForSingleObject( pi.hProcess, INFINITE );

				return true;
			}
		}

		return false;
	}
	//----------------------------------------------------------------------------
	/**
	 *	@note
	 */
	//----------------------------------------------------------------------------
	bool CheckDevTestStartup( LPTSTR lpCmdLine )
	{
		
		if ( !IsGameClientLaunching( lpCmdLine ) )
		{
			
			{
				if ( !WaitExitForProcess( TSTR_LAUNCHER_SETUP, _T("System") ) )
				{
					GUI::TempString strMsg, strTitle;
					_GetGUIText( 101601312, strMsg );		
					_GetGUIText( 101601313, strTitle );		
					::MessageBox( 0, strMsg.c_str(), strTitle.c_str(), MB_OK );
					return false;
				}

				
			}
			
			
			if ( !ExecuteProcess( TSTR_LAUNCHER_EXE, 0 ) )
			{
				GUI::TempString strMsg, strTitle;
				_GetGUIText( 101601314, strMsg );		
				_GetGUIText( 101601315, strTitle );		
				::MessageBox( 0, strMsg.c_str(), strTitle.c_str(), MB_OK );
				return false;
			}

			
			return false;
		}
		else
		{
			
		}

		return true;
	}

}

 

Seguido da inclusão no GameClientLauncher:  Xtrap4_Launcher.h

#pragma comment(lib, "urlmon.lib")
#pragma comment(lib, "wininet.lib")
#include "urlmon.h"	

#pragma comment(lib, "XTrap4Launcher_mt.lib")
#pragma comment(lib, "XTrap4Launcher_mt.lib")
#pragma comment(lib, "XTrap4Launcher_mtDll.lib")
#include "XTrap4Launcher.h"

void OnBtGameStart()
{
CHAR szXTrapArg[] = "URL";



CHAR szGame[]	= "\\GameJoin.exe";
OSVERSIONINFO osvi	= {NULL,};
SHELLEXECUTEINFO sei	= { NULL,};
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
sei.cbSize	= sizeof(SHELLEXECUTEINFO); GetVersionEx(&osvi );
if(osvi.dwMajorVersion == 6) sei.lpVerb = "runas";

sei.lpFile	= sGameClient;
sei.nShow	= SW_SHOWNORMAL;

XTrap_L_Patch( szXTrapArg ,NULL ,60 );


ShellExecuteEx(&sei);


}

Seguida da inclusão do: Xtrap4_Launcher.h


#ifndef __XTRAPAPI_LAUNCHER_H
#define __XTRAPAPI_LAUNCHER_H

VOID XTrap_L_Patch(
	IN LPCSTR	lpArgv,
	IN LPCSTR	lpGamePath, 
	IN DWORD	dwTimeout
);

VOID XTrap_L_Patch(
	IN  LPCSTR	lpArgv, 
	IN  LPCSTR	lpGamePath, 
	IN  DWORD	dwTimeout, 
	OUT LPCSTR	pMsg, 
	OUT LPCSTR	pErrCode,
	OUT BOOL   *pErrFlag
);

#endif

 

Editado por KevinDavid
Correções...
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Se você está cansado do jogo e gostaria de diversificá-lo de alguma forma, mas não sabe como fazer isso, recomendo que você tente chamar sua atenção para este site https://dmarket.com/pt/ingame-items/item-list/csgo-skins/pistol/usp-s, pois foi aqui que consegui encontrar um bom lugar para comprar skins legais. Tenho certeza que você ficará satisfeito, assim como eu

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...