Skip to content

Commit

Permalink
fs: add new outsize parameter to fsDeviceOperatorGetGameCardDeviceCer…
Browse files Browse the repository at this point in the history
…tificate
  • Loading branch information
SciresM committed Oct 29, 2024
1 parent a6924f2 commit 9323db3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nx/include/switch/services/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ Result fsDeviceOperatorIsGameCardInserted(FsDeviceOperator* d, bool* out);
Result fsDeviceOperatorGetGameCardHandle(FsDeviceOperator* d, FsGameCardHandle* out);
Result fsDeviceOperatorGetGameCardUpdatePartitionInfo(FsDeviceOperator* d, const FsGameCardHandle* handle, FsGameCardUpdatePartitionInfo* out);
Result fsDeviceOperatorGetGameCardAttribute(FsDeviceOperator* d, const FsGameCardHandle* handle, u8 *out);
Result fsDeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, s64 size);
Result fsDeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, s64* out_size, s64 size);
Result fsDeviceOperatorGetGameCardIdSet(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size);
Result fsDeviceOperatorGetGameCardErrorReportInfo(FsDeviceOperator* d, FsGameCardErrorReportInfo* out);
Result fsDeviceOperatorGetGameCardDeviceId(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size);
Expand Down
21 changes: 19 additions & 2 deletions nx/source/services/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1233,15 +1233,32 @@ Result fsDeviceOperatorGetGameCardAttribute(FsDeviceOperator* d, const FsGameCar
return _fsObjectDispatchInOut(&d->s, 205, *handle, *out);
}

Result fsDeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, s64 size) {
Result fsDeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, s64* out_size, s64 size) {
const struct {
FsGameCardHandle handle;
s64 buffer_size;
} in = { *handle, size };

return _fsObjectDispatchIn(&d->s, 206, in,
s64 os;
Result rc;

if (hosversionAtLeast(19,0,0)) {
rc = _fsObjectDispatchInOut(&d->s, 206, in, os,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { dst, dst_size } });
} else {
rc = _fsObjectDispatchIn(&d->s, 206, in,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { dst, dst_size } });

// Assume old gamecard certificate size on pre-19.0.0
os = 0x200;
}

if (R_SUCCEEDED(rc))
*out_size = os;

return rc;
}

Result fsDeviceOperatorGetGameCardIdSet(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size) {
Expand Down

0 comments on commit 9323db3

Please sign in to comment.