mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
ns.mitm/fs.mitm: allow program specific web override for non-hbl, if present
This commit is contained in:
parent
e702eab21c
commit
7e6b369605
5 changed files with 24 additions and 14 deletions
|
@ -196,7 +196,7 @@ namespace ams::mitm::fs {
|
||||||
|
|
||||||
/* Check for romfs folder with content. */
|
/* Check for romfs folder with content. */
|
||||||
FsDir romfs_dir;
|
FsDir romfs_dir;
|
||||||
if (R_FAILED(OpenAtmosphereSdRomfsDirectory(std::addressof(romfs_dir), program_id, "", OpenDirectoryMode_All))) {
|
if (R_FAILED(OpenAtmosphereSdRomfsDirectory(std::addressof(romfs_dir), program_id, "", fs::OpenDirectoryMode_All))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ON_SCOPE_EXIT { fsDirClose(std::addressof(romfs_dir)); };
|
ON_SCOPE_EXIT { fsDirClose(std::addressof(romfs_dir)); };
|
||||||
|
|
|
@ -52,4 +52,7 @@ namespace ams::mitm::fs {
|
||||||
Result SaveAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, void *data, size_t size);
|
Result SaveAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, void *data, size_t size);
|
||||||
Result CreateAndOpenAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, size_t size);
|
Result CreateAndOpenAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, size_t size);
|
||||||
|
|
||||||
|
/* NOTE: Implemented in fs.mitm logic. */
|
||||||
|
bool HasSdManualHtmlContent(ncm::ProgramId program_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,11 +96,7 @@ namespace ams::mitm::fs {
|
||||||
|
|
||||||
Result OpenProgramSpecificWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId program_id, FsFileSystemType filesystem_type, Service *fwd, const fssrv::sf::Path *path, bool with_id) {
|
Result OpenProgramSpecificWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId program_id, FsFileSystemType filesystem_type, Service *fwd, const fssrv::sf::Path *path, bool with_id) {
|
||||||
/* Directory must exist. */
|
/* Directory must exist. */
|
||||||
{
|
R_UNLESS(HasSdManualHtmlContent(program_id), sm::mitm::ResultShouldForwardToSession());
|
||||||
FsDir d;
|
|
||||||
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenAtmosphereSdDirectory(std::addressof(d), program_id, ProgramWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
|
|
||||||
fsDirClose(std::addressof(d));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open the SD card using fs.mitm's session. */
|
/* Open the SD card using fs.mitm's session. */
|
||||||
FsFileSystem sd_fs;
|
FsFileSystem sd_fs;
|
||||||
|
@ -162,6 +158,17 @@ namespace ams::mitm::fs {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasSdManualHtmlContent(ncm::ProgramId program_id) {
|
||||||
|
/* Directory must exist. */
|
||||||
|
FsDir d;
|
||||||
|
if (R_SUCCEEDED(OpenAtmosphereSdDirectory(std::addressof(d), program_id, ProgramWebContentDir, fs::OpenDirectoryMode_Directory))) {
|
||||||
|
::fsDirClose(std::addressof(d));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Result FsMitmService::OpenFileSystemWithPatch(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> out, ncm::ProgramId program_id, u32 _filesystem_type) {
|
Result FsMitmService::OpenFileSystemWithPatch(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> out, ncm::ProgramId program_id, u32 _filesystem_type) {
|
||||||
R_RETURN(OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast<FsFileSystemType>(_filesystem_type), m_forward_service.get(), nullptr, false, m_client_info.override_status.IsProgramSpecific()));
|
R_RETURN(OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast<FsFileSystemType>(_filesystem_type), m_forward_service.get(), nullptr, false, m_client_info.override_status.IsProgramSpecific()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
|
#include "../amsmitm_fs_utils.hpp"
|
||||||
#include "ns_am_mitm_service.hpp"
|
#include "ns_am_mitm_service.hpp"
|
||||||
#include "ns_shim.h"
|
#include "ns_shim.h"
|
||||||
|
|
||||||
|
@ -24,10 +25,9 @@ namespace ams::mitm::ns {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NsAmMitmService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) {
|
Result NsAmMitmService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) {
|
||||||
/* Always succeed for web applets asking about HBL. */
|
/* Always succeed for web applets asking about HBL to enable hbl_html, and applications with manual_html to allow custom manual data. */
|
||||||
/* This enables hbl html. */
|
bool is_hbl = false;
|
||||||
bool is_hbl;
|
if ((R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) || (static_cast<ncm::ContentType>(content_type) == ncm::ContentType::HtmlDocument && mitm::fs::HasSdManualHtmlContent(application_id))) {
|
||||||
if (R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, application_id)) && is_hbl) {
|
|
||||||
nsamResolveApplicationContentPathFwd(m_forward_service.get(), static_cast<u64>(application_id), static_cast<NcmContentType>(content_type));
|
nsamResolveApplicationContentPathFwd(m_forward_service.get(), static_cast<u64>(application_id), static_cast<NcmContentType>(content_type));
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
|
#include "../amsmitm_fs_utils.hpp"
|
||||||
#include "ns_web_mitm_service.hpp"
|
#include "ns_web_mitm_service.hpp"
|
||||||
|
|
||||||
namespace ams::mitm::ns {
|
namespace ams::mitm::ns {
|
||||||
|
@ -23,10 +24,9 @@ namespace ams::mitm::ns {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NsDocumentService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) {
|
Result NsDocumentService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) {
|
||||||
/* Always succeed for web applets asking about HBL. */
|
/* Always succeed for web applets asking about HBL to enable hbl_html, and applications with manual_html to allow custom manual data. */
|
||||||
/* This enables hbl html. */
|
bool is_hbl = false;
|
||||||
bool is_hbl;
|
if ((R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) || (static_cast<ncm::ContentType>(content_type) == ncm::ContentType::HtmlDocument && mitm::fs::HasSdManualHtmlContent(application_id))) {
|
||||||
if (R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) {
|
|
||||||
nswebResolveApplicationContentPath(m_srv.get(), static_cast<u64>(application_id), static_cast<NcmContentType>(content_type));
|
nswebResolveApplicationContentPath(m_srv.get(), static_cast<u64>(application_id), static_cast<NcmContentType>(content_type));
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue