mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
stratosphere: stop using kernelAbove
This commit is contained in:
parent
b5dd621250
commit
41f5b39f6b
11 changed files with 34 additions and 34 deletions
|
@ -101,7 +101,7 @@ void CrashReport::ProcessExceptions() {
|
|||
|
||||
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 @@ void CrashReport::HandleException(DebugEventInfo &d) {
|
|||
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::HandleException(DebugEventInfo &d) {
|
|||
|
||||
void CrashReport::ProcessDyingMessage() {
|
||||
/* Dying message is only stored starting in 5.0.0. */
|
||||
if (!kernelAbove500()) {
|
||||
if ((GetRuntimeFirmwareVersion() < FirmwareVersion_500)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ void CrashReport::SaveToFile(FILE *f_report) {
|
|||
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 @@ void CrashReport::SaveToFile(FILE *f_report) {
|
|||
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));
|
||||
|
|
|
@ -131,7 +131,7 @@ int main(int argc, char **argv) {
|
|||
});
|
||||
|
||||
/* Don't fatal if we have extra info. */
|
||||
if (kernelAbove500()) {
|
||||
if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) {
|
||||
if (g_Creport.IsApplication()) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ void DmntCheatDebugEventsManager::PerCoreThreadFunc(void *arg) {
|
|||
}
|
||||
|
||||
/* Continue the process, if needed. */
|
||||
if (kernelAbove300()) {
|
||||
if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_300)) {
|
||||
svcContinueDebugEvent(debug_handle, 5, nullptr, 0);
|
||||
} else {
|
||||
svcLegacyContinueDebugEvent(debug_handle, 5, 0);
|
||||
|
|
|
@ -874,7 +874,7 @@ Result DmntCheatManager::ForceOpenCheatProcess() {
|
|||
/* 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 @@ void DmntCheatManager::OnNewApplicationLaunch() {
|
|||
/* 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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -208,7 +208,7 @@ Result NpdmUtils::LoadNpdm(u64 tid, NpdmInfo *out) {
|
|||
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 @@ u32 NpdmUtils::GetApplicationType(u32 *caps, size_t num_caps) {
|
|||
}
|
||||
}
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ Result NsoUtils::CalculateNsoLoadExtents(u32 addspace_type, u32 args_size, NsoLo
|
|||
|
||||
/* 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:
|
||||
|
|
|
@ -64,7 +64,7 @@ Result ProcessCreation::InitializeProcessInfo(NpdmUtils::NpdmInfo *npdm, Handle
|
|||
}
|
||||
|
||||
/* 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 @@ Result ProcessCreation::InitializeProcessInfo(NpdmUtils::NpdmInfo *npdm, Handle
|
|||
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 @@ Result ProcessCreation::InitializeProcessInfo(NpdmUtils::NpdmInfo *npdm, Handle
|
|||
}
|
||||
|
||||
/* 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 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
|
|||
/* 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;
|
||||
|
|
|
@ -120,13 +120,13 @@ void Registration::HandleProcessLaunch() {
|
|||
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 @@ Result Registration::HandleSignaledProcess(std::shared_ptr<Registration::Process
|
|||
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 @@ Result Registration::HandleSignaledProcess(std::shared_ptr<Registration::Process
|
|||
}
|
||||
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 @@ void Registration::FinalizeExitedProcess(std::shared_ptr<Registration::Process>
|
|||
{
|
||||
std::scoped_lock<ProcessList &> 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 @@ void Registration::GetProcessEventType(u64 *out_pid, u64 *out_type) {
|
|||
std::scoped_lock<ProcessList &> 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 @@ void Registration::GetProcessEventType(u64 *out_pid, u64 *out_type) {
|
|||
}
|
||||
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 @@ void Registration::GetProcessEventType(u64 *out_pid, u64 *out_type) {
|
|||
*out_type = 0;
|
||||
}
|
||||
|
||||
if (kernelAbove500()) {
|
||||
if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) {
|
||||
std::scoped_lock<ProcessList &> dead_lk(g_dead_process_list);
|
||||
|
||||
if (g_dead_process_list.processes.size()) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -163,7 +163,7 @@ void Registration::CacheInitialProcessIdLimits() {
|
|||
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 {
|
||||
|
|
Loading…
Reference in a new issue