Capture services

Revision as of 17:54, 16 March 2019 by Hexkyz (talk | contribs) (→‎caps:u)

caps:a

This is "nn::capsrv::sf::IAlbumAccessorService".

Cmd Name
0 GetAlbumFileCount
1 GetAlbumFileList
2 LoadAlbumFile
3 DeleteAlbumFile
4 StorageCopyAlbumFile
5 IsAlbumMounted
6 GetAlbumUsage
7 GetAlbumFileSize
8 LoadAlbumFileThumbnail
9 [2.0.0+] LoadAlbumScreenShotImage
10 [2.0.0+] LoadAlbumScreenShotThumbnailImage
11 [2.0.0+] GetAlbumEntryFromApplicationAlbumEntry
12 [3.0.0+]
13 [3.0.0+]
14 [3.0.0+]
15 [4.0.0+]
16 [4.0.0+]
17 [4.0.0+]
202 [1.0.0-2.3.0] SaveEditedScreenShot
301 GetLastThumbnail
401 GetAutoSavingStorage
501 GetRequiredStorageSpaceSizeToCopyAll
1001 [3.0.0+]
1002 [3.0.0+]
1003 [4.0.0+]
8001 ForceAlbumUnmounted
8002 ResetAlbumMountStatus
8011 RefreshAlbumCache
8012 GetAlbumCache
8013 [4.0.0+]
8021 GetAlbumEntryFromApplicationAlbumEntryAruid
10011 SetInternalErrorConversionEnabled
60002 [4.0.0+]

caps:c

This is "nn::capsrv::sf::IAlbumControlService".

Cmd Name Notes
33 [7.0.0+] Takes a total of 0x10-bytes of input, no output.
2001
2002
2011
2012
2013
2014
2101 Takes an input u8 and u64, returns a 0x18-byte struct.
2102
2201
2301

caps:u

This is "nn::capsrv::sf::IAlbumApplicationService".

Cmd Name
32 [7.0.0+] #SetShimLibraryVersion
102 GetAlbumFileList0AafeAruidDeprecated
103 DeleteAlbumFileByAruid
104 GetAlbumFileSizeByAruid
105 DeleteAlbumFileByAruidForDebug
110 LoadAlbumScreenShotImageByAruid
120 LoadAlbumScreenShotThumbnailImageByAruid
130 PrecheckToCreateContentsByAruid
140 [6.0.0+] GetAlbumFileList1AafeAruidDeprecated
141 [6.0.0+] GetAlbumFileList2AafeUidAruidDeprecated
142 [7.0.0+] GetAlbumFileList3AaeAruid
143 [7.0.0+] GetAlbumFileList4AaeUidAruid
60002 OpenAccessorSessionForApplication

SetShimLibraryVersion

Takes a total of 0x10-bytes of input and a PID, no output.

IAlbumAccessorApplicationSession

This is "nn::capsrv::sf::IAlbumAccessorApplicationSession".

Cmd Name
2001 OpenAlbumMovieReadStream
2002 CloseAlbumMovieReadStream
2003 GetAlbumMovieReadStreamMovieDataSize
2004 ReadMovieDataFromAlbumMovieReadStream
2005 GetAlbumMovieReadStreamBrokenReason

Notes

capsrv is responsible for validating the MACs for screenshots stored on the SD card, if the setting capsrv!enable_album_screenshot_filedata_verification is non-zero.

Screenshots are validated as follows: The JPEG's MAC is extracted from the EXIF maker note, and stored. A timestamp string is generated by calling snprintf(&str, 20, "%04d:%02d:%02d %02d:%02d:%02d", ...); with stored timestamp values. If this doesn't match the timestamp string stored in EXIF, then an error 0xA34CE is returned. Otherwise, the entire JPEG is loaded into memory, and the stored EXIF maker note is cleared to zeroes. Then, an HMAC-SHA256 is computed over the entire JPEG using a hardcoded secret key. if (memcmp(calculated_hmac, stored_hmac, 0x10) == 0), the screenshot is valid, else 0xA3ACE is returned.

In 3.0.0, MAC calculation was changed: now, instead of calculating an HMAC, a plain SHA256 hash is calculated. capsrv basically does screenshot_kek = spl::GenerateAesKek(<hardcoded screenshot_kek_source>); spl::LoadAesKey(screenshot_kek, <hardcoded screenshot_key_source>); MAC = spl::ComputeCmac(hash);

Videos

4.0.0 includes video playback etc support in Album via mp4. These include a JPEG thumbnail, which is used for video "validation". The EXIF is also much larger: the MakerNote is 0x498-bytes, with encrypted data starting at offset +0x8. This encryption uses AES-CTR with hardcoded key/ctr. MAC calculation works the same way as the 3.0.0+ JPEG MAC calculation, except with a different movie_kek_source/movie_key_source.

Note: the Album process itself uses libstagefright for video playback.