fix: browser no longer crashes, doesn't work though

This commit is contained in:
Jacobwasbeast 2025-02-12 14:16:16 -06:00
parent 24c427ce01
commit 7e59519709
16 changed files with 223 additions and 1 deletions

View File

@ -181,6 +181,14 @@ namespace Ryujinx.HLE.HOS.Applets
{ {
if (process.State == ProcessState.Exited) if (process.State == ProcessState.Exited)
{ {
if (applet.CallerApplet != null)
{
if (applet.CallerApplet.ProcessHandle.IsPaused)
{
applet.CallerApplet.ProcessHandle.SetActivity(false);
}
}
_processHolders.Remove(holder); _processHolders.Remove(holder);
} }
else else

View File

@ -7,6 +7,7 @@ using System.Linq;
using Ryujinx.Horizon.Sdk.Applet; using Ryujinx.Horizon.Sdk.Applet;
using Ryujinx.Common; using Ryujinx.Common;
using Ryujinx.HLE.HOS.Applets.Types; using Ryujinx.HLE.HOS.Applets.Types;
using System.Collections;
using System.Threading; using System.Threading;
namespace Ryujinx.HLE.HOS.Applets namespace Ryujinx.HLE.HOS.Applets
@ -563,6 +564,10 @@ namespace Ryujinx.HLE.HOS.Applets
} }
} }
if (applet == null)
{
return _foregroundRequestedApplet;
}
return applet; return applet;
} }
@ -607,6 +612,20 @@ namespace Ryujinx.HLE.HOS.Applets
{ {
return _applets.Count > 0; return _applets.Count > 0;
} }
internal RealApplet[] GetApplets()
{
return _applets.Values.ToArray();
}
public void PauseOldWindows(ulong pid)
{
RealApplet applet = GetByAruId(pid);
if (applet?.CallerApplet != null)
{
applet.CallerApplet.ProcessHandle.SetActivity(true);
}
}
} }
internal class ButtonPressTracker internal class ButtonPressTracker

View File

@ -4,6 +4,7 @@ using Ryujinx.HLE.HOS.Applets;
using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel; using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Applet; using Ryujinx.Horizon.Sdk.Applet;
using System; using System;
@ -182,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
// CanUseApplicationCore() -> bool // CanUseApplicationCore() -> bool
public ResultCode CanUseApplicationCore(ServiceCtx context) public ResultCode CanUseApplicationCore(ServiceCtx context)
{ {
context.ResponseData.Write(false); context.ResponseData.Write(true);
Logger.Stub?.PrintStub(LogClass.ServiceAm); Logger.Stub?.PrintStub(LogClass.ServiceAm);
@ -217,6 +218,29 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(60)]
// GetMainAppletApplicationDesiredLanguage() -> nn::os::Language
public ResultCode GetMainAppletApplicationDesiredLanguage(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceAm);
// TODO: Find a better method to get the desired language.
string language = "en-US";
switch (context.Device.Configuration.Region)
{
case RegionCode.Japan:
language = "ja";
break;
case RegionCode.Europe:
language = "fr";
break;
case RegionCode.Korea:
language = "ko";
break;
}
context.ResponseData.Write(language);
return ResultCode.Success;
}
[CommandCmif(150)] [CommandCmif(150)]
// ShouldSetGpuTimeSliceManually() -> bool // ShouldSetGpuTimeSliceManually() -> bool
public ResultCode ShouldSetGpuTimeSliceManually(ServiceCtx context) public ResultCode ShouldSetGpuTimeSliceManually(ServiceCtx context)

View File

@ -22,5 +22,22 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
Logger.Info?.PrintStub(LogClass.ServiceAm); Logger.Info?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(100)]
// SetApplicationCoreUsageMode()
public ResultCode SetApplicationCoreUsageMode(ServiceCtx context)
{
Logger.Info?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[CommandCmif(300)] // 17.0.0+
// GetCurrentApplicationId() -> nn::am::detail::IApplicationId
public ResultCode GetCurrentApplicationId(ServiceCtx context)
{
Logger.Info?.PrintStub(LogClass.ServiceAm);
context.ResponseData.Write(context.Device.System.WindowSystem.GetApplicationApplet().ProcessHandle.TitleId);
return ResultCode.Success;
}
} }
} }

View File

@ -6,6 +6,7 @@ using Ryujinx.HLE.HOS.Services.Settings.Types;
using Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService; using Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService;
using Ryujinx.HLE.HOS.SystemState; using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Applet;
using Ryujinx.Horizon.Sdk.Lbl; using Ryujinx.Horizon.Sdk.Lbl;
using System; using System;
@ -325,6 +326,24 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return (ResultCode)_apmSystemManagerServer.GetCurrentPerformanceConfiguration(context); return (ResultCode)_apmSystemManagerServer.GetCurrentPerformanceConfiguration(context);
} }
[CommandCmif(120)] // 13.0.0+
// GetAppletLaunchedHistory() -> s32, buffer<AppletId>
public ResultCode GetAppletLaunchedHistory(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceAm);
var buffer = context.Request.ReceiveBuff[0];
int applets = 0;
Span<RealAppletId> appletsBuffer = CreateSpanFromBuffer<RealAppletId>(context, buffer, true);
foreach (var applet in context.Device.System.WindowSystem.GetApplets())
{
applets++;
appletsBuffer[applets - 1] = applet.AppletId;
}
context.ResponseData.Write((uint)applets);
WriteSpanToBuffer<RealAppletId>(context, buffer, appletsBuffer);
return ResultCode.Success;
}
[CommandCmif(200)] [CommandCmif(200)]
// GetOperationModeSystemInfo() -> u32 // GetOperationModeSystemInfo() -> u32
public ResultCode GetOperationModeSystemInfo(ServiceCtx context) public ResultCode GetOperationModeSystemInfo(ServiceCtx context)

View File

@ -193,6 +193,14 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(15)]
// SetScreenShotAppletIdentityInfo()
public ResultCode SetScreenShotAppletIdentityInfo(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[CommandCmif(16)] // 2.0.0+ [CommandCmif(16)] // 2.0.0+
// SetOutOfFocusSuspendingEnabled(b8) // SetOutOfFocusSuspendingEnabled(b8)

View File

@ -24,6 +24,16 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(2)]
// GetAppletResourceUserIdOfCallerApplet() -> nn::applet::AppletResourceUserId
public ResultCode GetAppletResourceUserIdOfCallerApplet(ServiceCtx context)
{
ulong appletResourceUserId = _pid;
appletResourceUserId = context.Device.System.WindowSystem.GetByAruId(_pid).CallerApplet.ProcessHandle.TitleId;
context.ResponseData.Write(appletResourceUserId);
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(10)] [CommandCmif(10)]
@ -31,6 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
public ResultCode AcquireForegroundRights(ServiceCtx context) public ResultCode AcquireForegroundRights(ServiceCtx context)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceAm); Logger.Stub?.PrintStub(LogClass.ServiceAm);
context.Device.System.WindowSystem.PauseOldWindows(_pid);
return ResultCode.Success; return ResultCode.Success;
} }

View File

@ -284,6 +284,14 @@ namespace Ryujinx.HLE.HOS.Services.Caps
var fileId = context.RequestData.ReadStruct<AlbumFileId>(); var fileId = context.RequestData.ReadStruct<AlbumFileId>();
return LoadImageEx1(320, 180, context, fileId); return LoadImageEx1(320, 180, context, fileId);
} }
[CommandCmif(50011)] // 19.0.0+
// GetAlbumAccessResultForDebug()
public ResultCode GetAlbumAccessResultForDebug(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceCaps);
return ResultCode.Success;
}
public void GetWidthAndHeightFromInputBuffer(AlbumFileId id, out int width, out int height) public void GetWidthAndHeightFromInputBuffer(AlbumFileId id, out int width, out int height)
{ {

View File

@ -13,6 +13,7 @@ using LibHac.Tools.FsSystem.NcaUtils;
using System; using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ApplicationId = LibHac.ApplicationId;
using Path = System.IO.Path; using Path = System.IO.Path;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy

View File

@ -13,11 +13,13 @@ using LibHac.Tools.FsSystem.NcaUtils;
using Ryujinx.Common; using Ryujinx.Common;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy; using Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy;
using Ryujinx.HLE.HOS.Services.Ns.Types;
using Ryujinx.HLE.HOS.Services.Pcv; using Ryujinx.HLE.HOS.Services.Pcv;
using Ryujinx.Memory; using Ryujinx.Memory;
using System; using System;
using System.IO; using System.IO;
using static Ryujinx.HLE.Utilities.StringUtils; using static Ryujinx.HLE.Utilities.StringUtils;
using ApplicationId = LibHac.ApplicationId;
using GameCardHandle = System.UInt32; using GameCardHandle = System.UInt32;
using IFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.IFile; using IFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.IFile;
using IFileSystem = LibHac.FsSrv.Sf.IFileSystem; using IFileSystem = LibHac.FsSrv.Sf.IFileSystem;
@ -45,6 +47,38 @@ namespace Ryujinx.HLE.HOS.Services.Fs
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(7)] // 2.0.0+
// OpenFileSystemWithPatch(nn::fssrv::sf::FileSystemType filesystem_type, nn::ApplicationId tid) -> object<nn::fssrv::sf::IFileSystem> contentFs
public ResultCode OpenFileSystemWithPatch(ServiceCtx context)
{
FileSystemType fileSystemType = (FileSystemType)context.RequestData.ReadInt32();
ulong titleId = context.RequestData.ReadUInt64();
string switchPath = string.Empty;
Logger.Stub?.PrintStub(LogClass.ServiceFs);
foreach (RyuApplicationData ryuApplicationData in context.Device.Configuration.Titles)
{
if (titleId == ryuApplicationData.AppId.Value)
{
switchPath = ryuApplicationData.Path;
break;
}
}
if (switchPath == string.Empty)
{
return ResultCode.PathDoesNotExist;
}
string fullPath = FileSystem.VirtualFileSystem.SwitchPathToSystemPath(switchPath);
ResultCode result = FileSystemProxyHelper.OpenFileSystemFromInternalFile(context, fullPath, out FileSystemProxy.IFileSystem fileSystem);
if (result == ResultCode.Success)
{
MakeObject(context, fileSystem);
}
return result;
}
[CommandCmif(8)] [CommandCmif(8)]
// OpenFileSystemWithId(nn::fssrv::sf::FileSystemType filesystem_type, nn::ApplicationId tid, buffer<bytes<0x301>, 0x19, 0x301> path) // OpenFileSystemWithId(nn::fssrv::sf::FileSystemType filesystem_type, nn::ApplicationId tid, buffer<bytes<0x301>, 0x19, 0x301> path)

View File

@ -184,6 +184,14 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(313)] // 9.0.0+
// GetNpadCaptureButtonAssignment()
public ResultCode GetNpadCaptureButtonAssignment(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
return ResultCode.Success;
}
[CommandCmif(314)] // 9.0.0+ [CommandCmif(314)] // 9.0.0+
// GetAppletFooterUiType(u32) -> u8 // GetAppletFooterUiType(u32) -> u8
public ResultCode GetAppletFooterUiType(ServiceCtx context) public ResultCode GetAppletFooterUiType(ServiceCtx context)

View File

@ -0,0 +1,23 @@
using Ryujinx.Common.Logging;
namespace Ryujinx.HLE.HOS.Services.Ns
{
class IDocumentInterface : IpcService
{
[CommandCmif(23)]
// ResolveApplicationContentPath()
public ResultCode ResolveApplicationContentPath(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceNs);
return ResultCode.Success;
}
[CommandCmif(92)] // 5.0.0+
// GetRunningApplicationProgramId() -> u64
public ResultCode GetRunningApplicationProgramId(ServiceCtx context)
{
context.ResponseData.Write(context.Device.Processes.ActiveApplication.ProgramId);
return ResultCode.Success;
}
}
}

View File

@ -0,0 +1,7 @@
namespace Ryujinx.HLE.HOS.Services.Ns
{
class IReadOnlyApplicationRecordInterface : IpcService
{
}
}

View File

@ -28,6 +28,15 @@ namespace Ryujinx.HLE.HOS.Services.Ns
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(7991)] // 5.0.0+
// GetReadOnlyApplicationRecordInterface() -> object<nn::ns::detail::IReadOnlyApplicationRecordInterface>
public ResultCode GetReadOnlyApplicationRecordInterface(ServiceCtx context)
{
MakeObject(context, new IReadOnlyApplicationRecordInterface());
return ResultCode.Success;
}
[CommandCmif(7996)] [CommandCmif(7996)]
// GetApplicationManagerInterface() -> object<nn::ns::detail::IApplicationManagerInterface> // GetApplicationManagerInterface() -> object<nn::ns::detail::IApplicationManagerInterface>
public ResultCode GetApplicationManagerInterface(ServiceCtx context) public ResultCode GetApplicationManagerInterface(ServiceCtx context)
@ -54,5 +63,14 @@ namespace Ryujinx.HLE.HOS.Services.Ns
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(7999)]
// GetDocumentInterface() -> object<nn::ns::detail::IDocumentInterface>
public ResultCode GetDocumentInterface(ServiceCtx context)
{
MakeObject(context, new IDocumentInterface());
return ResultCode.Success;
}
} }
} }

View File

@ -4,5 +4,13 @@ namespace Ryujinx.HLE.HOS.Services.Ns
class IVulnerabilityManagerInterface : IpcService class IVulnerabilityManagerInterface : IpcService
{ {
public IVulnerabilityManagerInterface(ServiceCtx context) { } public IVulnerabilityManagerInterface(ServiceCtx context) { }
[CommandCmif(1200)]
// NeedsUpdateVulnerability() -> bool
public ResultCode NeedsUpdateVulnerability(ServiceCtx context)
{
context.ResponseData.Write(false);
return ResultCode.Success;
}
} }
} }

View File

@ -551,6 +551,15 @@ namespace Ryujinx.HLE.HOS.Services.Settings
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(183)]
// GetPlatformRegion() -> s32
public ResultCode GetPlatformRegion(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceSet);
context.ResponseData.Write(0);
return ResultCode.Success;
}
[CommandCmif(201)] [CommandCmif(201)]
// GetFieldTestingFlag() -> bool // GetFieldTestingFlag() -> bool
public ResultCode GetFieldTestingFlag(ServiceCtx context) public ResultCode GetFieldTestingFlag(ServiceCtx context)