diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index 05b2b28fa5..51db8884c0 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -105,6 +105,8 @@ namespace Ryujinx.HLE.HOS public IntegrityCheckLevel FsIntegrityCheckLevel { get; set; } + public int GlobalAccessLogMode { get; set; } + internal long HidBaseAddress { get; private set; } public Horizon(Switch device) diff --git a/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystemProxy.cs b/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystemProxy.cs index 05abb7f068..2625d5715b 100644 --- a/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystemProxy.cs +++ b/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystemProxy.cs @@ -1,6 +1,7 @@ using LibHac; using LibHac.Fs; using LibHac.Fs.NcaUtils; +using Ryujinx.Common.Logging; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.Utilities; @@ -32,7 +33,8 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { 200, OpenDataStorageByCurrentProcess }, { 202, OpenDataStorageByDataId }, { 203, OpenPatchDataStorageByCurrentProcess }, - { 1005, GetGlobalAccessLogMode } + { 1005, GetGlobalAccessLogMode }, + { 1006, OutputAccessLogToSdCard } }; } @@ -208,7 +210,19 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv // GetGlobalAccessLogMode() -> u32 logMode public long GetGlobalAccessLogMode(ServiceCtx context) { - context.ResponseData.Write(0); + int mode = context.Device.System.GlobalAccessLogMode; + + context.ResponseData.Write(mode); + + return 0; + } + + // OutputAccessLogToSdCard(buffer log_text) + public long OutputAccessLogToSdCard(ServiceCtx context) + { + string message = ReadUtf8StringSend(context); + + Logger.PrintInfo(LogClass.ServiceFs, message.TrimEnd('\n')); return 0; } diff --git a/Ryujinx.HLE/Utilities/StringUtils.cs b/Ryujinx.HLE/Utilities/StringUtils.cs index e6602f48f3..055b8339ca 100644 --- a/Ryujinx.HLE/Utilities/StringUtils.cs +++ b/Ryujinx.HLE/Utilities/StringUtils.cs @@ -72,5 +72,28 @@ namespace Ryujinx.HLE.Utilities return Encoding.UTF8.GetString(ms.ToArray()); } } + + public static string ReadUtf8StringSend(ServiceCtx context, int index = 0) + { + long position = context.Request.SendBuff[index].Position; + long size = context.Request.SendBuff[index].Size; + + using (MemoryStream ms = new MemoryStream()) + { + while (size-- > 0) + { + byte value = context.Memory.ReadByte(position++); + + if (value == 0) + { + break; + } + + ms.WriteByte(value); + } + + return Encoding.UTF8.GetString(ms.ToArray()); + } + } } }