Skip to content

Commit

Permalink
Detect Atmosphère, and pass it down through HBABI
Browse files Browse the repository at this point in the history
  • Loading branch information
fincs committed Apr 11, 2021
1 parent 56868b4 commit e7ff5cb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e7ff5cb

Please sign in to comment.