From 70828916e6e15d518c666a205f815c5f6f6a5e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 26 Jun 2017 15:28:33 +0200 Subject: [PATCH] IOS/ES: Refuse to launch the shop with default credentials Prevents... misusing the shop. We are not legally obliged to do this, but let's not make piracy any easier. --- Source/Core/Core/CommonTitles.h | 2 ++ Source/Core/Core/IOS/ES/ES.cpp | 17 +++++++++++++++++ Source/Core/Core/ec_wii.cpp | 7 +++---- Source/Core/Core/ec_wii.h | 2 ++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/CommonTitles.h b/Source/Core/Core/CommonTitles.h index b3d07b6fb1..5b86db8f17 100644 --- a/Source/Core/Core/CommonTitles.h +++ b/Source/Core/Core/CommonTitles.h @@ -17,4 +17,6 @@ constexpr u64 SYSTEM_MENU_IOS = 0x0000000100000050; constexpr u64 BC = 0x0000000100000100; constexpr u64 MIOS = 0x0000000100000101; + +constexpr u64 SHOP = 0x0001000248414241; } // namespace Titles diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index eac70ae1dd..9cf025b8ae 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/ec_wii.h" #include "DiscIO/NANDContentLoader.h" namespace IOS @@ -242,6 +243,22 @@ bool ES::LaunchTitle(u64 title_id, bool skip_reload) // (supposedly when trying to re-open those files). DiscIO::NANDContentManager::Access().ClearCache(); + u32 device_id; + if (title_id == Titles::SHOP && + (GetDeviceId(&device_id) != IPC_SUCCESS || device_id == DEFAULT_WII_DEVICE_ID)) + { + ERROR_LOG(IOS_ES, "Refusing to launch the shop channel with default device credentials"); + CriticalAlertT("You cannot use the Wii Shop Channel without using your own device credentials." + "\nPlease refer to the NAND usage guide for setup instructions: " + "https://dolphin-emu.org/docs/guides/nand-usage-guide/"); + + // Send the user back to the system menu instead of returning an error, which would + // likely make the system menu crash. Doing this is okay as anyone who has the shop + // also has the system menu installed, and this behaviour is consistent with what + // ES does when its DRM system refuses the use of a particular title. + return LaunchTitle(Titles::SYSTEM_MENU); + } + if (IsTitleType(title_id, IOS::ES::TitleType::System) && title_id != Titles::SYSTEM_MENU) return LaunchIOS(title_id); return LaunchPPCTitle(title_id, skip_reload); diff --git a/Source/Core/Core/ec_wii.cpp b/Source/Core/Core/ec_wii.cpp index f58ad8e05e..28ffd0dabd 100644 --- a/Source/Core/Core/ec_wii.cpp +++ b/Source/Core/Core/ec_wii.cpp @@ -23,7 +23,6 @@ #include "Common/Logging/Log.h" #include "Common/Swap.h" -constexpr u32 default_NG_id = 0x0403AC68; constexpr u32 default_NG_key_id = 0x6AAB8C59; constexpr u8 default_NG_priv[] = { @@ -65,7 +64,7 @@ void MakeNGCert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, co char name[64]; if ((NG_id == 0) || (NG_key_id == 0) || (NG_priv == nullptr) || (NG_sig == nullptr)) { - NG_id = default_NG_id; + NG_id = DEFAULT_WII_DEVICE_ID; NG_key_id = default_NG_key_id; NG_priv = default_NG_priv; NG_sig = default_NG_sig; @@ -98,7 +97,7 @@ void MakeAPSigAndCert(u8* sig_out, u8* ap_cert_out, u64 title_id, u8* data, u32 if ((NG_id == 0) || (NG_priv == nullptr)) { NG_priv = default_NG_priv; - NG_id = default_NG_id; + NG_id = DEFAULT_WII_DEVICE_ID; } memset(ap_priv, 0, 0x1e); @@ -186,7 +185,7 @@ void EcWii::InitDefaults() { memset(&BootMiiKeysBin, 0, sizeof(BootMiiKeysBin)); - BootMiiKeysBin.ng_id = Common::swap32(default_NG_id); + BootMiiKeysBin.ng_id = Common::swap32(DEFAULT_WII_DEVICE_ID); BootMiiKeysBin.ng_key_id = Common::swap32(default_NG_key_id); memcpy(BootMiiKeysBin.ng_priv, default_NG_priv, sizeof(BootMiiKeysBin.ng_priv)); diff --git a/Source/Core/Core/ec_wii.h b/Source/Core/Core/ec_wii.h index 99b1bafeaf..eb4395a9a7 100644 --- a/Source/Core/Core/ec_wii.h +++ b/Source/Core/Core/ec_wii.h @@ -26,6 +26,8 @@ #include "Common/CommonTypes.h" +constexpr u32 DEFAULT_WII_DEVICE_ID = 0x0403AC68; + void MakeNGCert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, const u8* NG_sig); void MakeAPSigAndCert(u8* sig_out, u8* ap_cert_out, u64 title_id, u8* data, u32 data_size, const u8* NG_priv, u32 NG_id);