libnx  v4.6.0
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
16 typedef 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),
35 } PmLaunchFlag;
36 
37 /// ProcessEvent
38 typedef 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
48 typedef struct {
49  PmProcessEvent event;
50  u64 process_id;
52 
53 /// BootMode
54 typedef enum {
55  PmBootMode_Normal = 0, ///< Normal
56  PmBootMode_Maintenance = 1, ///< Maintenance
57  PmBootMode_SafeMode = 2, ///< SafeMode
58 } PmBootMode;
59 
60 /// ResourceLimitValues
61 typedef 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.
73 void 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.
82 void 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.
91 void 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.
100 void 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 
116 Result pmdmntGetJitDebugProcessIdList(u32* out_count, u64* out_pids, size_t max_pids);
117 Result pmdmntStartProcess(u64 pid);
118 Result pmdmntGetProcessId(u64* pid_out, u64 program_id);
119 Result pmdmntHookToCreateProcess(Event* out, u64 program_id);
120 Result pmdmntGetApplicationProcessId(u64* pid_out);
121 Result pmdmntHookToCreateApplicationProcess(Event* out);
122 Result pmdmntClearHook(u32 which);
123 Result pmdmntGetProgramId(u64* program_id_out, u64 pid);
124 
125 Result pminfoGetProgramId(u64* program_id_out, u64 pid);
126 Result pminfoGetAppletCurrentResourceLimitValues(PmResourceLimitValues* out);
127 Result pminfoGetAppletPeakResourceLimitValues(PmResourceLimitValues* out);
128 
129 Result pmshellLaunchProgram(u32 launch_flags, const NcmProgramLocation *location, u64 *pid);
130 Result pmshellTerminateProcess(u64 processID);
131 Result pmshellTerminateProgram(u64 program_id);
132 Result pmshellGetProcessEventHandle(Event* out); // Autoclear for pmshellProcessEvent is always true.
133 Result pmshellGetProcessEventInfo(PmProcessEventInfo* out);
134 Result pmshellCleanupProcess(u64 pid);
135 Result pmshellClearJitDebugOccured(u64 pid);
136 Result pmshellNotifyBootFinished(void);
137 Result pmshellGetApplicationProcessIdForShell(u64* pid_out);
138 Result pmshellBoostSystemMemoryResourceLimit(u64 boost_size);
139 Result pmshellBoostApplicationThreadResourceLimit(void);
140 Result pmshellBoostSystemThreadResourceLimit(void);
Result pmbmInitialize(void)
Initialize pm:bm.
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.
Service * pmdmntGetServiceSession(void)
Gets the Service object for the actual pm:dmnt service session.
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