1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-23 04:12:02 +00:00

strat: use atmosphere results instead of magics

This commit is contained in:
Michael Scire 2019-03-28 20:19:38 -07:00
parent 84c4cd7c53
commit 0001e93810
7 changed files with 39 additions and 33 deletions

View file

@ -89,7 +89,7 @@ static void DoRebootToPayload() {
Result BpcRebootManager::PerformReboot() { Result BpcRebootManager::PerformReboot() {
switch (g_reboot_type) { switch (g_reboot_type) {
case BpcRebootType::Standard: case BpcRebootType::Standard:
return RESULT_FORWARD_TO_SESSION; return ResultAtmosphereMitmShouldForwardToSession;
case BpcRebootType::ToRcm: case BpcRebootType::ToRcm:
RebootToRcm(); RebootToRcm();
return 0; return 0;

View file

@ -116,7 +116,7 @@ Result FsMitmService::OpenFileSystemWithPatch(Out<std::shared_ptr<IFileSystemInt
FsDir d; FsDir d;
if (!Utils::IsWebAppletTid(this->title_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || if (!Utils::IsWebAppletTid(this->title_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) ||
R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) { R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) {
return RESULT_FORWARD_TO_SESSION; return ResultAtmosphereMitmShouldForwardToSession;
} }
fsDirClose(&d); fsDirClose(&d);
} }
@ -127,7 +127,7 @@ Result FsMitmService::OpenFileSystemWithPatch(Out<std::shared_ptr<IFileSystemInt
FsFileSystem fs; FsFileSystem fs;
if (R_SUCCEEDED(fsOpenFileSystemWithPatchFwd(this->forward_service.get(), &fs, title_id, static_cast<FsFileSystemType>(filesystem_type)))) { if (R_SUCCEEDED(fsOpenFileSystemWithPatchFwd(this->forward_service.get(), &fs, title_id, static_cast<FsFileSystemType>(filesystem_type)))) {
fsFsClose(&fs); fsFsClose(&fs);
return RESULT_FORWARD_TO_SESSION; return ResultAtmosphereMitmShouldForwardToSession;
} }
} }
@ -140,7 +140,7 @@ Result FsMitmService::OpenFileSystemWithId(Out<std::shared_ptr<IFileSystemInterf
FsDir d; FsDir d;
if (!Utils::IsWebAppletTid(this->title_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || if (!Utils::IsWebAppletTid(this->title_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) ||
R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) { R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) {
return RESULT_FORWARD_TO_SESSION; return ResultAtmosphereMitmShouldForwardToSession;
} }
fsDirClose(&d); fsDirClose(&d);
} }
@ -151,7 +151,7 @@ Result FsMitmService::OpenFileSystemWithId(Out<std::shared_ptr<IFileSystemInterf
FsFileSystem fs; FsFileSystem fs;
if (R_SUCCEEDED(fsOpenFileSystemWithIdFwd(this->forward_service.get(), &fs, title_id, static_cast<FsFileSystemType>(filesystem_type), path.pointer))) { if (R_SUCCEEDED(fsOpenFileSystemWithIdFwd(this->forward_service.get(), &fs, title_id, static_cast<FsFileSystemType>(filesystem_type), path.pointer))) {
fsFsClose(&fs); fsFsClose(&fs);
return RESULT_FORWARD_TO_SESSION; return ResultAtmosphereMitmShouldForwardToSession;
} }
} }
@ -222,7 +222,7 @@ Result FsMitmService::OpenDataStorageByCurrentProcess(Out<std::shared_ptr<IStora
Result rc = 0; Result rc = 0;
if (!this->should_override_contents) { if (!this->should_override_contents) {
return RESULT_FORWARD_TO_SESSION; return ResultAtmosphereMitmShouldForwardToSession;
} }
bool has_cache = StorageCacheGetEntry(this->title_id, &storage); bool has_cache = StorageCacheGetEntry(this->title_id, &storage);
@ -275,7 +275,7 @@ Result FsMitmService::OpenDataStorageByCurrentProcess(Out<std::shared_ptr<IStora
} else { } else {
/* 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. */
fsStorageClose(&data_storage); fsStorageClose(&data_storage);
rc = RESULT_FORWARD_TO_SESSION; rc = ResultAtmosphereMitmShouldForwardToSession;
} }
} }
} }
@ -290,7 +290,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterf
FsFile data_file; FsFile data_file;
if (!this->should_override_contents) { if (!this->should_override_contents) {
return RESULT_FORWARD_TO_SESSION; return ResultAtmosphereMitmShouldForwardToSession;
} }
std::shared_ptr<IStorageInterface> storage = nullptr; std::shared_ptr<IStorageInterface> storage = nullptr;
@ -342,7 +342,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterf
} else { } else {
/* 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. */
fsStorageClose(&data_storage); fsStorageClose(&data_storage);
rc = RESULT_FORWARD_TO_SESSION; rc = ResultAtmosphereMitmShouldForwardToSession;
} }
} }
} }

View file

@ -70,22 +70,29 @@ void __appInit(void) {
/* Initialize services we need (TODO: NCM) */ /* Initialize services we need (TODO: NCM) */
rc = smInitialize(); rc = smInitialize();
if (R_FAILED(rc)) if (R_FAILED(rc)) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM)); std::abort();
}
rc = fsInitialize(); rc = fsInitialize();
if (R_FAILED(rc)) if (R_FAILED(rc)) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS)); std::abort();
}
rc = splInitialize(); rc = splInitialize();
if (R_FAILED(rc)) if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 1); std::abort();
}
rc = pmshellInitialize(); rc = pmshellInitialize();
if (R_FAILED(rc)) if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 2); std::abort();
}
fsdevMountSdmc(); rc = fsdevMountSdmc();
if (R_FAILED(rc)) {
std::abort();
}
CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION);
} }

View file

@ -214,7 +214,7 @@ Result ShowFatalTask::ShowFatal() {
FontManager::AddSpacingLines(0.5f); FontManager::AddSpacingLines(0.5f);
FontManager::PrintFormatLine(u8"Firmware: %s (Atmosphère %u.%u.%u-%s)", GetFatalConfig()->firmware_version.display_version, CURRENT_ATMOSPHERE_VERSION, GetAtmosphereGitRevision()); FontManager::PrintFormatLine(u8"Firmware: %s (Atmosphère %u.%u.%u-%s)", GetFatalConfig()->firmware_version.display_version, CURRENT_ATMOSPHERE_VERSION, GetAtmosphereGitRevision());
FontManager::AddSpacingLines(1.5f); FontManager::AddSpacingLines(1.5f);
if (this->ctx->error_code != 0xCAFEF) { if (this->ctx->error_code != ResultAtmosphereVersionMismatch) {
FontManager::Print(config->error_desc); FontManager::Print(config->error_desc);
} else { } else {
/* Print a special message for atmosphere version mismatch. */ /* Print a special message for atmosphere version mismatch. */

@ -1 +1 @@
Subproject commit 27164564a193e0a91aced93194c5e646585594e7 Subproject commit 8d15f82a9bf8a61e45856ae764f936a2d82e8a90

View file

@ -64,23 +64,22 @@ void __appInit(void) {
/* Initialize services we need (TODO: SPL) */ /* Initialize services we need (TODO: SPL) */
rc = smInitialize(); rc = smInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM)); std::abort();
} }
rc = fsInitialize(); rc = fsInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS)); std::abort();
} }
rc = lrInitialize(); rc = lrInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 1); std::abort();
} }
rc = fsldrInitialize(); rc = fsldrInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 2); std::abort();
} }
CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION);

View file

@ -90,12 +90,12 @@ void __appInit(void) {
rc = smInitialize(); rc = smInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM)); std::abort();
} }
rc = fsprInitialize(); rc = fsprInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 1); std::abort();
} }
/* This works around a bug with process permissions on < 4.0.0. */ /* This works around a bug with process permissions on < 4.0.0. */
@ -105,32 +105,32 @@ void __appInit(void) {
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
smManagerAmsEndInitialDefers(); smManagerAmsEndInitialDefers();
} else { } else {
fatalSimple(0xCAFE << 4 | 2); std::abort();
} }
rc = smManagerInitialize(); rc = smManagerInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 3); std::abort();
} }
rc = lrInitialize(); rc = lrInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 4); std::abort();
} }
rc = ldrPmInitialize(); rc = ldrPmInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 5); std::abort();
} }
rc = splInitialize(); rc = splInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 6); std::abort();
} }
rc = fsInitialize(); rc = fsInitialize();
if (R_FAILED(rc)) { if (R_FAILED(rc)) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS)); std::abort();
} }
CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION);