Esempio n. 1
0
bool CBNCSUtilInterface :: HELP_SID_AUTH_CHECK( bool TFT, string war3Path, string keyROC, string keyTFT, string valueStringFormula, string mpqFileName, BYTEARRAY clientToken, BYTEARRAY serverToken )
{
	// set m_EXEVersion, m_EXEVersionHash, m_EXEInfo, m_InfoROC, m_InfoTFT

	string FileWar3EXE = war3Path + "war3.exe";
	string FileStormDLL = war3Path + "Storm.dll";

	if( !UTIL_FileExists( FileStormDLL ) )
		FileStormDLL = war3Path + "storm.dll";

	string FileGameDLL = war3Path + "game.dll";
	bool ExistsWar3EXE = UTIL_FileExists( FileWar3EXE );
	bool ExistsStormDLL = UTIL_FileExists( FileStormDLL );
	bool ExistsGameDLL = UTIL_FileExists( FileGameDLL );

	if( ExistsWar3EXE && ExistsStormDLL && ExistsGameDLL )
	{
		// todotodo: check getExeInfo return value to ensure 1024 bytes was enough

		char buf[1024];
		uint32_t EXEVersion;
		getExeInfo( FileWar3EXE.c_str( ), (char *)&buf, 1024, (uint32_t *)&EXEVersion, BNCSUTIL_PLATFORM_X86 );
		m_EXEInfo = buf;
		m_EXEVersion = UTIL_CreateByteArray( EXEVersion, false );
		uint32_t EXEVersionHash;
		checkRevisionFlat( valueStringFormula.c_str( ), FileWar3EXE.c_str( ), FileStormDLL.c_str( ), FileGameDLL.c_str( ), extractMPQNumber( mpqFileName.c_str( ) ), (unsigned long *)&EXEVersionHash );
		m_EXEVersionHash = UTIL_CreateByteArray( EXEVersionHash, false );
		m_KeyInfoROC = CreateKeyInfo( keyROC, UTIL_ByteArrayToUInt32( clientToken, false ), UTIL_ByteArrayToUInt32( serverToken, false ) );

		if( TFT )
			m_KeyInfoTFT = CreateKeyInfo( keyTFT, UTIL_ByteArrayToUInt32( clientToken, false ), UTIL_ByteArrayToUInt32( serverToken, false ) );

		if( m_KeyInfoROC.size( ) == 36 && ( !TFT || m_KeyInfoTFT.size( ) == 36 ) )
			return true;
		else
		{
			if( m_KeyInfoROC.size( ) != 36 )
				CONSOLE_Print( "[BNCSUI] unable to create ROC key info - invalid ROC key" );

			if( TFT && m_KeyInfoTFT.size( ) != 36 )
				CONSOLE_Print( "[BNCSUI] unable to create TFT key info - invalid TFT key" );
		}
	}
	else
	{
		if( !ExistsWar3EXE )
			CONSOLE_Print( "[BNCSUI] unable to open [" + FileWar3EXE + "]" );

		if( !ExistsStormDLL )
			CONSOLE_Print( "[BNCSUI] unable to open [" + FileStormDLL + "]" );

		if( !ExistsGameDLL )
			CONSOLE_Print( "[BNCSUI] unable to open [" + FileGameDLL + "]" );
	}

	return false;
}
PIN_GameControllerKeyInfo PIN_GameControllerManager::GenerateKeyInfo(PIN_String strKey)
{
    printf("\t\tGenerateKeyInfo '%s'...\n",strKey);
    SDL_GameControllerButton btn = SDL_GameControllerGetButtonFromString(strKey);

    if(btn != SDL_CONTROLLER_BUTTON_INVALID)
    {
        printf("\t\t\tType BUTTON\n");
        return CreateKeyInfo(PIN_GKT_BUTTON,btn,SDL_CONTROLLER_AXIS_INVALID);
    }
    printf("\t\t\tNot a button. Checking if it's an axis...\n");
    boost::cmatch what;
    if(boost::regex_match(strKey, what, _regexAxisString))
    {
        printf("\t\t\tType AXIS\n");
        std::string strfAxis = what["func"].str();
        PIN_String fAxis = strfAxis.c_str();

        std::string strAxis = what["axis"].str();
        PIN_String axis = strAxis.c_str();

        SDL_GameControllerAxis ax = SDL_GameControllerGetAxisFromString(axis);

        PIN_GameControllerAxisDirection direction = PIN_GAD_BOTH;

        printf("\t\t\tAxis function for '%s' is '%s'\n",strKey, fAxis);

        if(boost::equals(fAxis, "POS"))
        {
            direction = PIN_GAD_POSITIVE;
            printf("\t\t\tDirection POSITIVE\n");
        }
        else if(boost::equals(fAxis, "NEG"))
        {
            direction = PIN_GAD_NEGATIVE;
            printf("\t\t\tDirection NEGATIVE\n");
        }
        else
        {
            printf("\t\t\tDirection BOTH\n");
        }

        return CreateKeyInfo(PIN_GKT_AXIS,SDL_CONTROLLER_BUTTON_INVALID,ax,direction);
    }
    else
    {
        printf("\t\t\tKey '%s' is INVALID!\n",strKey);
        return CreateKeyInfo(PIN_GKT_BUTTON,SDL_CONTROLLER_BUTTON_INVALID,SDL_CONTROLLER_AXIS_INVALID);
    }

}