126 lines
3.6 KiB
C++
126 lines
3.6 KiB
C++
#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)
|
|
{
|
|
}
|
|
}
|