diff --git a/src/GUI/Widgets/Addons/AddonItem.cpp b/src/GUI/Widgets/Addons/AddonItem.cpp index 12c21be4..6242fa91 100644 --- a/src/GUI/Widgets/Addons/AddonItem.cpp +++ b/src/GUI/Widgets/Addons/AddonItem.cpp @@ -5,7 +5,8 @@ namespace GUI void AddonItem(Addon* aAddon) { if (aAddon->State == EAddonState::NotLoadedDuplicate || - aAddon->State == EAddonState::Incompatible) + aAddon->State == EAddonState::Incompatible || + aAddon->Definitions == nullptr) { return; } @@ -34,7 +35,8 @@ namespace GUI ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetColumnWidth() - 120.0f); { ImGui::BeginGroup(); - if (aAddon->State == EAddonState::Loaded) + if (aAddon->State == EAddonState::Loaded && + !(aAddon->Definitions->Unload == nullptr || aAddon->Definitions->HasFlag(EAddonFlags::DisableHotloading))) { if (ImGui::Button(("Disable##" + sig).c_str(), ImVec2(120.0f, 24.0f))) { @@ -62,14 +64,17 @@ namespace GUI } } } - if (ImGui::Button(("Uninstall##" + sig).c_str(), ImVec2(120.0f, 24.0f))) + if (!(aAddon->Definitions->Unload == nullptr || aAddon->Definitions->HasFlag(EAddonFlags::DisableHotloading))) { - for (auto& it : Loader::Addons) + if (ImGui::Button(("Uninstall##" + sig).c_str(), ImVec2(120.0f, 24.0f))) { - if (it.second->Definitions == aAddon->Definitions) + for (auto& it : Loader::Addons) { - LogDebug(CH_GUI, "Uninstall called: %s", it.second->Definitions->Name); - Loader::QueueAddon(ELoaderAction::Uninstall, it.first); + if (it.second->Definitions == aAddon->Definitions) + { + LogDebug(CH_GUI, "Uninstall called: %s", it.second->Definitions->Name); + Loader::QueueAddon(ELoaderAction::Uninstall, it.first); + } } } } diff --git a/src/GUI/Widgets/Debug/DebugWindow.cpp b/src/GUI/Widgets/Debug/DebugWindow.cpp index 60220b64..680b435b 100644 --- a/src/GUI/Widgets/Debug/DebugWindow.cpp +++ b/src/GUI/Widgets/Debug/DebugWindow.cpp @@ -249,12 +249,12 @@ namespace GUI std::string state = "State: "; switch (addon->State) { - case EAddonState::None: state.append("None"); break; - case EAddonState::Loaded: state.append("Loaded"); break; - case EAddonState::NotLoaded: state.append("NotLoaded"); break; + case EAddonState::None: state.append("None"); break; + case EAddonState::Loaded: state.append("Loaded"); break; + case EAddonState::NotLoaded: state.append("NotLoaded"); break; case EAddonState::NotLoadedDuplicate: state.append("NotLoadedDuplicate"); break; - case EAddonState::Incompatible: state.append("Incompatible"); break; - case EAddonState::IncompatibleAPI: state.append("IncompatibleAPI"); break; + case EAddonState::Incompatible: state.append("Incompatible"); break; + case EAddonState::IncompatibleAPI: state.append("IncompatibleAPI"); break; } ImGui::TextDisabled(state.c_str()); @@ -262,6 +262,16 @@ namespace GUI ImGui::TextDisabled("Module Size: %u", addon->ModuleSize); ImGui::TextDisabled("AddonDefs: %p", addon->Definitions); + if (addon->Definitions != nullptr) + { + if (ImGui::SmallButton("Memory Editor")) + { + memEditor.Open = true; + memPtr = addon->Definitions; + memSz = sizeof(AddonDefinition); + } + } + ImGui::TreePop(); } } diff --git a/src/Loader/AddonDefinition.cpp b/src/Loader/AddonDefinition.cpp index 0c992ef1..f9632a25 100644 --- a/src/Loader/AddonDefinition.cpp +++ b/src/Loader/AddonDefinition.cpp @@ -31,8 +31,7 @@ bool AddonDefinition::HasMinimumRequirements() Name && Author && Description && - Load && - (HasFlag(EAddonFlags::DisableHotloading) || Unload)) + Load) { return true; } diff --git a/src/Loader/Loader.cpp b/src/Loader/Loader.cpp index e35a191b..65f6cebe 100644 --- a/src/Loader/Loader.cpp +++ b/src/Loader/Loader.cpp @@ -150,7 +150,7 @@ namespace Loader /* doesn't full fill min reqs */ if (hMod && !defs->HasMinimumRequirements()) { - LogWarning(CH_LOADER, "\"%s\" does not fulfill minimum requirements. At least define Name, Version, Author, Description as well as Load and Unload functions. Incompatible.", path); + LogWarning(CH_LOADER, "\"%s\" does not fulfill minimum requirements. At least define Name, Version, Author, Description as well as the Load function. Incompatible.", path); addon->State = EAddonState::Incompatible; FreeLibrary(hMod); return; @@ -162,7 +162,7 @@ namespace Loader // if defs defined && not the same path && signature the same though if (it.second->Definitions != nullptr && it.first != aPath && it.second->Definitions->Signature == defs->Signature) { - LogWarning(CH_LOADER, "\"%s\" or another addon with sig%d is already loaded. Added to blacklist.", path, defs->Signature); + LogWarning(CH_LOADER, "\"%s\" or another addon with this signature (%d) is already loaded. Added to blacklist.", path, defs->Signature); addon->State = EAddonState::NotLoadedDuplicate; FreeLibrary(hMod); return; diff --git a/src/core.cpp b/src/core.cpp index d13b9ad0..74b07d56 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -25,7 +25,7 @@ bool FindFunction(HMODULE aModule, LPVOID aFunction, LPCSTR aName) { FARPROC* fp = (FARPROC*)aFunction; *fp = aModule ? GetProcAddress(aModule, aName) : 0; - return (fp != 0); + return (*fp != 0); } std::string WStrToStr(std::wstring& aWstring)