diff --git a/Release/Plugins/Servo.dll b/Release/Plugins/Servo.dll index fcd98a2..ae09528 100644 Binary files a/Release/Plugins/Servo.dll and b/Release/Plugins/Servo.dll differ diff --git a/Source/Servo.vcxproj b/Source/Servo.vcxproj index 095f427..7051cac 100644 --- a/Source/Servo.vcxproj +++ b/Source/Servo.vcxproj @@ -68,6 +68,7 @@ Windows MachineX86 libci.lib + C:\Ashita\plugins\$(TargetName)$(TargetExt) diff --git a/Source/main.cpp b/Source/main.cpp index 45a47c9..61e84bb 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -45,8 +45,6 @@ static inline std::string trimmed(std::string s) { return s; } - - std::string Servo::StringSub(std::string instring, std::string subin, std::string subout) { if (instring.find(subin) != std::string::npos) @@ -140,7 +138,7 @@ void Servo::SetState(ServoMode::Mode mode) void Servo::Sync(std::string host) { me = m_AshitaCore->GetDataManager()->GetParty()->GetMemberName(0); - log << Chat::Format::RoyalBlue << "Servo started in client mode, connected to: "; + log << Chat::Format::RoyalBlue << "[Servo] Servo started in client mode, connected to: "; while (!lservAddr.try_lock()) std::this_thread::sleep_for(std::chrono::milliseconds(50)); if (host != "") @@ -171,17 +169,16 @@ bool Servo::Initialize(IAshitaCore* ashitaCore, ILogManager* logManager, uint32_ if (!::GetModuleInformation(::GetCurrentProcess(), ::GetModuleHandle("FFXiMain.dll"), &mod, sizeof(MODULEINFO))) return false; - // Cast the data and scan for the pattern.. - std::vector data((uint8_t*)(uintptr_t)mod.lpBaseOfDll, (uint8_t*)(uintptr_t)mod.lpBaseOfDll + mod.SizeOfImage); - - unsigned char* Pointer = (unsigned char*)Ashita::Memory::FindPattern(std::ref(data), (uintptr_t)mod.lpBaseOfDll, "8BCDE87F7????F8B0D7F7F7F7FE87F7F7F7F8BF885??750CB9", 0, 0); - StructPointer = NULL; - if (Pointer != NULL) + auto Pointer = (unsigned char*)Ashita::Memory::FindPattern((uintptr_t)mod.lpBaseOfDll, mod.SizeOfImage, "8BCFE8????????8B0D????????E8????????8BE885??750CB9", 0, 0); + StructPointer = nullptr; + if (Pointer != nullptr) { Pointer += 25; StructPointer = (auto_follow*)(*((DWORD*)Pointer)); } + else + ashitaCore->GetChatManager()->Write("[Servo] Failed to locate required signature for autofollow!"); if (StructPointer) { @@ -221,7 +218,14 @@ void Servo::Serv() hostmask.append("127.0.0.1"); lservAddr.unlock(); hostmask.append(":56556"); - publisher.bind(hostmask.c_str()); + try { + publisher.bind(hostmask.c_str()); + } + catch (...) { + this->m_AshitaCore->GetChatManager()->Write("[Servo] Failed to bind to socket."); + publisher.close(); + return; + } connected = true; @@ -256,7 +260,15 @@ void Servo::ServPos() hostmask.append("127.0.0.1"); lservAddr.unlock(); hostmask.append(":56557"); - publisher.bind(hostmask.c_str()); + try { + publisher.bind(hostmask.c_str()); + } + catch (...) { + this->m_AshitaCore->GetChatManager()->Write("[Servo] Failed to bind to socket."); + publisher.close(); + return; + } + if (!connected) std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -418,7 +430,7 @@ bool Servo::HandleCommand(const char* szCommand, int iType) cmdParse->GetNextCommand(&arg); if (arg == "on") { - log << Chat::Format::RoyalBlue << "Servo started in server mode, with a hostmask of: "; + log << Chat::Format::RoyalBlue << "[Servo] Servo started in server mode, with a hostmask of: "; while (!lservAddr.try_lock()) std::this_thread::sleep_for(std::chrono::milliseconds(50)); if (cmdParse->GetNextCommand(&arg)) @@ -447,7 +459,7 @@ bool Servo::HandleCommand(const char* szCommand, int iType) else if (arg == "off") { SetState(ServoMode::Mode::Standby); - log << Chat::Format::RoyalBlue << "Servo set to standy!" << Chat::Control::flush; + log << Chat::Format::RoyalBlue << "[Servo] Servo set to standy!" << Chat::Control::flush; } else if (arg == "command" || arg == "send") { @@ -588,10 +600,10 @@ __declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* lpBuffer) g_PluginInfo = lpBuffer; strcpy_s(g_PluginInfo->Name, sizeof(g_PluginInfo->Name), "Servo"); - strcpy_s(g_PluginInfo->Author, sizeof(g_PluginInfo->Author), "bluekirby0"); + strcpy_s(g_PluginInfo->Author, sizeof(g_PluginInfo->Author), "bluekirby0 & atom0s"); g_PluginInfo->InterfaceVersion = ASHITA_INTERFACE_VERSION; - g_PluginInfo->PluginVersion = 3.00f; + g_PluginInfo->PluginVersion = 3.01f; g_PluginInfo->Priority = 0; }