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..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; @@ -119,12 +120,19 @@ 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 ServiceNotImplementedException(this, context, $"{GetType().FullName}: 90"); + } + Logger.Stub?.PrintStub(LogClass.ServiceAm); return ResultCode.Success; } diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index f0e0c2ec3..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,19 +41,36 @@ 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) { 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)) + { + _ = 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)")) + { + _ = 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; + } } PreviewerDetached = true; 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); } }