mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 13:02:38 +02:00
Various web improvements, changed/added some structs.
This commit is contained in:
parent
bf13da990a
commit
4b8e501fdb
@ -34,16 +34,17 @@ typedef struct {
|
|||||||
WebWifiPageArg arg;
|
WebWifiPageArg arg;
|
||||||
} WebWifiConfig;
|
} WebWifiConfig;
|
||||||
|
|
||||||
|
/// TLV storage, starts with \ref WebArgHeader followed by \ref WebArgTLV entries.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 arg[0x2000];
|
u8 data[0x2000];
|
||||||
} WebPageConfig;
|
} WebCommonTLVStorage;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 webExitReason;
|
u32 exitReason;
|
||||||
u32 pad;
|
u32 pad;
|
||||||
char lastUrl[0x1000];
|
char lastUrl[0x1000];
|
||||||
u64 lastUrlSize;
|
u64 lastUrlSize;
|
||||||
} WebPageReturnValue;
|
} PACKED WebCommonReturnValue;
|
||||||
|
|
||||||
/// Header struct at offset 0 in the web Arg storage (non-webWifi).
|
/// Header struct at offset 0 in the web Arg storage (non-webWifi).
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -59,6 +60,10 @@ typedef struct {
|
|||||||
u8 pad[4];
|
u8 pad[4];
|
||||||
} PACKED WebArgTLV;
|
} PACKED WebArgTLV;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
WebCommonTLVStorage arg;
|
||||||
|
} WebPageConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates the config for WifiWebAuthApplet.
|
* @brief Creates the config for WifiWebAuthApplet.
|
||||||
* @param config WebWifiConfig object.
|
* @param config WebWifiConfig object.
|
||||||
@ -88,5 +93,5 @@ void webPageCreate(WebPageConfig* config, const char* url);
|
|||||||
* @param config WebPageConfig object.
|
* @param config WebPageConfig object.
|
||||||
* @param out Optional output applet reply data, can be NULL.
|
* @param out Optional output applet reply data, can be NULL.
|
||||||
*/
|
*/
|
||||||
Result webPageShow(WebPageConfig* config, WebPageReturnValue *out);
|
Result webPageShow(WebPageConfig* config, WebCommonReturnValue *out);
|
||||||
|
|
||||||
|
@ -55,18 +55,19 @@ static Result _webShow(AppletId id, u32 version, void* arg, size_t arg_size, voi
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _webArgInitialize(void* buffer, size_t size, WebShimKind shimKind) {
|
static void _webArgInitialize(WebCommonTLVStorage *storage, WebShimKind shimKind) {
|
||||||
WebArgHeader *hdr = (WebArgHeader*)buffer;
|
WebArgHeader *hdr = (WebArgHeader*)storage->data;
|
||||||
|
|
||||||
memset(buffer, 0, size);
|
memset(storage, 0, sizeof(*storage));
|
||||||
hdr->shimKind = shimKind;
|
hdr->shimKind = shimKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _webTLVWrite(void* buffer, size_t size, u16 type, const void* argdata, u16 argdata_size) {
|
static void _webTLVWrite(WebCommonTLVStorage *storage, u16 type, const void* argdata, u16 argdata_size) {
|
||||||
size_t i, count, offset;
|
size_t i, count, offset;
|
||||||
WebArgHeader *hdr = (WebArgHeader*)buffer;
|
u8 *dataptr = storage->data;
|
||||||
|
WebArgHeader *hdr = (WebArgHeader*)dataptr;
|
||||||
WebArgTLV *tlv;
|
WebArgTLV *tlv;
|
||||||
u8 *dataptr = (u8*)buffer;
|
size_t size = sizeof(storage->data);
|
||||||
|
|
||||||
offset = sizeof(WebArgHeader);
|
offset = sizeof(WebArgHeader);
|
||||||
if (size < offset) return;
|
if (size < offset) return;
|
||||||
@ -93,6 +94,8 @@ static void _webTLVWrite(void* buffer, size_t size, u16 type, const void* argdat
|
|||||||
tlv = (WebArgTLV*)&dataptr[offset];
|
tlv = (WebArgTLV*)&dataptr[offset];
|
||||||
|
|
||||||
if (tlv->type != type) {
|
if (tlv->type != type) {
|
||||||
|
if (hdr->total_entries == 0xFFFF) return;
|
||||||
|
|
||||||
tlv->type = type;
|
tlv->type = type;
|
||||||
tlv->size = argdata_size;
|
tlv->size = argdata_size;
|
||||||
hdr->total_entries++;
|
hdr->total_entries++;
|
||||||
@ -121,17 +124,18 @@ Result webWifiShow(WebWifiConfig* config, WebWifiReturnValue *out) {
|
|||||||
void webPageCreate(WebPageConfig* config, const char* url) {
|
void webPageCreate(WebPageConfig* config, const char* url) {
|
||||||
char tmpurl[0xc00];
|
char tmpurl[0xc00];
|
||||||
|
|
||||||
_webArgInitialize(config->arg, sizeof(config->arg), WebShimKind_Web);
|
_webArgInitialize(&config->arg, WebShimKind_Web);
|
||||||
|
|
||||||
u8 tmpval=1;
|
u8 tmpval=1;
|
||||||
_webTLVWrite(config->arg, sizeof(config->arg), 0x12, &tmpval, sizeof(tmpval)); /// Type was changed to 0xD with a newer version.
|
_webTLVWrite(&config->arg, 0xD, &tmpval, sizeof(tmpval));
|
||||||
|
_webTLVWrite(&config->arg, 0x12, &tmpval, sizeof(tmpval)); // Removed from user-process init with [3.0.0+].
|
||||||
|
|
||||||
memset(tmpurl, 0, sizeof(tmpurl));
|
memset(tmpurl, 0, sizeof(tmpurl));
|
||||||
strncpy(tmpurl, url, sizeof(tmpurl)-1);
|
strncpy(tmpurl, url, sizeof(tmpurl)-1);
|
||||||
_webTLVWrite(config->arg, sizeof(config->arg), 0x1, tmpurl, sizeof(tmpurl));
|
_webTLVWrite(&config->arg, 0x1, tmpurl, sizeof(tmpurl));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result webPageShow(WebPageConfig* config, WebPageReturnValue *out) {
|
Result webPageShow(WebPageConfig* config, WebCommonReturnValue *out) {
|
||||||
return _webShow(AppletId_web, 0x20000, config->arg, sizeof(config->arg), out, sizeof(*out));
|
return _webShow(AppletId_web, 0x20000, &config->arg, sizeof(config->arg), out, sizeof(*out));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user