Detect Atmosphère, and pass it down through HBABI

This commit is contained in:
fincs 2021-04-11 12:24:09 +02:00
parent 56868b4325
commit e7ff5cba3b
No known key found for this signature in database
GPG Key ID: 62C7609ADA219C60

View File

@ -77,6 +77,14 @@ void __appInit(void)
{ {
Result rc; Result rc;
// Detect Atmosphère early on. This is required for hosversion logic.
// In the future, this check will be replaced by detectMesosphere().
Handle dummy;
rc = svcConnectToNamedPort(&dummy, "ams");
u32 ams_flag = (R_VALUE(rc) != KERNELRESULT(NotFound)) ? BIT(31) : 0;
if (R_SUCCEEDED(rc))
svcCloseHandle(dummy);
rc = smInitialize(); rc = smInitialize();
if (R_FAILED(rc)) if (R_FAILED(rc))
diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 1)); diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 1));
@ -86,7 +94,7 @@ void __appInit(void)
SetSysFirmwareVersion fw; SetSysFirmwareVersion fw;
rc = setsysGetFirmwareVersion(&fw); rc = setsysGetFirmwareVersion(&fw);
if (R_SUCCEEDED(rc)) if (R_SUCCEEDED(rc))
hosversionSet(MAKEHOSVERSION(fw.major, fw.minor, fw.micro)); hosversionSet(ams_flag | MAKEHOSVERSION(fw.major, fw.minor, fw.micro));
readSetting("applet_heap_size", &g_appletHeapSize, sizeof(g_appletHeapSize)); readSetting("applet_heap_size", &g_appletHeapSize, sizeof(g_appletHeapSize));
readSetting("applet_heap_reservation_size", &g_appletHeapReservationSize, sizeof(g_appletHeapReservationSize)); readSetting("applet_heap_reservation_size", &g_appletHeapReservationSize, sizeof(g_appletHeapReservationSize));
setsysExit(); setsysExit();
@ -496,6 +504,7 @@ void loadNro(void)
entries[8].Value[1] = randomGet64(); entries[8].Value[1] = randomGet64();
// HosVersion // HosVersion
entries[10].Value[0] = hosversionGet(); entries[10].Value[0] = hosversionGet();
entries[10].Value[1] = hosversionIsAtmosphere() ? 0x41544d4f53504852UL : 0; // 'ATMOSPHR'
g_nroAddr = (u64)map_addr; g_nroAddr = (u64)map_addr;
g_nroSize = nro_size; g_nroSize = nro_size;