mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-29 00:02:39 +02:00
Added FsStorageId. Added pmshell init/exit and pmshellLaunchProcess.
This commit is contained in:
parent
a3baa0eeb1
commit
8091db8931
@ -94,6 +94,16 @@ typedef enum
|
|||||||
FS_DIROPEN_FILE = BIT(1), ///< Enable reading file entries.
|
FS_DIROPEN_FILE = BIT(1), ///< Enable reading file entries.
|
||||||
} FsDirectoryFlags;
|
} FsDirectoryFlags;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
FsStorageId_None = 0,
|
||||||
|
FsStorageId_Host = 1,
|
||||||
|
FsStorageId_GameCard = 2,
|
||||||
|
FsStorageId_NandSystem = 3,
|
||||||
|
FsStorageId_NandUser = 4,
|
||||||
|
FsStorageId_SdCard = 5,
|
||||||
|
} FsStorageId;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
FS_CONTENTSTORAGEID_NandSystem = 0,
|
FS_CONTENTSTORAGEID_NandSystem = 0,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* @file pm.h
|
* @file pm.h
|
||||||
* @brief Process management (pm*) service IPC wrapper.
|
* @brief Process management (pm*) service IPC wrapper.
|
||||||
* @author plutoo
|
* @author plutoo
|
||||||
|
* @author yellows8
|
||||||
* @copyright libnx Authors
|
* @copyright libnx Authors
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -10,8 +11,13 @@
|
|||||||
Result pmdmntInitialize(void);
|
Result pmdmntInitialize(void);
|
||||||
void pmdmntExit(void);
|
void pmdmntExit(void);
|
||||||
|
|
||||||
|
Result pmshellInitialize(void);
|
||||||
|
void pmshellExit(void);
|
||||||
|
|
||||||
Result pmdmntStartProcess(u64 pid);
|
Result pmdmntStartProcess(u64 pid);
|
||||||
Result pmdmntGetTitlePid(u64* pid_out, u64 title_id);
|
Result pmdmntGetTitlePid(u64* pid_out, u64 title_id);
|
||||||
Result pmdmntEnableDebugForTitleId(Handle* handle_out, u64 title_id);
|
Result pmdmntEnableDebugForTitleId(Handle* handle_out, u64 title_id);
|
||||||
Result pmdmntGetApplicationPid(u64* pid_out);
|
Result pmdmntGetApplicationPid(u64* pid_out);
|
||||||
Result pmdmntEnableDebugForApplication(Handle* handle_out);
|
Result pmdmntEnableDebugForApplication(Handle* handle_out);
|
||||||
|
|
||||||
|
Result pmshellLaunchProcess(u32 launch_flags, u64 titleID, u64 storageID, u64 *pid);
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
#include "services/pm.h"
|
#include "services/pm.h"
|
||||||
#include "services/sm.h"
|
#include "services/sm.h"
|
||||||
|
|
||||||
static Service g_pmdmntSrv;
|
static Service g_pmdmntSrv, g_pmshellSrv;
|
||||||
static u64 g_refCnt;
|
static u64 g_pmdmntRefCnt, g_pmshellRefCnt;
|
||||||
|
|
||||||
Result pmdmntInitialize(void)
|
Result pmdmntInitialize(void)
|
||||||
{
|
{
|
||||||
atomicIncrement64(&g_refCnt);
|
atomicIncrement64(&g_pmdmntRefCnt);
|
||||||
|
|
||||||
if (serviceIsActive(&g_pmdmntSrv))
|
if (serviceIsActive(&g_pmdmntSrv))
|
||||||
return 0;
|
return 0;
|
||||||
@ -21,11 +21,28 @@ Result pmdmntInitialize(void)
|
|||||||
|
|
||||||
void pmdmntExit(void)
|
void pmdmntExit(void)
|
||||||
{
|
{
|
||||||
if (atomicDecrement64(&g_refCnt) == 0) {
|
if (atomicDecrement64(&g_pmdmntRefCnt) == 0) {
|
||||||
serviceClose(&g_pmdmntSrv);
|
serviceClose(&g_pmdmntSrv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result pmshellInitialize(void)
|
||||||
|
{
|
||||||
|
atomicIncrement64(&g_pmshellRefCnt);
|
||||||
|
|
||||||
|
if (serviceIsActive(&g_pmshellSrv))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return smGetService(&g_pmshellSrv, "pm:shell");
|
||||||
|
}
|
||||||
|
|
||||||
|
void pmshellExit(void)
|
||||||
|
{
|
||||||
|
if (atomicDecrement64(&g_pmshellRefCnt) == 0) {
|
||||||
|
serviceClose(&g_pmshellSrv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Result pmdmntStartProcess(u64 pid) {
|
Result pmdmntStartProcess(u64 pid) {
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
@ -204,3 +221,43 @@ Result pmdmntEnableDebugForApplication(Handle* handle_out) {
|
|||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result pmshellLaunchProcess(u32 launch_flags, u64 titleID, u64 storageID, u64 *pid) {
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
u32 launch_flags;
|
||||||
|
u64 titleID;
|
||||||
|
u64 storageID;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 0;
|
||||||
|
raw->launch_flags = launch_flags;
|
||||||
|
raw->titleID = titleID;
|
||||||
|
raw->storageID = storageID;
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(&g_pmshellSrv);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
ipcParse(&r);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
u64 pid;
|
||||||
|
} *resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc) && pid) *pid = resp->pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user