2020-04-16 01:06:41 +01:00
|
|
|
/*
|
2020-07-03 10:31:22 +01:00
|
|
|
* fs_ext.c
|
2020-04-16 01:06:41 +01:00
|
|
|
*
|
2023-04-08 12:42:22 +01:00
|
|
|
* Copyright (c) 2020-2023, DarkMatterCore <pabloacurielz@gmail.com>.
|
2020-07-03 10:31:22 +01:00
|
|
|
*
|
|
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
|
|
*
|
2021-03-25 19:26:58 +00:00
|
|
|
* nxdumptool is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2020-04-16 01:06:41 +01:00
|
|
|
*
|
2021-03-25 19:26:58 +00:00
|
|
|
* nxdumptool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2020-04-16 01:06:41 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-03-25 19:26:58 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-04-16 01:06:41 +01:00
|
|
|
*/
|
|
|
|
|
2021-03-26 04:35:14 +00:00
|
|
|
#include "nxdt_utils.h"
|
2020-04-11 06:28:26 +01:00
|
|
|
#include "fs_ext.h"
|
|
|
|
|
2020-07-06 01:10:07 +01:00
|
|
|
/* IFileSystemProxy. */
|
2020-04-11 06:28:26 +01:00
|
|
|
Result fsOpenGameCardStorage(FsStorage *out, const FsGameCardHandle *handle, u32 partition)
|
|
|
|
{
|
2023-04-08 12:34:53 +01:00
|
|
|
const struct {
|
2020-04-15 06:59:12 +01:00
|
|
|
FsGameCardHandle handle;
|
2020-04-11 06:28:26 +01:00
|
|
|
u32 partition;
|
2020-04-15 06:59:12 +01:00
|
|
|
} in = { *handle, partition };
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2020-04-11 06:28:26 +01:00
|
|
|
return serviceDispatchIn(fsGetServiceSession(), 30, in,
|
|
|
|
.out_num_objects = 1,
|
|
|
|
.out_objects = &out->s
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Result fsOpenGameCardDetectionEventNotifier(FsEventNotifier *out)
|
|
|
|
{
|
|
|
|
return serviceDispatch(fsGetServiceSession(), 501,
|
|
|
|
.out_num_objects = 1,
|
|
|
|
.out_objects = &out->s
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-06 01:10:07 +01:00
|
|
|
/* IDeviceOperator. */
|
2020-04-11 06:28:26 +01:00
|
|
|
Result fsDeviceOperatorUpdatePartitionInfo(FsDeviceOperator *d, const FsGameCardHandle *handle, u32 *out_title_version, u64 *out_title_id)
|
|
|
|
{
|
2023-04-08 12:34:53 +01:00
|
|
|
const struct {
|
2020-04-15 06:59:12 +01:00
|
|
|
FsGameCardHandle handle;
|
|
|
|
} in = { *handle };
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2020-04-11 06:28:26 +01:00
|
|
|
struct {
|
2020-04-15 06:59:12 +01:00
|
|
|
u32 title_version;
|
2020-04-11 06:28:26 +01:00
|
|
|
u64 title_id;
|
|
|
|
} out;
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2020-04-11 06:28:26 +01:00
|
|
|
Result rc = serviceDispatchInOut(&d->s, 203, in, out);
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2020-04-15 06:59:12 +01:00
|
|
|
if (R_SUCCEEDED(rc) && out_title_version) *out_title_version = out.title_version;
|
2020-04-11 06:28:26 +01:00
|
|
|
if (R_SUCCEEDED(rc) && out_title_id) *out_title_id = out.title_id;
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2020-04-11 06:28:26 +01:00
|
|
|
return rc;
|
|
|
|
}
|
2020-04-15 06:59:12 +01:00
|
|
|
|
|
|
|
Result fsDeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator *d, const FsGameCardHandle *handle, FsGameCardCertificate *out)
|
|
|
|
{
|
2023-04-08 12:34:53 +01:00
|
|
|
const struct {
|
2020-04-15 06:59:12 +01:00
|
|
|
FsGameCardHandle handle;
|
|
|
|
u64 buf_size;
|
|
|
|
} in = { *handle, sizeof(FsGameCardCertificate) };
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2020-04-15 06:59:12 +01:00
|
|
|
Result rc = serviceDispatchIn(&d->s, 206, in,
|
|
|
|
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
|
|
|
.buffers = { { out, sizeof(FsGameCardCertificate) } }
|
|
|
|
);
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2020-04-15 06:59:12 +01:00
|
|
|
return rc;
|
|
|
|
}
|
2022-02-03 01:13:20 +00:00
|
|
|
|
|
|
|
Result fsDeviceOperatorGetGameCardIdSet(FsDeviceOperator *d, FsGameCardIdSet *out)
|
|
|
|
{
|
2023-04-08 12:34:53 +01:00
|
|
|
const struct {
|
2022-02-03 01:13:20 +00:00
|
|
|
u64 buf_size;
|
|
|
|
} in = { sizeof(FsGameCardIdSet) };
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2022-02-03 01:13:20 +00:00
|
|
|
Result rc = serviceDispatchIn(&d->s, 208, in,
|
|
|
|
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
|
|
|
.buffers = { { out, sizeof(FsGameCardIdSet) } }
|
|
|
|
);
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2022-02-03 01:13:20 +00:00
|
|
|
return rc;
|
|
|
|
}
|