add User or Sysmodule detection

This commit is contained in:
Fire Cube 2025-05-22 20:17:56 +02:00
parent 0753d53767
commit 4effcede9f
3 changed files with 34 additions and 11 deletions

View File

@ -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();
}

View File

@ -3,11 +3,13 @@
#pragma once
#include <string>
#include <vector>
#include <algorithm>
#include <filesystem>
#include <mutex>
#include <algorithm>
#include <string>
#include <vector>
#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::filesystem::path path;
};
static inline std::vector<ModuleListEntry> s_modules;

View File

@ -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;
}