From 2d0c881ffe752e5a23475b9dde410fc24cb3b40a Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 2 Jul 2019 20:54:16 -0700 Subject: [PATCH] strat: go all in on ncm::TitleId --- stratosphere/ams_mitm/source/amsmitm_main.cpp | 3 +- .../source/bpc_mitm/bpc_mitm_service.hpp | 4 +- .../source/fs_mitm/fsmitm_boot0storage.cpp | 4 +- .../source/fs_mitm/fsmitm_boot0storage.hpp | 6 +- .../source/fs_mitm/fsmitm_service.cpp | 46 ++--- .../source/fs_mitm/fsmitm_service.hpp | 10 +- .../source/ns_mitm/nsmitm_am_service.cpp | 2 +- .../source/ns_mitm/nsmitm_am_service.hpp | 4 +- .../source/ns_mitm/nsmitm_web_service.cpp | 4 +- .../source/ns_mitm/nsmitm_web_service.hpp | 4 +- .../source/set_mitm/set_mitm_service.cpp | 4 +- .../source/set_mitm/set_mitm_service.hpp | 4 +- .../set_mitm/setsys_firmware_version.cpp | 6 +- .../set_mitm/setsys_firmware_version.hpp | 2 +- .../source/set_mitm/setsys_mitm_service.hpp | 2 +- stratosphere/ams_mitm/source/utils.cpp | 14 +- stratosphere/boot/source/boot_main.cpp | 3 +- stratosphere/creport/source/creport_main.cpp | 3 +- stratosphere/dmnt/source/dmnt_main.cpp | 5 +- stratosphere/eclct.stub/source/eclct_stub.cpp | 3 +- stratosphere/fatal/source/fatal_main.cpp | 4 +- stratosphere/fatal/source/fatal_throw.cpp | 10 +- stratosphere/libstratosphere | 2 +- .../loader/source/ldr_launch_record.cpp | 4 +- .../loader/source/ldr_loader_service.cpp | 2 +- stratosphere/loader/source/ldr_main.cpp | 3 +- .../loader/source/ldr_process_creation.cpp | 22 +-- stratosphere/pm/source/boot2/boot2_api.cpp | 172 +++++++++--------- .../pm/source/impl/pm_process_manager.cpp | 8 +- stratosphere/pm/source/pm_main.cpp | 3 +- stratosphere/ro/source/ro_main.cpp | 8 +- stratosphere/sm/source/sm_main.cpp | 3 +- stratosphere/spl/source/spl_main.cpp | 3 +- 33 files changed, 191 insertions(+), 186 deletions(-) diff --git a/stratosphere/ams_mitm/source/amsmitm_main.cpp b/stratosphere/ams_mitm/source/amsmitm_main.cpp index 608b5e584..a5775efd8 100644 --- a/stratosphere/ams_mitm/source/amsmitm_main.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_main.cpp @@ -43,10 +43,11 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = 0x010041544D530000ul; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::AtmosphereMitm; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); } diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpc_mitm_service.hpp b/stratosphere/ams_mitm/source/bpc_mitm/bpc_mitm_service.hpp index d4d91e4e6..5fbc929e4 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpc_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpc_mitm_service.hpp @@ -31,13 +31,13 @@ class BpcMitmService : public IMitmServiceObject { /* ... */ } - static bool ShouldMitm(u64 pid, u64 tid) { + static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) { /* We will mitm: * - am, to intercept the Reboot/Power buttons in the overlay menu. * - fatal, to simplify payload reboot logic significantly * - applications, to allow homebrew to take advantage of the feature. */ - return tid == TitleId_Am || tid == TitleId_Fatal || TitleIdIsApplication(tid) || Utils::IsHblTid(tid); + return tid == sts::ncm::TitleId::Am || tid == sts::ncm::TitleId::Fatal || sts::ncm::IsApplicationTitleId(tid) || Utils::IsHblTid(static_cast(tid)); } static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp index 1d4b4cf11..d3597ee94 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp @@ -28,11 +28,11 @@ bool Boot0Storage::CanModifyBctPubks() { /* RCM bug patched. */ /* Only allow NS to update the BCT pubks. */ /* AutoRCM on a patched unit will cause a brick, so homebrew should NOT be allowed to write. */ - return this->title_id == TitleId_Ns; + return this->title_id == sts::ncm::TitleId::Ns; } else { /* RCM bug unpatched. */ /* Allow homebrew but not NS to update the BCT pubks. */ - return this->title_id != TitleId_Ns; + return this->title_id != sts::ncm::TitleId::Ns; } } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp index 4f0afadda..5dd1c046b 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp @@ -131,12 +131,12 @@ class Boot0Storage : public SectoredProxyStorage<0x200> { static constexpr u64 EksSize = 0x4000; static constexpr u64 EksEnd = EksStart + EksSize; private: - u64 title_id; + sts::ncm::TitleId title_id; private: bool CanModifyBctPubks(); public: - Boot0Storage(FsStorage *s, u64 t) : Base(s), title_id(t) { } - Boot0Storage(FsStorage s, u64 t) : Base(s), title_id(t) { } + Boot0Storage(FsStorage *s, sts::ncm::TitleId t) : Base(s), title_id(t) { } + Boot0Storage(FsStorage s, sts::ncm::TitleId t) : Base(s), title_id(t) { } public: virtual Result Read(void *_buffer, size_t size, u64 offset) override; virtual Result Write(void *_buffer, size_t size, u64 offset) override; diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_service.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_service.cpp index 935137e42..014e975ed 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_service.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_service.cpp @@ -39,13 +39,13 @@ static HosMutex g_StorageCacheLock; static std::unordered_map> g_StorageCache; -static bool StorageCacheGetEntry(u64 title_id, std::shared_ptr *out) { +static bool StorageCacheGetEntry(sts::ncm::TitleId title_id, std::shared_ptr *out) { std::scoped_lock lock(g_StorageCacheLock); - if (g_StorageCache.find(title_id) == g_StorageCache.end()) { + if (g_StorageCache.find(static_cast(title_id)) == g_StorageCache.end()) { return false; } - auto intf = g_StorageCache[title_id].lock(); + auto intf = g_StorageCache[static_cast(title_id)].lock(); if (intf != nullptr) { *out = intf; return true; @@ -53,18 +53,18 @@ static bool StorageCacheGetEntry(u64 title_id, std::shared_ptr *ptr) { +static void StorageCacheSetEntry(sts::ncm::TitleId title_id, std::shared_ptr *ptr) { std::scoped_lock lock(g_StorageCacheLock); /* Ensure we always use the cached copy if present. */ - if (g_StorageCache.find(title_id) != g_StorageCache.end()) { - auto intf = g_StorageCache[title_id].lock(); + if (g_StorageCache.find(static_cast(title_id)) != g_StorageCache.end()) { + auto intf = g_StorageCache[static_cast(title_id)].lock(); if (intf != nullptr) { *ptr = intf; } } - g_StorageCache[title_id] = *ptr; + g_StorageCache[static_cast(title_id)] = *ptr; } void FsMitmService::PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx) { @@ -74,7 +74,7 @@ void FsMitmService::PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx if (R_SUCCEEDED(ctx->rc)) { this_ptr->has_initialized = true; this_ptr->process_id = ctx->request.Pid; - this_ptr->title_id = this_ptr->process_id; + this_ptr->title_id = sts::ncm::TitleId{this_ptr->process_id}; if (R_FAILED(MitmQueryUtils::GetAssociatedTidForPid(this_ptr->process_id, &this_ptr->title_id))) { /* Log here, if desired. */ } @@ -105,7 +105,7 @@ Result FsMitmService::OpenFileSystemWithPatch(Outtitle_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || + if (!Utils::IsWebAppletTid(static_cast(this->title_id)) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) { return ResultAtmosphereMitmShouldForwardToSession; } @@ -129,7 +129,7 @@ Result FsMitmService::OpenFileSystemWithId(Outtitle_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || + if (!Utils::IsWebAppletTid(static_cast(this->title_id)) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) { return ResultAtmosphereMitmShouldForwardToSession; } @@ -151,7 +151,7 @@ Result FsMitmService::OpenFileSystemWithId(Out> out_fs) { /* We only care about redirecting this for NS/Emummc. */ - if (this->title_id != TitleId_Ns) { + if (this->title_id != sts::ncm::TitleId::Ns) { return ResultAtmosphereMitmShouldForwardToSession; } if (!IsEmummc()) { @@ -174,7 +174,7 @@ Result FsMitmService::OpenSdCardFileSystem(Out> out_fs, u8 space_id, FsSave save_struct) { bool should_redirect_saves = false; - const bool has_redirect_save_flags = Utils::HasFlag(this->title_id, "redirect_save"); + const bool has_redirect_save_flags = Utils::HasFlag(static_cast(this->title_id), "redirect_save"); if (R_FAILED(Utils::GetSettingsItemBooleanValue("atmosphere", "fsmitm_redirect_saves_to_sd", &should_redirect_saves))) { return ResultAtmosphereMitmShouldForwardToSession; } @@ -199,7 +199,7 @@ Result FsMitmService::OpenSaveDataFileSystem(Outtitle_id : save_struct.titleID; + const u64 target_tid = save_struct.titleID == 0 ? static_cast(this->title_id) : save_struct.titleID; FsPath save_dir_path; R_TRY(FsSaveUtils::GetSaveDataDirectoryPath(save_dir_path, space_id, save_struct.saveDataType, target_tid, save_struct.userID, save_struct.saveID)); @@ -240,9 +240,9 @@ Result FsMitmService::OpenBisStorage(Out> out FsStorage bis_storage; R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), &bis_storage, bis_partition_id)); - const bool is_sysmodule = TitleIdIsSystem(this->title_id); - const bool has_bis_write_flag = Utils::HasFlag(this->title_id, "bis_write"); - const bool has_cal0_read_flag = Utils::HasFlag(this->title_id, "cal_read"); + const bool is_sysmodule = sts::ncm::IsSystemTitleId(this->title_id); + const bool has_bis_write_flag = Utils::HasFlag(static_cast(this->title_id), "bis_write"); + const bool has_cal0_read_flag = Utils::HasFlag(static_cast(this->title_id), "cal_read"); /* Set output storage. */ if (bis_partition_id == FsBisStorageId_Boot0) { @@ -260,7 +260,7 @@ Result FsMitmService::OpenBisStorage(Out> out if (is_sysmodule || has_bis_write_flag) { /* Sysmodules should still be allowed to read and write. */ out_storage.SetValue(std::make_shared(new ProxyStorage(bis_storage))); - } else if (Utils::IsHblTid(this->title_id) && + } else if (Utils::IsHblTid(static_cast(this->title_id)) && ((FsBisStorageId_BootConfigAndPackage2NormalMain <= bis_partition_id && bis_partition_id <= FsBisStorageId_BootConfigAndPackage2RepairSub) || bis_partition_id == FsBisStorageId_Boot1)) { /* Allow HBL to write to boot1 (safe firm) + package2. */ @@ -288,7 +288,7 @@ Result FsMitmService::OpenDataStorageByCurrentProcess(Outtitle_id)) { + if (!Utils::HasSdRomfsContent(static_cast(this->title_id))) { return ResultAtmosphereMitmShouldForwardToSession; } @@ -318,10 +318,10 @@ Result FsMitmService::OpenDataStorageByCurrentProcess(Out storage_to_cache = nullptr; /* TODO: Is there a sensible path that ends in ".romfs" we can use?" */ FsFile data_file; - if (R_SUCCEEDED(Utils::OpenSdFileForAtmosphere(this->title_id, "romfs.bin", FS_OPEN_READ, &data_file))) { - storage_to_cache = std::make_shared(new LayeredRomFS(std::make_shared(new ProxyStorage(data_storage)), std::make_shared(new FileStorage(new ProxyFile(data_file))), this->title_id)); + if (R_SUCCEEDED(Utils::OpenSdFileForAtmosphere(static_cast(this->title_id), "romfs.bin", FS_OPEN_READ, &data_file))) { + storage_to_cache = std::make_shared(new LayeredRomFS(std::make_shared(new ProxyStorage(data_storage)), std::make_shared(new FileStorage(new ProxyFile(data_file))), static_cast(this->title_id))); } else { - storage_to_cache = std::make_shared(new LayeredRomFS(std::make_shared(new ProxyStorage(data_storage)), nullptr, this->title_id)); + storage_to_cache = std::make_shared(new LayeredRomFS(std::make_shared(new ProxyStorage(data_storage)), nullptr, static_cast(this->title_id))); } StorageCacheSetEntry(this->title_id, &storage_to_cache); @@ -351,7 +351,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out cached_storage = nullptr; - bool has_cache = StorageCacheGetEntry(data_id, &cached_storage); + bool has_cache = StorageCacheGetEntry(sts::ncm::TitleId{data_id}, &cached_storage); if (has_cache) { if (out_storage.IsDomain()) { @@ -380,7 +380,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out(new LayeredRomFS(std::make_shared(new ProxyStorage(data_storage)), nullptr, data_id)); } - StorageCacheSetEntry(data_id, &storage_to_cache); + StorageCacheSetEntry(sts::ncm::TitleId{data_id}, &storage_to_cache); out_storage.SetValue(std::move(storage_to_cache)); if (out_storage.IsDomain()) { diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_service.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_service.hpp index ed2ee56c6..c4c156aa5 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_service.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_service.hpp @@ -45,14 +45,14 @@ class FsMitmService : public IMitmServiceObject { bool should_override_contents; public: FsMitmService(std::shared_ptr s, u64 pid) : IMitmServiceObject(s, pid) { - if (Utils::HasSdDisableMitMFlag(this->title_id)) { + if (Utils::HasSdDisableMitMFlag(static_cast(this->title_id))) { this->should_override_contents = false; } else { - this->should_override_contents = (this->title_id >= TitleId_ApplicationStart || Utils::HasSdMitMFlag(this->title_id)) && Utils::HasOverrideButton(this->title_id); + this->should_override_contents = (this->title_id >= sts::ncm::TitleId::ApplicationStart || Utils::HasSdMitMFlag(static_cast(this->title_id))) && Utils::HasOverrideButton(static_cast(this->title_id)); } } - static bool ShouldMitm(u64 pid, u64 tid) { + static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) { /* Don't Mitm KIPs */ if (pid < 0x50) { return false; @@ -62,11 +62,11 @@ class FsMitmService : public IMitmServiceObject { /* TODO: intercepting everything seems to cause issues with sleep mode, for some reason. */ /* Figure out why, and address it. */ - if (tid == TitleId_AppletQlaunch || tid == TitleId_AppletMaintenanceMenu) { + if (tid == sts::ncm::TitleId::AppletQlaunch || tid == sts::ncm::TitleId::AppletMaintenanceMenu) { has_launched_qlaunch = true; } - return has_launched_qlaunch || tid == TitleId_Ns || tid >= TitleId_ApplicationStart || Utils::HasSdMitMFlag(tid); + return has_launched_qlaunch || tid == sts::ncm::TitleId::Ns || tid >= sts::ncm::TitleId::ApplicationStart || Utils::HasSdMitMFlag(static_cast(tid)); } static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); diff --git a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_am_service.cpp b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_am_service.cpp index 00d7a06d5..15b7da319 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_am_service.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_am_service.cpp @@ -30,7 +30,7 @@ Result NsAmMitmService::GetApplicationContentPath(OutBuffer out_path, u64 ap Result NsAmMitmService::ResolveApplicationContentPath(u64 title_id, u8 storage_type) { /* Always succeed for web applet asking about HBL. */ - if (Utils::IsWebAppletTid(this->title_id) && Utils::IsHblTid(title_id)) { + if (Utils::IsWebAppletTid(static_cast(this->title_id)) && Utils::IsHblTid(title_id)) { nsamResolveApplicationContentPathFwd(this->forward_service.get(), title_id, static_cast(storage_type)); return ResultSuccess; } diff --git a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_am_service.hpp b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_am_service.hpp index 5f74262b4..1bdbfd03c 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_am_service.hpp +++ b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_am_service.hpp @@ -32,11 +32,11 @@ class NsAmMitmService : public IMitmServiceObject { /* ... */ } - static bool ShouldMitm(u64 pid, u64 tid) { + static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) { /* We will mitm: * - web applets, to facilitate hbl web browser launching. */ - return Utils::IsWebAppletTid(tid); + return Utils::IsWebAppletTid(static_cast(tid)); } static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); diff --git a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_web_service.cpp b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_web_service.cpp index b970837fc..6eed885ff 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_web_service.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_web_service.cpp @@ -29,7 +29,7 @@ Result NsWebMitmService::GetDocumentInterface(Outforward_service.get(), &doc)); /* Set output interface. */ - out_intf.SetValue(std::move(std::make_shared(this->title_id, doc))); + out_intf.SetValue(std::move(std::make_shared(static_cast(this->title_id), doc))); if (out_intf.IsDomain()) { out_intf.ChangeObjectId(doc.s.object_id); } @@ -43,7 +43,7 @@ Result NsDocumentService::GetApplicationContentPath(OutBuffer out_path, u64 Result NsDocumentService::ResolveApplicationContentPath(u64 title_id, u8 storage_type) { /* Always succeed for web applet asking about HBL. */ - if (Utils::IsWebAppletTid(this->title_id) && Utils::IsHblTid(title_id)) { + if (Utils::IsWebAppletTid(static_cast(this->title_id)) && Utils::IsHblTid(title_id)) { nswebResolveApplicationContentPath(this->srv.get(), title_id, static_cast(storage_type)); return ResultSuccess; } diff --git a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_web_service.hpp b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_web_service.hpp index 2090afbe8..9957f76c8 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/nsmitm_web_service.hpp +++ b/stratosphere/ams_mitm/source/ns_mitm/nsmitm_web_service.hpp @@ -71,11 +71,11 @@ class NsWebMitmService : public IMitmServiceObject { /* ... */ } - static bool ShouldMitm(u64 pid, u64 tid) { + static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) { /* We will mitm: * - web applets, to facilitate hbl web browser launching. */ - return Utils::IsWebAppletTid(tid); + return Utils::IsWebAppletTid(static_cast(tid)); } static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); diff --git a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp index 30e8ebea9..2e1b95ce9 100644 --- a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp @@ -68,14 +68,14 @@ Result SetMitmService::EnsureLocale() { if (!this->got_locale) { std::memset(&this->locale, 0xCC, sizeof(this->locale)); - if (this->title_id == TitleId_Ns) { + if (this->title_id == sts::ncm::TitleId::Ns) { u64 app_pid = 0; u64 app_tid = 0; R_TRY(pmdmntGetApplicationPid(&app_pid)); R_TRY(pminfoGetTitleId(&app_tid, app_pid)); this->locale = Utils::GetTitleOverrideLocale(app_tid); } else { - this->locale = Utils::GetTitleOverrideLocale(this->title_id); + this->locale = Utils::GetTitleOverrideLocale(static_cast(this->title_id)); this->got_locale = true; } } diff --git a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp index 2e28bc60c..85db12db9 100644 --- a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp @@ -39,9 +39,9 @@ class SetMitmService : public IMitmServiceObject { this->got_locale = false; } - static bool ShouldMitm(u64 pid, u64 tid) { + static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) { /* Mitm all applications. */ - return tid == TitleId_Ns || TitleIdIsApplication(tid); + return tid == sts::ncm::TitleId::Ns || sts::ncm::IsApplicationTitleId(tid); } static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_firmware_version.cpp b/stratosphere/ams_mitm/source/set_mitm/setsys_firmware_version.cpp index 094b44b15..1f5e55ca2 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_firmware_version.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_firmware_version.cpp @@ -32,7 +32,7 @@ void VersionManager::Initialize() { } /* Mount firmware version data archive. */ - R_ASSERT(romfsMountFromDataArchive(TitleId_ArchiveSystemVersion, FsStorageId_NandSystem, "sysver")); + R_ASSERT(romfsMountFromDataArchive(static_cast(sts::ncm::TitleId::ArchiveSystemVersion), FsStorageId_NandSystem, "sysver")); { ON_SCOPE_EXIT { romfsUnmount("sysver"); }; @@ -70,11 +70,11 @@ void VersionManager::Initialize() { g_got_version = true; } -Result VersionManager::GetFirmwareVersion(u64 title_id, SetSysFirmwareVersion *out) { +Result VersionManager::GetFirmwareVersion(sts::ncm::TitleId title_id, SetSysFirmwareVersion *out) { VersionManager::Initialize(); /* Report atmosphere string to qlaunch, maintenance and nothing else. */ - if (title_id == TitleId_AppletQlaunch || title_id == TitleId_AppletMaintenanceMenu) { + if (title_id == sts::ncm::TitleId::AppletQlaunch || title_id == sts::ncm::TitleId::AppletMaintenanceMenu) { *out = g_ams_fw_version; } else { *out = g_fw_version; diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_firmware_version.hpp b/stratosphere/ams_mitm/source/set_mitm/setsys_firmware_version.hpp index a3570c62d..3711a4b5d 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_firmware_version.hpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_firmware_version.hpp @@ -21,5 +21,5 @@ class VersionManager { public: static void Initialize(); - static Result GetFirmwareVersion(u64 title_id, SetSysFirmwareVersion *out); + static Result GetFirmwareVersion(sts::ncm::TitleId title_id, SetSysFirmwareVersion *out); }; diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp index 63f6c4c96..eb900d4d2 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.hpp @@ -37,7 +37,7 @@ class SetSysMitmService : public IMitmServiceObject { /* ... */ } - static bool ShouldMitm(u64 pid, u64 tid) { + static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) { /* Mitm everything. */ return true; } diff --git a/stratosphere/ams_mitm/source/utils.cpp b/stratosphere/ams_mitm/source/utils.cpp index 9a77e7f88..86f7fc280 100644 --- a/stratosphere/ams_mitm/source/utils.cpp +++ b/stratosphere/ams_mitm/source/utils.cpp @@ -52,7 +52,7 @@ static HblOverrideConfig g_hbl_override_config = { .key_combination = KEY_R, .override_by_default = false }, - .title_id = TitleId_AppletPhotoViewer, + .title_id = static_cast(sts::ncm::TitleId::AppletPhotoViewer), .override_any_app = true }; @@ -378,12 +378,14 @@ Result Utils::SaveSdFileForAtmosphere(u64 title_id, const char *fn, void *data, return ResultSuccess; } -bool Utils::IsHblTid(u64 tid) { - return (g_hbl_override_config.override_any_app && TitleIdIsApplication(tid)) || (tid == g_hbl_override_config.title_id); +bool Utils::IsHblTid(u64 _tid) { + const sts::ncm::TitleId tid{_tid}; + return (g_hbl_override_config.override_any_app && sts::ncm::IsApplicationTitleId(tid)) || (_tid == g_hbl_override_config.title_id); } -bool Utils::IsWebAppletTid(u64 tid) { - return tid == TitleId_AppletWeb || tid == TitleId_AppletOfflineWeb || tid == TitleId_AppletLoginShare || tid == TitleId_AppletWifiWebAuth; +bool Utils::IsWebAppletTid(u64 _tid) { + const sts::ncm::TitleId tid{_tid}; + return tid == sts::ncm::TitleId::AppletWeb || tid == sts::ncm::TitleId::AppletOfflineWeb || tid == sts::ncm::TitleId::AppletLoginShare || tid == sts::ncm::TitleId::AppletWifiWebAuth; } bool Utils::HasTitleFlag(u64 tid, const char *flag) { @@ -472,7 +474,7 @@ static bool HasOverrideKey(OverrideKey *cfg) { bool Utils::HasOverrideButton(u64 tid) { - if ((!TitleIdIsApplication(tid)) || (!IsSdInitialized())) { + if ((!sts::ncm::IsApplicationTitleId(sts::ncm::TitleId{tid})) || (!IsSdInitialized())) { /* Disable button override disable for non-applications. */ return true; } diff --git a/stratosphere/boot/source/boot_main.cpp b/stratosphere/boot/source/boot_main.cpp index f7b120cb7..d0d010b73 100644 --- a/stratosphere/boot/source/boot_main.cpp +++ b/stratosphere/boot/source/boot_main.cpp @@ -58,10 +58,11 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = TitleId_Boot; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Boot; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); } diff --git a/stratosphere/creport/source/creport_main.cpp b/stratosphere/creport/source/creport_main.cpp index f536c779d..8f7937645 100644 --- a/stratosphere/creport/source/creport_main.cpp +++ b/stratosphere/creport/source/creport_main.cpp @@ -43,10 +43,11 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = TitleId_Creport; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Creport; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); } diff --git a/stratosphere/dmnt/source/dmnt_main.cpp b/stratosphere/dmnt/source/dmnt_main.cpp index 583c30ae6..156917a1a 100644 --- a/stratosphere/dmnt/source/dmnt_main.cpp +++ b/stratosphere/dmnt/source/dmnt_main.cpp @@ -40,11 +40,10 @@ extern "C" { void __libnx_initheap(void); void __appInit(void); void __appExit(void); - - /* Exception handling. */ - u64 __stratosphere_title_id = TitleId_Dmnt; } +/* Exception handling. */ +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Dmnt; void __libnx_initheap(void) { void* addr = nx_inner_heap; diff --git a/stratosphere/eclct.stub/source/eclct_stub.cpp b/stratosphere/eclct.stub/source/eclct_stub.cpp index 9ba761a8b..62b73d454 100644 --- a/stratosphere/eclct.stub/source/eclct_stub.cpp +++ b/stratosphere/eclct.stub/source/eclct_stub.cpp @@ -40,10 +40,11 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = TitleId_Eclct; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Eclct; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); } diff --git a/stratosphere/fatal/source/fatal_main.cpp b/stratosphere/fatal/source/fatal_main.cpp index 6da20c672..b246ab267 100644 --- a/stratosphere/fatal/source/fatal_main.cpp +++ b/stratosphere/fatal/source/fatal_main.cpp @@ -50,15 +50,15 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = TitleId_Fatal; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Fatal; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); } - void __libnx_initheap(void) { void* addr = nx_inner_heap; size_t size = nx_inner_heap_size; diff --git a/stratosphere/fatal/source/fatal_throw.cpp b/stratosphere/fatal/source/fatal_throw.cpp index 911044723..9e46c0b59 100644 --- a/stratosphere/fatal/source/fatal_throw.cpp +++ b/stratosphere/fatal/source/fatal_throw.cpp @@ -66,13 +66,13 @@ Result ThrowFatalImpl(u32 error, u64 pid, FatalType policy, FatalCpuContext *cpu const FatalConfig *config = GetFatalConfig(); /* Get title id. On failure, it'll be zero. */ - u64 title_id = 0; - pminfoGetTitleId(&title_id, pid); - ctx.is_creport = title_id == TitleId_Creport; + sts::ncm::TitleId title_id = sts::ncm::TitleId::Invalid; + sts::pm::info::GetTitleId(&title_id, pid); + ctx.is_creport = title_id == sts::ncm::TitleId::Creport; /* Support for ams creport. TODO: Make this its own command? */ if (ctx.is_creport && !cpu_ctx->is_aarch32 && cpu_ctx->aarch64_ctx.afsr0 != 0) { - title_id = cpu_ctx->aarch64_ctx.afsr0; + title_id = sts::ncm::TitleId{cpu_ctx->aarch64_ctx.afsr0}; } /* Atmosphere extension: automatic debug info collection. */ @@ -104,7 +104,7 @@ Result ThrowFatalImpl(u32 error, u64 pid, FatalType policy, FatalCpuContext *cpu /* Run tasks. */ if (config->transition_to_fatal) { - RunFatalTasks(&ctx, title_id, policy == FatalType_ErrorReportAndErrorScreen, &erpt_event, &battery_event); + RunFatalTasks(&ctx, static_cast(title_id), policy == FatalType_ErrorReportAndErrorScreen, &erpt_event, &battery_event); } else { /* If flag is not set, don't show the fatal screen. */ return ResultSuccess; diff --git a/stratosphere/libstratosphere b/stratosphere/libstratosphere index c9dc24cce..d7d7cba3d 160000 --- a/stratosphere/libstratosphere +++ b/stratosphere/libstratosphere @@ -1 +1 @@ -Subproject commit c9dc24cce1e832650e6a2fc67bce465062504279 +Subproject commit d7d7cba3d35e5aa029ace71891e317e0d5412131 diff --git a/stratosphere/loader/source/ldr_launch_record.cpp b/stratosphere/loader/source/ldr_launch_record.cpp index 79b85c26b..e3ff73047 100644 --- a/stratosphere/loader/source/ldr_launch_record.cpp +++ b/stratosphere/loader/source/ldr_launch_record.cpp @@ -43,8 +43,8 @@ namespace sts::ldr { /* This is necessary to prevent circular dependencies. */ namespace sts::pm::info { - Result HasLaunchedTitle(bool *out, u64 title_id) { - *out = ldr::HasLaunchedTitle(ncm::TitleId{title_id}); + Result HasLaunchedTitle(bool *out, ncm::TitleId title_id) { + *out = ldr::HasLaunchedTitle(title_id); return ResultSuccess; } diff --git a/stratosphere/loader/source/ldr_loader_service.cpp b/stratosphere/loader/source/ldr_loader_service.cpp index 04add5883..0142e7ac5 100644 --- a/stratosphere/loader/source/ldr_loader_service.cpp +++ b/stratosphere/loader/source/ldr_loader_service.cpp @@ -50,7 +50,7 @@ namespace sts::ldr { if (loc.storage_id != static_cast(ncm::StorageId::None) && loc.title_id != out->title_id) { char path[FS_MAX_PATH]; - const ncm::TitleLocation new_loc = ncm::MakeTitleLocation(out->title_id, static_cast(loc.storage_id)); + const ncm::TitleLocation new_loc = ncm::TitleLocation::Make(out->title_id, static_cast(loc.storage_id)); R_TRY(ResolveContentPath(path, loc)); R_TRY(RedirectContentPath(path, new_loc)); diff --git a/stratosphere/loader/source/ldr_main.cpp b/stratosphere/loader/source/ldr_main.cpp index 5e969630f..3223a040b 100644 --- a/stratosphere/loader/source/ldr_main.cpp +++ b/stratosphere/loader/source/ldr_main.cpp @@ -44,10 +44,11 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = TitleId_Loader; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Loader; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); } diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index d3238a051..f946c0ffd 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -196,17 +196,17 @@ namespace sts::ldr { return static_cast((meta->acid->flags & Acid::AcidFlag_PoolPartitionMask) >> Acid::AcidFlag_PoolPartitionShift); } - constexpr bool IsDisallowedVersion810(const u64 title_id, const u32 version) { + constexpr bool IsDisallowedVersion810(const ncm::TitleId title_id, const u32 version) { return version == 0 && - (title_id == TitleId_Settings || - title_id == TitleId_Bus || - title_id == TitleId_Audio || - title_id == TitleId_NvServices || - title_id == TitleId_Ns || - title_id == TitleId_Ssl || - title_id == TitleId_Es || - title_id == TitleId_Creport || - title_id == TitleId_Ro); + (title_id == ncm::TitleId::Settings || + title_id == ncm::TitleId::Bus || + title_id == ncm::TitleId::Audio || + title_id == ncm::TitleId::NvServices || + title_id == ncm::TitleId::Ns || + title_id == ncm::TitleId::Ssl || + title_id == ncm::TitleId::Es || + title_id == ncm::TitleId::Creport || + title_id == ncm::TitleId::Ro); } Result ValidateTitleVersion(ncm::TitleId title_id, u32 version) { @@ -214,7 +214,7 @@ namespace sts::ldr { return ResultSuccess; } else { #ifdef LDR_VALIDATE_PROCESS_VERSION - if (IsDisallowedVersion810(static_cast(title_id), version)) { + if (IsDisallowedVersion810(title_id, version)) { return ResultLoaderInvalidVersion; } else { return ResultSuccess; diff --git a/stratosphere/pm/source/boot2/boot2_api.cpp b/stratosphere/pm/source/boot2/boot2_api.cpp index 6614d61b2..ca9e43b46 100644 --- a/stratosphere/pm/source/boot2/boot2_api.cpp +++ b/stratosphere/pm/source/boot2/boot2_api.cpp @@ -30,97 +30,97 @@ namespace sts::boot2 { /* psc, bus, pcv is the minimal set of required titles to get SD card. */ /* bus depends on pcie, and pcv depends on settings. */ constexpr ncm::TitleId PreSdCardLaunchPrograms[] = { - ncm::TitleId{TitleId_Psc}, /* psc */ - ncm::TitleId{TitleId_Pcie}, /* pcie */ - ncm::TitleId{TitleId_Bus}, /* bus */ - ncm::TitleId{TitleId_Settings}, /* settings */ - ncm::TitleId{TitleId_Pcv}, /* pcv */ + ncm::TitleId::Psc, /* psc */ + ncm::TitleId::Pcie, /* pcie */ + ncm::TitleId::Bus, /* bus */ + ncm::TitleId::Settings, /* settings */ + ncm::TitleId::Pcv, /* pcv */ }; constexpr size_t NumPreSdCardLaunchPrograms = util::size(PreSdCardLaunchPrograms); constexpr ncm::TitleId AdditionalLaunchPrograms[] = { - ncm::TitleId{TitleId_Usb}, /* usb */ - ncm::TitleId{TitleId_Tma}, /* tma */ - ncm::TitleId{TitleId_Am}, /* am */ - ncm::TitleId{TitleId_NvServices}, /* nvservices */ - ncm::TitleId{TitleId_NvnFlinger}, /* nvnflinger */ - ncm::TitleId{TitleId_Vi}, /* vi */ - ncm::TitleId{TitleId_Ns}, /* ns */ - ncm::TitleId{TitleId_LogManager}, /* lm */ - ncm::TitleId{TitleId_Ppc}, /* ppc */ - ncm::TitleId{TitleId_Ptm}, /* ptm */ - ncm::TitleId{TitleId_Hid}, /* hid */ - ncm::TitleId{TitleId_Audio}, /* audio */ - ncm::TitleId{TitleId_Lbl}, /* lbl */ - ncm::TitleId{TitleId_Wlan}, /* wlan */ - ncm::TitleId{TitleId_Bluetooth}, /* bluetooth */ - ncm::TitleId{TitleId_BsdSockets}, /* bsdsockets */ - ncm::TitleId{TitleId_Nifm}, /* nifm */ - ncm::TitleId{TitleId_Ldn}, /* ldn */ - ncm::TitleId{TitleId_Account}, /* account */ - ncm::TitleId{TitleId_Friends}, /* friends */ - ncm::TitleId{TitleId_Nfc}, /* nfc */ - ncm::TitleId{TitleId_JpegDec}, /* jpegdec */ - ncm::TitleId{TitleId_CapSrv}, /* capsrv */ - ncm::TitleId{TitleId_Ssl}, /* ssl */ - ncm::TitleId{TitleId_Nim}, /* nim */ - ncm::TitleId{TitleId_Bcat}, /* bcat */ - ncm::TitleId{TitleId_Erpt}, /* erpt */ - ncm::TitleId{TitleId_Es}, /* es */ - ncm::TitleId{TitleId_Pctl}, /* pctl */ - ncm::TitleId{TitleId_Btm}, /* btm */ - ncm::TitleId{TitleId_Eupld}, /* eupld */ - ncm::TitleId{TitleId_Glue}, /* glue */ - /* ncm::TitleId{TitleId_Eclct}, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ - ncm::TitleId{TitleId_Npns}, /* npns */ - ncm::TitleId{TitleId_Fatal}, /* fatal */ - ncm::TitleId{TitleId_Ro}, /* ro */ - ncm::TitleId{TitleId_Profiler}, /* profiler */ - ncm::TitleId{TitleId_Sdb}, /* sdb */ - ncm::TitleId{TitleId_Migration}, /* migration */ - ncm::TitleId{TitleId_Grc}, /* grc */ - ncm::TitleId{TitleId_Olsc}, /* olsc */ + ncm::TitleId::Usb, /* usb */ + ncm::TitleId::Tma, /* tma */ + ncm::TitleId::Am, /* am */ + ncm::TitleId::NvServices, /* nvservices */ + ncm::TitleId::NvnFlinger, /* nvnflinger */ + ncm::TitleId::Vi, /* vi */ + ncm::TitleId::Ns, /* ns */ + ncm::TitleId::LogManager, /* lm */ + ncm::TitleId::Ppc, /* ppc */ + ncm::TitleId::Ptm, /* ptm */ + ncm::TitleId::Hid, /* hid */ + ncm::TitleId::Audio, /* audio */ + ncm::TitleId::Lbl, /* lbl */ + ncm::TitleId::Wlan, /* wlan */ + ncm::TitleId::Bluetooth, /* bluetooth */ + ncm::TitleId::BsdSockets, /* bsdsockets */ + ncm::TitleId::Nifm, /* nifm */ + ncm::TitleId::Ldn, /* ldn */ + ncm::TitleId::Account, /* account */ + ncm::TitleId::Friends, /* friends */ + ncm::TitleId::Nfc, /* nfc */ + ncm::TitleId::JpegDec, /* jpegdec */ + ncm::TitleId::CapSrv, /* capsrv */ + ncm::TitleId::Ssl, /* ssl */ + ncm::TitleId::Nim, /* nim */ + ncm::TitleId::Bcat, /* bcat */ + ncm::TitleId::Erpt, /* erpt */ + ncm::TitleId::Es, /* es */ + ncm::TitleId::Pctl, /* pctl */ + ncm::TitleId::Btm, /* btm */ + ncm::TitleId::Eupld, /* eupld */ + ncm::TitleId::Glue, /* glue */ + /* ncm::TitleId::Eclct, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ + ncm::TitleId::Npns, /* npns */ + ncm::TitleId::Fatal, /* fatal */ + ncm::TitleId::Ro, /* ro */ + ncm::TitleId::Profiler, /* profiler */ + ncm::TitleId::Sdb, /* sdb */ + ncm::TitleId::Migration, /* migration */ + ncm::TitleId::Grc, /* grc */ + ncm::TitleId::Olsc, /* olsc */ }; constexpr size_t NumAdditionalLaunchPrograms = util::size(AdditionalLaunchPrograms); constexpr ncm::TitleId AdditionalMaintenanceLaunchPrograms[] = { - ncm::TitleId{TitleId_Usb}, /* usb */ - ncm::TitleId{TitleId_Tma}, /* tma */ - ncm::TitleId{TitleId_Am}, /* am */ - ncm::TitleId{TitleId_NvServices}, /* nvservices */ - ncm::TitleId{TitleId_NvnFlinger}, /* nvnflinger */ - ncm::TitleId{TitleId_Vi}, /* vi */ - ncm::TitleId{TitleId_Ns}, /* ns */ - ncm::TitleId{TitleId_LogManager}, /* lm */ - ncm::TitleId{TitleId_Ppc}, /* ppc */ - ncm::TitleId{TitleId_Ptm}, /* ptm */ - ncm::TitleId{TitleId_Hid}, /* hid */ - ncm::TitleId{TitleId_Audio}, /* audio */ - ncm::TitleId{TitleId_Lbl}, /* lbl */ - ncm::TitleId{TitleId_Wlan}, /* wlan */ - ncm::TitleId{TitleId_Bluetooth}, /* bluetooth */ - ncm::TitleId{TitleId_BsdSockets}, /* bsdsockets */ - ncm::TitleId{TitleId_Nifm}, /* nifm */ - ncm::TitleId{TitleId_Ldn}, /* ldn */ - ncm::TitleId{TitleId_Account}, /* account */ - ncm::TitleId{TitleId_Nfc}, /* nfc */ - ncm::TitleId{TitleId_JpegDec}, /* jpegdec */ - ncm::TitleId{TitleId_CapSrv}, /* capsrv */ - ncm::TitleId{TitleId_Ssl}, /* ssl */ - ncm::TitleId{TitleId_Nim}, /* nim */ - ncm::TitleId{TitleId_Erpt}, /* erpt */ - ncm::TitleId{TitleId_Es}, /* es */ - ncm::TitleId{TitleId_Pctl}, /* pctl */ - ncm::TitleId{TitleId_Btm}, /* btm */ - ncm::TitleId{TitleId_Glue}, /* glue */ - /* ncm::TitleId{TitleId_Eclct}, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ - ncm::TitleId{TitleId_Fatal}, /* fatal */ - ncm::TitleId{TitleId_Ro}, /* ro */ - ncm::TitleId{TitleId_Profiler}, /* profiler */ - ncm::TitleId{TitleId_Sdb}, /* sdb */ - ncm::TitleId{TitleId_Migration}, /* migration */ - ncm::TitleId{TitleId_Grc}, /* grc */ - ncm::TitleId{TitleId_Olsc}, /* olsc */ + ncm::TitleId::Usb, /* usb */ + ncm::TitleId::Tma, /* tma */ + ncm::TitleId::Am, /* am */ + ncm::TitleId::NvServices, /* nvservices */ + ncm::TitleId::NvnFlinger, /* nvnflinger */ + ncm::TitleId::Vi, /* vi */ + ncm::TitleId::Ns, /* ns */ + ncm::TitleId::LogManager, /* lm */ + ncm::TitleId::Ppc, /* ppc */ + ncm::TitleId::Ptm, /* ptm */ + ncm::TitleId::Hid, /* hid */ + ncm::TitleId::Audio, /* audio */ + ncm::TitleId::Lbl, /* lbl */ + ncm::TitleId::Wlan, /* wlan */ + ncm::TitleId::Bluetooth, /* bluetooth */ + ncm::TitleId::BsdSockets, /* bsdsockets */ + ncm::TitleId::Nifm, /* nifm */ + ncm::TitleId::Ldn, /* ldn */ + ncm::TitleId::Account, /* account */ + ncm::TitleId::Nfc, /* nfc */ + ncm::TitleId::JpegDec, /* jpegdec */ + ncm::TitleId::CapSrv, /* capsrv */ + ncm::TitleId::Ssl, /* ssl */ + ncm::TitleId::Nim, /* nim */ + ncm::TitleId::Erpt, /* erpt */ + ncm::TitleId::Es, /* es */ + ncm::TitleId::Pctl, /* pctl */ + ncm::TitleId::Btm, /* btm */ + ncm::TitleId::Glue, /* glue */ + /* ncm::TitleId::Eclct, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ + ncm::TitleId::Fatal, /* fatal */ + ncm::TitleId::Ro, /* ro */ + ncm::TitleId::Profiler, /* profiler */ + ncm::TitleId::Sdb, /* sdb */ + ncm::TitleId::Migration, /* migration */ + ncm::TitleId::Grc, /* grc */ + ncm::TitleId::Olsc, /* olsc */ }; constexpr size_t NumAdditionalMaintenanceLaunchPrograms = util::size(AdditionalMaintenanceLaunchPrograms); @@ -164,7 +164,7 @@ namespace sts::boot2 { void LaunchList(const ncm::TitleId *launch_list, size_t num_entries) { for (size_t i = 0; i < num_entries; i++) { - LaunchTitle(nullptr, ncm::MakeTitleLocation(launch_list[i], ncm::StorageId::NandSystem), 0); + LaunchTitle(nullptr, ncm::TitleLocation::Make(launch_list[i], ncm::StorageId::NandSystem), 0); } } @@ -239,7 +239,7 @@ namespace sts::boot2 { FILE *f_flag = fopen(title_path, "rb"); if (f_flag != NULL) { fclose(f_flag); - LaunchTitle(nullptr, ncm::MakeTitleLocation(title_id, ncm::StorageId::None), 0); + LaunchTitle(nullptr, ncm::TitleLocation::Make(title_id, ncm::StorageId::None), 0); } } } @@ -275,7 +275,7 @@ namespace sts::boot2 { } /* Launch Atmosphere dmnt, using FsStorageId_None to force SD card boot. */ - LaunchTitle(nullptr, ncm::MakeTitleLocation(ncm::TitleId{TitleId_Dmnt}, ncm::StorageId::None), 0); + LaunchTitle(nullptr, ncm::TitleLocation::Make(ncm::TitleId::Dmnt, ncm::StorageId::None), 0); /* Launch additional programs. */ if (maintenance) { diff --git a/stratosphere/pm/source/impl/pm_process_manager.cpp b/stratosphere/pm/source/impl/pm_process_manager.cpp index 1958c8946..17bc69c99 100644 --- a/stratosphere/pm/source/impl/pm_process_manager.cpp +++ b/stratosphere/pm/source/impl/pm_process_manager.cpp @@ -208,7 +208,7 @@ namespace sts::pm::impl { } /* Fix the title location to use the right title id. */ - const ncm::TitleLocation location = ncm::MakeTitleLocation(program_info.title_id, static_cast(args->location.storage_id)); + const ncm::TitleLocation location = ncm::TitleLocation::Make(program_info.title_id, static_cast(args->location.storage_id)); /* Pin the program with loader. */ ldr::PinId pin_id; @@ -256,7 +256,7 @@ namespace sts::pm::impl { /* Process hooks/signaling. */ if (location.title_id == g_title_id_hook) { g_hook_to_create_process_event->Signal(); - g_title_id_hook = ncm::InvalidTitleId; + g_title_id_hook = ncm::TitleId::Invalid; } else if (is_application && g_application_hook) { g_hook_to_create_application_process_event->Signal(); g_application_hook = false; @@ -611,7 +611,7 @@ namespace sts::pm::impl { Result HookToCreateProcess(Handle *out_hook, ncm::TitleId title_id) { *out_hook = INVALID_HANDLE; - ncm::TitleId old_value = ncm::InvalidTitleId; + ncm::TitleId old_value = ncm::TitleId::Invalid; if (!g_title_id_hook.compare_exchange_strong(old_value, title_id)) { return ResultPmDebugHookInUse; } @@ -634,7 +634,7 @@ namespace sts::pm::impl { Result ClearHook(u32 which) { if (which & HookType_TitleId) { - g_title_id_hook = ncm::InvalidTitleId; + g_title_id_hook = ncm::TitleId::Invalid; } if (which & HookType_Application) { g_application_hook = false; diff --git a/stratosphere/pm/source/pm_main.cpp b/stratosphere/pm/source/pm_main.cpp index d04c4e0a9..b4e52cb66 100644 --- a/stratosphere/pm/source/pm_main.cpp +++ b/stratosphere/pm/source/pm_main.cpp @@ -49,10 +49,11 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = TitleId_Pm; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Pm; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); } diff --git a/stratosphere/ro/source/ro_main.cpp b/stratosphere/ro/source/ro_main.cpp index aa1a055d4..42e4510bd 100644 --- a/stratosphere/ro/source/ro_main.cpp +++ b/stratosphere/ro/source/ro_main.cpp @@ -40,14 +40,10 @@ extern "C" { void __libnx_initheap(void); void __appInit(void); void __appExit(void); - - /* Exception handling. */ - u64 __stratosphere_title_id = TitleId_Ro; } -void __libnx_exception_handler(ThreadExceptionDump *ctx) { - StratosphereCrashHandler(ctx); -} +/* Exception handling. */ +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Ro; void __libnx_initheap(void) { void* addr = nx_inner_heap; diff --git a/stratosphere/sm/source/sm_main.cpp b/stratosphere/sm/source/sm_main.cpp index 763bfed5e..9876b0a59 100644 --- a/stratosphere/sm/source/sm_main.cpp +++ b/stratosphere/sm/source/sm_main.cpp @@ -45,10 +45,11 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = TitleId_Sm; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Sm; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); } diff --git a/stratosphere/spl/source/spl_main.cpp b/stratosphere/spl/source/spl_main.cpp index 93973d87d..ca2ad5ce0 100644 --- a/stratosphere/spl/source/spl_main.cpp +++ b/stratosphere/spl/source/spl_main.cpp @@ -51,10 +51,11 @@ extern "C" { alignas(16) u8 __nx_exception_stack[0x1000]; u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); void __libnx_exception_handler(ThreadExceptionDump *ctx); - u64 __stratosphere_title_id = TitleId_Spl; void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); } +sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Spl; + void __libnx_exception_handler(ThreadExceptionDump *ctx) { StratosphereCrashHandler(ctx); }