From 02e4aad9dc1d106e919a54d99b204d7cf87610ee Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 14 Apr 2020 04:46:23 -0700 Subject: [PATCH] pgl: add pglTerminateProcess --- nx/include/switch.h | 1 + nx/include/switch/services/pgl.h | 20 ++++++++++++++++++++ nx/source/services/pgl.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 nx/include/switch/services/pgl.h create mode 100644 nx/source/services/pgl.c diff --git a/nx/include/switch.h b/nx/include/switch.h index 03043d60..755a0430 100644 --- a/nx/include/switch.h +++ b/nx/include/switch.h @@ -64,6 +64,7 @@ extern "C" { #include "switch/services/pcv.h" #include "switch/services/clkrst.h" #include "switch/services/fan.h" +#include "switch/services/pgl.h" #include "switch/services/psm.h" #include "switch/services/spsm.h" //#include "switch/services/bsd.h" Use instead diff --git a/nx/include/switch/services/pgl.h b/nx/include/switch/services/pgl.h new file mode 100644 index 00000000..a6d375ed --- /dev/null +++ b/nx/include/switch/services/pgl.h @@ -0,0 +1,20 @@ +/** + * @file pgl.h + * @brief PGL service IPC wrapper. + * @author SciresM + * @copyright libnx Authors + */ +#pragma once +#include "../types.h" +#include "../sf/service.h" + +/// Initialize pgl. +Result pglInitialize(void); + +/// Exit pgl. +void pglExit(void); + +/// Gets the Service object for the actual pgl service session. +Service* pglGetServiceSession(void); + +Result pglTerminateProcess(u64 pid); diff --git a/nx/source/services/pgl.c b/nx/source/services/pgl.c new file mode 100644 index 00000000..f3896623 --- /dev/null +++ b/nx/source/services/pgl.c @@ -0,0 +1,30 @@ +#define NX_SERVICE_ASSUME_NON_DOMAIN +#include "service_guard.h" +#include "services/pgl.h" +#include "runtime/hosversion.h" + +static Service g_pglSrv; + +NX_GENERATE_SERVICE_GUARD(pgl); + +Result _pglInitialize(void) { + if (hosversionBefore(10,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return smGetService(&g_pglSrv, "pgl"); +} + +void _pglCleanup(void) { + serviceClose(&g_pglSrv); +} + +Service* pglGetServiceSession(void) { + return &g_pglSrv; +} + +static Result _pglCmdInU64(Service* srv, u32 cmd_id, u64 inval) { + return serviceDispatchIn(srv, cmd_id, inval); +} + +Result pglTerminateProcess(u64 pid) { + return _pglCmdInU64(&g_pglSrv, 1, pid); +}