sm: add HasService/HasMitm, refactor into sts::
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
|
||||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/sm/sm_manager_api.hpp>
|
||||
|
||||
#include "pm_boot2.hpp"
|
||||
#include "pm_registration.hpp"
|
||||
#include "pm_boot_mode.hpp"
|
||||
@@ -181,18 +183,15 @@ static void MountSdCard() {
|
||||
}
|
||||
|
||||
static void WaitForMitm(const char *service) {
|
||||
bool mitm_installed = false;
|
||||
const auto name = sts::sm::ServiceName::Encode(service);
|
||||
|
||||
DoWithSmSession([&]() {
|
||||
R_ASSERT(smManagerAmsInitialize());
|
||||
});
|
||||
ON_SCOPE_EXIT { smManagerAmsExit(); };
|
||||
|
||||
while (!mitm_installed) {
|
||||
R_ASSERT(smManagerAmsHasMitm(&mitm_installed, service));
|
||||
if (!mitm_installed) {
|
||||
svcSleepThread(1000000ull);
|
||||
while (true) {
|
||||
bool mitm_installed = false;
|
||||
R_ASSERT(sts::sm::manager::HasMitm(&mitm_installed, name));
|
||||
if (mitm_installed) {
|
||||
break;
|
||||
}
|
||||
svcSleepThread(1000000ull);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <switch.h>
|
||||
#include <atmosphere.h>
|
||||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/sm/sm_manager_api.hpp>
|
||||
|
||||
#include "pm_boot_mode.hpp"
|
||||
#include "pm_info.hpp"
|
||||
@@ -99,18 +100,14 @@ void __appInit(void) {
|
||||
|
||||
DoWithSmSession([&]() {
|
||||
R_ASSERT(fsprInitialize());
|
||||
R_ASSERT(smManagerInitialize());
|
||||
|
||||
/* This works around a bug with process permissions on < 4.0.0. */
|
||||
RegisterPrivilegedProcessesWithFs();
|
||||
|
||||
/* Use AMS manager extension to tell SM that FS has been worked around. */
|
||||
{
|
||||
R_ASSERT(smManagerAmsInitialize());
|
||||
smManagerAmsEndInitialDefers();
|
||||
smManagerAmsExit();
|
||||
}
|
||||
R_ASSERT(sts::sm::manager::EndInitialDefers());
|
||||
|
||||
R_ASSERT(smManagerInitialize());
|
||||
R_ASSERT(lrInitialize());
|
||||
R_ASSERT(ldrPmInitialize());
|
||||
R_ASSERT(splInitialize());
|
||||
|
||||
Reference in New Issue
Block a user