Here is a simple class I wrote to help you handle internal function calls. It requires some integration as you'll have to plug in your ObjectGuid class and offsets, but it has everything you need to get started with internal botting.
Code:
// - MemoryMgr.h
#pragma once
#include "MemoryDefines.h"
#include "ObjectGuid.h"
class MemoryMgr
{
public:
static MemoryMgr* instance();
ObjectGuid GetLocalPlayerGuid() { return m_localGuid; }
bool Spell_C_GetSpellCooldown(uint32 spellId, bool pet, int64* duration, int64* startTime, bool* enabled, int64* modRate);
int64 CGUnit_C_GetPower(ObjectGuid* value, uint8 powerType, bool unmodified);
private:
MemoryMgr();
MemoryMgr(MemoryMgr const&) { }
MemoryMgr& operator=(MemoryMgr const&) { }
static MemoryMgr* m_instance;
ObjectGuid m_localGuid;
uintptr m_objMgr;
uintptr m_getSpellCooldown;
uintptr m_getPower;
};
#define sMemoryMgr MemoryMgr::instance()
Code:
// MemoryMgr.cpp
#include "MemoryMgr.h"
#include <Windows.h>
MemoryMgr* MemoryMgr::m_instance = NULL;
MemoryMgr::MemoryMgr()
{
uintptr base = (uintptr)GetModuleHandle(nullptr);
m_objMgr = base + (uintptr)BASE_ADDR_OFFSET_OBJ_MGR;
m_localGuid = *(ObjectGuid*)( (*(uintptr*)(m_objMgr)) + OFFSET_OBJ_MGR_ACTIVE_PLAYER_GUID);
m_getSpellCooldown = base + (uintptr)WOW_FUNCTION_GET_SPELL_COOLDOWN;
m_getPower = base + (uintptr)WOW_FUNCTION_GET_POWER;
}
MemoryMgr* MemoryMgr::instance()
{
if (!m_instance)
m_instance = new MemoryMgr;
return m_instance;
}
bool MemoryMgr::Spell_C_GetSpellCooldown(uint32 spellId, bool pet, int64* duration, int64* startTime, bool* enabled, int64* modRate)
{
return reinterpret_cast<bool(__fastcall*)(uint32, bool, int64*, int64*, bool*, intptr, intptr, int64*)>(m_getSpellCooldown)(spellId, pet, duration, startTime, enabled, 0, 0, modRate);
}
int64 MemoryMgr::CGUnit_C_GetPower(ObjectGuid* value, uint8 powerType, bool unmodified)
{
return reinterpret_cast<bool(__fastcall*)(ObjectGuid*, uint8, bool)>(m_getPower)(value, powerType, unmodified);
}
Code:
// Example use
ObjectGuid guid = sMemoryMgr->GetLocalPlayerGuid();
int64 energy = sMemoryMgr->CGUnit_C_GetPower(&guid, POWER_ENERGY, false);
int64 cp = sMemoryMgr->CGUnit_C_GetPower(&guid, POWER_COMBO_POINTS, false);
// TODO: Implement string formatting
sNotification->ShowMessage("Energy: " + std::to_string(energy) + " Combo Points: " + std::to_string(cp));