1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-26 20:22:17 +00:00
nxdumptool/source/fs_ext.c

131 lines
2.8 KiB
C
Raw Normal View History

2018-05-15 13:57:40 +01:00
#include <switch/kernel/ipc.h>
#include <stdlib.h>
#include <string.h>
2018-05-15 13:57:40 +01:00
2019-06-05 23:44:18 +01:00
#include "fs_ext.h"
2018-05-15 13:57:40 +01:00
// IFileSystemProxy
2019-04-21 17:27:33 +01:00
Result fsOpenGameCardStorage(FsStorage* out, const FsGameCardHandle* handle, u32 partition)
{
2019-04-21 17:27:33 +01:00
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u32 handle;
u32 partition;
} *raw;
raw = serviceIpcPrepareHeader(fsGetServiceSession(), &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 30;
raw->handle = handle->value;
raw->partition = partition;
Result rc = serviceIpcDispatch(fsGetServiceSession());
if (R_SUCCEEDED(rc))
{
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;
serviceIpcParse(fsGetServiceSession(), &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc)) serviceCreateSubservice(&out->s, fsGetServiceSession(), &r, 0);
}
return rc;
2018-05-15 13:57:40 +01:00
}
2019-04-21 17:27:33 +01:00
Result fsOpenGameCardDetectionEventNotifier(FsEventNotifier* out)
{
2019-04-21 17:27:33 +01:00
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
raw = serviceIpcPrepareHeader(fsGetServiceSession(), &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 501;
Result rc = serviceIpcDispatch(fsGetServiceSession());
if (R_SUCCEEDED(rc))
{
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;
serviceIpcParse(fsGetServiceSession(), &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc)) serviceCreateSubservice(&out->s, fsGetServiceSession(), &r, 0);
}
return rc;
2018-05-15 13:57:40 +01:00
}
2019-04-21 17:27:33 +01:00
// IDeviceOperator
Result fsDeviceOperatorUpdatePartitionInfo(FsDeviceOperator* d, const FsGameCardHandle* handle, u32* out_title_version, u64* out_title_id)
{
2019-04-21 17:27:33 +01:00
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u32 handle;
} *raw;
raw = serviceIpcPrepareHeader(&d->s, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 203;
raw->handle = handle->value;
Result rc = serviceIpcDispatch(&d->s);
if (R_SUCCEEDED(rc))
{
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
u32 title_ver;
u64 title_id;
} *resp;
serviceIpcParse(&d->s, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc))
{
if (out_title_version != NULL) *out_title_version = resp->title_ver;
if (out_title_id != NULL) *out_title_id = resp->title_id;
}
}
return rc;
2018-05-15 13:57:40 +01:00
}