diff --git a/stratosphere/creport/source/creport_crash_report.cpp b/stratosphere/creport/source/creport_crash_report.cpp index e13982f..1e389a3 100644 --- a/stratosphere/creport/source/creport_crash_report.cpp +++ b/stratosphere/creport/source/creport_crash_report.cpp @@ -101,7 +101,7 @@ void CrashReport::HandleAttachProcess(DebugEventInfo &d) { this->process_info = d.info.attach_process; - if (kernelAbove500() && IsApplication()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500) && IsApplication()) { /* Parse out user data. */ u64 address = this->process_info.user_exception_context_address; u64 userdata_address = 0; @@ -155,7 +155,7 @@ case DebugExceptionType::UserBreak: this->result = ResultCreportUserBreak; /* Try to parse out the user break result. */ - if (kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) { Result user_result = 0; if (IsAddressReadable(d.info.exception.specific.user_break.address, sizeof(user_result))) { svcReadDebugProcessMemory(&user_result, this->debug_handle, d.info.exception.specific.user_break.address, sizeof(user_result)); @@ -186,7 +186,7 @@ void CrashReport::ProcessDyingMessage() { /* Dying message is only stored starting in 5.0.0. */ - if (!kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() < FirmwareVersion_500)) { return; } @@ -318,7 +318,7 @@ fprintf(f_report, " Title ID: %016lx\n", this->process_info.title_id); fprintf(f_report, " Process ID: %016lx\n", this->process_info.process_id); fprintf(f_report, " Process Flags: %08x\n", this->process_info.flags); - if (kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) { fprintf(f_report, " User Exception Address: %s\n", this->code_list.GetFormattedAddressString(this->process_info.user_exception_context_address)); } @@ -350,7 +350,7 @@ fprintf(f_report, "Crashed Thread Info:\n"); this->crashed_thread_info.SaveToFile(f_report); - if (kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) { if (this->dying_message_size) { fprintf(f_report, "Dying Message Info:\n"); fprintf(f_report, " Address: 0x%s\n", this->code_list.GetFormattedAddressString(this->dying_message_address)); diff --git a/stratosphere/creport/source/creport_main.cpp b/stratosphere/creport/source/creport_main.cpp index 6d3423c..a2270ed 100644 --- a/stratosphere/creport/source/creport_main.cpp +++ b/stratosphere/creport/source/creport_main.cpp @@ -131,7 +131,7 @@ }); /* Don't fatal if we have extra info. */ - if (kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) { if (g_Creport.IsApplication()) { return 0; } diff --git a/stratosphere/dmnt/source/dmnt_cheat_debug_events_manager.cpp b/stratosphere/dmnt/source/dmnt_cheat_debug_events_manager.cpp index 0bb0a2a..1a9d4c0 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_debug_events_manager.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_debug_events_manager.cpp @@ -39,7 +39,7 @@ } /* Continue the process, if needed. */ - if (kernelAbove300()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_300)) { svcContinueDebugEvent(debug_handle, 5, nullptr, 0); } else { svcLegacyContinueDebugEvent(debug_handle, 5, 0); diff --git a/stratosphere/dmnt/source/dmnt_cheat_manager.cpp b/stratosphere/dmnt/source/dmnt_cheat_manager.cpp index 42cb5c4..14077a7 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_manager.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_manager.cpp @@ -874,7 +874,7 @@ /* Get memory extents. */ PopulateMemoryExtents(&g_cheat_process_metadata.heap_extents, proc_h, 4, 5); PopulateMemoryExtents(&g_cheat_process_metadata.alias_extents, proc_h, 2, 3); - if (kernelAbove200()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200)) { PopulateMemoryExtents(&g_cheat_process_metadata.address_space_extents, proc_h, 12, 13); } else { g_cheat_process_metadata.address_space_extents.base = 0x08000000UL; @@ -962,7 +962,7 @@ /* Get memory extents. */ PopulateMemoryExtents(&g_cheat_process_metadata.heap_extents, proc_h, 4, 5); PopulateMemoryExtents(&g_cheat_process_metadata.alias_extents, proc_h, 2, 3); - if (kernelAbove200()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200)) { PopulateMemoryExtents(&g_cheat_process_metadata.address_space_extents, proc_h, 12, 13); } else { g_cheat_process_metadata.address_space_extents.base = 0x08000000UL; diff --git a/stratosphere/loader/source/ldr_map.cpp b/stratosphere/loader/source/ldr_map.cpp index 468a57a..e2cd0a4 100644 --- a/stratosphere/loader/source/ldr_map.cpp +++ b/stratosphere/loader/source/ldr_map.cpp @@ -20,7 +20,7 @@ #include "ldr_map.hpp" Result MapUtils::LocateSpaceForMap(u64 *out, u64 out_size) { - if (kernelAbove200()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200)) { return LocateSpaceForMapModern(out, out_size); } else { return LocateSpaceForMapDeprecated(out, out_size); diff --git a/stratosphere/loader/source/ldr_npdm.cpp b/stratosphere/loader/source/ldr_npdm.cpp index 912dc77..7663457 100644 --- a/stratosphere/loader/source/ldr_npdm.cpp +++ b/stratosphere/loader/source/ldr_npdm.cpp @@ -208,7 +208,7 @@ if (ContentManagement::ShouldOverrideContentsWithHBL(tid) && R_SUCCEEDED(LoadNpdmInternal(OpenNpdmFromExeFS(), &g_original_npdm_cache))) { NpdmInfo *original_info = &g_original_npdm_cache.info; /* Fix pool partition. */ - if (kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) { info->acid->flags = (info->acid->flags & 0xFFFFFFC3) | (original_info->acid->flags & 0x0000003C); } /* Fix application type. */ @@ -506,7 +506,7 @@ } } /* After 1.0.0, allow_debug is used as bit 4. */ - if (kernelAbove200() && (caps[i] & 0x1FFFF) == 0xFFFF) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200) && (caps[i] & 0x1FFFF) == 0xFFFF) { application_type |= (caps[i] >> 15) & 4; } } diff --git a/stratosphere/loader/source/ldr_nso.cpp b/stratosphere/loader/source/ldr_nso.cpp index 8104e93..08cef21 100644 --- a/stratosphere/loader/source/ldr_nso.cpp +++ b/stratosphere/loader/source/ldr_nso.cpp @@ -191,7 +191,7 @@ /* Calculate ASLR extents for address space type. */ u64 addspace_start, addspace_size; - if (kernelAbove200()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200)) { switch (addspace_type & 0xE) { case 0: case 4: diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index cf86d97..695e15c 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -64,7 +64,7 @@ } /* 3.0.0+ System Resource Size. */ - if (kernelAbove300()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_300)) { if (npdm->header->system_resource_size & 0x1FFFFF) { return ResultLoaderInvalidSize; } @@ -72,7 +72,7 @@ if ((out_proc_info->process_flags & 6) == 0) { return ResultLoaderInvalidMeta; } - if (!(((application_type & 3) == 1) || (kernelAbove600() && (application_type & 3) == 2))) { + if (!(((application_type & 3) == 1) || ((GetRuntimeFirmwareVersion() >= FirmwareVersion_600) && (application_type & 3) == 2))) { return ResultLoaderInvalidMeta; } if (npdm->header->system_resource_size > 0x1FE00000) { @@ -85,7 +85,7 @@ } /* 5.0.0+ Pool Partition. */ - if (kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) { u32 pool_partition_id = (npdm->acid->flags >> 2) & 0xF; switch (pool_partition_id) { case 0: /* Application. */ @@ -206,7 +206,7 @@ /* Update the list of registered processes with the new process. */ svcGetProcessId(&process_id, process_h); bool is_64_bit_addspace; - if (kernelAbove200()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200)) { is_64_bit_addspace = (((npdm_info.header->mmu_flags >> 1) & 5) | 2) == 3; } else { is_64_bit_addspace = (npdm_info.header->mmu_flags & 0xE) == 0x2; diff --git a/stratosphere/pm/source/pm_registration.cpp b/stratosphere/pm/source/pm_registration.cpp index 9a6cdcd..5c655fa 100644 --- a/stratosphere/pm/source/pm_registration.cpp +++ b/stratosphere/pm/source/pm_registration.cpp @@ -120,13 +120,13 @@ if (program_info.application_type & 1) { new_process.flags |= PROCESSFLAGS_APPLICATION; } - if (kernelAbove200() && LAUNCHFLAGS_NOTIYDEBUGSPECIAL(launch_flags) && (program_info.application_type & 4)) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200) && LAUNCHFLAGS_NOTIYDEBUGSPECIAL(launch_flags) && (program_info.application_type & 4)) { new_process.flags |= PROCESSFLAGS_NOTIFYDEBUGSPECIAL; } if (LAUNCHFLAGS_NOTIFYWHENEXITED(launch_flags)) { new_process.flags |= PROCESSFLAGS_NOTIFYWHENEXITED; } - if (LAUNCHFLAGS_NOTIFYDEBUGEVENTS(launch_flags) && (!kernelAbove200() || (program_info.application_type & 4))) { + if (LAUNCHFLAGS_NOTIFYDEBUGEVENTS(launch_flags) && (GetRuntimeFirmwareVersion() < FirmwareVersion_200 || (program_info.application_type & 4))) { new_process.flags |= PROCESSFLAGS_NOTIFYDEBUGEVENTS; } @@ -253,7 +253,7 @@ process->flags |= PROCESSFLAGS_DEBUGEVENTPENDING; g_process_event->Signal(); } - if (kernelAbove200() && process->flags & PROCESSFLAGS_NOTIFYDEBUGSPECIAL) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200) && process->flags & PROCESSFLAGS_NOTIFYDEBUGSPECIAL) { process->flags &= ~(PROCESSFLAGS_NOTIFYDEBUGSPECIAL | PROCESSFLAGS_DEBUGDETACHED); process->flags |= PROCESSFLAGS_DEBUGDETACHED; } @@ -270,7 +270,7 @@ } break; case ProcessState_Exited: - if (process->flags & PROCESSFLAGS_NOTIFYWHENEXITED && !kernelAbove500()) { + if (process->flags & PROCESSFLAGS_NOTIFYWHENEXITED && GetRuntimeFirmwareVersion() < FirmwareVersion_500) { g_process_event->Signal(); } else { FinalizeExitedProcess(process); @@ -293,7 +293,7 @@ { std::scoped_lock lk(GetProcessList()); - signal_debug_process_5x = kernelAbove500() && process->flags & PROCESSFLAGS_NOTIFYWHENEXITED; + signal_debug_process_5x = (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) && process->flags & PROCESSFLAGS_NOTIFYWHENEXITED; /* Unregister with FS. */ if (R_FAILED(fsprUnregisterProgram(process->pid))) { @@ -427,17 +427,17 @@ std::scoped_lock lk(GetProcessList()); for (auto &p : g_process_list.processes) { - if (kernelAbove200() && p->state >= ProcessState_Running && p->flags & PROCESSFLAGS_DEBUGDETACHED) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200) && p->state >= ProcessState_Running && p->flags & PROCESSFLAGS_DEBUGDETACHED) { p->flags &= ~PROCESSFLAGS_DEBUGDETACHED; *out_pid = p->pid; - *out_type = kernelAbove500() ? PROCESSEVENTTYPE_500_DEBUGDETACHED : PROCESSEVENTTYPE_DEBUGDETACHED; + *out_type = (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) ? PROCESSEVENTTYPE_500_DEBUGDETACHED : PROCESSEVENTTYPE_DEBUGDETACHED; return; } if (p->flags & PROCESSFLAGS_DEBUGEVENTPENDING) { u64 old_flags = p->flags; p->flags &= ~PROCESSFLAGS_DEBUGEVENTPENDING; *out_pid = p->pid; - *out_type = kernelAbove500() ? + *out_type = (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) ? ((old_flags & PROCESSFLAGS_DEBUGSUSPENDED) ? PROCESSEVENTTYPE_500_SUSPENDED : PROCESSEVENTTYPE_500_RUNNING) : @@ -448,10 +448,10 @@ } if (p->flags & PROCESSFLAGS_CRASHED) { *out_pid = p->pid; - *out_type = kernelAbove500() ? PROCESSEVENTTYPE_500_CRASH : PROCESSEVENTTYPE_CRASH; + *out_type = (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) ? PROCESSEVENTTYPE_500_CRASH : PROCESSEVENTTYPE_CRASH; return; } - if (!kernelAbove500() && p->flags & PROCESSFLAGS_NOTIFYWHENEXITED && p->state == ProcessState_Exited) { + if (GetRuntimeFirmwareVersion() < FirmwareVersion_500 && p->flags & PROCESSFLAGS_NOTIFYWHENEXITED && p->state == ProcessState_Exited) { *out_pid = p->pid; *out_type = PROCESSEVENTTYPE_EXIT; return; @@ -462,7 +462,7 @@ *out_type = 0; } - if (kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) { std::scoped_lock dead_lk(g_dead_process_list); if (g_dead_process_list.processes.size()) { diff --git a/stratosphere/pm/source/pm_registration.hpp b/stratosphere/pm/source/pm_registration.hpp index b04b4ec..57de135 100644 --- a/stratosphere/pm/source/pm_registration.hpp +++ b/stratosphere/pm/source/pm_registration.hpp @@ -23,11 +23,11 @@ class ProcessList; #define LAUNCHFLAGS_NOTIFYWHENEXITED(flags) (flags & 1) -#define LAUNCHFLAGS_STARTSUSPENDED(flags) (flags & (kernelAbove500() ? 0x10 : 0x2)) -#define LAUNCHFLAGS_ARGLOW(flags) (kernelAbove500() ? ((flags & 0x14) != 0x10) : (kernelAbove200() ? ((flags & 0x6) != 0x2) : ((flags >> 2) & 1))) -#define LAUNCHFLAGS_ARGHIGH(flags) ((flags & (kernelAbove500() ? 0x20 : 0x8)) ? 2 : 0) -#define LAUNCHFLAGS_NOTIFYDEBUGEVENTS(flags) (flags & (kernelAbove500() ? 0x8 : 0x10)) -#define LAUNCHFLAGS_NOTIYDEBUGSPECIAL(flags) (flags & (kernelAbove500() ? 0x2 : (kernelAbove200() ? 0x20 : 0x0))) +#define LAUNCHFLAGS_STARTSUSPENDED(flags) (flags & (GetRuntimeFirmwareVersion() >= FirmwareVersion_500 ? 0x10 : 0x2)) +#define LAUNCHFLAGS_ARGLOW(flags) (GetRuntimeFirmwareVersion() >= FirmwareVersion_500 ? ((flags & 0x14) != 0x10) : (GetRuntimeFirmwareVersion() >= FirmwareVersion_200 ? ((flags & 0x6) != 0x2) : ((flags >> 2) & 1))) +#define LAUNCHFLAGS_ARGHIGH(flags) ((flags & (GetRuntimeFirmwareVersion() >= FirmwareVersion_500 ? 0x20 : 0x8)) ? 2 : 0) +#define LAUNCHFLAGS_NOTIFYDEBUGEVENTS(flags) (flags & (GetRuntimeFirmwareVersion() >= FirmwareVersion_500 ? 0x8 : 0x10)) +#define LAUNCHFLAGS_NOTIYDEBUGSPECIAL(flags) (flags & (GetRuntimeFirmwareVersion() >= FirmwareVersion_500 ? 0x2 : (GetRuntimeFirmwareVersion() >= FirmwareVersion_200 ? 0x20 : 0x0))) // none of these names are official or authoritative in any way enum { diff --git a/stratosphere/sm/source/sm_registration.cpp b/stratosphere/sm/source/sm_registration.cpp index eead4cc..7b0ea72 100644 --- a/stratosphere/sm/source/sm_registration.cpp +++ b/stratosphere/sm/source/sm_registration.cpp @@ -163,7 +163,7 @@ if (g_determined_initial_process_ids) { return; } - if (kernelAbove500()) { + if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) { svcGetSystemInfo(&g_initial_process_id_low, 2, 0, 0); svcGetSystemInfo(&g_initial_process_id_high, 2, 0, 1); } else {