diff --git a/nx/include/switch/kernel/svc.h b/nx/include/switch/kernel/svc.h index 22d72f8f26..144adcc4ce 100644 --- a/nx/include/switch/kernel/svc.h +++ b/nx/include/switch/kernel/svc.h @@ -42,6 +42,7 @@ typedef enum { MemType_CodeWritable=0x15, ///< Mapped in kernel during \ref svcControlCodeMemory. MemType_Coverage=0x16, ///< Not available. MemType_Insecure=0x17, ///< Mapped in kernel during \ref svcMapInsecurePhysicalMemory. + MemType_ShadowStack=0x1A, ///< Mapped in kernel. } MemoryType; /// Memory state bitmasks. @@ -213,6 +214,10 @@ typedef enum { InfoType_AliasRegionExtraSize = 28, ///< [18.0.0+] Extra size added to the reserved region. InfoType_TransferMemoryHint = 34, ///< [19.0.0+] Low bits of the process address for a KTransferMemory. + + InfoType_AddressSpaceSize = 36, ///< [23.0.0+] + InfoType_ShadowStackRegionAddress = 37, ///< [23.0.0+] + InfoType_ShadowStackRegionSize = 38, ///< [23.0.0+] InfoType_ThreadTickCountDeprecated = 0xF0000002, ///< [1.0.0-12.1.0] Number of ticks spent on thread. } InfoType; @@ -341,10 +346,11 @@ typedef enum { /// Address space types for CreateProcessFlags typedef enum { - CreateProcessFlagAddressSpace_32bit = 0, - CreateProcessFlagAddressSpace_64bitDeprecated = 1, ///< 36-bit width - CreateProcessFlagAddressSpace_32bitWithoutAlias = 2, - CreateProcessFlagAddressSpace_64bit = 3, ///< [2.0.0+] 39-bit width + CreateProcessFlagAddressSpace_32bit = 0, + CreateProcessFlagAddressSpace_64Bit36 = 1, ///< 36-bit width + CreateProcessFlagAddressSpace_32BitNoReserved = 2, + CreateProcessFlagAddressSpace_64Bit39 = 3, ///< [2.0.0+] 39-bit width + CreateProcessFlagAddressSpace_64Bit42 = 4, ///< [23.0.0+] 42-bit width } CreateProcessFlagAddressSpace; /// Memory regions @@ -364,7 +370,9 @@ typedef struct { u32 optimize_memory_allocation: 1; ///< [7.0.0+] Only allowed in combination with is_application u32 disable_device_address_space_merge: 1; ///< [11.0.0+] u32 enable_alias_region_extra_size: 1; ///< [18.0.0+] - u32 reserved: 18; + u32 unk: 4; + u32 enable_shadow_stack: 1; ///< [23.0.0+] + u32 reserved: 13; } CreateProcessFlags; /// DebugEvent structure diff --git a/nx/include/switch/services/pgl.h b/nx/include/switch/services/pgl.h index 5b3a882481..3f951d7067 100644 --- a/nx/include/switch/services/pgl.h +++ b/nx/include/switch/services/pgl.h @@ -27,12 +27,13 @@ typedef enum { } PglSnapShotDumpType; typedef struct { - u64 id; ///< Program Id - u32 version; ///< Version - u8 content_type; ///< NcmContentType - u8 id_offset; ///< Id Offset - u8 reserved_0E[2]; ///< Padding -} PglContentMetaInfo; + u64 id; ///< Program Id + u32 version; ///< Version + u8 content_type; ///< NcmContentType + u8 id_offset; ///< Id Offset + u8 content_meta_type; ///< NcmContentMetaType + u8 reserved_0F; ///< Padding +} PglProgramLaunchProperty; typedef union { Service s; @@ -54,16 +55,18 @@ TipcService* pglGetServiceSessionTipc(void); Result pglLaunchProgram(u64 *out_pid, const NcmProgramLocation *loc, u32 pm_launch_flags, u8 pgl_launch_flags); Result pglTerminateProcess(u64 pid); Result pglLaunchProgramFromHost(u64 *out_pid, const char *content_path, u32 pm_launch_flags); -Result pglGetHostContentMetaInfo(PglContentMetaInfo *out, const char *content_path); -Result pglGetApplicationProcessId(u64 *out); +Result pglGetHostProgramLaunchProperty(PglProgramLaunchProperty *out, const char *content_path); +Result pglGetRunningApplicationProcessId(u64 *out_pid); Result pglBoostSystemMemoryResourceLimit(u64 size); -Result pglIsProcessTracked(bool *out, u64 pid); +Result pglIsRunningProcess(bool *out, u64 pid); Result pglEnableApplicationCrashReport(bool en); Result pglIsApplicationCrashReportEnabled(bool *out); Result pglEnableApplicationAllThreadDumpOnCrash(bool en); -Result pglTriggerApplicationSnapShotDumper(PglSnapShotDumpType dump_type, const char *arg); -Result pglGetEventObserver(PglEventObserver *out); +Result pglGetProcessId(u64 *out_pid, u64 program_id); ///< [19.0.0+] +Result pglTriggerSnapShotDumper(PglSnapShotDumpType dump_type, const char *arg); ///< [10.0.0-11.0.1] +Result pglCreateShellEvent(PglEventObserver *out); +Result pglEnableApplicationCrashReport2(u64 pid, bool en); ///< [23.0.0+] -Result pglEventObserverGetProcessEvent(PglEventObserver *observer, Event *out); -Result pglEventObserverGetProcessEventInfo(PglEventObserver *observer, PmProcessEventInfo *out); +Result pglEventObserverGetShellEvent(PglEventObserver *observer, Event *out); +Result pglEventObserverGetShellEventInfo(PglEventObserver *observer, PmProcessEventInfo *out); void pglEventObserverClose(PglEventObserver *observer); diff --git a/nx/include/switch/services/spl.h b/nx/include/switch/services/spl.h index d8a1dc5caf..cbfed0a716 100644 --- a/nx/include/switch/services/spl.h +++ b/nx/include/switch/services/spl.h @@ -29,6 +29,7 @@ typedef enum { SplConfigItem_NewHardwareType = 15, SplConfigItem_NewKeyGeneration = 16, SplConfigItem_Package2Hash = 17, + SplConfigItem_Unknown18 = 18, } SplConfigItem; typedef enum { diff --git a/nx/source/services/pgl.c b/nx/source/services/pgl.c index a3457f0e8e..f94cb7d2ba 100644 --- a/nx/source/services/pgl.c +++ b/nx/source/services/pgl.c @@ -120,7 +120,7 @@ Result pglLaunchProgramFromHost(u64 *out_pid, const char *content_path, u32 pm_l } } -Result pglGetHostContentMetaInfo(PglContentMetaInfo *out, const char *content_path) { +Result pglGetHostProgramLaunchProperty(PglProgramLaunchProperty *out, const char *content_path) { if (_pglShouldUseTipc()) { return tipcDispatchOut(&g_pglSrv.tipc, 4, *out, .buffer_attrs = { SfBufferAttr_In | SfBufferAttr_HipcMapAlias }, @@ -134,11 +134,11 @@ Result pglGetHostContentMetaInfo(PglContentMetaInfo *out, const char *content_pa } } -Result pglGetApplicationProcessId(u64 *out) { +Result pglGetRunningApplicationProcessId(u64 *out_pid) { if (_pglShouldUseTipc()) { - return tipcDispatchOut(&g_pglSrv.tipc, 5, *out); + return tipcDispatchOut(&g_pglSrv.tipc, 5, *out_pid); } else { - return serviceDispatchOut(&g_pglSrv.cmif, 5, *out); + return serviceDispatchOut(&g_pglSrv.cmif, 5, *out_pid); } } @@ -146,7 +146,7 @@ Result pglBoostSystemMemoryResourceLimit(u64 size) { return _pglCmdInU64(size, 6); } -Result pglIsProcessTracked(bool *out, u64 pid) { +Result pglIsRunningProcess(bool *out, u64 pid) { u8 outval = 0; Result rc; @@ -174,8 +174,16 @@ Result pglEnableApplicationAllThreadDumpOnCrash(bool en) { return _pglCmdInBool(en, 10); } -Result pglTriggerApplicationSnapShotDumper(PglSnapShotDumpType dump_type, const char *arg) { - if (hosversionAtLeast(12,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); +Result pglGetProcessId(u64 *out_pid, u64 program_id) { + if (hosversionBefore(19,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return tipcDispatchInOut(&g_pglSrv.tipc, 11, program_id, *out_pid); +} + +Result pglTriggerSnapShotDumper(PglSnapShotDumpType dump_type, const char *arg) { + if (hosversionAtLeast(12,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); _Static_assert(sizeof(dump_type) == sizeof(u32), "PglSnapShotDumpType"); return serviceDispatchIn(&g_pglSrv.cmif, 12, dump_type, @@ -184,7 +192,7 @@ Result pglTriggerApplicationSnapShotDumper(PglSnapShotDumpType dump_type, const ); } -Result pglGetEventObserver(PglEventObserver *out) { +Result pglCreateShellEvent(PglEventObserver *out) { if (_pglShouldUseTipc()) { return tipcDispatch(&g_pglSrv.tipc, 20, .out_num_objects = 1, @@ -198,7 +206,20 @@ Result pglGetEventObserver(PglEventObserver *out) { } } -Result pglEventObserverGetProcessEvent(PglEventObserver *observer, Event *out) { +Result pglEnableApplicationCrashReport2(u64 pid, bool en) { + if (hosversionBefore(23,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + const struct { + u64 pid; + u8 en; + u8 pad[3]; + } in = { pid, en, {0} }; + + return tipcDispatchIn(&g_pglSrv.tipc, 31, in); +} + +Result pglEventObserverGetShellEvent(PglEventObserver *observer, Event *out) { Handle evt_handle; Result rc; @@ -221,7 +242,7 @@ Result pglEventObserverGetProcessEvent(PglEventObserver *observer, Event *out) { return rc; } -Result pglEventObserverGetProcessEventInfo(PglEventObserver *observer, PmProcessEventInfo *out) { +Result pglEventObserverGetShellEventInfo(PglEventObserver *observer, PmProcessEventInfo *out) { if (_pglShouldUseTipc()) { return tipcDispatchOut(&observer->t, 1, *out); } else {