diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp index 1a59aec63..29286ff57 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp @@ -26,6 +26,8 @@ namespace ams::mitm::fs { namespace { + constexpr const char AtmosphereHblWebContentDir[] = "/atmosphere/hbl_html/"; + os::Mutex g_storage_cache_lock; std::unordered_map> g_storage_cache; @@ -61,6 +63,39 @@ namespace ams::mitm::fs { return (tmp != 0); } + Result OpenHblWebContentFileSystem(sf::Out> &out, ncm::ProgramId client_program_id, ncm::ProgramId program_id, FsFileSystemType filesystem_type) { + /* Verify eligibility. */ + bool is_hbl; + R_UNLESS(ncm::IsWebAppletProgramId(client_program_id), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(filesystem_type == FsFileSystemType_ContentManual, sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, program_id)), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(is_hbl, sm::mitm::ResultShouldForwardToSession()); + + /* Hbl html directory must exist. */ + { + FsDir d; + R_UNLESS(R_SUCCEEDED(mitm::fs::OpenSdDirectory(&d, AtmosphereHblWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession()); + fsDirClose(&d); + } + + /* Open the SD card using fs.mitm's session. */ + FsFileSystem sd_fs; + R_TRY(fsOpenSdCardFileSystem(&sd_fs)); + const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)}; + std::unique_ptr sd_ifs = std::make_unique(sd_fs); + + out.SetValue(std::make_shared(std::make_shared(std::move(sd_ifs), AtmosphereHblWebContentDir), false), target_object_id); + return ResultSuccess(); + } + + } + + Result FsMitmService::OpenFileSystemWithPatch(sf::Out> out, ncm::ProgramId program_id, u32 _filesystem_type) { + return OpenHblWebContentFileSystem(out, this->client_info.program_id, program_id, static_cast(_filesystem_type)); + } + + Result FsMitmService::OpenFileSystemWithId(sf::Out> out, const fssrv::sf::Path &path, ncm::ProgramId program_id, u32 _filesystem_type) { + return OpenHblWebContentFileSystem(out, this->client_info.program_id, program_id, static_cast(_filesystem_type)); } Result FsMitmService::OpenSdCardFileSystem(sf::Out> out) { diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.hpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.hpp index 4ff9a2670..bf109e7c6 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.hpp @@ -60,8 +60,8 @@ namespace ams::mitm::fs { SF_MITM_SERVICE_OBJECT_CTOR(FsMitmService) { /* ... */ } protected: /* Overridden commands. */ - /* Result OpenFileSystemWithPatch(Out> out, u64 program_id, u32 filesystem_type); */ - /* Result OpenFileSystemWithId(Out> out, InPointer path, u64 program_id, u32 filesystem_type); */ + Result OpenFileSystemWithPatch(sf::Out> out, ncm::ProgramId program_id, u32 _filesystem_type); + Result OpenFileSystemWithId(sf::Out> out, const fssrv::sf::Path &path, ncm::ProgramId program_id, u32 _filesystem_type); Result OpenSdCardFileSystem(sf::Out> out); Result OpenSaveDataFileSystem(sf::Out> out, u8 space_id, const FsSaveDataAttribute &attribute); Result OpenBisStorage(sf::Out> out, u32 bis_partition_id); @@ -69,8 +69,8 @@ namespace ams::mitm::fs { Result OpenDataStorageByDataId(sf::Out> out, ncm::ProgramId /* TODO: ncm::DataId */ data_id, u8 storage_id); public: DEFINE_SERVICE_DISPATCH_TABLE { - /* MAKE_SERVICE_COMMAND_META(OpenFileSystemWithPatch, hos::Version_200), */ - /* MAKE_SERVICE_COMMAND_META(OpenFileSystemWithId, hos::Version_200), */ + MAKE_SERVICE_COMMAND_META(OpenFileSystemWithPatch, hos::Version_200), + MAKE_SERVICE_COMMAND_META(OpenFileSystemWithId, hos::Version_200), MAKE_SERVICE_COMMAND_META(OpenSdCardFileSystem), MAKE_SERVICE_COMMAND_META(OpenSaveDataFileSystem), MAKE_SERVICE_COMMAND_META(OpenBisStorage), diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp index daa7babb6..80c1d1e36 100644 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp @@ -30,7 +30,7 @@ namespace ams::fssystem { size_t after_dir_len; public: DirectoryRedirectionFileSystem(std::shared_ptr fs, const char *before, const char *after, bool unc = false); - DirectoryRedirectionFileSystem(std::unique_ptr &&fs, const char *before, const char *after, bool unc = false); + DirectoryRedirectionFileSystem(std::unique_ptr fs, const char *before, const char *after, bool unc = false); virtual ~DirectoryRedirectionFileSystem(); protected: diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp index 99a8213cb..549ceac6e 100644 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp @@ -28,7 +28,7 @@ namespace ams::fssystem { size_t base_path_len; public: SubDirectoryFileSystem(std::shared_ptr fs, const char *bp, bool unc = false); - SubDirectoryFileSystem(std::unique_ptr &&fs, const char *bp, bool unc = false); + SubDirectoryFileSystem(std::unique_ptr fs, const char *bp, bool unc = false); virtual ~SubDirectoryFileSystem(); protected: diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp index 4797ab77e..1ba6a388d 100644 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp +++ b/stratosphere/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp @@ -35,7 +35,7 @@ namespace ams::fssystem::impl { /* ... */ } - IPathResolutionFileSystem(std::unique_ptr &&fs, bool unc = false) : unique_fs(std::move(fs)), unc_preserved(unc), base_fs(unique_fs.get()) { + IPathResolutionFileSystem(std::unique_ptr fs, bool unc = false) : unique_fs(std::move(fs)), unc_preserved(unc), base_fs(unique_fs.get()) { /* ... */ } diff --git a/stratosphere/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp b/stratosphere/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp index 0da78f51c..94f5b5eca 100644 --- a/stratosphere/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp +++ b/stratosphere/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp @@ -25,8 +25,8 @@ namespace ams::fssystem { R_ASSERT(this->Initialize(before, after)); } - DirectoryRedirectionFileSystem::DirectoryRedirectionFileSystem(std::unique_ptr &&fs, const char *before, const char *after, bool unc) - : PathResolutionFileSystem(std::forward>(fs), unc) + DirectoryRedirectionFileSystem::DirectoryRedirectionFileSystem(std::unique_ptr fs, const char *before, const char *after, bool unc) + : PathResolutionFileSystem(std::move(fs), unc) { this->before_dir = nullptr; this->after_dir = nullptr; diff --git a/stratosphere/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp b/stratosphere/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp index 1be30c3f5..9376b3179 100644 --- a/stratosphere/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp +++ b/stratosphere/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp @@ -80,7 +80,7 @@ namespace ams::fssystem { } DirectorySaveDataFileSystem::DirectorySaveDataFileSystem(std::unique_ptr fs) - : PathResolutionFileSystem(std::forward>(fs)), open_writable_files(0) + : PathResolutionFileSystem(std::move(fs)), open_writable_files(0) { /* ... */ } diff --git a/stratosphere/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp b/stratosphere/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp index f359b10fa..4d64091e9 100644 --- a/stratosphere/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp +++ b/stratosphere/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp @@ -24,8 +24,8 @@ namespace ams::fssystem { R_ASSERT(this->Initialize(bp)); } - SubDirectoryFileSystem::SubDirectoryFileSystem(std::unique_ptr &&fs, const char *bp, bool unc) - : PathResolutionFileSystem(std::forward>(fs), unc) + SubDirectoryFileSystem::SubDirectoryFileSystem(std::unique_ptr fs, const char *bp, bool unc) + : PathResolutionFileSystem(std::move(fs), unc) { this->base_path = nullptr; R_ASSERT(this->Initialize(bp)); diff --git a/stratosphere/libstratosphere/source/pm/pm_ams.c b/stratosphere/libstratosphere/source/pm/pm_ams.c index 858cae2aa..020294451 100644 --- a/stratosphere/libstratosphere/source/pm/pm_ams.c +++ b/stratosphere/libstratosphere/source/pm/pm_ams.c @@ -34,7 +34,7 @@ Result pminfoAtmosphereGetProcessInfo(NcmProgramLocation *loc_out, CfgOverrideSt CfgOverrideStatus status; } out; - Result rc = serviceDispatchInOut(pmdmntGetServiceSession(), 65002, pid, out); + Result rc = serviceDispatchInOut(pminfoGetServiceSession(), 65002, pid, out); if (R_SUCCEEDED(rc)) { if (loc_out) *loc_out = out.loc;