forked from Ryubing/Ryujinx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dummy Applet to Replace NotImplementedException (Ryubing#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.
- Loading branch information
1 parent
2f0fca2
commit 092eaf2
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |