增加ACE安全测试工程
This commit is contained in:
@@ -0,0 +1,170 @@
|
||||
#include "stdafx.h"
|
||||
#include "MainDialog.h"
|
||||
|
||||
#include "AceReportInterface.h"
|
||||
|
||||
#include <tlhelp32.h>
|
||||
#include <psapi.h>
|
||||
|
||||
LRESULT CMainDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
CenterWindow(GetParent());
|
||||
if(m_gameClient.init()==false)
|
||||
{
|
||||
MessageBoxA("Failed to init Ace SDK client interface!", "Error", MB_OK|MB_ICONERROR);
|
||||
CloseDialog(IDCANCEL);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
CloseDialog(wID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
CloseDialog(wID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CMainDialog::CloseDialog(int nVal)
|
||||
{
|
||||
m_gameClient.deinit();
|
||||
DestroyWindow();
|
||||
::PostQuitMessage(nVal);
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
if(wParam==101)
|
||||
{
|
||||
m_gameClient.tick();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnConnectToGameServer(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
m_gameClient.connectToGameServer("127.0.0.1", 2025);
|
||||
this->SetTimer(101, 100, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnDisconnectToGameServer(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
this->KillTimer(101);
|
||||
m_gameClient.disconnectFromGameServer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnSendUGCContent(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
// To be implemented
|
||||
wchar_t wszUgcContent[2048];
|
||||
::GetDlgItemTextW(m_hWnd, IDC_EDIT_UGC_CONTENT, wszUgcContent, sizeof(wszUgcContent)/sizeof(wchar_t));
|
||||
|
||||
char szUtf8UgcContent[2048] = { 0 };
|
||||
::WideCharToMultiByte(CP_UTF8, 0, wszUgcContent, -1, szUtf8UgcContent, sizeof(szUtf8UgcContent), NULL, NULL);
|
||||
|
||||
m_gameClient.sendUGCContent(101, szUtf8UgcContent);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnSendReport(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
ACEReport* reportInterface = m_gameClient.getAceReportInterface();
|
||||
|
||||
auto ctx = reportInterface->createReportContext(
|
||||
"reporter_account",
|
||||
1,
|
||||
"reported_name",
|
||||
"reported_roleid",
|
||||
ACEReportScene::REPORT_SCENE_UGC,
|
||||
ACEReportCategory::REPORT_CATEGORY_BEHAVIOR,
|
||||
ACEReportReasonArray{ ACEReportReason::REPORT_REASON_ILLEGAL_ABUSE, ACEReportReason::REPORT_REASON_ILLEGAL_ADVERTISEMENT },
|
||||
DNF_REPORT_ENTRANCE_TEST
|
||||
);
|
||||
|
||||
reportInterface->uploadReport(ctx, [this](ACEReportContext ctx, int32_t result, const char* error_message) {
|
||||
if (result == 0) {
|
||||
::MessageBoxA(m_hWnd, "Report uploaded successfully!", "Info", MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
else {
|
||||
::MessageBoxA(m_hWnd, error_message, "Error", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
}
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnNetbarClientLoad(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
TencentNetbarInterface* netbarInterface = m_gameClient.getNetbarInterface();
|
||||
netbarInterface->beginRequestNetbarStatus(
|
||||
[this](TencentNetbarInterface::RequestStatus status)
|
||||
{
|
||||
// Handle the request status update here
|
||||
switch (status) {
|
||||
case TencentNetbarInterface::RS_RequestDone:
|
||||
::MessageBoxA(m_hWnd, "Netbar status request completed successfully!", "Info", MB_OK | MB_ICONINFORMATION);
|
||||
break;
|
||||
case TencentNetbarInterface::RS_ReqestFailed:
|
||||
::MessageBoxA(m_hWnd, "Netbar status request failed!", "Error", MB_OK | MB_ICONERROR);
|
||||
break;
|
||||
default:
|
||||
// Other statuses can be handled as needed
|
||||
break;
|
||||
}
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IsProcessRunning(DWORD pid)
|
||||
{
|
||||
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (hSnapshot == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PROCESSENTRY32 pe;
|
||||
pe.dwSize = sizeof(PROCESSENTRY32);
|
||||
|
||||
bool isRunning = false;
|
||||
if (Process32First(hSnapshot, &pe)) {
|
||||
do {
|
||||
if (pe.th32ProcessID == pid) {
|
||||
isRunning = true;
|
||||
break;
|
||||
}
|
||||
} while (Process32Next(hSnapshot, &pe));
|
||||
}
|
||||
|
||||
CloseHandle(hSnapshot);
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
LRESULT CMainDialog::OnCheckMainPlayProcess(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
wchar_t wszPid[64];
|
||||
::GetDlgItemTextW(m_hWnd, IDC_EDIT_MAINPLAY_PID, wszPid, sizeof(wszPid)/sizeof(wchar_t));
|
||||
DWORD pid = _wtoi(wszPid);
|
||||
if (pid == 0)
|
||||
{
|
||||
::MessageBoxA(m_hWnd, "Invalid PID!", "Error", MB_OK | MB_ICONERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool isRunning = IsProcessRunning(pid);
|
||||
if (isRunning)
|
||||
{
|
||||
::MessageBoxA(m_hWnd, "MainPlay process is running.", "Info", MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
::MessageBoxA(m_hWnd, "MainPlay process is not running.", "Info", MB_OK | MB_ICONSTOP);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user