mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
ldr/fsldr: update for 20.0.0
This commit is contained in:
parent
8f1cce6946
commit
4f5df9cf56
@ -9,6 +9,7 @@
|
|||||||
#include "../sf/service.h"
|
#include "../sf/service.h"
|
||||||
#include "../services/fs.h"
|
#include "../services/fs.h"
|
||||||
#include "../crypto/sha256.h"
|
#include "../crypto/sha256.h"
|
||||||
|
#include "../services/ncm_types.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 signature[0x100];
|
u8 signature[0x100];
|
||||||
@ -26,5 +27,5 @@ void fsldrExit(void);
|
|||||||
/// Gets the Service object for the actual fsp-ldr service session.
|
/// Gets the Service object for the actual fsp-ldr service session.
|
||||||
Service* fsldrGetServiceSession(void);
|
Service* fsldrGetServiceSession(void);
|
||||||
|
|
||||||
Result fsldrOpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, const char *path, FsContentAttributes attr, FsFileSystem* out);
|
Result fsldrOpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, NcmStorageId storage_id, const char *path, FsContentAttributes attr, FsFileSystem* out);
|
||||||
Result fsldrIsArchivedProgram(u64 pid, bool *out);
|
Result fsldrIsArchivedProgram(u64 pid, bool *out);
|
||||||
|
@ -42,6 +42,11 @@ typedef struct {
|
|||||||
u64 size;
|
u64 size;
|
||||||
} LoaderModuleInfo;
|
} LoaderModuleInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u8 platform; ///< NcmContentMetaPlatform
|
||||||
|
u8 content_attributes; ///< FsContentAttributes
|
||||||
|
} LoaderProgramAttributes;
|
||||||
|
|
||||||
/// Initialize ldr:shel.
|
/// Initialize ldr:shel.
|
||||||
Result ldrShellInitialize(void);
|
Result ldrShellInitialize(void);
|
||||||
|
|
||||||
@ -76,8 +81,8 @@ Result ldrDmntSetProgramArguments(u64 program_id, const void *args, size_t args_
|
|||||||
Result ldrDmntFlushArguments(void);
|
Result ldrDmntFlushArguments(void);
|
||||||
Result ldrDmntGetProcessModuleInfo(u64 pid, LoaderModuleInfo *out_module_infos, size_t max_out_modules, s32 *num_out);
|
Result ldrDmntGetProcessModuleInfo(u64 pid, LoaderModuleInfo *out_module_infos, size_t max_out_modules, s32 *num_out);
|
||||||
|
|
||||||
Result ldrPmCreateProcess(u64 pin_id, u32 flags, Handle reslimit_h, Handle *out_process_h);
|
Result ldrPmCreateProcess(u64 pin_id, u32 flags, Handle reslimit_h, const LoaderProgramAttributes *attrs, Handle *out_process_h);
|
||||||
Result ldrPmGetProgramInfo(const NcmProgramLocation *loc, LoaderProgramInfo *out_program_info); ///< [19.0.0+/Atmosphere]
|
Result ldrPmGetProgramInfo(const NcmProgramLocation *loc, const LoaderProgramAttributes *attrs, LoaderProgramInfo *out_program_info); ///< [19.0.0+/Atmosphere]
|
||||||
Result ldrPmGetProgramInfoV1(const NcmProgramLocation *loc, LoaderProgramInfoV1 *out_program_info); ///< [1.0.0-18.1.0/Non-Atmosphere]
|
Result ldrPmGetProgramInfoV1(const NcmProgramLocation *loc, LoaderProgramInfoV1 *out_program_info); ///< [1.0.0-18.1.0/Non-Atmosphere]
|
||||||
Result ldrPmPinProgram(const NcmProgramLocation *loc, u64 *out_pin_id);
|
Result ldrPmPinProgram(const NcmProgramLocation *loc, u64 *out_pin_id);
|
||||||
Result ldrPmUnpinProgram(u64 pin_id);
|
Result ldrPmUnpinProgram(u64 pin_id);
|
||||||
|
@ -32,13 +32,32 @@ Service* fsldrGetServiceSession(void) {
|
|||||||
return &g_fsldrSrv;
|
return &g_fsldrSrv;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result fsldrOpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, const char *path, FsContentAttributes attr, FsFileSystem* out) {
|
Result fsldrOpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, NcmStorageId storage_id, const char *path, FsContentAttributes attr, FsFileSystem* out) {
|
||||||
memset(out_code_info, 0, sizeof(*out_code_info));
|
memset(out_code_info, 0, sizeof(*out_code_info));
|
||||||
|
|
||||||
char send_path[FS_MAX_PATH]={0};
|
char send_path[FS_MAX_PATH]={0};
|
||||||
strncpy(send_path, path, FS_MAX_PATH-1);
|
if (hosversionBefore(20,0,0))
|
||||||
|
strncpy(send_path, path, FS_MAX_PATH-1);
|
||||||
|
|
||||||
if (hosversionAtLeast(17,0,0)) {
|
if (hosversionAtLeast(20,0,0)) {
|
||||||
|
const struct {
|
||||||
|
u8 attr;
|
||||||
|
u8 storage_id;
|
||||||
|
u64 tid;
|
||||||
|
} in = { attr, storage_id, tid };
|
||||||
|
|
||||||
|
serviceAssumeDomain(&g_fsldrSrv);
|
||||||
|
return serviceDispatchIn(&g_fsldrSrv, 0, in,
|
||||||
|
.buffer_attrs = {
|
||||||
|
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,
|
||||||
|
},
|
||||||
|
.buffers = {
|
||||||
|
{ out_code_info, sizeof(*out_code_info) },
|
||||||
|
},
|
||||||
|
.out_num_objects = 1,
|
||||||
|
.out_objects = &out->s,
|
||||||
|
);
|
||||||
|
} else if (hosversionAtLeast(17,0,0)) {
|
||||||
const struct {
|
const struct {
|
||||||
u8 attr;
|
u8 attr;
|
||||||
u64 tid;
|
u64 tid;
|
||||||
|
@ -79,28 +79,57 @@ Result ldrDmntGetProcessModuleInfo(u64 pid, LoaderModuleInfo *out_module_infos,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ldrPmCreateProcess(u64 pin_id, u32 flags, Handle reslimit_h, Handle *out_process_h) {
|
Result ldrPmCreateProcess(u64 pin_id, u32 flags, Handle reslimit_h, const LoaderProgramAttributes *attrs, Handle *out_process_h) {
|
||||||
const struct {
|
if (hosversionIsAtmosphere() || hosversionAtLeast(20,0,0)) {
|
||||||
u32 flags;
|
const struct {
|
||||||
u32 pad;
|
LoaderProgramAttributes attr;
|
||||||
u64 pin_id;
|
u16 pad;
|
||||||
} in = { flags, 0, pin_id };
|
u32 flags;
|
||||||
return serviceDispatchIn(&g_ldrPmSrv, 0, in,
|
u64 pin_id;
|
||||||
.in_num_handles = 1,
|
} in = { *attrs, 0, flags, pin_id };
|
||||||
.in_handles = { reslimit_h },
|
return serviceDispatchIn(&g_ldrPmSrv, 0, in,
|
||||||
.out_handle_attrs = { SfOutHandleAttr_HipcMove },
|
.in_num_handles = 1,
|
||||||
.out_handles = out_process_h,
|
.in_handles = { reslimit_h },
|
||||||
);
|
.out_handle_attrs = { SfOutHandleAttr_HipcMove },
|
||||||
|
.out_handles = out_process_h,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const struct {
|
||||||
|
u32 flags;
|
||||||
|
u32 pad;
|
||||||
|
u64 pin_id;
|
||||||
|
} in = { flags, 0, pin_id };
|
||||||
|
return serviceDispatchIn(&g_ldrPmSrv, 0, in,
|
||||||
|
.in_num_handles = 1,
|
||||||
|
.in_handles = { reslimit_h },
|
||||||
|
.out_handle_attrs = { SfOutHandleAttr_HipcMove },
|
||||||
|
.out_handles = out_process_h,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ldrPmGetProgramInfo(const NcmProgramLocation *loc, LoaderProgramInfo *out_program_info) {
|
Result ldrPmGetProgramInfo(const NcmProgramLocation *loc, const LoaderProgramAttributes *attrs, LoaderProgramInfo *out_program_info) {
|
||||||
if (!hosversionIsAtmosphere() && hosversionBefore(19, 0, 0))
|
if (!hosversionIsAtmosphere() && hosversionBefore(19, 0, 0))
|
||||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
return serviceDispatchIn(&g_ldrPmSrv, 1, *loc,
|
if (hosversionIsAtmosphere() || hosversionAtLeast(20,0,0)) {
|
||||||
.buffer_attrs = { SfBufferAttr_Out | SfBufferAttr_HipcPointer | SfBufferAttr_FixedSize },
|
const struct {
|
||||||
.buffers = { { out_program_info, sizeof(*out_program_info) } },
|
LoaderProgramAttributes attr;
|
||||||
);
|
u16 pad1;
|
||||||
|
u32 pad2;
|
||||||
|
NcmProgramLocation loc;
|
||||||
|
} in = { *attrs, 0, 0, *loc };
|
||||||
|
_Static_assert(sizeof(in) == 0x18);
|
||||||
|
return serviceDispatchIn(&g_ldrPmSrv, 1, in,
|
||||||
|
.buffer_attrs = { SfBufferAttr_Out | SfBufferAttr_HipcPointer | SfBufferAttr_FixedSize },
|
||||||
|
.buffers = { { out_program_info, sizeof(*out_program_info) } },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return serviceDispatchIn(&g_ldrPmSrv, 1, *loc,
|
||||||
|
.buffer_attrs = { SfBufferAttr_Out | SfBufferAttr_HipcPointer | SfBufferAttr_FixedSize },
|
||||||
|
.buffers = { { out_program_info, sizeof(*out_program_info) } },
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ldrPmGetProgramInfoV1(const NcmProgramLocation *loc, LoaderProgramInfoV1 *out_program_info) {
|
Result ldrPmGetProgramInfoV1(const NcmProgramLocation *loc, LoaderProgramInfoV1 *out_program_info) {
|
||||||
|
Loading…
Reference in New Issue
Block a user