增加ACE安全测试工程

This commit is contained in:
2025-12-06 16:42:21 +08:00
parent b78ee53326
commit b38ad590a9
68 changed files with 5385 additions and 0 deletions
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,92 @@
#ifndef __ACE_SDK_ACCOUNT_H__
#define __ACE_SDK_ACCOUNT_H__
#include "ace_sdk_common.h"
#pragma pack(push, 1)
#ifndef ACE_SDK_ACCOUNT_TYPE_ENUM
#define ACE_SDK_ACCOUNT_TYPE_ENUM
typedef enum
{
ACE_SDK_ACCOUNT_TYPE_QQ = 1, // QQ Number
ACE_SDK_ACCOUNT_TYPE_WECHAT = 2, // WeChat Openid
ACE_SDK_ACCOUNT_TYPE_BAIDU = 3, // Baidu Account
ACE_SDK_ACCOUNT_TYPE_QQ_OPENID = 4, // QQ Openid
ACE_SDK_ACCOUNT_TYPE_VISITOR = 7, // Visitor
ACE_SDK_ACCOUNT_TYPE_GOPENID = 8, // Gopenid
ACE_SDK_ACCOUNT_TYPE_GOOGLE = 101, // Google Mail
ACE_SDK_ACCOUNT_TYPE_WEGAME_MAIL = 102, // Wegame Mail
ACE_SDK_ACCOUNT_TYPE_4399 = 201, // 4399
ACE_SDK_ACCOUNT_TYPE_GARENA = 202, // Garena
ACE_SDK_ACCOUNT_TYPE_GIANT_NETWORK = 203, // Giant Network
ACE_SDK_ACCOUNT_TYPE_WEGAME = 301, // WeGame Rail ID
ACE_SDK_ACCOUNT_TYPE_STEAM = 302, // Steam
ACE_SDK_ACCOUNT_TYPE_WEGAME_COMMON_ID = 308, // WeGame Common ID
ACE_SDK_ACCOUNT_TYPE_WOODUAN = 312, // WOODUAN
ACE_SDK_ACCOUNT_TYPE_VK = 314, // VK
ACE_SDK_ACCOUNT_TYPE_COMMON_ID = 601, // Common Account
ACE_SDK_ACCOUNT_TYPE_FACEBOOK = 1001, // Facebook
ACE_SDK_ACCOUNT_TYPE_SUPERCELL = 1002, // Supercell
ACE_SDK_ACCOUNT_TYPE_TCOMMIC = 1005, // Tcommic
ACE_SDK_ACCOUNT_TYPE_UPLAY = 1006, // Uplay
ACE_SDK_ACCOUNT_TYPE_PHONE_OPENID = 1014, // Telephone Openid
ACE_SDK_ACCOUNT_TYPE_LINE = 1019, // Line
ACE_SDK_ACCOUNT_TYPE_APPLE = 1020, // Apple
} AceSdkAccountType;
#endif
#ifndef ACE_SDK_ACCOUNT_PLAT_ENUM
#define ACE_SDK_ACCOUNT_PLAT_ENUM
typedef enum
{
ACE_SDK_PLAT_ID_IOS = 0, // IOS
ACE_SDK_PLAT_ID_ANDROID = 1, // Android
ACE_SDK_PLAT_ID_PC_CLIENT = 3, // PC
ACE_SDK_PLAT_ID_LINUX = 4, // Linux
ACE_SDK_PLAT_ID_SWITCH = 6, // Switch client
ACE_SDK_PLAT_ID_MAC = 7, // Mac
ACE_SDK_PLAT_ID_PS_CLIENT = 8, // PS client
ACE_SDK_PLAT_ID_XBOX_CLIENT = 9, // XBOX client
ACE_SDK_PLAT_ID_PC_EMULATOR_CLIENT = 11, // PC Emulator
ACE_SDK_PLAT_ID_HARMONY_MOBILE = 12, // Harmony Mobile
ACE_SDK_PLAT_ID_HARMONY_PC = 13, // Harmony PC
ACE_SDK_PLAT_ID_UNKNOWN = 99,
} AceSdkAccountPlatID;
#endif
#ifndef ACE_SDK_MAX_ACCOUNT_LEN
#define ACE_SDK_MAX_ACCOUNT_LEN 65
#endif
/**
* 1. Some fields below also require filling in on the client side, their consistency between client and server needs to be ensured.
*/
typedef struct
{
/**
* Player's account is a C-style string composed only of printable ascii characters(except spaces) and '\0' terminator.
* Player's account must be unique for the same 'game_id_'.
*/
char account_[ACE_SDK_MAX_ACCOUNT_LEN];
/**
* If it is not defined in 'AceSdkAccountType', fill it with 'AceSdkAccountType::ACE_SDK_ACCOUNT_TYPE_COMMON_ID'.
*/
AceSdkAccountType account_type_;
// Plat ID of player's client.
AceSdkAccountPlatID plat_id_;
// Contact ACE to obtain your game ID.
uint32_t game_id_;
/**
* For games with separate zones, please fill in the zone ID to uniquely identify a zone; for games without separate zones, please fill in 0.
*/
uint32_t world_id_;
} AceSdkAccount;
#pragma pack(pop)
#endif // __ACE_SDK_ACCOUNT_H__
@@ -0,0 +1,21 @@
#ifndef __ACE_SDK_CLIENT_H__
#define __ACE_SDK_CLIENT_H__
#include <stdint.h>
#include "ace_sdk_common.h"
#include "ace_sdk_account.h"
#include "ace_sdk_client_impl.h"
/**
* Initializes the ACE Client SDK.
* This function should be called before any other functions in the ACE Client SDK.
*/
AceSdkResult ace_sdk_client_init();
/**
* Should be called when the game process is exiting.
*/
AceSdkResult ace_sdk_client_deinit();
#endif
@@ -0,0 +1,52 @@
#ifndef __ACE_SDK_CLIENT_ANTI_CHEAT_CORE_H__
#define __ACE_SDK_CLIENT_ANTI_CHEAT_CORE_H__
#include <stdint.h>
#include "ace_sdk_common.h"
#include "ace_sdk_account.h"
#include "ace_sdk_client_impl.h"
/**
* This function should be called when the user logs in succesfully.
* @param account_id The GLOBALLY UNIQUE account ID. Its length must be less than or equal to 64 characters, and each must be printable ASCII characters except space.
* @param account_type Find the account type in AceSdkAccountType, or set to ACE_SDK_ACCOUNT_TYPE_COMMON_ID.
* @param world_id For games with multiple zones, set to the unique zone id, or set to 0.
* @param login_ticket The login ticket. A C-style string which is transfered from the game server by ace_sdk_server_get_ticket() of the ACE server sdk.
* @note For each player, the first 3 parameters must be the same as the fields with same name in the server sdk.
*/
AceSdkResult ace_sdk_client_log_in(const char* account_id, AceSdkAccountType account_type, uint32_t world_id, const char* login_ticket);
/**
* Should be called when the user succesfully logs out from the server.
*/
AceSdkResult ace_sdk_client_log_out();
/** The packet buffer */
typedef struct __AceSdkClientPacket {
/** packer buffer */
uint8_t buffer[2048];
/** packet len */
uint32_t len;
} AceSdkClientPacket;
/**
* Should be called every 100ms once the game connects to the game server, and the packet should be sent through the relay channel.
* @param packet The packet buffer.
* @return ACE_SDK_RESULT_OK if there is a packet that need to be sent, and ACE_SDK_RESULT_NO_PACKET_NEED_SENDING if no packets need to be sent.
* @note This function is thread-safe.
*/
AceSdkResult ace_sdk_client_get_packet(AceSdkClientPacket* out_packet);
/**
* Should be called when game received a packet from the relay channel.
* @param packet Pointer to the packet buffer.
* @param len The length of the packet.
* @note This function is NOT thread-safe. Please call this function from a single thread, or ensure that the calls to this function are sequential and do not overlap.
*/
AceSdkResult ace_sdk_client_on_packet_received(const uint8_t* packet_buffer, uint32_t packet_len);
#endif
@@ -0,0 +1,166 @@
#ifndef __ACE_SDK_CLIENT_IMPL_H__
#define __ACE_SDK_CLIENT_IMPL_H__
#ifndef _WIN32
#error ACE Client SDK is only compatible with Windows programs now.
#endif
#include <stdint.h>
#include <string.h>
#include <windows.h>
#define STRSAFE_NO_DEPRECATE
#include <strsafe.h>
#include "ace_sdk_common.h"
#include "ace_sdk_account.h"
struct __AceSdkClientPacket;
struct __AceSdkClientLightFeaturePacket;
struct __AceSdkClientLightFeature;
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientLogInRoutine)(void*, const char*, uint32_t, uint32_t, const char*);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientLogOutRoutine)(void*);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientDeinitRoutine)(void*);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientGetPacketRoutine)(void*, struct __AceSdkClientPacket* out_packet);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientOnPacketReceivedRoutine)(void*, const uint8_t*, uint32_t);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientGetLightFeaturePacketRoutine)(void*, struct __AceSdkClientLightFeaturePacket*);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientOnLightFeatureReceivedRoutine)(void*, const struct __AceSdkClientLightFeature*);
typedef struct {
void* handle_;
void* deprecated1_;
__AceSdkClientLogOutRoutine log_out_;
__AceSdkClientDeinitRoutine deinit_;
__AceSdkClientGetPacketRoutine get_packet_;
__AceSdkClientOnPacketReceivedRoutine on_packet_received_;
__AceSdkClientLogInRoutine log_in_;
__AceSdkClientGetLightFeaturePacketRoutine get_light_feature_packet_;
__AceSdkClientOnLightFeatureReceivedRoutine on_light_feature_received_;
}__AceSdkClientObject;
typedef struct {
const ACE_CHAR* config_path_;
}__AceSdkClientInitParams;
#ifdef _MSC_VER
__declspec(selectany) __AceSdkClientObject* __ace_sdk_client_object = NULL;
#else
__attribute__((weak)) __AceSdkClientObject* __ace_sdk_client_object = NULL;
#endif
#define __ACE_SDK_CLIENT_VERSION 9
inline int32_t __ace_sdk_get_exe_mod_path(ACE_CHAR* path, uint32_t len)
{
uint32_t ret = GetModuleFileNameW(NULL, path, len);
if (ret == 0 || ret == len)
{
return -1;
}
ACE_CHAR* pos = wcsrchr(path, L'\\');
if (pos == NULL)
{
return -1;
}
*pos = L'\0';
return 0;
}
inline AceSdkResult ace_sdk_client_init()
{
ACE_CHAR full_path[1024];
if (__ace_sdk_get_exe_mod_path(full_path, ARRAYSIZE(full_path)) != 0)
{
return ACE_SDK_RESULT_CALC_PATH_FAILED;
}
#ifdef _WIN64
const ACE_CHAR* dll_path = L"\\AntiCheatExpert\\ACE-Base64.dll";
#else
const ACE_CHAR* dll_path = L"\\AntiCheatExpert\\x86\\ACE-Base32.dll";
#endif
if (FAILED(StringCchCatW(full_path, ARRAYSIZE(full_path), dll_path)))
{
return ACE_SDK_RESULT_CALC_PATH_FAILED;
}
int32_t ret = __ace_sdk_load_library(full_path);
if (ret != 0)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
typedef AceSdkResult(*InitRoutine)(uint32_t, const __AceSdkClientInitParams*, __AceSdkClientObject**);
InitRoutine init = (InitRoutine)__ace_sdk_get_symbol("InitAceClient5");
if (init == NULL)
{
__ace_sdk_unload_library();
return ACE_SDK_RESULT_SYMBOL_NOT_FOUND;
}
return init(__ACE_SDK_CLIENT_VERSION, NULL, &__ace_sdk_client_object);
}
inline AceSdkResult ace_sdk_client_log_in(const char* account_id, AceSdkAccountType account_type, uint32_t world_id, const char* login_token)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->log_in_(__ace_sdk_client_object->handle_, account_id, (uint32_t)account_type, world_id, login_token);
}
inline AceSdkResult ace_sdk_client_log_out()
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->log_out_(__ace_sdk_client_object->handle_);
}
inline AceSdkResult ace_sdk_client_deinit()
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
AceSdkResult ret = __ace_sdk_client_object->deinit_(__ace_sdk_client_object->handle_);
__ace_sdk_client_object = NULL;
return ret;
}
inline AceSdkResult ace_sdk_client_get_packet(struct __AceSdkClientPacket* out_packet)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->get_packet_(__ace_sdk_client_object->handle_, out_packet);
}
inline AceSdkResult ace_sdk_client_on_packet_received(const uint8_t* packet, uint32_t len)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->on_packet_received_(__ace_sdk_client_object->handle_, packet, len);
}
inline AceSdkResult ace_sdk_client_get_light_feature_packet(struct __AceSdkClientLightFeaturePacket* out_packet)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->get_light_feature_packet_(__ace_sdk_client_object->handle_, out_packet);
}
inline AceSdkResult ace_sdk_client_on_light_feature_received(const struct __AceSdkClientLightFeature* light_feature)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->on_light_feature_received_(__ace_sdk_client_object->handle_, light_feature);
}
#endif
@@ -0,0 +1,41 @@
#ifndef __ACE_SDK_CLIENT_LIGHT_FEATURE_H__
#define __ACE_SDK_CLIENT_LIGHT_FEATURE_H__
#include <stdint.h>
#include "ace_sdk_common.h"
#include "ace_sdk_account.h"
#include "ace_sdk_client_impl.h"
/** The light feature packet buffer */
typedef struct __AceSdkClientLightFeaturePacket {
/** packer buffer */
uint8_t buffer[1024];
/** packet len */
uint32_t len;
} AceSdkClientLightFeaturePacket;
/* The light feature info. All fields are transfered from the game server.
* See AceSdkLightFeatureResponse in ace_sdk_server_light_feature.h */
typedef struct __AceSdkClientLightFeature {
const char* name;
const uint8_t* data;
uint32_t data_len;
uint32_t crc;
} AceSdkClientLightFeature;
/**
* Should be called every time the client tries to send a packet to the game server.
* @param out_packet packet that should be bind to a game protocol to send to the game server.
*/
AceSdkResult ace_sdk_client_get_light_feature_packet(AceSdkClientLightFeaturePacket* out_packet);
/**
* Should be called when game received the light feature from the game server.
* @param data date received from the game server
*/
AceSdkResult ace_sdk_client_on_light_feature_received(const AceSdkClientLightFeature* data);
#endif
@@ -0,0 +1,234 @@
#ifndef __ACE_SDK_COMMON_H__
#define __ACE_SDK_COMMON_H__
#include <stdint.h>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <dlfcn.h>
#endif
#ifdef __cplusplus
#define ACE_EXTERN_C extern "C"
#else
#define ACE_EXTERN_C
#endif
#if defined(_WIN32) && !defined(_WIN64)
#define ACE_SDK_CALL __cdecl
#else
#define ACE_SDK_CALL
#endif
#ifdef _WIN32
typedef wchar_t ACE_CHAR;
#else
typedef char ACE_CHAR;
#endif
typedef enum
{
ACE_SDK_RESULT_OK = 0,
ACE_SDK_RESULT_NOT_SUPPORTED = 1,
ACE_SDK_RESULT_INVALID_PARAMETER = 2,
ACE_SDK_RESULT_CALC_PATH_FAILED = 3,
ACE_SDK_RESULT_LOAD_LIBRARY_FAILED = 4,
ACE_SDK_RESULT_UNLOAD_LIBRARY_FAILED = 5,
ACE_SDK_RESULT_SYMBOL_NOT_FOUND = 6,
ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED = 7,
ACE_SDK_RESULT_INTERNAL_ERROR = 8,
ACE_SDK_RESULT_ACCOUNT_TOO_LONG = 9,
ACE_SDK_RESULT_ACCOUNT_ILLEGAL_CHARACTER = 10,
ACE_SDK_RESULT_NO_PACKET_NEED_SENDING = 100,
ACE_SDK_RESULT_ILLEGAL_LOG_IN = 101,
ACE_SDK_RESULT_COMMON_END = 1000,
ACE_SDK_RESULT_DEVELOP_LANGUAGE_BEGIN = 10000,
ACE_SDK_RESULT_PACK_STRUCT_1BYTE_ERROR = 10001,
ACE_SDK_RESULT_UNPACK_STRUCT_1BYTE_ERROR = 10002,
ACE_SDK_RESULT_PACK_STRUCT_1BYTE_LEN_ERROR = 10003,
ACE_SDK_RESLUT_JAVA_JNI_BEGIN = 20001,
ACE_SDK_RESLUT_JAVA_JNI_ENV_NULL = 20002,
ACE_SDK_RESLUT_JAVA_JNI_JVM_NULL = 20003,
ACE_SDK_RESLUT_JAVA_JNI_JOBJECT_NULL = 20004,
ACE_SDK_RESLUT_JAVA_JNI_CLASS_NULL = 20005,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_DATA_FAILED = 20006,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_OFFSET_FAILED = 20007,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_CAPACITY_FAILED = 20008,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_LENGTH_ERROR = 20009,
// Array field must use the pre-defined length
ACE_SDK_RESLUT_JAVA_ARRAY_LENTGH_ERROR = 20010,
ACE_SDK_RESLUT_JAVA_JNI_END = 20100,
ACE_SDK_RESULT_DEVELOP_LANGUAGE_END = 99999,
ACE_SDK_RESULT_BUSI_INTERFACE_BEGIN = 100000,
ACE_SDK_RESLUT_LIGHT_FEATURE_BEGIN = 100001,
ACE_SDK_RESLUT_LIGHT_FEATURE_NOT_OPENED = 100002,
ACE_SDK_RESLUT_LIGHT_FEATURE_END = 100100,
ACE_SDK_RESLUT_UIC_BEGIN = 100101,
ACE_SDK_RESULT_UIC_TEXT_INTERF_CALL_FAILED = 100102,
ACE_SDK_RESULT_UIC_TEXT_CALLBACK_HAS_NOT_SET = 100103,
ACE_SDK_RESULT_UIC_PIC_INTERF_CALL_FAILED = 100104,
ACE_SDK_RESULT_UIC_PIC_CALLBACK_HAS_NOT_SET = 100105,
ACE_SDK_RESLUT_UIC_END = 100200,
ACE_SDK_RESULT_SAFEMODE_BEGIN = 100201,
ACE_SDK_RESULT_SAFEMODE_CALLBACK_HAS_NOT_SET = 100202,
ACE_SDK_RESULT_SAFEMODE_INTERF_CALL_FAILED = 100203,
ACE_SDK_RESULT_SAFEMODE_END = 100300,
ACE_SDK_RESULT_GAME_SESSION_BEGIN = 100301,
ACE_SDK_RESULT_GAME_SESSION_INTERF_CALL_FAILED = 100302,
ACE_SDK_RESULT_GAME_SESSION_END = 100400,
ACE_SDK_RESULT_BUSI_INTERFACE_END = 999999,
ACE_SDK_RESULT_MAX_INT32 = 0x7fffffff,
} AceSdkResult;
// ----------------------------------------------------
// Internal definitions and functions
// ----------------------------------------------------
#ifdef _WIN32
typedef HMODULE __ACE_SDK_MODULE;
#else
typedef void* __ACE_SDK_MODULE;
#endif
#if defined(ACE_CGO)
extern __ACE_SDK_MODULE __ace_sdk_global_module;
#elif defined(_WIN32) && defined(_MSC_VER)
__declspec(selectany) __ACE_SDK_MODULE __ace_sdk_global_module;
#else
__attribute__((weak)) __ACE_SDK_MODULE __ace_sdk_global_module;
#endif
#ifdef _WIN32
inline int32_t __ace_sdk_load_library_win(const ACE_CHAR* path)
{
if (__ace_sdk_global_module != NULL)
{
return ACE_SDK_RESULT_OK;
}
__ace_sdk_global_module = LoadLibraryW(path);
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
inline void* __ace_sdk_get_symbol_win(const char* symbol_name)
{
if (__ace_sdk_global_module == NULL)
{
return NULL;
}
void* func = (void*)GetProcAddress(__ace_sdk_global_module, symbol_name);
return func;
}
inline int32_t __ace_sdk_unload_library_win()
{
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_OK;
}
BOOL ret = FreeLibrary(__ace_sdk_global_module);
__ace_sdk_global_module = NULL;
return ret == TRUE ? ACE_SDK_RESULT_OK : ACE_SDK_RESULT_UNLOAD_LIBRARY_FAILED;
}
#else
inline int32_t __ace_sdk_load_library_linux(const ACE_CHAR* path)
{
char* error = NULL;
if (__ace_sdk_global_module != NULL)
{
return ACE_SDK_RESULT_OK;
}
__ace_sdk_global_module = dlopen(path, RTLD_NOW);
error = dlerror();
if (error)
{
fprintf(stderr, "Open shared library %s failed, %s.\n", path, error);
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
inline void* __ace_sdk_get_symbol_linux(const char* symbol_name)
{
void *func = NULL;
char *error = NULL;
if (__ace_sdk_global_module == NULL)
{
return NULL;
}
func = dlsym(__ace_sdk_global_module, symbol_name);
error = dlerror();
if (error)
{
fprintf(stderr, "dlsym failed, %s.\n", error);
return NULL;
}
return func;
}
inline int32_t __ace_sdk_unload_library_linux()
{
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_OK;
}
int32_t ret = dlclose(__ace_sdk_global_module);
__ace_sdk_global_module = NULL;
if (ret != 0)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
#endif
inline int32_t __ace_sdk_load_library(const ACE_CHAR* path)
{
#ifdef _WIN32
return __ace_sdk_load_library_win(path);
#else
return __ace_sdk_load_library_linux(path);
#endif
}
inline void* __ace_sdk_get_symbol(const char* symbol_name)
{
#ifdef _WIN32
return __ace_sdk_get_symbol_win(symbol_name);
#else
return __ace_sdk_get_symbol_linux(symbol_name);
#endif
}
inline int32_t __ace_sdk_unload_library()
{
#if defined(_WIN32)
return __ace_sdk_unload_library_win();
#else
return __ace_sdk_unload_library_linux();
#endif
}
#endif
@@ -0,0 +1,47 @@
#ifndef __ACE_SDK_PROTOCOL_BINDING_H__
#define __ACE_SDK_PROTOCOL_BINDING_H__
#include <stdint.h>
#include <stdio.h>
#define INIT_FUNC_KEY (0xaa55abca)
namespace AceProtocolBindingSDK
{
#pragma pack(push, 1)
struct AceSdkAntiDataInfo
{
unsigned int anti_data_len_; /* [in] length of anti data */
const unsigned char *anti_data_; /* [in] anti data buffer */
};
#pragma pack(pop)
typedef struct
{
uint64_t xor_key;
uint64_t get_report_data3_ptr;
uint64_t del_report_data_ptr;
uint64_t on_receive_signature;
}SharedMemInfo,*PSharedMemInfo;
typedef struct
{
uint64_t xor_key;
uint64_t report_data_encrypt_ptr;
uint64_t get_encrypt_key_ptr;
}EncryptSharedMemInfo, *PEncryptSharedMemInfo;
//游戏启动时调用该函数初始化共享内存数据
uint32_t __ace_sdk_protocol_binding_init();
//在发送协议时通过该指针调获取安全需要上报的数据
extern void (*g__ace_sdk_get_report_data3)(AceSdkAntiDataInfo*);
//上报完成后调用该函数删除数据
extern void(*g__ace_sdk_del_report_data)(AceSdkAntiDataInfo*);
//下行收到服务端下发的夹带数据调用该函数
extern void(*g__ace_sdk_on_receive_signature)(const char* name, const unsigned char *buf, uint32_t buf_len, uint32_t crc);
}
#endif
#include "ace_sdk_protocol_binding_impl.h"
@@ -0,0 +1,125 @@
#undef BUILD_WITH_UE
#ifdef BUILD_WITH_UE
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"
#include <windows.h>
#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"
#else
#include <windows.h>
#endif
#include <strsafe.h>
//#include "ace_sdk_protocol_binding.h"
#define XOR_CHAR(x) (x^(0x2A))
#define SHARED_MEM_SIZE (255)
#define XOR_KEY_SALT (0x255)
namespace AceProtocolBindingSDK
{
enum
{
PROTOCOL_BINDING_ERROR_SUCCESS = 0,
PROTOCOL_BINDING_ERROR_EXE_PATH = 1,
PROTOCOL_BINDING_ERROR_FULL_PATH = 2,
PROTOCOL_BINDING_ERROR_HANDLE_NULL = 3,
PROTOCOL_BINDING_ERROR_CALL_FUNC = 4,
PROTOCOL_BINDING_ERROR_GET_FUNC = 5,
};
void __ace_sdk_get_report_data3(AceSdkAntiDataInfo* report_data);
void __ace_sdk_del_report_data(AceSdkAntiDataInfo* del_data);
void __ace_sdk_on_receive_signature(const char* name, const unsigned char *buf, uint32_t buf_len, uint32_t crc);
void(*g__ace_sdk_get_report_data3)(AceSdkAntiDataInfo*) = __ace_sdk_get_report_data3;
void(*g__ace_sdk_del_report_data)(AceSdkAntiDataInfo*) = __ace_sdk_del_report_data;
void(*g__ace_sdk_on_receive_signature)(const char* name, const unsigned char *buf, uint32_t buf_len, uint32_t crc) = __ace_sdk_on_receive_signature;
inline int32_t __ace_sdk_get_exe_mod_path(wchar_t* path, uint32_t len)
{
uint32_t ret = GetModuleFileNameW(NULL, path, len);
if (ret == 0 || ret == len)
{
return -1;
}
wchar_t* pos = wcsrchr(path, L'\\');
if (pos == NULL)
{
return -1;
}
*pos = L'\0';
return 0;
}
uint32_t __ace_sdk_protocol_binding_init()
{
static bool init_successful = false;
if (init_successful == true)
{
return PROTOCOL_BINDING_ERROR_SUCCESS;
}
auto now_time = GetTickCount64();
uint64_t mem_xor_key = (now_time << 32) | now_time;
SharedMemInfo info;
info.xor_key = mem_xor_key;
info.get_report_data3_ptr = reinterpret_cast<uint64_t>(&g__ace_sdk_get_report_data3) ^ (info.xor_key + XOR_KEY_SALT);
info.del_report_data_ptr = reinterpret_cast<uint64_t>(&g__ace_sdk_del_report_data) ^ (info.xor_key + XOR_KEY_SALT);
info.on_receive_signature = reinterpret_cast<uint64_t>(&g__ace_sdk_on_receive_signature) ^ (info.xor_key + XOR_KEY_SALT);
wchar_t full_path[1024] = { 0 };
if (__ace_sdk_get_exe_mod_path(full_path, ARRAYSIZE(full_path)) != 0)
{
return PROTOCOL_BINDING_ERROR_EXE_PATH;
}
const wchar_t dll_path[] = { L'\\', L'A', L'n', L't', L'i', L'C', L'h', L'e', L'a', L't', L'E', L'x', L'p', L'e', L'r', L't', L'\\', L'A', L'C', L'E', L'-', L'P', L'B', L'C', L'-', L'G', L'a', L'm', L'e', L'6', L'4', L'.', L'd', L'l', L'l', L'\0' };;
if (FAILED(StringCchCatW(full_path, ARRAYSIZE(full_path), dll_path)))
{
return PROTOCOL_BINDING_ERROR_FULL_PATH;
}
auto handle = GetModuleHandleW(full_path);
if (handle == NULL)
{
handle = LoadLibraryW(full_path);
}
if (handle == NULL)
{
return PROTOCOL_BINDING_ERROR_HANDLE_NULL;
}
typedef bool(*InitRoutine)(SharedMemInfo*, uint32_t key);
InitRoutine func = (InitRoutine)GetProcAddress(handle, MAKEINTRESOURCEA(7));
if (func == NULL)
{
return PROTOCOL_BINDING_ERROR_GET_FUNC;
}
bool init_result = func(&info, INIT_FUNC_KEY);
if (init_result == true)
{
init_successful = true;
return PROTOCOL_BINDING_ERROR_SUCCESS;
}
return PROTOCOL_BINDING_ERROR_CALL_FUNC;
}
void __ace_sdk_get_report_data3(AceSdkAntiDataInfo* report_data)
{
}
void __ace_sdk_del_report_data(AceSdkAntiDataInfo* del_data)
{
}
void __ace_sdk_on_receive_signature(const char* name, const unsigned char *buf, uint32_t buf_len, uint32_t crc)
{
}
}