From ff9a75f895921451474a5c5b5036b2f6acb4a250 Mon Sep 17 00:00:00 2001 From: LotP <22-lotp@users.noreply.git.ryujinx.app> Date: Tue, 28 Oct 2025 13:37:20 -0500 Subject: [PATCH 1/4] ILibraryAppletAccessor:90 tweak (ryubing/ryujinx!199) See merge request ryubing/ryujinx!199 --- .../LibraryAppletCreator/ILibraryAppletAccessor.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs index e1c0e5e62..5ce56de75 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs @@ -119,11 +119,18 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib } [CommandCmif(90)] - // ILibraryAppletAccessor:90 + // Unknown90(ulong[4]) public ResultCode Unknown90(ServiceCtx context) { // NOTE: This call is performed on SDK 20+ when applet is called. - // Since we don't support applets for now, it's fine to stub it. + // Since we don't support most applets for now, it's fine to stub it. + // Throw if values are not 0 to learn more about what this function does. + + if (context.RequestData.ReadUInt64() != 0 || context.RequestData.ReadUInt64() != 0 || + context.RequestData.ReadUInt64() != 0 || context.RequestData.ReadUInt64() != 0) + { + throw new ArgumentException("Invalid data: values are not 0"); + } Logger.Stub?.PrintStub(LogClass.ServiceAm); return ResultCode.Success; From 53aae9b5848170298cd7e502e6860081a2cd99f1 Mon Sep 17 00:00:00 2001 From: GreemDev Date: Tue, 28 Oct 2025 15:37:59 -0500 Subject: [PATCH 2/4] hle: Throw a ServiceNotImplementedException instead of ArgumentException if any number arguments provided to ILibraryAppletAccessor are nonzero --- .../LibraryAppletCreator/ILibraryAppletAccessor.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs index 5ce56de75..cd71103ca 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs @@ -1,4 +1,5 @@ using Ryujinx.Common.Logging; +using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.HOS.Applets; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Kernel; @@ -129,9 +130,9 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib if (context.RequestData.ReadUInt64() != 0 || context.RequestData.ReadUInt64() != 0 || context.RequestData.ReadUInt64() != 0 || context.RequestData.ReadUInt64() != 0) { - throw new ArgumentException("Invalid data: values are not 0"); + throw new ServiceNotImplementedException(this, context, $"{GetType().FullName}: 90"); } - + Logger.Stub?.PrintStub(LogClass.ServiceAm); return ResultCode.Success; } From 40f709ff550065eed9bf083c84dd7a06d94310f1 Mon Sep 17 00:00:00 2001 From: GreemDev Date: Tue, 28 Oct 2025 19:04:25 -0500 Subject: [PATCH 3/4] misc: Add a launch guard for program files (the emulator does not work properly when put here as it does not require admin) --- src/Ryujinx/Program.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index f0e0c2ec3..1659683c1 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -48,11 +48,21 @@ namespace Ryujinx.Ava public static int Main(string[] args) { Version = ReleaseInformation.Version; - - if (OperatingSystem.IsWindows() && !OperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041)) + + if (OperatingSystem.IsWindows()) { - _ = MessageBoxA(nint.Zero, "You are running an outdated version of Windows.\n\nRyujinx supports Windows 10 version 20H1 and newer.\n", $"Ryujinx {Version}", MbIconwarning); - return 0; + if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041)) + { + _ = MessageBoxA(nint.Zero, "You are running an outdated version of Windows.\n\nRyujinx supports Windows 10 version 20H1 and newer.\n", $"Ryujinx {Version}", MbIconwarning); + return 0; + } + + if (Environment.CurrentDirectory.StartsWithIgnoreCase("C:\\Program Files") || + Environment.CurrentDirectory.StartsWithIgnoreCase("C:\\Program Files (x86)")) + { + _ = MessageBoxA(nint.Zero, "Ryujinx is not intended to be run from the Program Files folder. Please move it out and relaunch.", $"Ryujinx {Version}", MbIconwarning); + return 0; + } } PreviewerDetached = true; From 3140ec5f059be7c5f788ebc2c6118a24d5ccc275 Mon Sep 17 00:00:00 2001 From: GreemDev Date: Tue, 28 Oct 2025 20:57:03 -0500 Subject: [PATCH 4/4] misc: Also show an error message box and quit if the process was launched with administrator rights. --- src/Ryujinx/Program.cs | 20 ++++++++++++++------ src/Ryujinx/UI/Helpers/Win32NativeInterop.cs | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index 1659683c1..b5b5447db 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -24,11 +24,12 @@ using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; +using System.Security.Principal; using System.Threading.Tasks; namespace Ryujinx.Ava { - internal partial class Program + internal static class Program { public static double WindowScaleFactor { get; set; } public static double DesktopScaleFactor { get; set; } = 1.0; @@ -40,9 +41,6 @@ namespace Ryujinx.Ava public static bool UseHardwareAcceleration { get; private set; } public static string BackendThreadingArg { get; private set; } - [LibraryImport("user32.dll", SetLastError = true)] - public static partial int MessageBoxA(nint hWnd, [MarshalAs(UnmanagedType.LPStr)] string text, [MarshalAs(UnmanagedType.LPStr)] string caption, uint type); - private const uint MbIconwarning = 0x30; public static int Main(string[] args) @@ -53,14 +51,24 @@ namespace Ryujinx.Ava { if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041)) { - _ = MessageBoxA(nint.Zero, "You are running an outdated version of Windows.\n\nRyujinx supports Windows 10 version 20H1 and newer.\n", $"Ryujinx {Version}", MbIconwarning); + _ = Win32NativeInterop.MessageBoxA(nint.Zero, "You are running an outdated version of Windows.\n\nRyujinx supports Windows 10 version 20H1 and newer.\n", $"Ryujinx {Version}", MbIconwarning); return 0; } if (Environment.CurrentDirectory.StartsWithIgnoreCase("C:\\Program Files") || Environment.CurrentDirectory.StartsWithIgnoreCase("C:\\Program Files (x86)")) { - _ = MessageBoxA(nint.Zero, "Ryujinx is not intended to be run from the Program Files folder. Please move it out and relaunch.", $"Ryujinx {Version}", MbIconwarning); + _ = Win32NativeInterop.MessageBoxA(nint.Zero, "Ryujinx is not intended to be run from the Program Files folder. Please move it out and relaunch.", $"Ryujinx {Version}", MbIconwarning); + return 0; + } + + // The names of everything here makes no sense for what this actually checks for. Thanks, Microsoft. + // If you can't tell by the error string, + // this actually checks if the current process was run with "Run as Administrator" + // ...but this reads like it checks if the current is in/has the Windows admin role? lol + if (new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)) + { + _ = Win32NativeInterop.MessageBoxA(nint.Zero, "Ryujinx is not intended to be run as administrator.", $"Ryujinx {Version}", MbIconwarning); return 0; } } diff --git a/src/Ryujinx/UI/Helpers/Win32NativeInterop.cs b/src/Ryujinx/UI/Helpers/Win32NativeInterop.cs index fc4193948..0ff7f5fde 100644 --- a/src/Ryujinx/UI/Helpers/Win32NativeInterop.cs +++ b/src/Ryujinx/UI/Helpers/Win32NativeInterop.cs @@ -112,5 +112,8 @@ namespace Ryujinx.Ava.UI.Helpers [LibraryImport("user32.dll", SetLastError = true)] public static partial ushort GetAsyncKeyState(int nVirtKey); + + [LibraryImport("user32.dll", SetLastError = true)] + public static partial int MessageBoxA(nint hWnd, [MarshalAs(UnmanagedType.LPStr)] string text, [MarshalAs(UnmanagedType.LPStr)] string caption, uint type); } }