#include "MultiSend.h" #pragma comment(lib, "psapi.lib") #include #include MultiSend::MultiSend(void) : m_AshitaCore(NULL) , m_PluginId(0) , m_Direct3DDevice(NULL) { } MultiSend::~MultiSend(void) { } plugininfo_t* g_PluginInfo = NULL; plugininfo_t MultiSend::GetPluginInfo(void) { return (*g_PluginInfo); } bool MultiSend::Initialize(IAshitaCore* core, ILogManager* log, uint32_t id) { this->m_AshitaCore = core; this->m_PluginId = id; this->m_LogManager = log; LoadGroups(); DWORD Pointer = NULL; MODULEINFO mod = { 0 }; if (!::GetModuleInformation(::GetCurrentProcess(), ::GetModuleHandle("FFXiMain.dll"), &mod, sizeof(MODULEINFO))) return false; Pointer = Ashita::Memory::FindPattern((uintptr_t)mod.lpBaseOfDll, (uintptr_t)mod.SizeOfImage, "8BCFE8????FFFF8B0D????????E8????????8BE885ED750CB9", 0, 0); if (Pointer == NULL) return false; Pointer += 25; p_Follow = (sFollow*)(*((DWORD*)Pointer)); char buffer[256]; strcpy_s(buffer, 256, "FFXI_Multisend_Compatibility"); /* Create name for memory mapped file using plugin version, to guarantee mismatched multisends don't collide if user loads two. sprintf_s(buffer, 256, "FFXI_Multisend_Compatibility", this->GetPluginInfo().PluginVersion); */ //create a handle to the MMF, size matches the struct we're using for it HANDLE hMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, // maximum object size (high-order DWORD) sizeof(MMF_Global), // maximum object size (low-order DWORD) buffer); bool made = (GetLastError() == 0); if (hMapFile == NULL) { throw exception("Could not open or create MMF."); } p_MMF = (MMF_Global*)MapViewOfFile(hMapFile, // handle to map object FILE_MAP_ALL_ACCESS, // read/write permission 0, 0, sizeof(MMF_Global)); if (p_MMF == NULL) { CloseHandle(hMapFile); throw exception("Could not map MMF."); } if (made) { memset(p_MMF, 0, sizeof(MMF_Global)); } s_last_run_state = false; s_position = p_MMF->Command.Position; s_name = ""; if (m_AshitaCore->GetDataManager()->GetParty()->GetMemberActive(0)) { uint16_t myindex = m_AshitaCore->GetDataManager()->GetParty()->GetMemberTargetIndex(0); UpdateName(std::string(m_AshitaCore->GetDataManager()->GetEntity()->GetName(myindex))); } //Default settings. c_follow = true; c_ignoreself = false; c_attemptzone = false; c_debug = false; c_safemode = false; c_maxdist = 5000.0f; this->Start(); return true; } void MultiSend::Release(void) { this->Stop(); if (p_MMF) { UnmapViewOfFile((LPCVOID)p_MMF); } if (hMapFile) { CloseHandle(hMapFile); } } __declspec(dllexport) double __stdcall GetInterfaceVersion(void) { return ASHITA_INTERFACE_VERSION; } __declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* lpBuffer) { g_PluginInfo = lpBuffer; strcpy_s(g_PluginInfo->Name, sizeof(g_PluginInfo->Name), "MultiSend"); strcpy_s(g_PluginInfo->Author, sizeof(g_PluginInfo->Author), "Thorny"); g_PluginInfo->InterfaceVersion = ASHITA_INTERFACE_VERSION; g_PluginInfo->PluginVersion = 1.18f; g_PluginInfo->Priority = 0; } __declspec(dllexport) IPlugin* __stdcall CreatePlugin(void) { return (IPlugin*)new MultiSend(); }