1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-26 13:52:21 +00:00

sm: change InstallMitM to wait for registration instead of 0xE15

This commit is contained in:
Michael Scire 2019-01-20 17:00:35 -08:00
parent b6684ff845
commit 83025080c8
5 changed files with 25 additions and 15 deletions

View file

@ -62,11 +62,6 @@ void __appInit(void) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM)); fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM));
} }
rc = fsInitialize();
if (R_FAILED(rc)) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS));
}
CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION);
} }
@ -94,6 +89,14 @@ int main(int argc, char **argv)
/* Create fsp-srv mitm. */ /* Create fsp-srv mitm. */
AddMitmServerToManager<FsMitmService>(server_manager, "fsp-srv", 61); AddMitmServerToManager<FsMitmService>(server_manager, "fsp-srv", 61);
/* Connect to FS */
{
Result rc = fsInitialize();
if (R_FAILED(rc)) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS));
}
}
if (R_FAILED(threadCreate(&sd_initializer_thread, &Utils::InitializeSdThreadFunc, NULL, 0x4000, 0x15, 0))) { if (R_FAILED(threadCreate(&sd_initializer_thread, &Utils::InitializeSdThreadFunc, NULL, 0x4000, 0x15, 0))) {
/* TODO: Panic. */ /* TODO: Panic. */

@ -1 +1 @@
Subproject commit 05015b9354d3df80e0836aa95d1d4dcfc2aef4b7 Subproject commit f9d38856f335c4cb0ed3c7253d9319a965815af2

View file

@ -123,8 +123,7 @@ static void MountSdCard() {
fsdevMountSdmc(); fsdevMountSdmc();
} }
void EmbeddedBoot2::Main() { static void WaitForFsMitm() {
/* Wait until fs.mitm has installed itself. We want this to happen as early as possible. */
bool fs_mitm_installed = false; bool fs_mitm_installed = false;
Result rc = smManagerAmsInitialize(); Result rc = smManagerAmsInitialize();
@ -138,6 +137,11 @@ void EmbeddedBoot2::Main() {
svcSleepThread(1000ull); svcSleepThread(1000ull);
} }
smManagerAmsExit(); smManagerAmsExit();
}
void EmbeddedBoot2::Main() {
/* Wait until fs.mitm has installed itself. We want this to happen as early as possible. */
WaitForFsMitm();
/* 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. */

View file

@ -60,11 +60,6 @@ void __appInit(void) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM)); fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM));
} }
rc = setsysInitialize();
if (R_FAILED(rc)) {
fatalSimple(rc);
}
CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION);
} }
@ -89,8 +84,16 @@ int main(int argc, char **argv)
/* TODO: What's a good timeout value to use here? */ /* TODO: What's a good timeout value to use here? */
auto server_manager = new SetMitmManager(1); auto server_manager = new SetMitmManager(1);
/* Create fsp-srv mitm. */ /* Create set:sys mitm. */
AddMitmServerToManager<SetSysMitmService>(server_manager, "set:sys", 4); AddMitmServerToManager<SetSysMitmService>(server_manager, "set:sys", 4);
/* Connect to set:sys. */
{
Result rc = setsysInitialize();
if (R_FAILED(rc)) {
fatalSimple(rc);
}
}
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->Process(); server_manager->Process();

View file

@ -467,7 +467,7 @@ Result Registration::InstallMitmForPid(u64 pid, u64 service, Handle *out, Handle
/* Verify the service exists. */ /* Verify the service exists. */
Registration::Service *target_service = GetService(service); Registration::Service *target_service = GetService(service);
if (target_service == NULL) { if (target_service == NULL) {
return 0xE15; return RESULT_DEFER_SESSION;
} }
/* Verify the service isn't already being mitm'd. */ /* Verify the service isn't already being mitm'd. */