当前位置: 首页>>代码示例>>C++>>正文


C++ UTIL_CreateByteArray函数代码示例

本文整理汇总了C++中UTIL_CreateByteArray函数的典型用法代码示例。如果您正苦于以下问题:C++ UTIL_CreateByteArray函数的具体用法?C++ UTIL_CreateByteArray怎么用?C++ UTIL_CreateByteArray使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了UTIL_CreateByteArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SendAuthAccept

BYTEARRAY CPUBProtocol :: SendAuthAccept( string login, string pass, string key, deque<CBotData> BotList )
{
    BYTEARRAY packet;

    packet.push_back( PUB_HEADER_CONSTANT );		// Auth header  1 byte
    packet.push_back( PUB_AUTH_ACCEPT );           // 1 byte

    packet.push_back( 0 ); // assign later
    packet.push_back( 0 ); // assign later

    packet.push_back( login.size( ) ); // 1 byte
    UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (unsigned char *)login.c_str( ), login.size( ) )); //

    packet.push_back( BotList.size() ); // 1 byte

    for (uint32_t i = 0; i < BotList.size(); i++)
    {
        packet.push_back(BotList[i].bot_ip.size( ));

        UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (unsigned char *)BotList[i].bot_ip.c_str( ), BotList[i].bot_ip.size( ) ));
        UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (uint16_t)(0) , false));
        UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (uint16_t)(BotList[i].bot_gameport) , false));
    }

    packet.push_back( key.size( ) ); // 1 byte
    UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (unsigned char *)key.c_str( ), key.size( ) ));

    AssignLength(packet);

    return packet;
}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:31,代码来源:pubprotocol.cpp

示例2: GetExternalIP

BYTEARRAY CPotentialPlayer :: GetExternalIP( )
{
	unsigned char Zeros[] = { 0, 0, 0, 0 };
	BYTEARRAY IP;

	if( m_Socket )
	{
		bool local=false;
		IP=	m_Socket->GetIP( );
		if (IP.size()>=2)
		{
			if (IP[0]==10 && IP[1]==0)
				local=true;
			if (IP[0]==10 && IP[1]==1)
				local=true;
			if (IP[0]==192 && IP[1]==168)
				local=true;
			if (IP[0]==169 && IP[1]==254)
				local=true;
			if (IP[0]==8 && IP[1]==0)
				local=true;
			if (IP[0]==5)
				local=true;
		}
		if (local && !m_Game->m_Config->m_ExternalIP.empty())
		{
			IP=UTIL_CreateByteArray(m_Game->m_GHost->m_ExternalIPL,true);
		}
		return IP;
	}

	return UTIL_CreateByteArray( Zeros, 4 );
}
开发者ID:RiseCakoPlusplus,项目名称:brtGHost,代码行数:33,代码来源:gameplayer.cpp

示例3: GetGarenaIP

BYTEARRAY CPotentialPlayer :: GetGarenaIP( )
{
    if( m_IncomingGarenaUser == NULL ) {
        return UTIL_CreateByteArray( (uint32_t) 0, true );
    } else {
        return UTIL_CreateByteArray( m_IncomingGarenaUser->GetIP( ), true );
    }
}
开发者ID:m-unkel,项目名称:OHSystem,代码行数:8,代码来源:gameplayer.cpp

示例4: HELP_SID_AUTH_CHECK

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;
}
开发者ID:Artyom91,项目名称:OHBot,代码行数:57,代码来源:bncsutilinterface.cpp

示例5: ExtractPackets

void CBNLSClient :: ExtractPackets( )
{
	string *RecvBuffer = m_Socket->GetBytes( );
	BYTEARRAY Bytes = UTIL_CreateByteArray( (unsigned char *)RecvBuffer->c_str( ), RecvBuffer->size( ) );

	while( Bytes.size( ) >= 3 )
	{
		uint16_t Length = UTIL_ByteArrayToUInt16( Bytes, false );

		if( Length >= 3 )
		{
			if( Bytes.size( ) >= Length )
			{
				m_Packets.push( new CCommandPacket( 0, Bytes[2], BYTEARRAY( Bytes.begin( ), Bytes.begin( ) + Length ) ) );
				*RecvBuffer = RecvBuffer->substr( Length );
				Bytes = BYTEARRAY( Bytes.begin( ) + Length, Bytes.end( ) );
			}
			else
				return;
		}
		else
		{
			CONSOLE_Print( "[BNLSC: " + m_Server + ":" + UTIL_ToString( m_Port ) + ":C" + UTIL_ToString( m_WardenCookie ) + "] error - received invalid packet from BNLS server (bad length), disconnecting" );
			m_Socket->Disconnect( );
			return;
		}
	}
}
开发者ID:NetCreator,项目名称:GHostPP,代码行数:28,代码来源:bnlsclient.cpp

示例6: SEND_W3GS_MAPPART

BYTEARRAY CGameProtocol :: SEND_W3GS_MAPPART( unsigned char fromPID, unsigned char toPID, uint32_t start, string *mapData )
{
	unsigned char Unknown[] = { 1, 0, 0, 0 };

	BYTEARRAY packet;

	if( start < mapData->size( ) )
	{
		packet.push_back( W3GS_HEADER_CONSTANT );				// W3GS header constant
		packet.push_back( W3GS_MAPPART );						// W3GS_MAPPART
		packet.push_back( 0 );									// packet length will be assigned later
		packet.push_back( 0 );									// packet length will be assigned later
		packet.push_back( toPID );								// to PID
		packet.push_back( fromPID );							// from PID
		UTIL_AppendByteArray( packet, Unknown, 4 );				// ???
		UTIL_AppendByteArray( packet, start, false );			// start position

		// calculate end position (don't send more than 1442 map bytes in one packet)

		uint32_t End = start + 1442;

		if( End > mapData->size( ) )
			End = mapData->size( );

		// calculate crc
		CCRC32* m_CRC = new CCRC32( );
		m_CRC->Initialize( );

		BYTEARRAY crc32 = UTIL_CreateByteArray( m_CRC->FullCRC( (unsigned char *)mapData->c_str( ) + start, End - start ), false );
		UTIL_AppendByteArray( packet, crc32 );

		delete m_CRC;

		// map data

		BYTEARRAY Data = UTIL_CreateByteArray( (unsigned char *)mapData->c_str( ) + start, End - start );
		UTIL_AppendByteArray( packet, Data );
		AssignLength( packet );
	}
	else
		CONSOLE_Print( "[GAMEPROTO] invalid parameters passed to SEND_W3GS_MAPPART" );

	// DEBUG_Print( "SENT W3GS_MAPPART" );
	// DEBUG_Print( packet );
	return packet;
}
开发者ID:RiseCakoPlusplus,项目名称:brtGHost,代码行数:46,代码来源:gameprotocol.cpp

示例7: Update

bool CPotentialPlayer :: Update( void *fd )
{
	if( m_DeleteMe )
		return true;

	if( !m_Socket )
		return false;

	m_Socket->DoRecv( (fd_set *)fd );
	
	// extract as many packets as possible from the socket's receive buffer and process them

	string *RecvBuffer = m_Socket->GetBytes( );
	BYTEARRAY Bytes = UTIL_CreateByteArray( (unsigned char *)RecvBuffer->c_str( ), RecvBuffer->size( ) );

	// a packet is at least 4 bytes so loop as long as the buffer contains 4 bytes

	while( Bytes.size( ) >= 4 )
	{
		if( Bytes[0] == W3GS_HEADER_CONSTANT || Bytes[0] == GPS_HEADER_CONSTANT )
		{
			// bytes 2 and 3 contain the length of the packet

			uint16_t Length = UTIL_ByteArrayToUInt16( Bytes, false, 2 );

			if( Length >= 4 )
			{
				if( Bytes.size( ) >= Length )
				{
                                        if( Bytes[0] == W3GS_HEADER_CONSTANT && Bytes[1] == CGameProtocol :: W3GS_REQJOIN )
                                        {
                                                delete m_IncomingJoinPlayer;
                                                m_IncomingJoinPlayer = m_Protocol->RECEIVE_W3GS_REQJOIN( BYTEARRAY( Bytes.begin( ), Bytes.begin( ) + Length ) );

                                                if( m_IncomingJoinPlayer )
                                                        m_Game->EventPlayerJoined( this, m_IncomingJoinPlayer );

                                                // this is the packet which interests us for now, the remaining is left for CGamePlayer

                                                *RecvBuffer = RecvBuffer->substr( Length );
                                                Bytes = BYTEARRAY( Bytes.begin( ) + Length, Bytes.end( ) );
                                                break;
                                        }

					*RecvBuffer = RecvBuffer->substr( Length );
					Bytes = BYTEARRAY( Bytes.begin( ) + Length, Bytes.end( ) );
				}
				else
					break;
			}
		}
	}        

	// don't call DoSend here because some other players may not have updated yet and may generate a packet for this player
	// also m_Socket may have been set to NULL during ProcessPackets but we're banking on the fact that m_DeleteMe has been set to true as well so it'll short circuit before dereferencing

	return m_DeleteMe || !m_Socket->GetConnected( ) || m_Socket->HasError( );
}
开发者ID:NoodleBoy,项目名称:aura-bot,代码行数:58,代码来源:gameplayer.cpp

示例8: HELP_PvPGNPasswordHash

bool CBNCSUtilInterface :: HELP_PvPGNPasswordHash( string userPassword )
{
	// set m_PvPGNPasswordHash

	char buf[20];
	hashPassword( userPassword.c_str( ), buf );
	m_PvPGNPasswordHash = UTIL_CreateByteArray( (unsigned char *)buf, 20 );
	return true;
}
开发者ID:SparkoPro,项目名称:ghostnordicleague,代码行数:9,代码来源:bncsutilinterface.cpp

示例9: GetExternalIP

BYTEARRAY CPotentialPlayer :: GetExternalIP( )
{
	unsigned char Zeros[] = { 0, 0, 0, 0 };

	if( m_Socket )
		return m_Socket->GetIP( );

	return UTIL_CreateByteArray( Zeros, 4 );
}
开发者ID:4RtY,项目名称:ghostpp,代码行数:9,代码来源:gameplayer.cpp

示例10: HELP_SID_AUTH_ACCOUNTLOGONPROOF

bool CBNCSUtilInterface :: HELP_SID_AUTH_ACCOUNTLOGONPROOF( BYTEARRAY salt, BYTEARRAY serverKey )
{
	// set m_M1

	char buf[20];
	// nls_get_M1( (nls_t *)m_nls, buf, string( serverKey.begin( ), serverKey.end( ) ).c_str( ), string( salt.begin( ), salt.end( ) ).c_str( ) );
	( (NLS *)m_NLS )->getClientSessionKey( buf, string( salt.begin( ), salt.end( ) ).c_str( ), string( serverKey.begin( ), serverKey.end( ) ).c_str( ) );
	m_M1 = UTIL_CreateByteArray( (unsigned char *)buf, 20 );
	return true;
}
开发者ID:SparkoPro,项目名称:ghostnordicleague,代码行数:10,代码来源:bncsutilinterface.cpp

示例11: HELP_SID_AUTH_ACCOUNTLOGON

bool CBNCSUtilInterface :: HELP_SID_AUTH_ACCOUNTLOGON( )
{
	// set m_ClientKey

	char buf[32];
	// nls_get_A( (nls_t *)m_nls, buf );
	( (NLS *)m_NLS )->getPublicKey( buf );
	m_ClientKey = UTIL_CreateByteArray( (unsigned char *)buf, 32 );
	return true;
}
开发者ID:SparkoPro,项目名称:ghostnordicleague,代码行数:10,代码来源:bncsutilinterface.cpp

示例12: SendRealName

BYTEARRAY CPUBProtocol :: SendRealName( const string login, const string& key )
{
    BYTEARRAY packet;

    packet.push_back( PUB_HEADER_CONSTANT );		// Auth header  1 byte
    packet.push_back( PUB_AUTH_NAME );           // 1 byte

    packet.push_back( 0 );           // 1 byte
    packet.push_back( 0 );           // 1 byte

    packet.push_back( login.size() );
    UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (unsigned char *)login.c_str( ), login.size( ) ));

    packet.push_back( key.size() );
    UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (unsigned char *)key.c_str( ), key.size( ) ));

    AssignLength(packet);

    return packet;
}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:20,代码来源:pubprotocol.cpp

示例13: DoRecv

void CTCPSocket :: DoRecv( fd_set *fd )
{
	if( m_Socket == INVALID_SOCKET || m_HasError || !m_Connected )
		return;

	if( FD_ISSET( m_Socket, fd ) )
	{
		// data is waiting, receive it

		char buffer[1024];
		int c = recv( m_Socket, buffer, 1024, 0 );

		if( c == SOCKET_ERROR && GetLastError( ) != EWOULDBLOCK )
		{
			// receive error

			m_HasError = true;
			m_Error = GetLastError( );

			if (m_isConsolePrint)
				CONSOLE_Print( "[TCPSOCKET] error (recv) - " + GetErrorString( ) );

			return;
		}
		else if( c == 0 )
		{
			// the other end closed the connection

			if (m_isConsolePrint)
				CONSOLE_Print( "[TCPSOCKET] closed by remote host" );

			m_Connected = false;
		}
		else if( c > 0 )
		{
			// success! add the received data to the buffer

			if( !m_LogFile.empty( ) )
			{
				ofstream Log;
				Log.open( m_LogFile.c_str( ), ios :: app );

				if( !Log.fail( ) )
				{
					Log << "					RECEIVE <<< " << UTIL_ByteArrayToHexString( UTIL_CreateByteArray( (unsigned char *)buffer, c ) ) << endl;
					Log.close( );
				}
			}

			m_RecvBuffer += string( buffer, c );
			m_LastRecv = GetTime( );
		}
	}
}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:54,代码来源:socket.cpp

示例14: CreateKeyInfo

BYTEARRAY CBNCSUtilInterface :: CreateKeyInfo( string key, uint32_t clientToken, uint32_t serverToken )
{
	unsigned char Zeros[] = { 0, 0, 0, 0 };
	BYTEARRAY KeyInfo;
	CDKeyDecoder Decoder( key.c_str( ), key.size( ) );

	if( Decoder.isKeyValid( ) )
	{
		UTIL_AppendByteArray( KeyInfo, UTIL_CreateByteArray( (uint32_t)key.size( ), false ) );
		UTIL_AppendByteArray( KeyInfo, UTIL_CreateByteArray( Decoder.getProduct( ), false ) );
		UTIL_AppendByteArray( KeyInfo, UTIL_CreateByteArray( Decoder.getVal1( ), false ) );
		UTIL_AppendByteArray( KeyInfo, UTIL_CreateByteArray( Zeros, 4 ) );
		size_t Length = Decoder.calculateHash( clientToken, serverToken );
		char *buf = new char[Length];
		Length = Decoder.getHash( buf );
		UTIL_AppendByteArray( KeyInfo, UTIL_CreateByteArray( (unsigned char *)buf, Length ) );
		delete [] buf;
	}

	return KeyInfo;
}
开发者ID:SparkoPro,项目名称:ghostnordicleague,代码行数:21,代码来源:bncsutilinterface.cpp

示例15: sha1

string sha1(const string& input)
{
    SHA1.Reset();
    SHA1.Update((unsigned char *)input.c_str(), input.size());
    SHA1.Final();
    unsigned char uResult[20];
    SHA1.GetHash(uResult);

    BYTEARRAY MapSHA1 = UTIL_CreateByteArray( uResult, 20 );
    string sResult = UTIL_ByteArrayToHexStringWithoutSpaces(MapSHA1);

    return sResult;
}
开发者ID:RiseCakoPlusplus,项目名称:brtGHost,代码行数:13,代码来源:util.cpp


注:本文中的UTIL_CreateByteArray函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。