mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-04 16:53:48 -04:00
dmnt: refactor to use sts:: namespace.
This commit is contained in:
parent
a750e55f75
commit
78a730ddf6
36 changed files with 3684 additions and 4318 deletions
|
@ -94,3 +94,94 @@ Result pminfoAtmosphereHasLaunchedTitle(bool *out, u64 tid) {
|
|||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result pmdmntAtmosphereGetProcessInfo(Handle* out, u64 *tid_out, u8 *sid_out, u64 pid) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
Service *s = pmdmntGetServiceSession();
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 pid;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(s, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 65000;
|
||||
raw->pid = pid;
|
||||
|
||||
Result rc = serviceIpcDispatch(s);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u64 title_id;
|
||||
FsStorageId storage_id;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(s, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (out) {
|
||||
*out = r.Handles[0];
|
||||
} else {
|
||||
svcCloseHandle(r.Handles[0]);
|
||||
}
|
||||
if (tid_out) *tid_out = resp->title_id;
|
||||
if (sid_out) *sid_out = resp->storage_id;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result pmdmntAtmosphereGetCurrentLimitInfo(u64 *out_cur, u64 *out_lim, u32 group, u32 resource) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
Service *s = pmdmntGetServiceSession();
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u32 group;
|
||||
u32 resource;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(s, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 65001;
|
||||
raw->group = group;
|
||||
raw->resource = resource;
|
||||
|
||||
Result rc = serviceIpcDispatch(s);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u64 cur_value;
|
||||
u64 lim_value;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(s, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (out_cur) *out_cur = resp->cur_value;
|
||||
if (out_lim) *out_lim = resp->lim_value;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ extern "C" {
|
|||
Result pminfoAtmosphereGetProcessId(u64 *out_pid, u64 tid);
|
||||
Result pminfoAtmosphereHasLaunchedTitle(bool *out, u64 tid);
|
||||
|
||||
Result pmdmntAtmosphereGetProcessInfo(Handle *out, u64 *tid_out, u8 *sid_out, u64 pid);
|
||||
Result pmdmntAtmosphereGetCurrentLimitInfo(u64 *out_cur, u64 *out_lim, u32 group, u32 resource);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
54
stratosphere/libstratosphere/source/pm/pm_dmnt_api.cpp
Normal file
54
stratosphere/libstratosphere/source/pm/pm_dmnt_api.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/pm.hpp>
|
||||
|
||||
#include "pm_ams.h"
|
||||
|
||||
namespace sts::pm::dmnt {
|
||||
|
||||
/* Debug Monitor API. */
|
||||
Result StartProcess(u64 process_id) {
|
||||
return pmdmntStartProcess(process_id);
|
||||
}
|
||||
|
||||
Result GetProcessId(u64 *out_process_id, const ncm::TitleId title_id) {
|
||||
return pmdmntGetTitlePid(out_process_id, static_cast<u64>(title_id));
|
||||
}
|
||||
|
||||
Result GetApplicationProcessId(u64 *out_process_id) {
|
||||
return pmdmntGetApplicationPid(out_process_id);
|
||||
}
|
||||
|
||||
Result HookToCreateApplicationProcess(Handle *out_handle) {
|
||||
return pmdmntEnableDebugForApplication(out_handle);
|
||||
}
|
||||
|
||||
Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::TitleLocation *out_loc, u64 process_id) {
|
||||
*out_handle = INVALID_HANDLE;
|
||||
*out_loc = {};
|
||||
return pmdmntAtmosphereGetProcessInfo(out_handle, reinterpret_cast<u64 *>(&out_loc->title_id), &out_loc->storage_id, process_id);
|
||||
}
|
||||
|
||||
Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, LimitableResource resource) {
|
||||
*out_current_value = 0;
|
||||
*out_limit_value = 0;
|
||||
return pmdmntAtmosphereGetCurrentLimitInfo(out_current_value, out_limit_value, group, resource);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue