lr: fix 9.x RedirectApplication* commands (#326)

* lr: fix 9.x RedirectApplication* commands

* lr: correct LegalInformation->ApplicationLegalInformation
This commit is contained in:
SciresM 2019-09-13 03:34:21 -07:00 committed by fincs
parent 9d632b856d
commit c55383c973
2 changed files with 84 additions and 38 deletions

View File

@ -31,10 +31,10 @@ Result lrLrRedirectProgramPath(LrLocationResolver* lr, u64 tid, const char *path
Result lrLrResolveApplicationControlPath(LrLocationResolver* lr, u64 tid, char *out);
Result lrLrResolveApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, char *out);
Result lrLrResolveDataPath(LrLocationResolver* lr, u64 tid, char *out);
Result lrLrRedirectApplicationControlPath(LrLocationResolver* lr, u64 tid, const char *path);
Result lrLrRedirectApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, const char *path);
Result lrLrResolveLegalInformationPath(LrLocationResolver* lr, u64 tid, char *out);
Result lrLrRedirectLegalInformationPath(LrLocationResolver* lr, u64 tid, const char *path);
Result lrLrRedirectApplicationControlPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path);
Result lrLrRedirectApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path);
Result lrLrResolveApplicationLegalInformationPath(LrLocationResolver* lr, u64 tid, char *out);
Result lrLrRedirectApplicationLegalInformationPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path);
Result lrLrRefresh(LrLocationResolver* lr);
// IRegisteredLocationResolver

View File

@ -7,6 +7,7 @@
#include "services/lr.h"
#include "services/fs.h"
#include "services/sm.h"
#include "runtime/hosversion.h"
static Service g_managerSrv;
static u64 g_managerRefCnt;
@ -182,6 +183,51 @@ static Result _lrRedirectPath(Service* s, u64 cmd_id, u64 tid, const char *path)
return rc;
}
/*
In 9.0.0, "RedirectApplication" commands began taking in a second tid argument.
This is a helper function to perform the work for those funcs, given a command ID.
*/
static Result _lrRedirectApplicationPath(Service* s, u64 cmd_id, u64 tid, u64 tid2, const char *path) {
// On < 9.0.0, call the original redirection helper.
if (hosversionBefore(9,0,0)) {
return _lrRedirectPath(s, cmd_id, tid, path);
}
char send_path[FS_MAX_PATH+1] = {0};
IpcCommand c;
ipcInitialize(&c);
ipcAddSendStatic(&c, send_path, FS_MAX_PATH, 0);
struct {
u64 magic;
u64 cmd_id;
u64 tid;
u64 tid2;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = cmd_id;
raw->tid = tid;
raw->tid = tid2;
strncpy(send_path, path, FS_MAX_PATH);
Result rc = serviceIpcDispatch(s);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
}
return rc;
}
Result lrLrResolveProgramPath(LrLocationResolver* lr, u64 tid, char *out) {
return _lrResolvePath(&lr->s, 0, tid, out);
@ -203,20 +249,20 @@ Result lrLrResolveDataPath(LrLocationResolver* lr, u64 tid, char *out) {
return _lrResolvePath(&lr->s, 4, tid, out);
}
Result lrLrRedirectApplicationControlPath(LrLocationResolver* lr, u64 tid, const char *path) {
return _lrRedirectPath(&lr->s, 5, tid, path);
Result lrLrRedirectApplicationControlPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path) {
return _lrRedirectApplicationPath(&lr->s, 5, tid, tid2, path);
}
Result lrLrRedirectApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, const char *path) {
return _lrRedirectPath(&lr->s, 6, tid, path);
Result lrLrRedirectApplicationHtmlDocumentPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path) {
return _lrRedirectApplicationPath(&lr->s, 6, tid, tid2, path);
}
Result lrLrResolveLegalInformationPath(LrLocationResolver* lr, u64 tid, char *out) {
Result lrLrResolveApplicationLegalInformationPath(LrLocationResolver* lr, u64 tid, char *out) {
return _lrResolvePath(&lr->s, 7, tid, out);
}
Result lrLrRedirectLegalInformationPath(LrLocationResolver* lr, u64 tid, const char *path) {
return _lrRedirectPath(&lr->s, 8, tid, path);
Result lrLrRedirectApplicationLegalInformationPath(LrLocationResolver* lr, u64 tid, u64 tid2, const char *path) {
return _lrRedirectApplicationPath(&lr->s, 8, tid, tid2, path);
}
Result lrLrRefresh(LrLocationResolver* lr) {