IScreenShotApplicationService.cs
1 using Ryujinx.Common; 2 using Ryujinx.HLE.HOS.Services.Caps.Types; 3 4 namespace Ryujinx.HLE.HOS.Services.Caps 5 { 6 [Service("caps:su")] // 6.0.0+ 7 class IScreenShotApplicationService : IpcService 8 { 9 public IScreenShotApplicationService(ServiceCtx context) { } 10 11 [CommandCmif(32)] // 7.0.0+ 12 // SetShimLibraryVersion(pid, u64, nn::applet::AppletResourceUserId) 13 public ResultCode SetShimLibraryVersion(ServiceCtx context) 14 { 15 return context.Device.System.CaptureManager.SetShimLibraryVersion(context); 16 } 17 18 [CommandCmif(203)] 19 // SaveScreenShotEx0(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, pid, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry 20 public ResultCode SaveScreenShotEx0(ServiceCtx context) 21 { 22 // TODO: Use the ScreenShotAttribute. 23 #pragma warning disable IDE0059 // Remove unnecessary value assignment 24 ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>(); 25 26 uint unknown = context.RequestData.ReadUInt32(); 27 #pragma warning restore IDE0059 28 ulong appletResourceUserId = context.RequestData.ReadUInt64(); 29 #pragma warning disable IDE0059 // Remove unnecessary value assignment 30 ulong pidPlaceholder = context.RequestData.ReadUInt64(); 31 #pragma warning restore IDE0059 32 33 ulong screenshotDataPosition = context.Request.SendBuff[0].Position; 34 ulong screenshotDataSize = context.Request.SendBuff[0].Size; 35 36 byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray(); 37 38 ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Processes.ActiveApplication.ProgramId, out ApplicationAlbumEntry applicationAlbumEntry); 39 40 context.ResponseData.WriteStruct(applicationAlbumEntry); 41 42 return resultCode; 43 } 44 45 [CommandCmif(205)] // 8.0.0+ 46 // SaveScreenShotEx1(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, pid, buffer<bytes, 0x15> ApplicationData, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry 47 public ResultCode SaveScreenShotEx1(ServiceCtx context) 48 { 49 // TODO: Use the ScreenShotAttribute. 50 _ = context.RequestData.ReadStruct<ScreenShotAttribute>(); 51 52 _ = context.RequestData.ReadUInt32(); 53 ulong appletResourceUserId = context.RequestData.ReadUInt64(); 54 55 _ = context.RequestData.ReadUInt64(); 56 57 ulong applicationDataPosition = context.Request.SendBuff[0].Position; 58 ulong applicationDataSize = context.Request.SendBuff[0].Size; 59 60 ulong screenshotDataPosition = context.Request.SendBuff[1].Position; 61 ulong screenshotDataSize = context.Request.SendBuff[1].Size; 62 63 64 // TODO: Parse the application data: At 0x00 it's UserData (Size of 0x400), at 0x404 it's a uint UserDataSize (Always empty for now). 65 _ = context.Memory.GetSpan(applicationDataPosition, (int)applicationDataSize).ToArray(); 66 67 byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray(); 68 69 ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Processes.ActiveApplication.ProgramId, out ApplicationAlbumEntry applicationAlbumEntry); 70 71 context.ResponseData.WriteStruct(applicationAlbumEntry); 72 73 return resultCode; 74 } 75 76 [CommandCmif(210)] 77 // SaveScreenShotEx2(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, buffer<bytes, 0x15> UserIdList, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry 78 public ResultCode SaveScreenShotEx2(ServiceCtx context) 79 { 80 // TODO: Use the ScreenShotAttribute. 81 _ = context.RequestData.ReadStruct<ScreenShotAttribute>(); 82 83 _ = context.RequestData.ReadUInt32(); 84 ulong appletResourceUserId = context.RequestData.ReadUInt64(); 85 86 ulong userIdListPosition = context.Request.SendBuff[0].Position; 87 ulong userIdListSize = context.Request.SendBuff[0].Size; 88 89 ulong screenshotDataPosition = context.Request.SendBuff[1].Position; 90 ulong screenshotDataSize = context.Request.SendBuff[1].Size; 91 92 93 // TODO: Parse the UserIdList. 94 _ = context.Memory.GetSpan(userIdListPosition, (int)userIdListSize).ToArray(); 95 96 byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray(); 97 98 ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Processes.ActiveApplication.ProgramId, out ApplicationAlbumEntry applicationAlbumEntry); 99 100 context.ResponseData.WriteStruct(applicationAlbumEntry); 101 102 return resultCode; 103 } 104 } 105 }