From 7c1d2bbb989f314e4a8316b33651b27e8a7024bc Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 17 Oct 2022 10:37:05 -0300 Subject: [PATCH] Implement OpenDataStorageWithProgramIndex partially (#3765) * Implement OpenDataStorageWithProgramIndex partially * Was not supposed to change this --- .../HOS/Services/Fs/IFileSystemProxy.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs b/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs index c32750be1e..2ec45aa530 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs @@ -12,6 +12,7 @@ using LibHac.Tools.FsSystem.NcaUtils; using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy; +using System; using System.IO; using static Ryujinx.HLE.Utilities.StringUtils; @@ -787,6 +788,26 @@ namespace Ryujinx.HLE.HOS.Services.Fs return ResultCode.Success; } + [CommandHipc(205)] + // OpenDataStorageWithProgramIndex(u8 program_index) -> object + public ResultCode OpenDataStorageWithProgramIndex(ServiceCtx context) + { + byte programIndex = context.RequestData.ReadByte(); + + if ((context.Device.Application.TitleId & 0xf) != programIndex) + { + throw new NotImplementedException($"Accessing storage from other programs is not supported (program index = {programIndex})."); + } + + var storage = context.Device.FileSystem.RomFs.AsStorage(true); + using var sharedStorage = new SharedRef(storage); + using var sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref())); + + MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref())); + + return ResultCode.Success; + } + [CommandHipc(400)] // OpenDataStorageByCurrentProcess() -> object dataStorage public ResultCode OpenDeviceOperator(ServiceCtx context)