2021-03-26 01:16:08 +01:00
|
|
|
|
using Ryujinx.Common;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Caps.Types;
|
2020-09-20 05:32:48 +02:00
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Caps
|
2019-09-19 02:45:11 +02:00
|
|
|
|
{
|
|
|
|
|
[Service("caps:su")] // 6.0.0+
|
|
|
|
|
class IScreenShotApplicationService : IpcService
|
|
|
|
|
{
|
|
|
|
|
public IScreenShotApplicationService(ServiceCtx context) { }
|
2020-09-20 05:32:48 +02:00
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(32)] // 7.0.0+
|
2020-09-20 05:32:48 +02:00
|
|
|
|
// SetShimLibraryVersion(pid, u64, nn::applet::AppletResourceUserId)
|
|
|
|
|
public ResultCode SetShimLibraryVersion(ServiceCtx context)
|
|
|
|
|
{
|
2021-03-26 01:16:08 +01:00
|
|
|
|
return context.Device.System.CaptureManager.SetShimLibraryVersion(context);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(203)]
|
2021-03-26 01:16:08 +01:00
|
|
|
|
// SaveScreenShotEx0(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, pid, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry
|
|
|
|
|
public ResultCode SaveScreenShotEx0(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Use the ScreenShotAttribute.
|
|
|
|
|
ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>();
|
|
|
|
|
|
|
|
|
|
uint unknown = context.RequestData.ReadUInt32();
|
|
|
|
|
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
|
|
|
|
ulong pidPlaceholder = context.RequestData.ReadUInt64();
|
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong screenshotDataPosition = context.Request.SendBuff[0].Position;
|
|
|
|
|
ulong screenshotDataSize = context.Request.SendBuff[0].Size;
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray();
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
2023-03-31 21:16:46 +02:00
|
|
|
|
ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Processes.ActiveApplication.ProgramId, out ApplicationAlbumEntry applicationAlbumEntry);
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
|
|
|
|
context.ResponseData.WriteStruct(applicationAlbumEntry);
|
|
|
|
|
|
|
|
|
|
return resultCode;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(205)] // 8.0.0+
|
2021-03-26 01:16:08 +01:00
|
|
|
|
// SaveScreenShotEx1(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, pid, buffer<bytes, 0x15> ApplicationData, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry
|
|
|
|
|
public ResultCode SaveScreenShotEx1(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Use the ScreenShotAttribute.
|
|
|
|
|
ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>();
|
|
|
|
|
|
|
|
|
|
uint unknown = context.RequestData.ReadUInt32();
|
2020-09-20 05:32:48 +02:00
|
|
|
|
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
2021-03-26 01:16:08 +01:00
|
|
|
|
ulong pidPlaceholder = context.RequestData.ReadUInt64();
|
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong applicationDataPosition = context.Request.SendBuff[0].Position;
|
|
|
|
|
ulong applicationDataSize = context.Request.SendBuff[0].Size;
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong screenshotDataPosition = context.Request.SendBuff[1].Position;
|
|
|
|
|
ulong screenshotDataSize = context.Request.SendBuff[1].Size;
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
|
|
|
|
// TODO: Parse the application data: At 0x00 it's UserData (Size of 0x400), at 0x404 it's a uint UserDataSize (Always empty for now).
|
2021-04-24 12:16:01 +02:00
|
|
|
|
byte[] applicationData = context.Memory.GetSpan(applicationDataPosition, (int)applicationDataSize).ToArray();
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray();
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
2023-03-31 21:16:46 +02:00
|
|
|
|
ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Processes.ActiveApplication.ProgramId, out ApplicationAlbumEntry applicationAlbumEntry);
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
|
|
|
|
context.ResponseData.WriteStruct(applicationAlbumEntry);
|
|
|
|
|
|
|
|
|
|
return resultCode;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(210)]
|
2021-03-26 01:16:08 +01:00
|
|
|
|
// SaveScreenShotEx2(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, buffer<bytes, 0x15> UserIdList, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry
|
|
|
|
|
public ResultCode SaveScreenShotEx2(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Use the ScreenShotAttribute.
|
|
|
|
|
ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>();
|
|
|
|
|
|
|
|
|
|
uint unknown = context.RequestData.ReadUInt32();
|
|
|
|
|
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong userIdListPosition = context.Request.SendBuff[0].Position;
|
|
|
|
|
ulong userIdListSize = context.Request.SendBuff[0].Size;
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong screenshotDataPosition = context.Request.SendBuff[1].Position;
|
|
|
|
|
ulong screenshotDataSize = context.Request.SendBuff[1].Size;
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
|
|
|
|
// TODO: Parse the UserIdList.
|
2021-04-24 12:16:01 +02:00
|
|
|
|
byte[] userIdList = context.Memory.GetSpan(userIdListPosition, (int)userIdListSize).ToArray();
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray();
|
2021-03-26 01:16:08 +01:00
|
|
|
|
|
2023-03-31 21:16:46 +02:00
|
|
|
|
ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Processes.ActiveApplication.ProgramId, out ApplicationAlbumEntry applicationAlbumEntry);
|
2020-09-20 05:32:48 +02:00
|
|
|
|
|
2021-03-26 01:16:08 +01:00
|
|
|
|
context.ResponseData.WriteStruct(applicationAlbumEntry);
|
2020-09-20 05:32:48 +02:00
|
|
|
|
|
2021-03-26 01:16:08 +01:00
|
|
|
|
return resultCode;
|
2020-09-20 05:32:48 +02:00
|
|
|
|
}
|
2019-09-19 02:45:11 +02:00
|
|
|
|
}
|
|
|
|
|
}
|