Add OutputAccessLogToSdCard

This commit is contained in:
Alex Barney 2019-06-13 19:47:58 -05:00
parent d87c5375f1
commit caf40313fa
3 changed files with 41 additions and 2 deletions

View file

@ -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)

View file

@ -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<bytes, 5> log_text)
public long OutputAccessLogToSdCard(ServiceCtx context)
{
string message = ReadUtf8StringSend(context);
Logger.PrintInfo(LogClass.ServiceFs, message.TrimEnd('\n'));
return 0;
}

View file

@ -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());
}
}
}
}