diff --git a/libctru/include/3ds/srv.h b/libctru/include/3ds/srv.h index 961ddbe..9fbe481 100644 --- a/libctru/include/3ds/srv.h +++ b/libctru/include/3ds/srv.h @@ -4,6 +4,8 @@ Result srvInit(); Result srvExit(); Result srvRegisterClient(); Result srvGetServiceHandle(Handle* out, const char* name); +Result srvRegisterService(Handle* out, const char* name, int maxSessions); +Result srvUnregisterService(const char* name); Result srvPmInit(); Result srvRegisterProcess(u32 procid, u32 count, void *serviceaccesscontrol); diff --git a/libctru/source/srv.c b/libctru/source/srv.c index 366eca6..53c0767 100644 --- a/libctru/source/srv.c +++ b/libctru/source/srv.c @@ -136,6 +136,34 @@ Result srvGetServiceHandle(Handle* out, const char* name) return cmdbuf[1]; } +Result srvRegisterService(Handle* out, const char* name, int maxSessions) +{ + u32* cmdbuf = getThreadCommandBuffer(); + cmdbuf[0] = 0x30100; + strcpy((char*) &cmdbuf[1], name); + cmdbuf[3] = strlen(name); + cmdbuf[4] = maxSessions; + + Result rc; + if((rc = svcSendSyncRequest(g_srv_handle)))return rc; + + *out = cmdbuf[3]; + return cmdbuf[1]; +} + +Result srvUnregisterService(const char* name) +{ + u32* cmdbuf = getThreadCommandBuffer(); + cmdbuf[0] = 0x400C0; + strcpy((char*) &cmdbuf[1], name); + cmdbuf[3] = strlen(name); + + Result rc; + if((rc = svcSendSyncRequest(g_srv_handle)))return rc; + + return cmdbuf[1]; +} + // Old srv:pm interface, will only work on systems where srv:pm was a port (<7.X) Result srvPmInit() {