ryubing-ryujinx/src/Ryujinx.HLE/HOS/Services/Caps
yell0wsuit f8167eb625
Some checks are pending
Canary CI / Release for linux-arm64 (push) Waiting to run
Canary CI / Release for linux-x64 (push) Waiting to run
Canary CI / Release for win-x64 (push) Waiting to run
Canary CI / Release MacOS universal (push) Waiting to run
Canary CI / Post CI Steps (push) Blocked by required conditions
[HLE] Match hardware screenshot buffer size behavior for captures (#44)
## Description

~~Fixes a fatal CLR crash when `caps` screenshot saving receives an input buffer larger than `0x384000`.~~

~~Resolves a crash in Tomodachi Life: Living the Dream where saving the pictures to the system's album crashes with 0x80131506.~~

Follow up to #18. This PR adjusts the validation and copy behavior to better match real hardware, and adds logging to make invalid screenshot buffer cases easier to diagnose.

Real hardware accepts screenshot buffers with a size greater than or equal to `0x384000`, but only `0x384000` bytes are needed for the 1280x720 RGBA image.

This changes screenshot saving to:

- reject buffers smaller than `0x384000`
- accept buffers equal to or larger than `0x384000`
- copy only the first `0x384000` bytes into the 1280x720 bitmap

## Testing

Tested with a real Switch NRO using `capssuSaveScreenShotEx0`, `capssuSaveScreenShotEx1`, and `capssuSaveScreenShotEx2`.

Observed hardware behavior:

```text
0x384000     => OK
0x384000 - 1 => NullInputBuffer
0x384000 + 1 => OK
0x3C0000     => OK // Tomo life picture size
```

Co-authored-by: yell0wsuit <5692900+yell0wsuit@users.noreply.github.com>
Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/44
2026-05-10 23:57:05 +00:00
..
Types editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
CaptureManager.cs [HLE] Match hardware screenshot buffer size behavior for captures (#44) 2026-05-10 23:57:05 +00:00
IAlbumAccessorService.cs [Ryujinx.HLE] Address dotnet-format issues (#5380) 2023-07-16 19:31:14 +02:00
IAlbumApplicationService.cs Fix ~3500 analyser issues 2025-05-30 17:08:34 -05:00
IAlbumControlService.cs [Ryujinx.HLE] Address dotnet-format issues (#5380) 2023-07-16 19:31:14 +02:00
IScreenShotApplicationService.cs [HLE] Match hardware screenshot buffer size behavior for captures (#44) 2026-05-10 23:57:05 +00:00
IScreenShotControlService.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
IScreenshotService.cs [Ryujinx.HLE] Address dotnet-format issues (#5380) 2023-07-16 19:31:14 +02:00
ResultCode.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00