strat: go all in on ncm::TitleId

This commit is contained in:
Michael Scire 2019-07-02 20:54:16 -07:00 committed by SciresM
parent c916a7db88
commit 2d0c881ffe
33 changed files with 191 additions and 186 deletions

View file

@ -43,10 +43,11 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = 0x010041544D530000ul;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::AtmosphereMitm;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }

View file

@ -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: /* We will mitm:
* - am, to intercept the Reboot/Power buttons in the overlay menu. * - am, to intercept the Reboot/Power buttons in the overlay menu.
* - fatal, to simplify payload reboot logic significantly * - fatal, to simplify payload reboot logic significantly
* - applications, to allow homebrew to take advantage of the feature. * - 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<u64>(tid));
} }
static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);

View file

@ -28,11 +28,11 @@ bool Boot0Storage::CanModifyBctPubks() {
/* RCM bug patched. */ /* RCM bug patched. */
/* Only allow NS to update the BCT pubks. */ /* 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. */ /* 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 { } else {
/* RCM bug unpatched. */ /* RCM bug unpatched. */
/* Allow homebrew but not NS to update the BCT pubks. */ /* Allow homebrew but not NS to update the BCT pubks. */
return this->title_id != TitleId_Ns; return this->title_id != sts::ncm::TitleId::Ns;
} }
} }

View file

@ -131,12 +131,12 @@ class Boot0Storage : public SectoredProxyStorage<0x200> {
static constexpr u64 EksSize = 0x4000; static constexpr u64 EksSize = 0x4000;
static constexpr u64 EksEnd = EksStart + EksSize; static constexpr u64 EksEnd = EksStart + EksSize;
private: private:
u64 title_id; sts::ncm::TitleId title_id;
private: private:
bool CanModifyBctPubks(); bool CanModifyBctPubks();
public: public:
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, u64 t) : Base(s), title_id(t) { } Boot0Storage(FsStorage s, sts::ncm::TitleId t) : Base(s), title_id(t) { }
public: public:
virtual Result Read(void *_buffer, size_t size, u64 offset) override; virtual Result Read(void *_buffer, size_t size, u64 offset) override;
virtual Result Write(void *_buffer, size_t size, u64 offset) override; virtual Result Write(void *_buffer, size_t size, u64 offset) override;

View file

@ -39,13 +39,13 @@
static HosMutex g_StorageCacheLock; static HosMutex g_StorageCacheLock;
static std::unordered_map<u64, std::weak_ptr<IStorageInterface>> g_StorageCache; static std::unordered_map<u64, std::weak_ptr<IStorageInterface>> g_StorageCache;
static bool StorageCacheGetEntry(u64 title_id, std::shared_ptr<IStorageInterface> *out) { static bool StorageCacheGetEntry(sts::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *out) {
std::scoped_lock<HosMutex> lock(g_StorageCacheLock); std::scoped_lock<HosMutex> lock(g_StorageCacheLock);
if (g_StorageCache.find(title_id) == g_StorageCache.end()) { if (g_StorageCache.find(static_cast<u64>(title_id)) == g_StorageCache.end()) {
return false; return false;
} }
auto intf = g_StorageCache[title_id].lock(); auto intf = g_StorageCache[static_cast<u64>(title_id)].lock();
if (intf != nullptr) { if (intf != nullptr) {
*out = intf; *out = intf;
return true; return true;
@ -53,18 +53,18 @@ static bool StorageCacheGetEntry(u64 title_id, std::shared_ptr<IStorageInterface
return false; return false;
} }
static void StorageCacheSetEntry(u64 title_id, std::shared_ptr<IStorageInterface> *ptr) { static void StorageCacheSetEntry(sts::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *ptr) {
std::scoped_lock<HosMutex> lock(g_StorageCacheLock); std::scoped_lock<HosMutex> lock(g_StorageCacheLock);
/* Ensure we always use the cached copy if present. */ /* Ensure we always use the cached copy if present. */
if (g_StorageCache.find(title_id) != g_StorageCache.end()) { if (g_StorageCache.find(static_cast<u64>(title_id)) != g_StorageCache.end()) {
auto intf = g_StorageCache[title_id].lock(); auto intf = g_StorageCache[static_cast<u64>(title_id)].lock();
if (intf != nullptr) { if (intf != nullptr) {
*ptr = intf; *ptr = intf;
} }
} }
g_StorageCache[title_id] = *ptr; g_StorageCache[static_cast<u64>(title_id)] = *ptr;
} }
void FsMitmService::PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx) { void FsMitmService::PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx) {
@ -74,7 +74,7 @@ void FsMitmService::PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx
if (R_SUCCEEDED(ctx->rc)) { if (R_SUCCEEDED(ctx->rc)) {
this_ptr->has_initialized = true; this_ptr->has_initialized = true;
this_ptr->process_id = ctx->request.Pid; 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))) { if (R_FAILED(MitmQueryUtils::GetAssociatedTidForPid(this_ptr->process_id, &this_ptr->title_id))) {
/* Log here, if desired. */ /* Log here, if desired. */
} }
@ -105,7 +105,7 @@ Result FsMitmService::OpenFileSystemWithPatch(Out<std::shared_ptr<IFileSystemInt
/* Check for eligibility. */ /* Check for eligibility. */
{ {
FsDir d; FsDir d;
if (!Utils::IsWebAppletTid(this->title_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || if (!Utils::IsWebAppletTid(static_cast<u64>(this->title_id)) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) ||
R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) { R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) {
return ResultAtmosphereMitmShouldForwardToSession; return ResultAtmosphereMitmShouldForwardToSession;
} }
@ -129,7 +129,7 @@ Result FsMitmService::OpenFileSystemWithId(Out<std::shared_ptr<IFileSystemInterf
/* Check for eligibility. */ /* Check for eligibility. */
{ {
FsDir d; FsDir d;
if (!Utils::IsWebAppletTid(this->title_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || if (!Utils::IsWebAppletTid(static_cast<u64>(this->title_id)) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) ||
R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) { R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) {
return ResultAtmosphereMitmShouldForwardToSession; return ResultAtmosphereMitmShouldForwardToSession;
} }
@ -151,7 +151,7 @@ Result FsMitmService::OpenFileSystemWithId(Out<std::shared_ptr<IFileSystemInterf
Result FsMitmService::OpenSdCardFileSystem(Out<std::shared_ptr<IFileSystemInterface>> out_fs) { Result FsMitmService::OpenSdCardFileSystem(Out<std::shared_ptr<IFileSystemInterface>> out_fs) {
/* We only care about redirecting this for NS/Emummc. */ /* 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; return ResultAtmosphereMitmShouldForwardToSession;
} }
if (!IsEmummc()) { if (!IsEmummc()) {
@ -174,7 +174,7 @@ Result FsMitmService::OpenSdCardFileSystem(Out<std::shared_ptr<IFileSystemInterf
Result FsMitmService::OpenSaveDataFileSystem(Out<std::shared_ptr<IFileSystemInterface>> out_fs, u8 space_id, FsSave save_struct) { Result FsMitmService::OpenSaveDataFileSystem(Out<std::shared_ptr<IFileSystemInterface>> out_fs, u8 space_id, FsSave save_struct) {
bool should_redirect_saves = false; 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<u64>(this->title_id), "redirect_save");
if (R_FAILED(Utils::GetSettingsItemBooleanValue("atmosphere", "fsmitm_redirect_saves_to_sd", &should_redirect_saves))) { if (R_FAILED(Utils::GetSettingsItemBooleanValue("atmosphere", "fsmitm_redirect_saves_to_sd", &should_redirect_saves))) {
return ResultAtmosphereMitmShouldForwardToSession; return ResultAtmosphereMitmShouldForwardToSession;
} }
@ -199,7 +199,7 @@ Result FsMitmService::OpenSaveDataFileSystem(Out<std::shared_ptr<IFileSystemInte
/* Verify that we can open the save directory, and that it exists. */ /* Verify that we can open the save directory, and that it exists. */
const u64 target_tid = save_struct.titleID == 0 ? this->title_id : save_struct.titleID; const u64 target_tid = save_struct.titleID == 0 ? static_cast<u64>(this->title_id) : save_struct.titleID;
FsPath save_dir_path; FsPath save_dir_path;
R_TRY(FsSaveUtils::GetSaveDataDirectoryPath(save_dir_path, space_id, save_struct.saveDataType, target_tid, save_struct.userID, save_struct.saveID)); 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<std::shared_ptr<IStorageInterface>> out
FsStorage bis_storage; FsStorage bis_storage;
R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), &bis_storage, bis_partition_id)); R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), &bis_storage, bis_partition_id));
const bool is_sysmodule = TitleIdIsSystem(this->title_id); const bool is_sysmodule = sts::ncm::IsSystemTitleId(this->title_id);
const bool has_bis_write_flag = Utils::HasFlag(this->title_id, "bis_write"); const bool has_bis_write_flag = Utils::HasFlag(static_cast<u64>(this->title_id), "bis_write");
const bool has_cal0_read_flag = Utils::HasFlag(this->title_id, "cal_read"); const bool has_cal0_read_flag = Utils::HasFlag(static_cast<u64>(this->title_id), "cal_read");
/* Set output storage. */ /* Set output storage. */
if (bis_partition_id == FsBisStorageId_Boot0) { if (bis_partition_id == FsBisStorageId_Boot0) {
@ -260,7 +260,7 @@ Result FsMitmService::OpenBisStorage(Out<std::shared_ptr<IStorageInterface>> out
if (is_sysmodule || has_bis_write_flag) { if (is_sysmodule || has_bis_write_flag) {
/* Sysmodules should still be allowed to read and write. */ /* Sysmodules should still be allowed to read and write. */
out_storage.SetValue(std::make_shared<IStorageInterface>(new ProxyStorage(bis_storage))); out_storage.SetValue(std::make_shared<IStorageInterface>(new ProxyStorage(bis_storage)));
} else if (Utils::IsHblTid(this->title_id) && } else if (Utils::IsHblTid(static_cast<u64>(this->title_id)) &&
((FsBisStorageId_BootConfigAndPackage2NormalMain <= bis_partition_id && bis_partition_id <= FsBisStorageId_BootConfigAndPackage2RepairSub) || ((FsBisStorageId_BootConfigAndPackage2NormalMain <= bis_partition_id && bis_partition_id <= FsBisStorageId_BootConfigAndPackage2RepairSub) ||
bis_partition_id == FsBisStorageId_Boot1)) { bis_partition_id == FsBisStorageId_Boot1)) {
/* Allow HBL to write to boot1 (safe firm) + package2. */ /* Allow HBL to write to boot1 (safe firm) + package2. */
@ -288,7 +288,7 @@ Result FsMitmService::OpenDataStorageByCurrentProcess(Out<std::shared_ptr<IStora
} }
/* If we don't have anything to modify, there's no sense in maintaining a copy of the metadata tables. */ /* If we don't have anything to modify, there's no sense in maintaining a copy of the metadata tables. */
if (!Utils::HasSdRomfsContent(this->title_id)) { if (!Utils::HasSdRomfsContent(static_cast<u64>(this->title_id))) {
return ResultAtmosphereMitmShouldForwardToSession; return ResultAtmosphereMitmShouldForwardToSession;
} }
@ -318,10 +318,10 @@ Result FsMitmService::OpenDataStorageByCurrentProcess(Out<std::shared_ptr<IStora
std::shared_ptr<IStorageInterface> storage_to_cache = nullptr; std::shared_ptr<IStorageInterface> storage_to_cache = nullptr;
/* TODO: Is there a sensible path that ends in ".romfs" we can use?" */ /* TODO: Is there a sensible path that ends in ".romfs" we can use?" */
FsFile data_file; FsFile data_file;
if (R_SUCCEEDED(Utils::OpenSdFileForAtmosphere(this->title_id, "romfs.bin", FS_OPEN_READ, &data_file))) { if (R_SUCCEEDED(Utils::OpenSdFileForAtmosphere(static_cast<u64>(this->title_id), "romfs.bin", FS_OPEN_READ, &data_file))) {
storage_to_cache = std::make_shared<IStorageInterface>(new LayeredRomFS(std::make_shared<ReadOnlyStorageAdapter>(new ProxyStorage(data_storage)), std::make_shared<ReadOnlyStorageAdapter>(new FileStorage(new ProxyFile(data_file))), this->title_id)); storage_to_cache = std::make_shared<IStorageInterface>(new LayeredRomFS(std::make_shared<ReadOnlyStorageAdapter>(new ProxyStorage(data_storage)), std::make_shared<ReadOnlyStorageAdapter>(new FileStorage(new ProxyFile(data_file))), static_cast<u64>(this->title_id)));
} else { } else {
storage_to_cache = std::make_shared<IStorageInterface>(new LayeredRomFS(std::make_shared<ReadOnlyStorageAdapter>(new ProxyStorage(data_storage)), nullptr, this->title_id)); storage_to_cache = std::make_shared<IStorageInterface>(new LayeredRomFS(std::make_shared<ReadOnlyStorageAdapter>(new ProxyStorage(data_storage)), nullptr, static_cast<u64>(this->title_id)));
} }
StorageCacheSetEntry(this->title_id, &storage_to_cache); StorageCacheSetEntry(this->title_id, &storage_to_cache);
@ -351,7 +351,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterf
/* Try to get from the cache. */ /* Try to get from the cache. */
{ {
std::shared_ptr<IStorageInterface> cached_storage = nullptr; std::shared_ptr<IStorageInterface> 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 (has_cache) {
if (out_storage.IsDomain()) { if (out_storage.IsDomain()) {
@ -380,7 +380,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterf
storage_to_cache = std::make_shared<IStorageInterface>(new LayeredRomFS(std::make_shared<ReadOnlyStorageAdapter>(new ProxyStorage(data_storage)), nullptr, data_id)); storage_to_cache = std::make_shared<IStorageInterface>(new LayeredRomFS(std::make_shared<ReadOnlyStorageAdapter>(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)); out_storage.SetValue(std::move(storage_to_cache));
if (out_storage.IsDomain()) { if (out_storage.IsDomain()) {

View file

@ -45,14 +45,14 @@ class FsMitmService : public IMitmServiceObject {
bool should_override_contents; bool should_override_contents;
public: public:
FsMitmService(std::shared_ptr<Service> s, u64 pid) : IMitmServiceObject(s, pid) { FsMitmService(std::shared_ptr<Service> s, u64 pid) : IMitmServiceObject(s, pid) {
if (Utils::HasSdDisableMitMFlag(this->title_id)) { if (Utils::HasSdDisableMitMFlag(static_cast<u64>(this->title_id))) {
this->should_override_contents = false; this->should_override_contents = false;
} else { } 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<u64>(this->title_id))) && Utils::HasOverrideButton(static_cast<u64>(this->title_id));
} }
} }
static bool ShouldMitm(u64 pid, u64 tid) { static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
/* Don't Mitm KIPs */ /* Don't Mitm KIPs */
if (pid < 0x50) { if (pid < 0x50) {
return false; return false;
@ -62,11 +62,11 @@ class FsMitmService : public IMitmServiceObject {
/* TODO: intercepting everything seems to cause issues with sleep mode, for some reason. */ /* TODO: intercepting everything seems to cause issues with sleep mode, for some reason. */
/* Figure out why, and address it. */ /* 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; 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<u64>(tid));
} }
static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);

View file

@ -30,7 +30,7 @@ Result NsAmMitmService::GetApplicationContentPath(OutBuffer<u8> out_path, u64 ap
Result NsAmMitmService::ResolveApplicationContentPath(u64 title_id, u8 storage_type) { Result NsAmMitmService::ResolveApplicationContentPath(u64 title_id, u8 storage_type) {
/* Always succeed for web applet asking about HBL. */ /* Always succeed for web applet asking about HBL. */
if (Utils::IsWebAppletTid(this->title_id) && Utils::IsHblTid(title_id)) { if (Utils::IsWebAppletTid(static_cast<u64>(this->title_id)) && Utils::IsHblTid(title_id)) {
nsamResolveApplicationContentPathFwd(this->forward_service.get(), title_id, static_cast<FsStorageId>(storage_type)); nsamResolveApplicationContentPathFwd(this->forward_service.get(), title_id, static_cast<FsStorageId>(storage_type));
return ResultSuccess; return ResultSuccess;
} }

View file

@ -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: /* We will mitm:
* - web applets, to facilitate hbl web browser launching. * - web applets, to facilitate hbl web browser launching.
*/ */
return Utils::IsWebAppletTid(tid); return Utils::IsWebAppletTid(static_cast<u64>(tid));
} }
static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);

View file

@ -29,7 +29,7 @@ Result NsWebMitmService::GetDocumentInterface(Out<std::shared_ptr<NsDocumentServ
R_TRY(nsGetDocumentInterfaceFwd(this->forward_service.get(), &doc)); R_TRY(nsGetDocumentInterfaceFwd(this->forward_service.get(), &doc));
/* Set output interface. */ /* Set output interface. */
out_intf.SetValue(std::move(std::make_shared<NsDocumentService>(this->title_id, doc))); out_intf.SetValue(std::move(std::make_shared<NsDocumentService>(static_cast<u64>(this->title_id), doc)));
if (out_intf.IsDomain()) { if (out_intf.IsDomain()) {
out_intf.ChangeObjectId(doc.s.object_id); out_intf.ChangeObjectId(doc.s.object_id);
} }
@ -43,7 +43,7 @@ Result NsDocumentService::GetApplicationContentPath(OutBuffer<u8> out_path, u64
Result NsDocumentService::ResolveApplicationContentPath(u64 title_id, u8 storage_type) { Result NsDocumentService::ResolveApplicationContentPath(u64 title_id, u8 storage_type) {
/* Always succeed for web applet asking about HBL. */ /* Always succeed for web applet asking about HBL. */
if (Utils::IsWebAppletTid(this->title_id) && Utils::IsHblTid(title_id)) { if (Utils::IsWebAppletTid(static_cast<u64>(this->title_id)) && Utils::IsHblTid(title_id)) {
nswebResolveApplicationContentPath(this->srv.get(), title_id, static_cast<FsStorageId>(storage_type)); nswebResolveApplicationContentPath(this->srv.get(), title_id, static_cast<FsStorageId>(storage_type));
return ResultSuccess; return ResultSuccess;
} }

View file

@ -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: /* We will mitm:
* - web applets, to facilitate hbl web browser launching. * - web applets, to facilitate hbl web browser launching.
*/ */
return Utils::IsWebAppletTid(tid); return Utils::IsWebAppletTid(static_cast<u64>(tid));
} }
static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx); static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);

View file

@ -68,14 +68,14 @@ Result SetMitmService::EnsureLocale() {
if (!this->got_locale) { if (!this->got_locale) {
std::memset(&this->locale, 0xCC, sizeof(this->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_pid = 0;
u64 app_tid = 0; u64 app_tid = 0;
R_TRY(pmdmntGetApplicationPid(&app_pid)); R_TRY(pmdmntGetApplicationPid(&app_pid));
R_TRY(pminfoGetTitleId(&app_tid, app_pid)); R_TRY(pminfoGetTitleId(&app_tid, app_pid));
this->locale = Utils::GetTitleOverrideLocale(app_tid); this->locale = Utils::GetTitleOverrideLocale(app_tid);
} else { } else {
this->locale = Utils::GetTitleOverrideLocale(this->title_id); this->locale = Utils::GetTitleOverrideLocale(static_cast<u64>(this->title_id));
this->got_locale = true; this->got_locale = true;
} }
} }

View file

@ -39,9 +39,9 @@ class SetMitmService : public IMitmServiceObject {
this->got_locale = false; this->got_locale = false;
} }
static bool ShouldMitm(u64 pid, u64 tid) { static bool ShouldMitm(u64 pid, sts::ncm::TitleId tid) {
/* Mitm all applications. */ /* 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); static void PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx);

View file

@ -32,7 +32,7 @@ void VersionManager::Initialize() {
} }
/* Mount firmware version data archive. */ /* Mount firmware version data archive. */
R_ASSERT(romfsMountFromDataArchive(TitleId_ArchiveSystemVersion, FsStorageId_NandSystem, "sysver")); R_ASSERT(romfsMountFromDataArchive(static_cast<u64>(sts::ncm::TitleId::ArchiveSystemVersion), FsStorageId_NandSystem, "sysver"));
{ {
ON_SCOPE_EXIT { romfsUnmount("sysver"); }; ON_SCOPE_EXIT { romfsUnmount("sysver"); };
@ -70,11 +70,11 @@ void VersionManager::Initialize() {
g_got_version = true; g_got_version = true;
} }
Result VersionManager::GetFirmwareVersion(u64 title_id, SetSysFirmwareVersion *out) { Result VersionManager::GetFirmwareVersion(sts::ncm::TitleId title_id, SetSysFirmwareVersion *out) {
VersionManager::Initialize(); VersionManager::Initialize();
/* Report atmosphere string to qlaunch, maintenance and nothing else. */ /* 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; *out = g_ams_fw_version;
} else { } else {
*out = g_fw_version; *out = g_fw_version;

View file

@ -21,5 +21,5 @@
class VersionManager { class VersionManager {
public: public:
static void Initialize(); static void Initialize();
static Result GetFirmwareVersion(u64 title_id, SetSysFirmwareVersion *out); static Result GetFirmwareVersion(sts::ncm::TitleId title_id, SetSysFirmwareVersion *out);
}; };

View file

@ -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. */ /* Mitm everything. */
return true; return true;
} }

View file

@ -52,7 +52,7 @@ static HblOverrideConfig g_hbl_override_config = {
.key_combination = KEY_R, .key_combination = KEY_R,
.override_by_default = false .override_by_default = false
}, },
.title_id = TitleId_AppletPhotoViewer, .title_id = static_cast<u64>(sts::ncm::TitleId::AppletPhotoViewer),
.override_any_app = true .override_any_app = true
}; };
@ -378,12 +378,14 @@ Result Utils::SaveSdFileForAtmosphere(u64 title_id, const char *fn, void *data,
return ResultSuccess; return ResultSuccess;
} }
bool Utils::IsHblTid(u64 tid) { bool Utils::IsHblTid(u64 _tid) {
return (g_hbl_override_config.override_any_app && TitleIdIsApplication(tid)) || (tid == g_hbl_override_config.title_id); 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) { bool Utils::IsWebAppletTid(u64 _tid) {
return tid == TitleId_AppletWeb || tid == TitleId_AppletOfflineWeb || tid == TitleId_AppletLoginShare || tid == TitleId_AppletWifiWebAuth; 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) { bool Utils::HasTitleFlag(u64 tid, const char *flag) {
@ -472,7 +474,7 @@ static bool HasOverrideKey(OverrideKey *cfg) {
bool Utils::HasOverrideButton(u64 tid) { 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. */ /* Disable button override disable for non-applications. */
return true; return true;
} }

View file

@ -58,10 +58,11 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = TitleId_Boot;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Boot;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }

View file

@ -43,10 +43,11 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = TitleId_Creport;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Creport;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }

View file

@ -40,11 +40,10 @@ extern "C" {
void __libnx_initheap(void); void __libnx_initheap(void);
void __appInit(void); void __appInit(void);
void __appExit(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 __libnx_initheap(void) {
void* addr = nx_inner_heap; void* addr = nx_inner_heap;

View file

@ -40,10 +40,11 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = TitleId_Eclct;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Eclct;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }

View file

@ -50,15 +50,15 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = TitleId_Fatal;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Fatal;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }
void __libnx_initheap(void) { void __libnx_initheap(void) {
void* addr = nx_inner_heap; void* addr = nx_inner_heap;
size_t size = nx_inner_heap_size; size_t size = nx_inner_heap_size;

View file

@ -66,13 +66,13 @@ Result ThrowFatalImpl(u32 error, u64 pid, FatalType policy, FatalCpuContext *cpu
const FatalConfig *config = GetFatalConfig(); const FatalConfig *config = GetFatalConfig();
/* Get title id. On failure, it'll be zero. */ /* Get title id. On failure, it'll be zero. */
u64 title_id = 0; sts::ncm::TitleId title_id = sts::ncm::TitleId::Invalid;
pminfoGetTitleId(&title_id, pid); sts::pm::info::GetTitleId(&title_id, pid);
ctx.is_creport = title_id == TitleId_Creport; ctx.is_creport = title_id == sts::ncm::TitleId::Creport;
/* Support for ams creport. TODO: Make this its own command? */ /* Support for ams creport. TODO: Make this its own command? */
if (ctx.is_creport && !cpu_ctx->is_aarch32 && cpu_ctx->aarch64_ctx.afsr0 != 0) { 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. */ /* Atmosphere extension: automatic debug info collection. */
@ -104,7 +104,7 @@ Result ThrowFatalImpl(u32 error, u64 pid, FatalType policy, FatalCpuContext *cpu
/* Run tasks. */ /* Run tasks. */
if (config->transition_to_fatal) { if (config->transition_to_fatal) {
RunFatalTasks(&ctx, title_id, policy == FatalType_ErrorReportAndErrorScreen, &erpt_event, &battery_event); RunFatalTasks(&ctx, static_cast<u64>(title_id), policy == FatalType_ErrorReportAndErrorScreen, &erpt_event, &battery_event);
} else { } else {
/* If flag is not set, don't show the fatal screen. */ /* If flag is not set, don't show the fatal screen. */
return ResultSuccess; return ResultSuccess;

@ -1 +1 @@
Subproject commit c9dc24cce1e832650e6a2fc67bce465062504279 Subproject commit d7d7cba3d35e5aa029ace71891e317e0d5412131

View file

@ -43,8 +43,8 @@ namespace sts::ldr {
/* This is necessary to prevent circular dependencies. */ /* This is necessary to prevent circular dependencies. */
namespace sts::pm::info { namespace sts::pm::info {
Result HasLaunchedTitle(bool *out, u64 title_id) { Result HasLaunchedTitle(bool *out, ncm::TitleId title_id) {
*out = ldr::HasLaunchedTitle(ncm::TitleId{title_id}); *out = ldr::HasLaunchedTitle(title_id);
return ResultSuccess; return ResultSuccess;
} }

View file

@ -50,7 +50,7 @@ namespace sts::ldr {
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None) && loc.title_id != out->title_id) { if (loc.storage_id != static_cast<u8>(ncm::StorageId::None) && loc.title_id != out->title_id) {
char path[FS_MAX_PATH]; char path[FS_MAX_PATH];
const ncm::TitleLocation new_loc = ncm::MakeTitleLocation(out->title_id, static_cast<ncm::StorageId>(loc.storage_id)); const ncm::TitleLocation new_loc = ncm::TitleLocation::Make(out->title_id, static_cast<ncm::StorageId>(loc.storage_id));
R_TRY(ResolveContentPath(path, loc)); R_TRY(ResolveContentPath(path, loc));
R_TRY(RedirectContentPath(path, new_loc)); R_TRY(RedirectContentPath(path, new_loc));

View file

@ -44,10 +44,11 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = TitleId_Loader;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Loader;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }

View file

@ -196,17 +196,17 @@ namespace sts::ldr {
return static_cast<Acid::PoolPartition>((meta->acid->flags & Acid::AcidFlag_PoolPartitionMask) >> Acid::AcidFlag_PoolPartitionShift); return static_cast<Acid::PoolPartition>((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 && return version == 0 &&
(title_id == TitleId_Settings || (title_id == ncm::TitleId::Settings ||
title_id == TitleId_Bus || title_id == ncm::TitleId::Bus ||
title_id == TitleId_Audio || title_id == ncm::TitleId::Audio ||
title_id == TitleId_NvServices || title_id == ncm::TitleId::NvServices ||
title_id == TitleId_Ns || title_id == ncm::TitleId::Ns ||
title_id == TitleId_Ssl || title_id == ncm::TitleId::Ssl ||
title_id == TitleId_Es || title_id == ncm::TitleId::Es ||
title_id == TitleId_Creport || title_id == ncm::TitleId::Creport ||
title_id == TitleId_Ro); title_id == ncm::TitleId::Ro);
} }
Result ValidateTitleVersion(ncm::TitleId title_id, u32 version) { Result ValidateTitleVersion(ncm::TitleId title_id, u32 version) {
@ -214,7 +214,7 @@ namespace sts::ldr {
return ResultSuccess; return ResultSuccess;
} else { } else {
#ifdef LDR_VALIDATE_PROCESS_VERSION #ifdef LDR_VALIDATE_PROCESS_VERSION
if (IsDisallowedVersion810(static_cast<u64>(title_id), version)) { if (IsDisallowedVersion810(title_id, version)) {
return ResultLoaderInvalidVersion; return ResultLoaderInvalidVersion;
} else { } else {
return ResultSuccess; return ResultSuccess;

View file

@ -30,97 +30,97 @@ namespace sts::boot2 {
/* psc, bus, pcv is the minimal set of required titles to get SD card. */ /* psc, bus, pcv is the minimal set of required titles to get SD card. */
/* bus depends on pcie, and pcv depends on settings. */ /* bus depends on pcie, and pcv depends on settings. */
constexpr ncm::TitleId PreSdCardLaunchPrograms[] = { constexpr ncm::TitleId PreSdCardLaunchPrograms[] = {
ncm::TitleId{TitleId_Psc}, /* psc */ ncm::TitleId::Psc, /* psc */
ncm::TitleId{TitleId_Pcie}, /* pcie */ ncm::TitleId::Pcie, /* pcie */
ncm::TitleId{TitleId_Bus}, /* bus */ ncm::TitleId::Bus, /* bus */
ncm::TitleId{TitleId_Settings}, /* settings */ ncm::TitleId::Settings, /* settings */
ncm::TitleId{TitleId_Pcv}, /* pcv */ ncm::TitleId::Pcv, /* pcv */
}; };
constexpr size_t NumPreSdCardLaunchPrograms = util::size(PreSdCardLaunchPrograms); constexpr size_t NumPreSdCardLaunchPrograms = util::size(PreSdCardLaunchPrograms);
constexpr ncm::TitleId AdditionalLaunchPrograms[] = { constexpr ncm::TitleId AdditionalLaunchPrograms[] = {
ncm::TitleId{TitleId_Usb}, /* usb */ ncm::TitleId::Usb, /* usb */
ncm::TitleId{TitleId_Tma}, /* tma */ ncm::TitleId::Tma, /* tma */
ncm::TitleId{TitleId_Am}, /* am */ ncm::TitleId::Am, /* am */
ncm::TitleId{TitleId_NvServices}, /* nvservices */ ncm::TitleId::NvServices, /* nvservices */
ncm::TitleId{TitleId_NvnFlinger}, /* nvnflinger */ ncm::TitleId::NvnFlinger, /* nvnflinger */
ncm::TitleId{TitleId_Vi}, /* vi */ ncm::TitleId::Vi, /* vi */
ncm::TitleId{TitleId_Ns}, /* ns */ ncm::TitleId::Ns, /* ns */
ncm::TitleId{TitleId_LogManager}, /* lm */ ncm::TitleId::LogManager, /* lm */
ncm::TitleId{TitleId_Ppc}, /* ppc */ ncm::TitleId::Ppc, /* ppc */
ncm::TitleId{TitleId_Ptm}, /* ptm */ ncm::TitleId::Ptm, /* ptm */
ncm::TitleId{TitleId_Hid}, /* hid */ ncm::TitleId::Hid, /* hid */
ncm::TitleId{TitleId_Audio}, /* audio */ ncm::TitleId::Audio, /* audio */
ncm::TitleId{TitleId_Lbl}, /* lbl */ ncm::TitleId::Lbl, /* lbl */
ncm::TitleId{TitleId_Wlan}, /* wlan */ ncm::TitleId::Wlan, /* wlan */
ncm::TitleId{TitleId_Bluetooth}, /* bluetooth */ ncm::TitleId::Bluetooth, /* bluetooth */
ncm::TitleId{TitleId_BsdSockets}, /* bsdsockets */ ncm::TitleId::BsdSockets, /* bsdsockets */
ncm::TitleId{TitleId_Nifm}, /* nifm */ ncm::TitleId::Nifm, /* nifm */
ncm::TitleId{TitleId_Ldn}, /* ldn */ ncm::TitleId::Ldn, /* ldn */
ncm::TitleId{TitleId_Account}, /* account */ ncm::TitleId::Account, /* account */
ncm::TitleId{TitleId_Friends}, /* friends */ ncm::TitleId::Friends, /* friends */
ncm::TitleId{TitleId_Nfc}, /* nfc */ ncm::TitleId::Nfc, /* nfc */
ncm::TitleId{TitleId_JpegDec}, /* jpegdec */ ncm::TitleId::JpegDec, /* jpegdec */
ncm::TitleId{TitleId_CapSrv}, /* capsrv */ ncm::TitleId::CapSrv, /* capsrv */
ncm::TitleId{TitleId_Ssl}, /* ssl */ ncm::TitleId::Ssl, /* ssl */
ncm::TitleId{TitleId_Nim}, /* nim */ ncm::TitleId::Nim, /* nim */
ncm::TitleId{TitleId_Bcat}, /* bcat */ ncm::TitleId::Bcat, /* bcat */
ncm::TitleId{TitleId_Erpt}, /* erpt */ ncm::TitleId::Erpt, /* erpt */
ncm::TitleId{TitleId_Es}, /* es */ ncm::TitleId::Es, /* es */
ncm::TitleId{TitleId_Pctl}, /* pctl */ ncm::TitleId::Pctl, /* pctl */
ncm::TitleId{TitleId_Btm}, /* btm */ ncm::TitleId::Btm, /* btm */
ncm::TitleId{TitleId_Eupld}, /* eupld */ ncm::TitleId::Eupld, /* eupld */
ncm::TitleId{TitleId_Glue}, /* glue */ ncm::TitleId::Glue, /* glue */
/* ncm::TitleId{TitleId_Eclct}, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ /* ncm::TitleId::Eclct, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */
ncm::TitleId{TitleId_Npns}, /* npns */ ncm::TitleId::Npns, /* npns */
ncm::TitleId{TitleId_Fatal}, /* fatal */ ncm::TitleId::Fatal, /* fatal */
ncm::TitleId{TitleId_Ro}, /* ro */ ncm::TitleId::Ro, /* ro */
ncm::TitleId{TitleId_Profiler}, /* profiler */ ncm::TitleId::Profiler, /* profiler */
ncm::TitleId{TitleId_Sdb}, /* sdb */ ncm::TitleId::Sdb, /* sdb */
ncm::TitleId{TitleId_Migration}, /* migration */ ncm::TitleId::Migration, /* migration */
ncm::TitleId{TitleId_Grc}, /* grc */ ncm::TitleId::Grc, /* grc */
ncm::TitleId{TitleId_Olsc}, /* olsc */ ncm::TitleId::Olsc, /* olsc */
}; };
constexpr size_t NumAdditionalLaunchPrograms = util::size(AdditionalLaunchPrograms); constexpr size_t NumAdditionalLaunchPrograms = util::size(AdditionalLaunchPrograms);
constexpr ncm::TitleId AdditionalMaintenanceLaunchPrograms[] = { constexpr ncm::TitleId AdditionalMaintenanceLaunchPrograms[] = {
ncm::TitleId{TitleId_Usb}, /* usb */ ncm::TitleId::Usb, /* usb */
ncm::TitleId{TitleId_Tma}, /* tma */ ncm::TitleId::Tma, /* tma */
ncm::TitleId{TitleId_Am}, /* am */ ncm::TitleId::Am, /* am */
ncm::TitleId{TitleId_NvServices}, /* nvservices */ ncm::TitleId::NvServices, /* nvservices */
ncm::TitleId{TitleId_NvnFlinger}, /* nvnflinger */ ncm::TitleId::NvnFlinger, /* nvnflinger */
ncm::TitleId{TitleId_Vi}, /* vi */ ncm::TitleId::Vi, /* vi */
ncm::TitleId{TitleId_Ns}, /* ns */ ncm::TitleId::Ns, /* ns */
ncm::TitleId{TitleId_LogManager}, /* lm */ ncm::TitleId::LogManager, /* lm */
ncm::TitleId{TitleId_Ppc}, /* ppc */ ncm::TitleId::Ppc, /* ppc */
ncm::TitleId{TitleId_Ptm}, /* ptm */ ncm::TitleId::Ptm, /* ptm */
ncm::TitleId{TitleId_Hid}, /* hid */ ncm::TitleId::Hid, /* hid */
ncm::TitleId{TitleId_Audio}, /* audio */ ncm::TitleId::Audio, /* audio */
ncm::TitleId{TitleId_Lbl}, /* lbl */ ncm::TitleId::Lbl, /* lbl */
ncm::TitleId{TitleId_Wlan}, /* wlan */ ncm::TitleId::Wlan, /* wlan */
ncm::TitleId{TitleId_Bluetooth}, /* bluetooth */ ncm::TitleId::Bluetooth, /* bluetooth */
ncm::TitleId{TitleId_BsdSockets}, /* bsdsockets */ ncm::TitleId::BsdSockets, /* bsdsockets */
ncm::TitleId{TitleId_Nifm}, /* nifm */ ncm::TitleId::Nifm, /* nifm */
ncm::TitleId{TitleId_Ldn}, /* ldn */ ncm::TitleId::Ldn, /* ldn */
ncm::TitleId{TitleId_Account}, /* account */ ncm::TitleId::Account, /* account */
ncm::TitleId{TitleId_Nfc}, /* nfc */ ncm::TitleId::Nfc, /* nfc */
ncm::TitleId{TitleId_JpegDec}, /* jpegdec */ ncm::TitleId::JpegDec, /* jpegdec */
ncm::TitleId{TitleId_CapSrv}, /* capsrv */ ncm::TitleId::CapSrv, /* capsrv */
ncm::TitleId{TitleId_Ssl}, /* ssl */ ncm::TitleId::Ssl, /* ssl */
ncm::TitleId{TitleId_Nim}, /* nim */ ncm::TitleId::Nim, /* nim */
ncm::TitleId{TitleId_Erpt}, /* erpt */ ncm::TitleId::Erpt, /* erpt */
ncm::TitleId{TitleId_Es}, /* es */ ncm::TitleId::Es, /* es */
ncm::TitleId{TitleId_Pctl}, /* pctl */ ncm::TitleId::Pctl, /* pctl */
ncm::TitleId{TitleId_Btm}, /* btm */ ncm::TitleId::Btm, /* btm */
ncm::TitleId{TitleId_Glue}, /* glue */ ncm::TitleId::Glue, /* glue */
/* ncm::TitleId{TitleId_Eclct}, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ /* ncm::TitleId::Eclct, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */
ncm::TitleId{TitleId_Fatal}, /* fatal */ ncm::TitleId::Fatal, /* fatal */
ncm::TitleId{TitleId_Ro}, /* ro */ ncm::TitleId::Ro, /* ro */
ncm::TitleId{TitleId_Profiler}, /* profiler */ ncm::TitleId::Profiler, /* profiler */
ncm::TitleId{TitleId_Sdb}, /* sdb */ ncm::TitleId::Sdb, /* sdb */
ncm::TitleId{TitleId_Migration}, /* migration */ ncm::TitleId::Migration, /* migration */
ncm::TitleId{TitleId_Grc}, /* grc */ ncm::TitleId::Grc, /* grc */
ncm::TitleId{TitleId_Olsc}, /* olsc */ ncm::TitleId::Olsc, /* olsc */
}; };
constexpr size_t NumAdditionalMaintenanceLaunchPrograms = util::size(AdditionalMaintenanceLaunchPrograms); 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) { void LaunchList(const ncm::TitleId *launch_list, size_t num_entries) {
for (size_t i = 0; i < num_entries; i++) { 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"); FILE *f_flag = fopen(title_path, "rb");
if (f_flag != NULL) { if (f_flag != NULL) {
fclose(f_flag); 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. */ /* 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. */ /* Launch additional programs. */
if (maintenance) { if (maintenance) {

View file

@ -208,7 +208,7 @@ namespace sts::pm::impl {
} }
/* Fix the title location to use the right title id. */ /* Fix the title location to use the right title id. */
const ncm::TitleLocation location = ncm::MakeTitleLocation(program_info.title_id, static_cast<ncm::StorageId>(args->location.storage_id)); const ncm::TitleLocation location = ncm::TitleLocation::Make(program_info.title_id, static_cast<ncm::StorageId>(args->location.storage_id));
/* Pin the program with loader. */ /* Pin the program with loader. */
ldr::PinId pin_id; ldr::PinId pin_id;
@ -256,7 +256,7 @@ namespace sts::pm::impl {
/* Process hooks/signaling. */ /* Process hooks/signaling. */
if (location.title_id == g_title_id_hook) { if (location.title_id == g_title_id_hook) {
g_hook_to_create_process_event->Signal(); 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) { } else if (is_application && g_application_hook) {
g_hook_to_create_application_process_event->Signal(); g_hook_to_create_application_process_event->Signal();
g_application_hook = false; g_application_hook = false;
@ -611,7 +611,7 @@ namespace sts::pm::impl {
Result HookToCreateProcess(Handle *out_hook, ncm::TitleId title_id) { Result HookToCreateProcess(Handle *out_hook, ncm::TitleId title_id) {
*out_hook = INVALID_HANDLE; *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)) { if (!g_title_id_hook.compare_exchange_strong(old_value, title_id)) {
return ResultPmDebugHookInUse; return ResultPmDebugHookInUse;
} }
@ -634,7 +634,7 @@ namespace sts::pm::impl {
Result ClearHook(u32 which) { Result ClearHook(u32 which) {
if (which & HookType_TitleId) { if (which & HookType_TitleId) {
g_title_id_hook = ncm::InvalidTitleId; g_title_id_hook = ncm::TitleId::Invalid;
} }
if (which & HookType_Application) { if (which & HookType_Application) {
g_application_hook = false; g_application_hook = false;

View file

@ -49,10 +49,11 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = TitleId_Pm;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Pm;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }

View file

@ -40,14 +40,10 @@ extern "C" {
void __libnx_initheap(void); void __libnx_initheap(void);
void __appInit(void); void __appInit(void);
void __appExit(void); void __appExit(void);
/* Exception handling. */
u64 __stratosphere_title_id = TitleId_Ro;
} }
void __libnx_exception_handler(ThreadExceptionDump *ctx) { /* Exception handling. */
StratosphereCrashHandler(ctx); sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Ro;
}
void __libnx_initheap(void) { void __libnx_initheap(void) {
void* addr = nx_inner_heap; void* addr = nx_inner_heap;

View file

@ -45,10 +45,11 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = TitleId_Sm;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Sm;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }

View file

@ -51,10 +51,11 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx); void __libnx_exception_handler(ThreadExceptionDump *ctx);
u64 __stratosphere_title_id = TitleId_Spl;
void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx); void __libstratosphere_exception_handler(AtmosphereFatalErrorContext *ctx);
} }
sts::ncm::TitleId __stratosphere_title_id = sts::ncm::TitleId::Spl;
void __libnx_exception_handler(ThreadExceptionDump *ctx) { void __libnx_exception_handler(ThreadExceptionDump *ctx) {
StratosphereCrashHandler(ctx); StratosphereCrashHandler(ctx);
} }