mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-05 16:43:52 +00:00
Integrate Unicorn emulator into WardenModule
Connected cross-platform emulation to module execution pipeline! Integration Points: - Added emulator_ member to WardenModule - Initialize emulator in initializeModule() when HAVE_UNICORN defined - Setup Windows API hooks automatically - Ready to call module entry point via emulated execution Changes: - WardenModule now has moduleBase_ (0x400000 default) - Emulator initialized with loaded module code - Common Windows APIs hooked (VirtualAlloc, GetTickCount, etc.) - processCheckRequest() prepared for emulated execution Build Flow: #ifdef HAVE_UNICORN → Use Unicorn emulator (Linux/macOS/ARM) #elif _WIN32 → Native Windows execution #else → Platform not supported #endif Status: ✅ Emulator infrastructure integrated ✅ Module code loaded into emulated environment ✅ API hooks ready ⏳ Entry point calling (TODO - needs callback struct setup) ⏳ PacketHandler execution (TODO - needs implementation) Next: Call module entry point with ClientCallbacks structure
This commit is contained in:
parent
ea69cac526
commit
f032ae8455
2 changed files with 54 additions and 9 deletions
|
|
@ -11,6 +11,9 @@
|
||||||
namespace wowee {
|
namespace wowee {
|
||||||
namespace game {
|
namespace game {
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class WardenEmulator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents Warden callback functions exported by loaded module
|
* Represents Warden callback functions exported by loaded module
|
||||||
*
|
*
|
||||||
|
|
@ -126,10 +129,12 @@ private:
|
||||||
std::vector<uint8_t> decryptedData_; // RC4 decrypted data
|
std::vector<uint8_t> decryptedData_; // RC4 decrypted data
|
||||||
std::vector<uint8_t> decompressedData_; // zlib decompressed data
|
std::vector<uint8_t> decompressedData_; // zlib decompressed data
|
||||||
|
|
||||||
// Module execution context (for future native code execution)
|
// Module execution context
|
||||||
void* moduleMemory_; // Allocated executable memory region
|
void* moduleMemory_; // Allocated executable memory region
|
||||||
size_t moduleSize_; // Size of loaded code
|
size_t moduleSize_; // Size of loaded code
|
||||||
|
uint32_t moduleBase_; // Module base address (for emulator)
|
||||||
WardenFuncList funcList_; // Callback functions
|
WardenFuncList funcList_; // Callback functions
|
||||||
|
std::unique_ptr<WardenEmulator> emulator_; // Cross-platform x86 emulator
|
||||||
|
|
||||||
// Validation and loading steps
|
// Validation and loading steps
|
||||||
bool verifyMD5(const std::vector<uint8_t>& data,
|
bool verifyMD5(const std::vector<uint8_t>& data,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNICORN
|
||||||
|
#include "game/warden_emulator.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace wowee {
|
namespace wowee {
|
||||||
namespace game {
|
namespace game {
|
||||||
|
|
||||||
|
|
@ -25,6 +29,7 @@ WardenModule::WardenModule()
|
||||||
: loaded_(false)
|
: loaded_(false)
|
||||||
, moduleMemory_(nullptr)
|
, moduleMemory_(nullptr)
|
||||||
, moduleSize_(0)
|
, moduleSize_(0)
|
||||||
|
, moduleBase_(0x400000) // Default module base address
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,13 +121,23 @@ bool WardenModule::processCheckRequest(const std::vector<uint8_t>& checkData,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Call module's PacketHandler function
|
#ifdef HAVE_UNICORN
|
||||||
// This would execute native x86 code to:
|
if (emulator_ && emulator_->isInitialized()) {
|
||||||
// - Parse check opcodes (0xF3 MEM_CHECK, 0xB2 PAGE_CHECK, etc.)
|
std::cout << "[WardenModule] Processing check request via emulator..." << std::endl;
|
||||||
// - Read actual memory from process
|
|
||||||
// - Compute real SHA1 hashes
|
// TODO: Call module's PacketHandler function via emulator
|
||||||
// - Scan MPQ files
|
// This would execute native x86 code to:
|
||||||
// - Generate authentic response data
|
// - Parse check opcodes (0xF3 MEM_CHECK, 0xB2 PAGE_CHECK, etc.)
|
||||||
|
// - Read actual memory from process
|
||||||
|
// - Compute real SHA1 hashes
|
||||||
|
// - Scan MPQ files
|
||||||
|
// - Generate authentic response data
|
||||||
|
|
||||||
|
// For now, not implemented
|
||||||
|
std::cout << "[WardenModule] ⚠ Emulated PacketHandler call not yet implemented" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::cout << "[WardenModule] ⚠ processCheckRequest NOT IMPLEMENTED" << std::endl;
|
std::cout << "[WardenModule] ⚠ processCheckRequest NOT IMPLEMENTED" << std::endl;
|
||||||
std::cout << "[WardenModule] Would call module->PacketHandler() here" << std::endl;
|
std::cout << "[WardenModule] Would call module->PacketHandler() here" << std::endl;
|
||||||
|
|
@ -729,7 +744,32 @@ bool WardenModule::initializeModule() {
|
||||||
// Module entry point is typically at offset 0 (first bytes of loaded code)
|
// Module entry point is typically at offset 0 (first bytes of loaded code)
|
||||||
// Function signature: WardenFuncList* (*entryPoint)(ClientCallbacks*)
|
// Function signature: WardenFuncList* (*entryPoint)(ClientCallbacks*)
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef HAVE_UNICORN
|
||||||
|
// Use Unicorn emulator for cross-platform execution
|
||||||
|
std::cout << "[WardenModule] Initializing Unicorn emulator..." << std::endl;
|
||||||
|
|
||||||
|
emulator_ = std::make_unique<WardenEmulator>();
|
||||||
|
if (!emulator_->initialize(moduleMemory_, moduleSize_, moduleBase_)) {
|
||||||
|
std::cerr << "[WardenModule] Failed to initialize emulator" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup Windows API hooks
|
||||||
|
emulator_->setupCommonAPIHooks();
|
||||||
|
|
||||||
|
std::cout << "[WardenModule] ✓ Emulator initialized successfully" << std::endl;
|
||||||
|
std::cout << "[WardenModule] Ready to execute module at 0x" << std::hex << moduleBase_ << std::dec << std::endl;
|
||||||
|
|
||||||
|
// TODO: Call module entry point via emulator
|
||||||
|
// uint32_t entryPoint = moduleBase_; // Typically at module base
|
||||||
|
// std::vector<uint32_t> args = { ... }; // Pass ClientCallbacks struct address
|
||||||
|
// uint32_t result = emulator_->callFunction(entryPoint, args);
|
||||||
|
|
||||||
|
std::cout << "[WardenModule] ⚠ Module entry call via emulator not yet implemented" << std::endl;
|
||||||
|
std::cout << "[WardenModule] Infrastructure ready for execution" << std::endl;
|
||||||
|
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
// Native Windows execution (dangerous without sandboxing)
|
||||||
typedef void* (*ModuleEntryPoint)(ClientCallbacks*);
|
typedef void* (*ModuleEntryPoint)(ClientCallbacks*);
|
||||||
ModuleEntryPoint entryPoint = reinterpret_cast<ModuleEntryPoint>(moduleMemory_);
|
ModuleEntryPoint entryPoint = reinterpret_cast<ModuleEntryPoint>(moduleMemory_);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue