Skip to content

Commit

Permalink
Implement IFSDeviceOperator "ChallengeCardExistence" and "GetGameCard…
Browse files Browse the repository at this point in the history
…DeviceCertificate"
  • Loading branch information
EpicUsername12 authored and fincs committed Feb 3, 2024
1 parent ce1f870 commit 827c6b6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nx/include/switch/services/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,9 @@ 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 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);
Result fsDeviceOperatorChallengeCardExistence(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, void* seed, size_t seed_size, void* value, size_t value_size);
void fsDeviceOperatorClose(FsDeviceOperator* d);
29 changes: 29 additions & 0 deletions nx/source/services/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,17 @@ 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) {
const struct {
FsGameCardHandle handle;
s64 buffer_size;
} in = { *handle, size };

return _fsObjectDispatchIn(&d->s, 206, in,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { dst, dst_size } });
}

Result fsDeviceOperatorGetGameCardIdSet(FsDeviceOperator* d, void* dst, size_t dst_size, s64 size) {
return _fsCmdInSizeOutBuffer(&d->s, dst, dst_size, size, 208);
}
Expand All @@ -1242,6 +1253,24 @@ Result fsDeviceOperatorGetGameCardDeviceId(FsDeviceOperator* d, void* dst, size_
return _fsCmdInSizeOutBuffer(&d->s, dst, dst_size, size, 218);
}

Result fsDeviceOperatorChallengeCardExistence(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, void* seed, size_t seed_size, void* value, size_t value_size) {
if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

return _fsObjectDispatchIn(&d->s, 219, *handle,
.buffer_attrs = {
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
},
.buffers = {
{ dst, dst_size },
{ seed, seed_size },
{ value, value_size },
},
);
}

void fsDeviceOperatorClose(FsDeviceOperator* d) {
_fsObjectClose(&d->s);
}

0 comments on commit 827c6b6

Please sign in to comment.