From e7ff5cba3b822b3859f6b2c783dc6285a40b07b1 Mon Sep 17 00:00:00 2001 From: fincs Date: Sun, 11 Apr 2021 12:24:09 +0200 Subject: [PATCH] =?UTF-8?q?Detect=20Atmosph=C3=A8re,=20and=20pass=20it=20d?= =?UTF-8?q?own=20through=20HBABI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/main.c b/source/main.c index a27ab80..fb1d70a 100644 --- a/source/main.c +++ b/source/main.c @@ -77,6 +77,14 @@ void __appInit(void) { 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(); if (R_FAILED(rc)) diagAbortWithResult(MAKERESULT(Module_HomebrewLoader, 1)); @@ -86,7 +94,7 @@ void __appInit(void) SetSysFirmwareVersion fw; rc = setsysGetFirmwareVersion(&fw); 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_reservation_size", &g_appletHeapReservationSize, sizeof(g_appletHeapReservationSize)); setsysExit(); @@ -496,6 +504,7 @@ void loadNro(void) entries[8].Value[1] = randomGet64(); // HosVersion entries[10].Value[0] = hosversionGet(); + entries[10].Value[1] = hosversionIsAtmosphere() ? 0x41544d4f53504852UL : 0; // 'ATMOSPHR' g_nroAddr = (u64)map_addr; g_nroSize = nro_size;