From 2ed160624a036438f637b8d692f39de64c105468 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sat, 2 Mar 2019 11:11:39 -0500 Subject: [PATCH] webConfigShow now uses new struct WebCommonReply as the output, for supporting WebCommonTLVStorage reply data. --- nx/include/switch/applets/web.h | 8 +++++++- nx/source/applets/web.c | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/nx/include/switch/applets/web.h b/nx/include/switch/applets/web.h index a7570081..65b7def4 100644 --- a/nx/include/switch/applets/web.h +++ b/nx/include/switch/applets/web.h @@ -68,6 +68,12 @@ typedef struct { u32 version; } WebCommonConfig; +typedef struct { + bool type; ///< false = ret, true = storage. + WebCommonReturnValue ret; + WebCommonTLVStorage storage; +} WebCommonReply; + /// Types for \ref WebArgTLV. typedef enum { WebArgType_Url = 0x1, ///< [1.0.0+] String, size 0xC00. Initial URL. @@ -466,5 +472,5 @@ Result webConfigSetPageScrollIndicator(WebCommonConfig* config, bool flag); * @param config WebCommonConfig object. * @param out Optional output applet reply data, can be NULL. */ -Result webConfigShow(WebCommonConfig* config, WebCommonReturnValue *out); +Result webConfigShow(WebCommonConfig* config, WebCommonReply *out); diff --git a/nx/source/applets/web.c b/nx/source/applets/web.c index d378e0dc..03bd2e2b 100644 --- a/nx/source/applets/web.c +++ b/nx/source/applets/web.c @@ -506,7 +506,23 @@ Result webConfigSetPageScrollIndicator(WebCommonConfig* config, bool flag) { return _webConfigSetFlag(config, WebArgType_PageScrollIndicator, flag); } -Result webConfigShow(WebCommonConfig* config, WebCommonReturnValue *out) { - return _webShow(config->appletid, config->version, &config->arg, sizeof(config->arg), out, sizeof(*out)); +Result webConfigShow(WebCommonConfig* config, WebCommonReply *out) { + void* reply; + size_t size; + + // ShareApplet on [3.0.0+] uses TLV storage for the reply, while older versions + everything else uses *ReturnValue. + memset(out, 0, sizeof(*out)); + if (config->version >= 0x30000 && _webGetShimKind(config) == WebShimKind_Share) out->type = true; + + if (!out->type) { + reply = &out->ret; + size = sizeof(out->ret); + } + else { + reply = &out->storage; + size = sizeof(out->storage); + } + + return _webShow(config->appletid, config->version, &config->arg, sizeof(config->arg), reply, size); }