From 5cf684c951b893261b228f9fccebd42cd74715b7 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Sat, 7 Sep 2019 01:52:18 -0700 Subject: [PATCH] Filter non-executable files out of the game list. --- src/citra_qt/game_list_worker.cpp | 5 +++++ src/core/loader/loader.h | 10 ++++++++++ src/core/loader/ncch.cpp | 9 +++++++++ src/core/loader/ncch.h | 2 ++ 4 files changed, 26 insertions(+) diff --git a/src/citra_qt/game_list_worker.cpp b/src/citra_qt/game_list_worker.cpp index 1ae2e2f38..42d748ece 100644 --- a/src/citra_qt/game_list_worker.cpp +++ b/src/citra_qt/game_list_worker.cpp @@ -49,6 +49,11 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign if (!loader) return true; + bool executable = false; + loader->IsExecutable(executable); + if (!executable) + return true; + u64 program_id = 0; loader->ReadProgramId(program_id); diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 1a8e15823..20e84c6a9 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -112,6 +112,16 @@ public: return std::make_pair(2, ResultStatus::Success); } + /** + * Get whether this application is executable. + * @param out_executable Reference to store the executable flag into. + * @return ResultStatus result of function + */ + virtual ResultStatus IsExecutable(bool& out_executable) { + out_executable = true; + return ResultStatus::Success; + } + /** * Get the code (typically .code section) of the application * @param buffer Reference to buffer to store data diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 286eadaab..016a11ef2 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -198,6 +198,15 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr& process) { return ResultStatus::Success; } +ResultStatus AppLoader_NCCH::IsExecutable(bool& out_executable) { + Loader::ResultStatus result = overlay_ncch->Load(); + if (result != Loader::ResultStatus::Success) + return result; + + out_executable = overlay_ncch->ncch_header.is_executable != 0; + return ResultStatus::Success; +} + ResultStatus AppLoader_NCCH::ReadCode(std::vector& buffer) { return overlay_ncch->LoadSectionExeFS(".code", buffer); } diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index d45ae8781..7c86f85d8 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -41,6 +41,8 @@ public: */ std::pair, ResultStatus> LoadKernelSystemMode() override; + ResultStatus IsExecutable(bool& out_executable) override; + ResultStatus ReadCode(std::vector& buffer) override; ResultStatus ReadIcon(std::vector& buffer) override;