Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 SaveDataSpaceId) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; struct { u64 magic; u64 cmd_id; u8 SaveDataSpaceId; } *raw2; if (SaveDataSpaceId == FsSaveDataSpaceId_All) { raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 60; } else { raw2 = ipcPrepareHeader(&c, sizeof(*raw2)); raw2->magic = SFCI_MAGIC; raw2->cmd_id = 61; raw2->SaveDataSpaceId = SaveDataSpaceId; } Result rc = serviceIpcDispatch(&g_fsSrv); 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 fsDirGetEntryCount(FsDir* d, u64* count) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 1; Result rc = serviceIpcDispatch(&d->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u64 count; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc) && count) *count = resp->count; } return rc; }
// IStorage implementation Result fsStorageRead(FsStorage* s, u64 off, void* buf, size_t len) { IpcCommand c; ipcInitialize(&c); ipcAddRecvBuffer(&c, buf, len, 1); struct { u64 magic; u64 cmd_id; u64 offset; u64 read_size; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 0; raw->offset = off; raw->read_size = len; Result rc = serviceIpcDispatch(&s->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
Result audinAppendAudioInBuffer(AudioInBuffer *Buffer) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u64 tag; } *raw; ipcAddSendBuffer(&c, Buffer, sizeof(*Buffer), 0); raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 3; raw->tag = (u64)Buffer; Result rc = serviceIpcDispatch(&g_audinIAudioIn); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
Result fsldrSetCurrentProcess() { IpcCommand c; ipcInitialize(&c); ipcSendPid(&c); struct { u64 magic; u64 cmd_id; u64 unk; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 2; raw->unk = 0; Result rc = serviceIpcDispatch(&g_fsldrSrv); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
Result fsFileGetSize(FsFile* f, u64* out) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 4; Result rc = serviceIpcDispatch(&f->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u64 size; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc) && out) *out = resp->size; } return rc; }
Result fsMountSdcard(FsFileSystem* out) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 18; Result rc = serviceIpcDispatch(&g_fsSrv); 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; }
static Result _audinRegisterBufferEvent(Handle *BufferEvent) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 4; Result rc = serviceIpcDispatch(&g_audinIAudioIn); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc) && BufferEvent) *BufferEvent = r.Handles[0]; } return rc; }
Result smMitMUninstall(const char *name) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u64 service_name; u64 reserved; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 65001; raw->service_name = smEncodeName(name); Result rc = ipcDispatch(g_smMitmHandle); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
Result fsFsCommit(FsFileSystem* fs) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 10; Result rc = serviceIpcDispatch(&fs->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
Result fsFsRenameDirectory(FsFileSystem* fs, const char* path0, const char* path1) { IpcCommand c; ipcInitialize(&c); ipcAddSendStatic(&c, path0, FS_MAX_PATH, 0); ipcAddSendStatic(&c, path1, FS_MAX_PATH, 0); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 6; Result rc = serviceIpcDispatch(&fs->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
Result fsOpenDataStorageByCurrentProcess(FsStorage* 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(&g_fsSrv); 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 audinStopAudioIn(void) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 2; Result rc = serviceIpcDispatch(&g_audinIAudioIn); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
Result smMitMInitialize(void) { atomicIncrement64(&g_refCnt); if (g_smMitmHandle != INVALID_HANDLE) return 0; Result rc = svcConnectToNamedPort(&g_smMitmHandle, "sm:"); if (R_SUCCEEDED(rc)) { IpcCommand c; ipcInitialize(&c); ipcSendPid(&c); struct { u64 magic; u64 cmd_id; u64 zero; u64 reserved[2]; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 0; raw->zero = 0; rc = ipcDispatch(g_smMitmHandle); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } } if (R_FAILED(rc)) smExit(); return rc; }
Result fsInitialize(void) { atomicIncrement64(&g_refCnt); if (serviceIsActive(&g_fsSrv)) return 0; Result rc = smGetService(&g_fsSrv, "fsp-srv"); if (R_SUCCEEDED(rc)) { IpcCommand c; ipcInitialize(&c); ipcSendPid(&c); struct { u64 magic; u64 cmd_id; u64 unk; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 1; raw->unk = 0; rc = serviceIpcDispatch(&g_fsSrv); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } } return rc; }
Result smMitMGetService(Service* service_out, const char *name_str) { u64 name = smEncodeName(name_str); IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u64 service_name; u64 reserved[2]; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 1; raw->service_name = name; Result rc = ipcDispatch(g_smMitmHandle); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { service_out->type = ServiceType_Normal; service_out->handle = r.Handles[0]; } } return rc; }
Result fsldrOpenCodeFileSystem(u64 tid, const char *path, FsFileSystem* out) { char send_path[FS_MAX_PATH] = {0}; IpcCommand c; ipcInitialize(&c); ipcAddSendStatic(&c, send_path, FS_MAX_PATH, 0); struct { u64 magic; u64 cmd_id; u64 tid; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 0; raw->tid = tid; strncpy(send_path, path, FS_MAX_PATH); Result rc = serviceIpcDispatch(&g_fsldrSrv); 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 fsDirRead(FsDir* d, u64 inval, size_t* total_entries, size_t max_entries, FsDirectoryEntry *buf) { IpcCommand c; ipcInitialize(&c); ipcAddRecvBuffer(&c, buf, sizeof(FsDirectoryEntry)*max_entries, 0); struct { u64 magic; u64 cmd_id; u64 inval; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 0; raw->inval = inval; Result rc = serviceIpcDispatch(&d->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u64 total_entries; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { if (total_entries) *total_entries = resp->total_entries; } } return rc; }
Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, FsSave *save) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u64 inval;//Actually u8. FsSave save; } PACKED *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 52; raw->inval = (u64)inval; memcpy(&raw->save, save, sizeof(FsSave)); Result rc = serviceIpcDispatch(&g_fsSrv); 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 fsFsOpenDirectory(FsFileSystem* fs, const char* path, int flags, FsDir* out) { IpcCommand c; ipcInitialize(&c); ipcAddSendStatic(&c, path, FS_MAX_PATH, 0); struct { u64 magic; u64 cmd_id; u32 flags; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 9; raw->flags = flags; Result rc = serviceIpcDispatch(&fs->s); 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; }
// IFileSystem impl Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags) { IpcCommand c; ipcInitialize(&c); ipcAddSendStatic(&c, path, FS_MAX_PATH, 0); struct { u64 magic; u64 cmd_id; u64 zero; u64 size; u32 flags; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 0; raw->zero = 0; raw->size = size; raw->flags = flags; Result rc = serviceIpcDispatch(&fs->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
Result smMitMInstall(Handle *handle_out, Handle *query_out, const char *name) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u64 service_name; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 65000; raw->service_name = smEncodeName(name); Result rc = ipcDispatch(g_smMitmHandle); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { *handle_out = r.Handles[0]; *query_out = r.Handles[1]; } } return rc; }
Result fsFileWrite(FsFile* f, u64 off, const void* buf, size_t len) { IpcCommand c; ipcInitialize(&c); ipcAddSendBuffer(&c, buf, len, 1); struct { u64 magic; u64 cmd_id; u64 zero; u64 offset; u64 write_size; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 1; raw->zero = 0; raw->offset = off; raw->write_size = len; Result rc = serviceIpcDispatch(&f->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; } *resp = r.Raw; rc = resp->result; } return rc; }
// ISaveDataInfoReader Result fsSaveDataIteratorRead(FsSaveDataIterator *s, FsSaveDataInfo* buf, size_t max_entries, size_t* total_entries) { IpcCommand c; ipcInitialize(&c); ipcAddRecvBuffer(&c, buf, sizeof(FsSaveDataInfo)*max_entries, 0); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 0; Result rc = serviceIpcDispatch(&s->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u64 total_entries; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { if (total_entries) *total_entries = resp->total_entries; } } return rc; }
Result audinContainsAudioInBuffer(AudioInBuffer *Buffer, bool *ContainsBuffer) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u64 tag; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 6; raw->tag = (u64)Buffer; Result rc = serviceIpcDispatch(&g_audinIAudioIn); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u32 contains_buffer; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc) && ContainsBuffer) *ContainsBuffer = (resp->contains_buffer & 0x01); } return rc; }
Result audinGetReleasedAudioInBuffer(AudioInBuffer **Buffer, u32 *ReleasedBuffersCount) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; ipcAddRecvBuffer(&c, Buffer, sizeof(*Buffer), 0); raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 5; Result rc = serviceIpcDispatch(&g_audinIAudioIn); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u32 released_buffers_count; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc) && ReleasedBuffersCount) *ReleasedBuffersCount = resp->released_buffers_count; } return rc; }
Result fsFsGetTotalSpace(FsFileSystem* fs, const char* path, u64* out) { IpcCommand c; ipcInitialize(&c); ipcAddSendStatic(&c, path, FS_MAX_PATH, 0); struct { u64 magic; u64 cmd_id; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 12; Result rc = serviceIpcDispatch(&fs->s); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u64 space; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { *out = resp->space; } } return rc; }
Result fsldrIsArchivedProgram(u64 pid, bool *out) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u64 pid; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 1; raw->pid = pid; Result rc = serviceIpcDispatch(&g_fsldrSrv); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u8 is_archived; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { *out = resp->is_archived != 0; } } return rc; }
Result audinListAudioIns(char *DeviceNames, u32 *DeviceNamesCount) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; } *raw; ipcAddRecvBuffer(&c, DeviceNames, DEVICE_NAME_LENGTH, 0); raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 0; Result rc = serviceIpcDispatch(&g_audinSrv); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u32 DeviceNamesCount; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc) && DeviceNamesCount) *DeviceNamesCount = resp->DeviceNamesCount; } return rc; }
Result audinOpenAudioIn(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioInState *State) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; u32 sample_rate; u32 channel_count; u64 client_pid; } *raw; ipcSendPid(&c); ipcSendHandleCopy(&c, CUR_PROCESS_HANDLE); ipcAddSendBuffer(&c, DeviceNameIn, DEVICE_NAME_LENGTH, 0); ipcAddRecvBuffer(&c, DeviceNameOut, DEVICE_NAME_LENGTH, 0); raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; raw->cmd_id = 1; raw->sample_rate = SampleRateIn; raw->channel_count = ChannelCountIn; raw->client_pid = 0; Result rc = serviceIpcDispatch(&g_audinSrv); if (R_SUCCEEDED(rc)) { IpcParsedCommand r; ipcParse(&r); struct { u64 magic; u64 result; u32 sample_rate; u32 channel_count; u32 pcm_format; u32 state; } *resp = r.Raw; rc = resp->result; if (R_SUCCEEDED(rc)) { serviceCreate(&g_audinIAudioIn, r.Handles[0]); if (SampleRateOut) *SampleRateOut = resp->sample_rate; if (ChannelCountOut) *ChannelCountOut = resp->channel_count; if (Format) *Format = resp->pcm_format; if (State) *State = resp->state; } } return rc; }