mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2025-02-16 21:45:39 +00:00
* Fixed building using latest libnx commit + recently added pacman packages (switch-libxml2 and switch-libjson-c). * Removed ncm-related code because libnx now includes what's needed by the application. * Cleaned up the fs-srv service additional functions. * Mounted partition filesystems are now properly closed. * Changed some output text.
200 lines
3.1 KiB
C
200 lines
3.1 KiB
C
#include <switch/kernel/ipc.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "fsext.h"
|
|
|
|
// IFileSystemProxy
|
|
Result fsOpenGameCardStorage(FsStorage* out, u32 handle, u32 partition)
|
|
{
|
|
IpcCommand c;
|
|
ipcInitialize(&c);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 cmd_id;
|
|
u32 handle;
|
|
u32 partition;
|
|
} *raw;
|
|
|
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
|
|
|
raw->magic = SFCI_MAGIC;
|
|
raw->cmd_id = 30;
|
|
raw->handle = handle;
|
|
raw->partition = partition;
|
|
|
|
Result rc = serviceIpcDispatch(fsGetServiceSession());
|
|
|
|
if (R_SUCCEEDED(rc))
|
|
{
|
|
IpcParsedCommand r;
|
|
ipcParse(&r);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 result;
|
|
} *resp = r.Raw;
|
|
|
|
rc = resp->result;
|
|
|
|
if (R_SUCCEEDED(rc)) serviceCreate(&out->s, r.Handles[0]);
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|
|
Result fsOpenGameCardFileSystem(FsFileSystem* out, u32 handle, u32 partition)
|
|
{
|
|
IpcCommand c;
|
|
ipcInitialize(&c);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 cmd_id;
|
|
u32 handle;
|
|
u32 partition;
|
|
} *raw;
|
|
|
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
|
|
|
raw->magic = SFCI_MAGIC;
|
|
raw->cmd_id = 31;
|
|
raw->handle = handle;
|
|
raw->partition = partition;
|
|
|
|
Result rc = serviceIpcDispatch(fsGetServiceSession());
|
|
|
|
if (R_SUCCEEDED(rc))
|
|
{
|
|
IpcParsedCommand r;
|
|
ipcParse(&r);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 result;
|
|
} *resp = r.Raw;
|
|
|
|
rc = resp->result;
|
|
|
|
if (R_SUCCEEDED(rc)) serviceCreate(&out->s, r.Handles[0]);
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|
|
// IDeviceOperator
|
|
Result fsDeviceOperatorIsGameCardInserted(FsDeviceOperator* d, bool* out)
|
|
{
|
|
IpcCommand c;
|
|
ipcInitialize(&c);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 cmd_id;
|
|
} *raw;
|
|
|
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
|
|
|
raw->magic = SFCI_MAGIC;
|
|
raw->cmd_id = 200;
|
|
|
|
Result rc = serviceIpcDispatch(&d->s);
|
|
|
|
if (R_SUCCEEDED(rc))
|
|
{
|
|
IpcParsedCommand r;
|
|
ipcParse(&r);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 result;
|
|
u8 is_inserted;
|
|
} *resp = r.Raw;
|
|
|
|
rc = resp->result;
|
|
|
|
if (R_SUCCEEDED(rc)) *out = resp->is_inserted != 0;
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|
|
Result fsDeviceOperatorGetGameCardHandle(FsDeviceOperator* d, u32* out)
|
|
{
|
|
IpcCommand c;
|
|
ipcInitialize(&c);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 cmd_id;
|
|
} *raw;
|
|
|
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
|
|
|
raw->magic = SFCI_MAGIC;
|
|
raw->cmd_id = 202;
|
|
|
|
Result rc = serviceIpcDispatch(&d->s);
|
|
|
|
if (R_SUCCEEDED(rc))
|
|
{
|
|
IpcParsedCommand r;
|
|
ipcParse(&r);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 result;
|
|
u32 handle;
|
|
} *resp = r.Raw;
|
|
|
|
rc = resp->result;
|
|
|
|
if (R_SUCCEEDED(rc)) *out = resp->handle;
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|
|
Result fsDeviceOperatorUpdatePartitionInfo(FsDeviceOperator* d, u32 handle, u32* out_title_version, u64* out_title_id)
|
|
{
|
|
IpcCommand c;
|
|
ipcInitialize(&c);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 cmd_id;
|
|
u32 handle;
|
|
} *raw;
|
|
|
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
|
|
|
raw->magic = SFCI_MAGIC;
|
|
raw->cmd_id = 203;
|
|
raw->handle = handle;
|
|
|
|
Result rc = serviceIpcDispatch(&d->s);
|
|
|
|
if (R_SUCCEEDED(rc))
|
|
{
|
|
IpcParsedCommand r;
|
|
ipcParse(&r);
|
|
|
|
struct {
|
|
u64 magic;
|
|
u64 result;
|
|
u32 title_ver;
|
|
u64 title_id;
|
|
} *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;
|
|
}
|