add commands for accessing process storage

This commit is contained in:
HookedBehemoth 2020-06-05 14:16:07 +02:00
parent eb9d377320
commit ca1cc2c83c
2 changed files with 26 additions and 1 deletions

View File

@ -313,9 +313,10 @@ void fsSetPriority(FsPriority prio);
/// Mount requested filesystem type from content file
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); ///< same as calling fsOpenFileSystemWithId with 0 as id
Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out);
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 id, FsFileSystemType fsType); ///< [2.0.0+], like OpenFileSystemWithId but without content path.
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath); ///< works on all firmwares, id is ignored on [1.0.0]
Result fsOpenDataFileSystemByProgramId(FsFileSystem *out, u64 program_id);
Result fsOpenBisFileSystem(FsFileSystem* out, FsBisPartitionId partitionId, const char* string);
Result fsOpenBisStorage(FsStorage* out, FsBisPartitionId partitionId);
@ -346,7 +347,9 @@ Result fsOpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId cont
Result fsOpenCustomStorageFileSystem(FsFileSystem* out, FsCustomStorageId custom_storage_id); ///< [7.0.0+]
Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
Result fsOpenDataStorageByProgramId(FsStorage *out, u64 program_id);
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storageId);
Result fsOpenPatchDataStorageByCurrentProcess(FsStorage* out);
Result fsOpenDeviceOperator(FsDeviceOperator* out);
Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out);

View File

@ -146,6 +146,10 @@ static Result _fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, cons
);
}
Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out) {
return _fsCmdGetSession(&g_fsSrv, &out->s, 2);
}
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 id, FsFileSystemType fsType) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
@ -175,6 +179,13 @@ static Result _fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemTyp
);
}
Result fsOpenDataFileSystemByProgramId(FsFileSystem *out, u64 program_id) {
return _fsObjectDispatchIn(&g_fsSrv, 9, program_id,
.out_num_objects = 1,
.out_objects = &out->s,
);
}
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath) {
char sendStr[FS_MAX_PATH] = {0};
strncpy(sendStr, contentPath, sizeof(sendStr)-1);
@ -398,6 +409,13 @@ Result fsOpenDataStorageByCurrentProcess(FsStorage* out) {
return _fsCmdGetSession(&g_fsSrv, &out->s, 200);
}
Result fsOpenDataStorageByProgramId(FsStorage *out, u64 program_id) {
return _fsObjectDispatchIn(&g_fsSrv, 201, program_id,
.out_num_objects = 1,
.out_objects = &out->s,
);
}
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storageId) {
const struct {
u8 storage_id;
@ -410,6 +428,10 @@ Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storag
);
}
Result fsOpenPatchDataStorageByCurrentProcess(FsStorage* out) {
return _fsCmdGetSession(&g_fsSrv, &out->s, 203);
}
Result fsOpenDeviceOperator(FsDeviceOperator* out) {
return _fsCmdGetSession(&g_fsSrv, &out->s, 400);
}