From 4effcede9f69af08a880487b8bee8d50b8ac67e1 Mon Sep 17 00:00:00 2001 From: Fire Cube Date: Thu, 22 May 2025 20:17:56 +0200 Subject: [PATCH] add User or Sysmodule detection --- src/core/devtools/widget/module_list.cpp | 12 +++++++-- src/core/devtools/widget/module_list.h | 31 ++++++++++++++++++------ src/core/linker.cpp | 2 +- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/core/devtools/widget/module_list.cpp b/src/core/devtools/widget/module_list.cpp index ea08d9607..347c7a0bc 100644 --- a/src/core/devtools/widget/module_list.cpp +++ b/src/core/devtools/widget/module_list.cpp @@ -20,17 +20,18 @@ void ModuleList::Draw() { for (const auto& entry : s_modules) { ModuleInfo info; info.name = entry.name; + info.is_sys_module = IsSystemModule(entry.path); modules.push_back(info); } } - SetNextWindowSize({500.0f, 600.0f}, ImGuiCond_FirstUseEver); + SetNextWindowSize({550.0f, 600.0f}, ImGuiCond_FirstUseEver); if (!Begin("LLE Module List", &open)) { End(); return; } - if (BeginTable("ModuleTable", 1, + if (BeginTable("ModuleTable", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_RowBg)) { TableSetupColumn("Modulname", ImGuiTableColumnFlags_WidthStretch); @@ -41,6 +42,13 @@ void ModuleList::Draw() { TableSetColumnIndex(0); TextUnformatted(module.name.c_str()); + + TableSetColumnIndex(1); + if (module.is_sys_module) { + TextColored({0.0f, 1.0f, 0.0f, 1.0f}, "System Module"); + } else { + TextColored({1.0f, 0.0f, 0.0f, 1.0f}, "User Module"); + } } EndTable(); } diff --git a/src/core/devtools/widget/module_list.h b/src/core/devtools/widget/module_list.h index 2e2dcd6f8..0336b73c2 100644 --- a/src/core/devtools/widget/module_list.h +++ b/src/core/devtools/widget/module_list.h @@ -3,11 +3,13 @@ #pragma once -#include -#include +#include #include #include -#include +#include +#include + +#include "common/path_util.h" namespace Core::Devtools::Widget { @@ -18,24 +20,37 @@ public: void Draw(); bool open = false; - char search_box[256] = ""; - static void AddModule(const std::string& name) { + bool ModuleList::IsSystemModule(const std::filesystem::path& path) { + + const auto sys_modules_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir); + + const auto canonical_path = std::filesystem::canonical(path); + const auto canonical_sys_path = std::filesystem::canonical(sys_modules_path); + + const auto path_str = canonical_path.string(); + const auto sys_path_str = canonical_sys_path.string(); + + return path_str.starts_with(sys_path_str); + } + + static void AddModule(const std::string& name, std::filesystem::path path) { if (name == "eboot.bin") { return; } std::scoped_lock lock(s_modules_mutex); - s_modules.push_back({name}); + s_modules.push_back({name, path}); } private: - struct ModuleInfo { std::string name; + bool is_sys_module; }; struct ModuleListEntry { - std::string name; + std::string name; + std::filesystem::path path; }; static inline std::vector s_modules; diff --git a/src/core/linker.cpp b/src/core/linker.cpp index 15115f0f0..5fe4b7ca2 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -149,7 +149,7 @@ s32 Linker::LoadModule(const std::filesystem::path& elf_name, bool is_dynamic) { num_static_modules += !is_dynamic; m_modules.emplace_back(std::move(module)); - Core::Devtools::Widget::ModuleList::AddModule(elf_name.filename().string()); + Core::Devtools::Widget::ModuleList::AddModule(elf_name.filename().string(), elf_name); return m_modules.size() - 1; }