diff --git a/KBotExt/Config.h b/KBotExt/Config.h index cb3f11f..9619e3f 100644 --- a/KBotExt/Config.h +++ b/KBotExt/Config.h @@ -14,6 +14,7 @@ struct Settings } HWND hwnd; + std::string fileName = ""; const std::string settingsFile = "config.JSON"; std::string currentDebugger; // debugger path std::vector ignoredVersions; diff --git a/KBotExt/DirectX.cpp b/KBotExt/DirectX.cpp index e2dea47..93f1b8a 100644 --- a/KBotExt/DirectX.cpp +++ b/KBotExt/DirectX.cpp @@ -45,7 +45,7 @@ bool Direct3D11Render::DirectXInit(const HWND hWnd) Misc::CheckVersion(); if (S.checkPrerelease) - Misc::CheckPrerelease(); + Misc::CheckPrerelease(S.fileName); gamePatch = Misc::GetCurrentPatch(); diff --git a/KBotExt/GameTab.h b/KBotExt/GameTab.h index 3731105..fab8df3 100644 --- a/KBotExt/GameTab.h +++ b/KBotExt/GameTab.h @@ -451,7 +451,7 @@ class GameTab unsigned invitedCount = 0; for (auto& i : root) { - if (i["groupId"].asUInt() != itemsInvite[itemIdxInvite].second) + if (i["groupId"].asInt() != itemsInvite[itemIdxInvite].second) continue; std::string friendSummId = i["summonerId"].asString(); diff --git a/KBotExt/KBotExt.cpp b/KBotExt/KBotExt.cpp index d2d0451..3fac14f 100644 --- a/KBotExt/KBotExt.cpp +++ b/KBotExt/KBotExt.cpp @@ -100,7 +100,7 @@ int WINAPI wWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPWSTR }; if (S.autoRename) - Utils::RenameExe(); + S.fileName = Utils::RenameExe(); RegisterClassExW(&wc); diff --git a/KBotExt/Misc.h b/KBotExt/Misc.h index 13e3c80..25c4209 100644 --- a/KBotExt/Misc.h +++ b/KBotExt/Misc.h @@ -114,7 +114,7 @@ class Misc } } - static void CheckPrerelease() + static void CheckPrerelease(std::string newName = "") { const std::string getPrerelease = cpr::Get(cpr::Url{ "https://api.github.com/repos/KebsCS/KBotExt/releases/tags/prerelease" }).text; @@ -136,7 +136,10 @@ class Misc static HMODULE kernel32 = GetModuleHandleA("kernel32"); static auto pGetModuleFileNameA = (decltype(&GetModuleFileNameA))GetProcAddress(kernel32, "GetModuleFileNameA"); pGetModuleFileNameA(nullptr, szExeFileName, MAX_PATH); - const auto path = std::string(szExeFileName); + std::string path = std::string(szExeFileName); + + if (newName != "") + path = path.substr(0, path.find_last_of('\\') + 1) + newName; const std::filesystem::file_time_type lastWriteTime = std::filesystem::last_write_time(path); const auto systemTime = std::chrono::clock_cast(lastWriteTime); diff --git a/KBotExt/MiscTab.h b/KBotExt/MiscTab.h index e51c037..304bcce 100644 --- a/KBotExt/MiscTab.h +++ b/KBotExt/MiscTab.h @@ -250,7 +250,7 @@ class MiscTab int iDeleted = 0; for (auto& i : root) { - if (i["groupId"].asUInt() == items[item_current_idx].second) + if (i["groupId"].asInt() == items[item_current_idx].second) { std::string req = "https://127.0.0.1/lol-chat/v1/friends/" + i["pid"].asString(); LCU::Request("DELETE", req, ""); diff --git a/KBotExt/Utils.cpp b/KBotExt/Utils.cpp index 80a9965..deae1ea 100644 --- a/KBotExt/Utils.cpp +++ b/KBotExt/Utils.cpp @@ -226,7 +226,7 @@ std::string Utils::Exec(const char* cmd) return result; } -bool Utils::RenameExe() +std::string Utils::RenameExe() { char szExeFileName[MAX_PATH]; static HMODULE kernel32 = GetModuleHandleA("kernel32"); @@ -234,11 +234,11 @@ bool Utils::RenameExe() pGetModuleFileNameA(nullptr, szExeFileName, MAX_PATH); const auto path = std::string(szExeFileName); const std::string exe = path.substr(path.find_last_of('\\') + 1, path.size()); - std::string newname = RandomString(RandomInt(5, 10)); - newname += ".exe"; - if (!rename(exe.c_str(), newname.c_str())) - return true; - return false; + std::string newName = RandomString(RandomInt(5, 10)); + newName += ".exe"; + if (!rename(exe.c_str(), newName.c_str())) + return newName; + return ""; } void Utils::OpenUrl(const char* url, const char* args, int flags) diff --git a/KBotExt/Utils.h b/KBotExt/Utils.h index 7556333..be97397 100644 --- a/KBotExt/Utils.h +++ b/KBotExt/Utils.h @@ -38,7 +38,7 @@ class Utils static std::string Exec(const char* cmd); - static bool RenameExe(); + static std::string RenameExe(); static void OpenUrl(const char* url, const char* args = nullptr, int flags = SW_SHOWNORMAL); static void OpenUrl(const wchar_t* url, const wchar_t* args = nullptr, int flags = SW_SHOWNORMAL);