增加ACE安全测试工程
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
#include "stdafx.h"
|
||||
#include "AceClientInterface.h"
|
||||
|
||||
#include <ace_sdk_client.h>
|
||||
#include <ace_sdk_client_anti_cheat_core.h>
|
||||
#include <ace_sdk_protocol_binding.h>
|
||||
|
||||
bool AceClientInterface::init()
|
||||
{
|
||||
//init ace sdk client protocol binding
|
||||
m_protoBindingInitRetCode = AceProtocolBindingSDK::__ace_sdk_protocol_binding_init();
|
||||
if (m_protoBindingInitRetCode != ACE_SDK_RESULT_OK)
|
||||
{
|
||||
printf(">>ACE fail to init ace sdk client proto binding, ret : %d\n", m_protoBindingInitRetCode);
|
||||
//continue even failed...
|
||||
}
|
||||
printf(">>ACE SDK client proto binding init success.\n");
|
||||
|
||||
//init ace sdk
|
||||
AceSdkResult ret = ace_sdk_client_init();
|
||||
if(ret!= ACE_SDK_RESULT_OK)
|
||||
{
|
||||
printf(">>ACE fail to init ace sdk client, ret : %d\n", ret);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AceClientInterface::deinit()
|
||||
{
|
||||
AceSdkResult ret = ace_sdk_client_deinit();
|
||||
}
|
||||
|
||||
bool AceClientInterface::onServerLoginReply(const char* accountID, uint32_t worldID,
|
||||
const char* loginToken,
|
||||
const char* lightFeatureName, uint32_t lightFeatureDataCRC,
|
||||
const uint8_t* lightFeatureData, uint32_t lightFeatureDataLengh)
|
||||
{
|
||||
//call ace client login
|
||||
AceSdkResult ret = ace_sdk_client_log_in(
|
||||
accountID, ACE_SDK_ACCOUNT_TYPE_QQ,
|
||||
worldID, loginToken
|
||||
);
|
||||
if(ret != ACE_SDK_RESULT_OK)
|
||||
{
|
||||
printf(">>ACE fail to call ace_sdk_client_log_in, ret : %d\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
//call ace client light feature data
|
||||
AceProtocolBindingSDK::g__ace_sdk_on_receive_signature(
|
||||
lightFeatureName,
|
||||
lightFeatureData,
|
||||
lightFeatureDataLengh,
|
||||
lightFeatureDataCRC
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AceClientInterface::onServerLogout()
|
||||
{
|
||||
AceSdkResult ret = ace_sdk_client_log_out();
|
||||
if(ret != ACE_SDK_RESULT_OK)
|
||||
{
|
||||
printf(">>ACE fail to call ace_sdk_client_log_out, ret : %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AceClientInterface::getClientTickPacket(uint8_t* out_buffer, uint32_t& out_len)
|
||||
{
|
||||
int64_t timeNow = cyclone::sys_api::utc_time_now();
|
||||
if(timeNow - m_lastTickTime < 100ll*1000ll)
|
||||
{
|
||||
out_len = 0;
|
||||
return;
|
||||
}
|
||||
m_lastTickTime = timeNow;
|
||||
AceSdkClientPacket packet;
|
||||
AceSdkResult ret = ace_sdk_client_get_packet(&packet);
|
||||
if (ret == ACE_SDK_RESULT_OK)
|
||||
{
|
||||
printf(">>ACE ace_sdk_client_get_packet, len : %d\n", packet.len);
|
||||
out_len = packet.len;
|
||||
memcpy(out_buffer, packet.buffer, packet.len);
|
||||
}
|
||||
else
|
||||
{
|
||||
out_len = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AceClientInterface::onServerTickPacket(const uint8_t* input_buffer, uint32_t input_len)
|
||||
{
|
||||
AceSdkResult ret = ace_sdk_client_on_packet_received(input_buffer, input_len);
|
||||
if(ret != ACE_SDK_RESULT_OK)
|
||||
{
|
||||
printf(">>ACE fail to call ace_sdk_client_on_packet_received, ret : %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AceClientInterface::getProtoBindingData(uint8_t* bindDataBuf, uint32_t buffSize)
|
||||
{
|
||||
AceProtocolBindingSDK::AceSdkAntiDataInfo bindingData;
|
||||
memset(&bindingData, 0, sizeof(bindingData));
|
||||
|
||||
AceProtocolBindingSDK::g__ace_sdk_get_report_data3(&bindingData);
|
||||
uint32_t dataLength = bindingData.anti_data_len_;
|
||||
|
||||
if (bindingData.anti_data_len_ <= buffSize)
|
||||
{
|
||||
memcpy(bindDataBuf, bindingData.anti_data_, bindingData.anti_data_len_);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(">>ACE fail to get proto binding data, buffer size too small!\n");
|
||||
}
|
||||
|
||||
AceProtocolBindingSDK::g__ace_sdk_del_report_data(&bindingData);
|
||||
return dataLength;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user