From 2ce7fff819cd9c60e2ce4330f61e13177fa7f93d Mon Sep 17 00:00:00 2001 From: Sepalani Date: Sun, 11 Feb 2018 06:49:20 +0100 Subject: [PATCH] ES: Make it fail on unsupported installed IOSes --- Source/Core/Core/IOS/ES/ES.cpp | 5 +++++ Source/Core/Core/IOS/ES/Views.cpp | 14 ++++++++++++-- Source/Core/Core/IOS/VersionInfo.cpp | 18 ++++++++++++++++++ Source/Core/Core/IOS/VersionInfo.h | 2 ++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index 1250651024..fae3bfbf50 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -26,6 +26,7 @@ #include "Core/HW/Memmap.h" #include "Core/IOS/ES/Formats.h" #include "Core/IOS/IOSC.h" +#include "Core/IOS/VersionInfo.h" #include "Core/ec_wii.h" namespace IOS @@ -586,6 +587,10 @@ IPCCommandResult ES::Launch(const IOCtlVRequest& request) INFO_LOG(IOS_ES, "IOCTL_ES_LAUNCH %016" PRIx64 " %08x %016" PRIx64 " %08x %016" PRIx64 " %04x", TitleID, view, ticketid, devicetype, titleid, access); + // Prevent loading installed IOSes that are not emulated. + if (!IOS::HLE::IsEmulated(TitleID)) + return GetDefaultReply(FS_ENOENT); + // IOS replies to the request through the mailbox on failure, and acks if the launch succeeds. // Note: Launch will potentially reset the whole IOS state -- including this ES instance. if (!LaunchTitle(TitleID)) diff --git a/Source/Core/Core/IOS/ES/Views.cpp b/Source/Core/Core/IOS/ES/Views.cpp index f3227b7f0a..ceee6b08b3 100644 --- a/Source/Core/Core/IOS/ES/Views.cpp +++ b/Source/Core/Core/IOS/ES/Views.cpp @@ -17,6 +17,7 @@ #include "Core/Core.h" #include "Core/HW/Memmap.h" #include "Core/IOS/ES/Formats.h" +#include "Core/IOS/VersionInfo.h" namespace IOS { @@ -51,7 +52,12 @@ IPCCommandResult ES::GetTicketViewCount(const IOCtlVRequest& request) const IOS::ES::TicketReader ticket = FindSignedTicket(TitleID); u32 view_count = ticket.IsValid() ? static_cast(ticket.GetNumberOfTickets()) : 0; - if (ShouldReturnFakeViewsForIOSes(TitleID, m_title_context)) + if (!IOS::HLE::IsEmulated(TitleID)) + { + view_count = 0; + ERROR_LOG(IOS_ES, "GetViewCount: Dolphin doesn't emulate IOS title %016" PRIx64, TitleID); + } + else if (ShouldReturnFakeViewsForIOSes(TitleID, m_title_context)) { view_count = 1; WARN_LOG(IOS_ES, "GetViewCount: Faking IOS title %016" PRIx64 " being present", TitleID); @@ -74,7 +80,11 @@ IPCCommandResult ES::GetTicketViews(const IOCtlVRequest& request) const IOS::ES::TicketReader ticket = FindSignedTicket(TitleID); - if (ticket.IsValid()) + if (!IOS::HLE::IsEmulated(TitleID)) + { + ERROR_LOG(IOS_ES, "GetViews: Dolphin doesn't emulate IOS title %016" PRIx64, TitleID); + } + else if (ticket.IsValid()) { u32 number_of_views = std::min(maxViews, static_cast(ticket.GetNumberOfTickets())); for (u32 view = 0; view < number_of_views; ++view) diff --git a/Source/Core/Core/IOS/VersionInfo.cpp b/Source/Core/Core/IOS/VersionInfo.cpp index 38e4eb003e..8ce4c011ef 100644 --- a/Source/Core/Core/IOS/VersionInfo.cpp +++ b/Source/Core/Core/IOS/VersionInfo.cpp @@ -4,9 +4,12 @@ #include "Core/IOS/VersionInfo.h" +#include #include #include "Common/CommonTypes.h" +#include "Core/CommonTitles.h" +#include "Core/IOS/ES/Formats.h" namespace IOS { @@ -374,5 +377,20 @@ bool HasFeature(u32 major_version, Feature feature) { return HasFeature(GetFeatures(major_version), feature); } + +bool IsEmulated(u32 major_version) +{ + return std::any_of( + ios_memory_values.begin(), ios_memory_values.end(), + [major_version](const MemoryValues& values) { return values.ios_number == major_version; }); +} + +bool IsEmulated(u64 title_id) +{ + const bool ios = + IsTitleType(title_id, IOS::ES::TitleType::System) && title_id != Titles::SYSTEM_MENU; + const u32 version = static_cast(title_id); + return ios && IsEmulated(version); +} } } diff --git a/Source/Core/Core/IOS/VersionInfo.h b/Source/Core/Core/IOS/VersionInfo.h index 1b64b8b2aa..cc0c28a4ff 100644 --- a/Source/Core/Core/IOS/VersionInfo.h +++ b/Source/Core/Core/IOS/VersionInfo.h @@ -83,5 +83,7 @@ constexpr bool HasFeature(Feature features, Feature feature) bool HasFeature(u32 major_version, Feature feature); Feature GetFeatures(u32 major_version); +bool IsEmulated(u32 major_version); +bool IsEmulated(u64 title_id); } }