aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Sm
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Sm')
-rw-r--r--Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs37
-rw-r--r--Ryujinx.HLE/HOS/Services/Sm/SmErr.cs1
2 files changed, 35 insertions, 3 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs
index 6940bfc8..914862f1 100644
--- a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs
+++ b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs
@@ -23,9 +23,10 @@ namespace Ryujinx.HLE.HOS.Services.Sm
{
_commands = new Dictionary<int, ServiceProcessRequest>
{
- { 0, Initialize },
- { 1, GetService },
- { 2, RegisterService }
+ { 0, Initialize },
+ { 1, GetService },
+ { 2, RegisterService },
+ { 3, UnregisterService }
};
_registeredServices = new ConcurrentDictionary<string, KPort>();
@@ -128,6 +129,36 @@ namespace Ryujinx.HLE.HOS.Services.Sm
return 0;
}
+ public long UnregisterService(ServiceCtx context)
+ {
+ if (!_isInitialized)
+ {
+ return ErrorCode.MakeError(ErrorModule.Sm, SmErr.NotInitialized);
+ }
+
+ long namePosition = context.RequestData.BaseStream.Position;
+
+ string name = ReadName(context);
+
+ context.RequestData.BaseStream.Seek(namePosition + 8, SeekOrigin.Begin);
+
+ bool isLight = (context.RequestData.ReadInt32() & 1) != 0;
+
+ int maxSessions = context.RequestData.ReadInt32();
+
+ if (name == string.Empty)
+ {
+ return ErrorCode.MakeError(ErrorModule.Sm, SmErr.InvalidName);
+ }
+
+ if (!_registeredServices.TryRemove(name, out _))
+ {
+ return ErrorCode.MakeError(ErrorModule.Sm, SmErr.NotRegistered);
+ }
+
+ return 0;
+ }
+
private static string ReadName(ServiceCtx context)
{
string name = string.Empty;
diff --git a/Ryujinx.HLE/HOS/Services/Sm/SmErr.cs b/Ryujinx.HLE/HOS/Services/Sm/SmErr.cs
index 5b5a66dc..7dd3a205 100644
--- a/Ryujinx.HLE/HOS/Services/Sm/SmErr.cs
+++ b/Ryujinx.HLE/HOS/Services/Sm/SmErr.cs
@@ -5,5 +5,6 @@ namespace Ryujinx.HLE.HOS.Services.Sm
public const int NotInitialized = 2;
public const int AlreadyRegistered = 4;
public const int InvalidName = 6;
+ public const int NotRegistered = 7;
}
} \ No newline at end of file