From 08272ed12e0e5e81900cdab8386ef9e879998c0e Mon Sep 17 00:00:00 2001 From: yellows8 Date: Mon, 30 Sep 2019 19:23:36 -0400 Subject: [PATCH] Improved docs. Added nsGetServiceSession_GetterInterface, nsGetServiceSession_ApplicationManagerInterface, nsvmGetServiceSession, nsdevGetServiceSession, and nssuGetServiceSession. --- nx/include/switch/services/ns.h | 27 +++++++++++++++++++++++++++ nx/source/services/ns.c | 20 ++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/nx/include/switch/services/ns.h b/nx/include/switch/services/ns.h index 0d2664da..e8196423 100644 --- a/nx/include/switch/services/ns.h +++ b/nx/include/switch/services/ns.h @@ -118,9 +118,18 @@ typedef struct { ///@name ns ///@{ +/// Initialize ns services. Uses ns:am on pre-3.0.0, ns:am2 on [3.0.0+]. Result nsInitialize(void); + +/// Exit ns services. void nsExit(void); +/// Gets the Service object for the actual ns:* service session. Only initialized on [3.0.0+], on pre-3.0.0 see \ref nsGetServiceSession_ApplicationManagerInterface. +Service* nsGetServiceSession_GetterInterface(void); + +/// Gets the Service object for IApplicationManagerInterface. +Service* nsGetServiceSession_ApplicationManagerInterface(void); + /** * @brief Gets an listing of \ref NsApplicationRecord. * @param[out] records Output array of \ref NsApplicationRecord. @@ -169,9 +178,15 @@ Result nsGetFreeSpaceSize(FsStorageId storage_id, u64 *size); ///@name ns:vm ///@{ +/// Initialize ns:vm. On pre-3.0.0 this must be used with \ref nsInitialize. Result nsvmInitialize(void); + +/// Exit ns:vm. void nsvmExit(void); +/// Gets the Service object for ns:vm. This is only initialized on [3.0.0+]. +Service* nsvmGetServiceSession(void); + Result nsvmNeedsUpdateVulnerability(bool *out); Result nsvmGetSafeSystemVersion(NcmContentMetaKey *out); ///< [4.0.0+] @@ -180,9 +195,15 @@ Result nsvmGetSafeSystemVersion(NcmContentMetaKey *out); ///< [4.0.0+] ///@name ns:dev ///@{ +/// Initialize ns:dev. Result nsdevInitialize(void); + +/// Initialize ns:dev. void nsdevExit(void); +/// Gets the Service object for ns:dev. +Service* nsdevGetServiceSession(void); + Result nsdevLaunchProgram(u64* out_pid, const NsLaunchProperties* properties, u32 flags); Result nsdevTerminateProcess(u64 pid); Result nsdevTerminateProgram(u64 tid); @@ -201,9 +222,15 @@ Result nsdevSetCurrentApplicationRightsEnvironmentCanBeActiveForDevelop(bool can ///@name ns:su ///@{ +/// Initialize ns:su. Result nssuInitialize(void); + +/// Exit ns:su. void nssuExit(void); +/// Gets the Service object for ns:su. +Service* nssuGetServiceSession(void); + /** * @brief Gets the \ref NsBackgroundNetworkUpdateState. * @note Internally this uses nim commands ListSystemUpdateTask and GetSystemUpdateTaskInfo to determine the output state. diff --git a/nx/source/services/ns.c b/nx/source/services/ns.c index 1cc3c158..3a13c085 100644 --- a/nx/source/services/ns.c +++ b/nx/source/services/ns.c @@ -44,6 +44,14 @@ void _nsCleanup(void) serviceClose(&g_nsGetterSrv); } +Service* nsGetServiceSession_GetterInterface(void) { + return &g_nsGetterSrv; +} + +Service* nsGetServiceSession_ApplicationManagerInterface(void) { + return &g_nsAppManSrv; +} + static Result _nsGetSession(Service* srv, Service* srv_out, u32 cmd_id) { return serviceDispatch(srv, cmd_id, .out_num_objects = 1, @@ -230,6 +238,10 @@ void _nsvmCleanup(void) serviceClose(&g_nsvmSrv); } +Service* nsvmGetServiceSession(void) { + return &g_nsvmSrv; +} + Result nsvmNeedsUpdateVulnerability(bool *out) { Service *srv = &g_nsAppManSrv; if (hosversionAtLeast(3,0,0)) srv = &g_nsvmSrv; @@ -256,6 +268,10 @@ void _nsdevCleanup(void) { serviceClose(&g_nsdevSrv); } +Service* nsdevGetServiceSession(void) { + return &g_nsdevSrv; +} + Result nsdevLaunchProgram(u64* out_pid, const NsLaunchProperties* properties, u32 flags) { const struct { u32 flags; @@ -352,6 +368,10 @@ void _nssuCleanup(void) { serviceClose(&g_nssuSrv); } +Service* nssuGetServiceSession(void) { + return &g_nssuSrv; +} + Result nssuGetBackgroundNetworkUpdateState(NsBackgroundNetworkUpdateState *out) { u8 tmpout=0; Result rc = _nsCmdNoInOutU8(&g_nssuSrv, &tmpout, 0);