增加ACE安全测试工程
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
#include "stdafx.h"
|
||||
#include "NetbarInterface.h"
|
||||
#include "iigw_api_client.h"
|
||||
#include "GameProto.h"
|
||||
#include "GameProto.pb.h"
|
||||
#include "GameClient.h"
|
||||
|
||||
TencentNetbarInterface::TencentNetbarInterface()
|
||||
{
|
||||
m_requestStatus.store(RS_NotRequest);
|
||||
m_workThread = NULL;
|
||||
m_netbarStatus = NS_Unknown;
|
||||
m_clientErrorCode = 0;
|
||||
m_serverErrorCode = 0;
|
||||
m_serverErrorMessage.clear();
|
||||
m_netbarLevel = -1;
|
||||
m_clientNetbarReq = new Game::NetbaraStatusReq();
|
||||
}
|
||||
|
||||
TencentNetbarInterface::~TencentNetbarInterface()
|
||||
{
|
||||
delete m_clientNetbarReq;
|
||||
m_clientNetbarReq = nullptr;
|
||||
}
|
||||
|
||||
void TencentNetbarInterface::init(GameClient* client)
|
||||
{
|
||||
m_client = client;
|
||||
}
|
||||
|
||||
void TencentNetbarInterface::tick()
|
||||
{
|
||||
switch (m_requestStatus)
|
||||
{
|
||||
case RequestStatus::RS_ClientRequest_Done:
|
||||
{
|
||||
m_client->sendProtobufMessage(GameProto::GAME_PROTO_NETBAR_REQ, m_clientNetbarReq);
|
||||
m_requestStatus = RequestStatus::RS_ServerRequesting;
|
||||
}
|
||||
break;
|
||||
|
||||
case RequestStatus::RS_ClientRequest_Failed:
|
||||
{
|
||||
m_requestStatus = RequestStatus::RS_ReqestFailed;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool TencentNetbarInterface::beginRequestNetbarStatus(RequestCallback callback)
|
||||
{
|
||||
if(m_requestStatus==RequestStatus::RS_RequestDone || m_requestStatus==RequestStatus::RS_ReqestFailed)
|
||||
{
|
||||
//already done
|
||||
if(callback)
|
||||
{
|
||||
callback(m_requestStatus.load());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(m_requestStatus != RequestStatus::RS_NotRequest)
|
||||
{
|
||||
//already requesting
|
||||
return false;
|
||||
}
|
||||
|
||||
m_requestStatus = RequestStatus::RS_ClientRequesting;
|
||||
|
||||
unsigned int threadID = 0;
|
||||
m_workThread = (HANDLE)_beginthreadex(NULL, 0, TencentNetbarInterface::_workingThreadEntry, this, 0,&threadID);
|
||||
if(m_workThread == NULL)
|
||||
{
|
||||
m_requestStatus = RequestStatus::RS_ClientRequest_Failed;
|
||||
return false;
|
||||
}
|
||||
m_requestCallback = callback;
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int TencentNetbarInterface::_workingThreadEntry(void* param)
|
||||
{
|
||||
TencentNetbarInterface* pThis = (TencentNetbarInterface*)param;
|
||||
if(pThis)
|
||||
{
|
||||
pThis->workThreadEntry();
|
||||
}
|
||||
::CloseHandle(pThis->m_workThread);
|
||||
pThis->m_workThread = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool TencentNetbarInterface::workThreadEntry()
|
||||
{
|
||||
HMODULE hNetbarDllHandle = NULL;
|
||||
bool isSuccess = false;
|
||||
|
||||
do {
|
||||
hNetbarDllHandle = ::LoadLibraryW(L"iigw_client_api.dll");
|
||||
if (hNetbarDllHandle == NULL)
|
||||
{
|
||||
m_clientErrorCode = GetLastError();
|
||||
m_requestStatus = RequestStatus::RS_ClientRequest_Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
//create interface
|
||||
iepm_qqwb::IQQNetbarIIGWPlugin *pProxy = iepm_qqwb::CreateQQNetbarIIGWPlugin(hNetbarDllHandle);
|
||||
if(pProxy == nullptr)
|
||||
{
|
||||
m_requestStatus = RequestStatus::RS_ClientRequest_Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
//call client interfae
|
||||
int ret = pProxy->IsNetbarMachine(TENCENT_NETBAR_DNF_CLIENT_GAME_ID, GameClient::s_default_account_id, iepm_qqwb::at_qq);
|
||||
bool isNetbar = (ret == IIGW_MSG_STATUS_NETBAR_PC);
|
||||
|
||||
iepm_qqwb::NetbarLv netbarlv = {0};
|
||||
memset(&netbarlv, 0, sizeof(netbarlv));
|
||||
|
||||
m_clientErrorCode = pProxy->ReqNetbarLv2(
|
||||
TENCENT_NETBAR_DNF_CLIENT_GAME_ID,
|
||||
GameClient::s_default_world_id,
|
||||
GameClient::s_default_account_id,
|
||||
iepm_qqwb::at_qq,
|
||||
nullptr,
|
||||
0,
|
||||
&netbarlv,
|
||||
5000
|
||||
);
|
||||
|
||||
if (m_clientErrorCode != 0 || netbarlv.tokenLen<=0 )
|
||||
{
|
||||
m_requestStatus = RequestStatus::RS_ClientRequest_Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
m_clientNetbarReq->Clear();
|
||||
m_clientNetbarReq->set_is_netbar_machine(isNetbar);
|
||||
m_clientNetbarReq->set_token((const char*)netbarlv.tokenBuff, (size_t)netbarlv.tokenLen);
|
||||
m_clientNetbarReq->set_macs(netbarlv.macs);
|
||||
|
||||
m_requestStatus = RequestStatus::RS_ClientRequest_Done;
|
||||
|
||||
isSuccess = true;
|
||||
} while (false);
|
||||
|
||||
if(hNetbarDllHandle)
|
||||
{
|
||||
::FreeLibrary(hNetbarDllHandle);
|
||||
hNetbarDllHandle = NULL;
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
void TencentNetbarInterface::onReceiveNetbarReportRequest(Game::NetbarStatusRes* response)
|
||||
{
|
||||
m_netbarLevel = response->netbar_level();
|
||||
m_serverErrorCode = response->error_code();
|
||||
m_serverErrorMessage = response->error_message();
|
||||
|
||||
if (m_serverErrorCode == 0)
|
||||
{
|
||||
m_serverErrorCode = NetbarStatus::NS_Netbar;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_serverErrorCode = NetbarStatus::NS_ServerFailed;
|
||||
}
|
||||
m_requestStatus = RequestStatus::RS_RequestDone;
|
||||
|
||||
if (m_requestCallback)
|
||||
{
|
||||
m_requestCallback(m_requestStatus);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user