libnx v4.9.0
Loading...
Searching...
No Matches
pm.h
Go to the documentation of this file.
1/**
2 * @file pm.h
3 * @brief Process management (pm*) service IPC wrapper.
4 * @author plutoo
5 * @author yellows8
6 * @author mdbell
7 * @copyright libnx Authors
8 */
9#pragma once
10#include "../types.h"
11#include "../kernel/event.h"
12#include "../sf/service.h"
13#include "../services/ncm_types.h"
14
15/// LaunchFlag
16typedef enum {
18
19 ///< PmLaunchFlag_* should be used on [5.0.0+].
20 PmLaunchFlag_SignalOnExit = (1 << 0),
21 PmLaunchFlag_SignalOnStart = (1 << 1),
22 PmLaunchFlag_SignalOnCrash = (1 << 2),
23 PmLaunchFlag_SignalOnDebug = (1 << 3),
24 PmLaunchFlag_StartSuspended = (1 << 4),
25 PmLaunchFlag_DisableAslr = (1 << 5),
26
27 ///< PmLaunchFlagOld_* should be used on [1.0.0-4.1.0].
28 PmLaunchFlagOld_SignalOnExit = (1 << 0),
29 PmLaunchFlagOld_StartSuspended = (1 << 1),
30 PmLaunchFlagOld_SignalOnCrash = (1 << 2),
31 PmLaunchFlagOld_DisableAslr = (1 << 3),
33 ///< PmLaunchFlagOld_SignalOnStart is only available on [2.0.0+].
34 PmLaunchFlagOld_SignalOnStart = (1 << 5),
36
37/// ProcessEvent
38typedef enum {
39 PmProcessEvent_None = 0,
40 PmProcessEvent_Exit = 1,
41 PmProcessEvent_Start = 2,
42 PmProcessEvent_Crash = 3,
43 PmProcessEvent_DebugStart = 4,
44 PmProcessEvent_DebugBreak = 5,
46
47/// ProcessEventInfo
48typedef struct {
49 PmProcessEvent event;
50 u64 process_id;
52
53/// BootMode
54typedef enum {
55 PmBootMode_Normal = 0, ///< Normal
56 PmBootMode_Maintenance = 1, ///< Maintenance
57 PmBootMode_SafeMode = 2, ///< SafeMode
59
60/// ResourceLimitValues
61typedef struct {
62 u64 physical_memory;
63 u32 thread_count;
64 u32 event_count;
65 u32 transfer_memory_count;
66 u32 session_count;
68
69/// Initialize pm:dmnt.
71
72/// Exit pm:dmnt.
73void pmdmntExit(void);
74
75/// Gets the Service object for the actual pm:dmnt service session.
77
78/// Initialize pm:info.
80
81/// Exit pm:info.
82void pminfoExit(void);
83
84/// Gets the Service object for the actual pm:info service session.
86
87/// Initialize pm:shell.
89
90/// Exit pm:shell.
91void pmshellExit(void);
92
93/// Gets the Service object for the actual pm:shell service session.
95
96/// Initialize pm:bm.
98
99/// Exit pm:bm.
100void pmbmExit(void);
101
102/// Gets the Service object for the actual pm:bm service session.
104
105/**
106 * @brief Gets the \ref PmBootMode.
107 * @param[out] out \ref PmBootMode
108 */
110
111/**
112 * @brief Sets the \ref PmBootMode to ::PmBootMode_Maintenance.
113 */
115
116Result pmdmntGetJitDebugProcessIdList(u32* out_count, u64* out_pids, size_t max_pids);
117Result pmdmntStartProcess(u64 pid);
118Result pmdmntGetProcessId(u64* pid_out, u64 program_id);
119Result pmdmntHookToCreateProcess(Event* out, u64 program_id);
120Result pmdmntGetApplicationProcessId(u64* pid_out);
121Result pmdmntHookToCreateApplicationProcess(Event* out);
122Result pmdmntClearHook(u32 which);
123Result pmdmntGetProgramId(u64* program_id_out, u64 pid);
124
125Result pminfoGetProgramId(u64* program_id_out, u64 pid);
126Result pminfoGetAppletCurrentResourceLimitValues(PmResourceLimitValues* out);
127Result pminfoGetAppletPeakResourceLimitValues(PmResourceLimitValues* out);
128
129Result pmshellLaunchProgram(u32 launch_flags, const NcmProgramLocation *location, u64 *pid);
130Result pmshellTerminateProcess(u64 processID);
131Result pmshellTerminateProgram(u64 program_id);
132Result pmshellGetProcessEventHandle(Event* out); // Autoclear for pmshellProcessEvent is always true.
133Result pmshellGetProcessEventInfo(PmProcessEventInfo* out);
134Result pmshellCleanupProcess(u64 pid);
135Result pmshellClearJitDebugOccured(u64 pid);
136Result pmshellNotifyBootFinished(void);
137Result pmshellGetApplicationProcessIdForShell(u64* pid_out);
138Result pmshellBoostSystemMemoryResourceLimit(u64 boost_size);
139Result pmshellBoostApplicationThreadResourceLimit(void);
140Result pmshellBoostSystemThreadResourceLimit(void);
Result pmbmInitialize(void)
Initialize pm:bm.
Service * pmdmntGetServiceSession(void)
Gets the Service object for the actual pm:dmnt service session.
void pmdmntExit(void)
Exit pm:dmnt.
Service * pmshellGetServiceSession(void)
Gets the Service object for the actual pm:shell service session.
void pmshellExit(void)
Exit pm:shell.
Result pmbmSetMaintenanceBoot(void)
Sets the PmBootMode to PmBootMode_Maintenance.
PmBootMode
BootMode.
Definition pm.h:54
@ PmBootMode_SafeMode
SafeMode.
Definition pm.h:57
@ PmBootMode_Maintenance
Maintenance.
Definition pm.h:56
@ PmBootMode_Normal
Normal.
Definition pm.h:55
Service * pminfoGetServiceSession(void)
Gets the Service object for the actual pm:info service session.
void pminfoExit(void)
Exit pm:info.
PmLaunchFlag
LaunchFlag.
Definition pm.h:16
@ PmLaunchFlag_None
PmLaunchFlag_* should be used on [5.0.0+].
Definition pm.h:17
@ PmLaunchFlagOld_SignalOnDebug
PmLaunchFlagOld_SignalOnStart is only available on [2.0.0+].
Definition pm.h:32
@ PmLaunchFlag_DisableAslr
PmLaunchFlagOld_* should be used on [1.0.0-4.1.0].
Definition pm.h:25
PmProcessEvent
ProcessEvent.
Definition pm.h:38
Result pmbmGetBootMode(PmBootMode *out)
Gets the PmBootMode.
Result pminfoInitialize(void)
Initialize pm:info.
void pmbmExit(void)
Exit pm:bm.
Result pmshellInitialize(void)
Initialize pm:shell.
Result pmdmntInitialize(void)
Initialize pm:dmnt.
Service * pmbmGetServiceSession(void)
Gets the Service object for the actual pm:bm service session.
Kernel-mode event structure.
Definition event.h:13
ProgramLocation.
Definition ncm_types.h:173
ProcessEventInfo.
Definition pm.h:48
ResourceLimitValues.
Definition pm.h:61
Service object structure.
Definition service.h:14
uint64_t u64
64-bit unsigned integer.
Definition types.h:22
u32 Result
Function error code result type.
Definition types.h:44
uint32_t u32
32-bit unsigned integer.
Definition types.h:21