From c0c0210b6681852e4a82be97738d4a34178f19ce Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 18 Feb 2026 18:39:07 -0800 Subject: [PATCH] Fix Windows build errors in warden and CharCreateResult warden_emulator.cpp: guard unicorn include + entire implementation with HAVE_UNICORN; provide stub implementations for platforms without Unicorn (Windows ARM64 which has no unicorn MSYS2 package) warden_module.cpp: include for VirtualAlloc/HMODULE/etc on Windows; always include warden_emulator.hpp so unique_ptr destructor compiles regardless of HAVE_UNICORN world_packets.hpp + game_handler.cpp: rename CharCreateResult::ERROR to CharCreateResult::CHAR_ERROR to avoid wingdi.h #define ERROR 0 collision --- include/game/world_packets.hpp | 2 +- src/game/game_handler.cpp | 2 +- src/game/warden_emulator.cpp | 30 ++++++++++++++++++++++++++++++ src/game/warden_module.cpp | 12 ++++++++---- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/include/game/world_packets.hpp b/include/game/world_packets.hpp index ef60f977..10aa9430 100644 --- a/include/game/world_packets.hpp +++ b/include/game/world_packets.hpp @@ -187,7 +187,7 @@ enum class CharCreateResult : uint8_t { // CHAR_CREATE error codes IN_PROGRESS = 0x2E, // CHAR_CREATE_IN_PROGRESS - ERROR = 0x30, // CHAR_CREATE_ERROR + CHAR_ERROR = 0x30, // CHAR_CREATE_ERROR FAILED = 0x31, // CHAR_CREATE_FAILED NAME_IN_USE = 0x32, // CHAR_CREATE_NAME_IN_USE DISABLED = 0x33, // CHAR_CREATE_DISABLED diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 892336a6..0e993f42 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -2065,7 +2065,7 @@ void GameHandler::handleCharCreateResponse(network::Packet& packet) { } else { std::string msg; switch (data.result) { - case CharCreateResult::ERROR: msg = "Server error"; break; + case CharCreateResult::CHAR_ERROR: msg = "Server error"; break; case CharCreateResult::FAILED: msg = "Creation failed"; break; case CharCreateResult::NAME_IN_USE: msg = "Name already in use"; break; case CharCreateResult::DISABLED: msg = "Character creation disabled"; break; diff --git a/src/game/warden_emulator.cpp b/src/game/warden_emulator.cpp index abfd89b2..9e204cad 100644 --- a/src/game/warden_emulator.cpp +++ b/src/game/warden_emulator.cpp @@ -3,12 +3,16 @@ #include #include +#ifdef HAVE_UNICORN // Unicorn Engine headers #include +#endif namespace wowee { namespace game { +#ifdef HAVE_UNICORN + // Memory layout for emulated environment constexpr uint32_t STACK_BASE = 0x00100000; // 1MB constexpr uint32_t STACK_SIZE = 0x00100000; // 1MB stack @@ -396,5 +400,31 @@ void WardenEmulator::hookMemInvalid(uc_engine* uc, int type, uint64_t address, i << " (size=" << size << ")" << std::endl; } +#else // !HAVE_UNICORN +// Stub implementations — Unicorn Engine not available on this platform. +WardenEmulator::WardenEmulator() + : uc_(nullptr), moduleBase_(0), moduleSize_(0) + , stackBase_(0), stackSize_(0) + , heapBase_(0), heapSize_(0) + , apiStubBase_(0), nextHeapAddr_(0) {} +WardenEmulator::~WardenEmulator() {} +bool WardenEmulator::initialize(const void*, size_t, uint32_t) { return false; } +uint32_t WardenEmulator::hookAPI(const std::string&, const std::string&, + std::function&)>) { return 0; } +uint32_t WardenEmulator::callFunction(uint32_t, const std::vector&) { return 0; } +bool WardenEmulator::readMemory(uint32_t, void*, size_t) { return false; } +bool WardenEmulator::writeMemory(uint32_t, const void*, size_t) { return false; } +std::string WardenEmulator::readString(uint32_t, size_t) { return {}; } +uint32_t WardenEmulator::allocateMemory(size_t, uint32_t) { return 0; } +bool WardenEmulator::freeMemory(uint32_t) { return false; } +uint32_t WardenEmulator::getRegister(int) { return 0; } +void WardenEmulator::setRegister(int, uint32_t) {} +void WardenEmulator::setupCommonAPIHooks() {} +uint32_t WardenEmulator::writeData(const void*, size_t) { return 0; } +std::vector WardenEmulator::readData(uint32_t, size_t) { return {}; } +void WardenEmulator::hookCode(uc_engine*, uint64_t, uint32_t, void*) {} +void WardenEmulator::hookMemInvalid(uc_engine*, int, uint64_t, int, int64_t, void*) {} +#endif // HAVE_UNICORN + } // namespace game } // namespace wowee diff --git a/src/game/warden_module.cpp b/src/game/warden_module.cpp index 5df03aa4..0e11441d 100644 --- a/src/game/warden_module.cpp +++ b/src/game/warden_module.cpp @@ -9,14 +9,18 @@ #include #include -#ifndef _WIN32 +#ifdef _WIN32 + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN + #endif + #include +#else #include #include #endif -#ifdef HAVE_UNICORN - #include "game/warden_emulator.hpp" -#endif +// Always include the full definition so unique_ptr destructor compiles +#include "game/warden_emulator.hpp" namespace wowee { namespace game {