0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 18:05:46 +00:00

Add Dummy Applet to Replace NotImplementedException (#216)

Currently, in Ryujinx, if an app attempts to open an unimplemented
applet, it crashes. This change adds a dummy applet to send a dummy
response instead of crashing and logs the applet.
This commit is contained in:
Jacobwasbeast 2024-11-09 19:28:12 -06:00 committed by GitHub
parent 2a23000fed
commit 8c2d6192ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 50 additions and 1 deletions

View file

@ -1,4 +1,6 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Applets.Browser; using Ryujinx.HLE.HOS.Applets.Browser;
using Ryujinx.HLE.HOS.Applets.Dummy;
using Ryujinx.HLE.HOS.Applets.Error; using Ryujinx.HLE.HOS.Applets.Error;
using Ryujinx.HLE.HOS.Services.Am.AppletAE; using Ryujinx.HLE.HOS.Services.Am.AppletAE;
using System; using System;
@ -26,9 +28,13 @@ namespace Ryujinx.HLE.HOS.Applets
return new BrowserApplet(system); return new BrowserApplet(system);
case AppletId.LibAppletOff: case AppletId.LibAppletOff:
return new BrowserApplet(system); return new BrowserApplet(system);
case AppletId.MiiEdit:
Logger.Warning?.Print(LogClass.Application, $"Please use the MiiEdit inside File/Open Applet");
return new DummyApplet(system);
} }
throw new NotImplementedException($"{applet} applet is not implemented."); Logger.Warning?.Print(LogClass.Application, $"Applet {applet} not implemented!");
return new DummyApplet(system);
} }
} }
} }

View file

@ -0,0 +1,43 @@
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
using Ryujinx.HLE.HOS.Applets;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Applets.Dummy
{
internal class DummyApplet : IApplet
{
private readonly Horizon _system;
private AppletSession _normalSession;
public event EventHandler AppletStateChanged;
public DummyApplet(Horizon system)
{
_system = system;
}
public ResultCode Start(AppletSession normalSession, AppletSession interactiveSession)
{
_normalSession = normalSession;
_normalSession.Push(BuildResponse());
AppletStateChanged?.Invoke(this, null);
_system.ReturnFocus();
return ResultCode.Success;
}
private static T ReadStruct<T>(byte[] data) where T : struct
{
return MemoryMarshal.Read<T>(data.AsSpan());
}
private static byte[] BuildResponse()
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.Write((ulong)ResultCode.Success);
return stream.ToArray();
}
public ResultCode GetResult()
{
return ResultCode.Success;
}
}
}