diff --git a/nx/include/switch/applets/error.h b/nx/include/switch/applets/error.h index 6f8f78ca..71e049a5 100644 --- a/nx/include/switch/applets/error.h +++ b/nx/include/switch/applets/error.h @@ -10,7 +10,13 @@ /// Error configuration struct. typedef struct { - u8 args[0x1018]; + bool custom_text; ///< Whether to show a custom error message. If this is false, a default message will be shown. + u8 pad[7]; + u32 major_code; ///< First part of the error-code. + u32 minor_code; ///< Second part of the error-code. + u8 pad2[8]; + char short_description[0x800]; ///< Short description. + char detailed_description[0x800]; ///< Detailed description (displayed when the user clicks, on "Details"). } ErrorConfig; /** diff --git a/nx/source/applets/error.cpp b/nx/source/applets/error.cpp index 0305ea61..739760ea 100644 --- a/nx/source/applets/error.cpp +++ b/nx/source/applets/error.cpp @@ -7,13 +7,12 @@ #include "applets/error.h" void errorCreate(ErrorConfig* c) { - memset(c->args, 0, 0x1018); - - c->args[0x0] = 0; - *(u64*) &c->args[0x8] = 2000; - *(u64*) &c->args[0xC] = 0; - strcpy((char*) &c->args[0x18], ""); - strcpy((char*) &c->args[0x818], ""); + memset(c, 0, sizeof(ErrorConfig)); + c->custom_text = false; + c->major_code = 2000; + c->minor_code = 0; + strcpy((char*) &c->short_description, ""); + strcpy((char*) &c->detailed_description, ""); } void errorClose(ErrorConfig* c) { @@ -25,12 +24,15 @@ void errorShow(ErrorConfig* c) { AppletStorage errStor; LibAppletArgs errArgs; + u8 args[0x1018] = {0}; + memcpy(&args, c, 0x1018); + appletCreateLibraryApplet(&err, AppletId_error, LibAppletMode_AllForeground); libappletArgsCreate(&errArgs, 1); libappletArgsPush(&errArgs, &err); appletCreateStorage(&errStor, 4120); - appletStorageWrite(&errStor, 0, c->args, 0x1018); + appletStorageWrite(&errStor, 0, args, 0x1018); appletHolderPushInData(&err, &errStor); @@ -39,22 +41,22 @@ void errorShow(ErrorConfig* c) { appletHolderClose(&err); } -void errorConfigSetMajorCode(ErrorConfig* c, u64 code) { - *(u64*) &c->args[0x8] = code; +void errorConfigSetMajorCode(ErrorConfig* c, u32 code) { + c->major_code = code; } -void errorConfigSetMinorCode(ErrorConfig* c, u64 code) { - *(u64*) &c->args[0xC] = code; +void errorConfigSetMinorCode(ErrorConfig* c, u32 code) { + c->minor_code = code; } void errorConfigSetCustomText(ErrorConfig* c, bool customText) { - c->args[0x0] = customText; + c->custom_text = customText; } void errorConfigSetShortDescription(ErrorConfig* c, const char* str) { - strcpy((char*) &c->args[0x18], str); + strcpy((char*) &c->short_description, str); } void errorConfigSetDetailedDescription(ErrorConfig* c, const char* str) { - strcpy((char*) &c->args[0x818], str); + strcpy((char*) &c->detailed_description, str); }