diff --git a/installer/wad/0001000154484246.tmd b/installer/wad/0001000154484246.tmd index 1b1f2f8..b9680db 100644 Binary files a/installer/wad/0001000154484246.tmd and b/installer/wad/0001000154484246.tmd differ diff --git a/source/Prompts/prompt_loader.cpp b/source/Prompts/prompt_loader.cpp index 71ba442..6cbd567 100644 --- a/source/Prompts/prompt_loader.cpp +++ b/source/Prompts/prompt_loader.cpp @@ -40,22 +40,35 @@ loaderPrompt() // Buttons data GuiImageData btn(Theme.button); GuiImage nandemuImg(&btn); + GuiImage priiloaderImg(&btn); GuiImage backImg(&btn); // Buttons over data GuiImageData btn_over(Theme.button_focus); GuiImage nandemuImgOver(&btn_over); + GuiImage priiloaderImgOver(&btn_over); GuiImage backImgOver(&btn_over); - GuiText nandemuTxt(tr("Launch NandEmu (Uniiloader)"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); + GuiText nandemuTxt(tr("Launch Uniiloader"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); GuiButton nandemu(btn.GetWidth(), btn.GetHeight()); nandemu.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - nandemu.SetPosition(0, 75); + nandemu.SetPosition(0, 90); nandemu.SetLabel(&nandemuTxt); nandemu.SetImage(&nandemuImg); nandemu.SetImageOver(&nandemuImgOver); nandemu.SetTrigger(&trigA); + GuiText priiloaderTxt(tr("Launch Priiloader"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); + GuiButton priiloader(btn.GetWidth(), btn.GetHeight()); + priiloader.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + priiloader.SetPosition(0, 90); + if(get_nandemu()) + priiloader.SetPosition(0, 140); + priiloader.SetLabel(&priiloaderTxt); + priiloader.SetImage(&priiloaderImg); + priiloader.SetImageOver(&priiloaderImgOver); + priiloader.SetTrigger(&trigA); + GuiText backTxt(tr("Back"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); GuiButton back(btn.GetWidth(), btn.GetHeight()); back.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); @@ -69,11 +82,12 @@ loaderPrompt() GuiButton back2(0, 0); back2.SetTrigger(&trigHOME); - promptWindow.Append(&dialogBoxImg); promptWindow.Append(&titleTxt); if(get_nandemu()) promptWindow.Append(&nandemu); + if(get_priiloader()) + promptWindow.Append(&priiloader); promptWindow.Append(&back); promptWindow.Append(&back2); @@ -94,6 +108,13 @@ loaderPrompt() stop = true; } + if(priiloader.GetState() == STATE_CLICKED) + { + set_priiloader(2); + menu = MENU_EXIT; + stop = true; + } + if(back.GetState() == STATE_CLICKED || back2.GetState() == STATE_CLICKED) stop = true; } diff --git a/source/Tools/SelectIos.cpp b/source/Tools/SelectIos.cpp index 0065b4a..bd1b08d 100644 --- a/source/Tools/SelectIos.cpp +++ b/source/Tools/SelectIos.cpp @@ -13,6 +13,170 @@ int selectedIos = IOS_GetVersion(); int ios_pos = 0; int bootmii = 0; int nandemu = 0; +int priiloader = 0; + + +s32 NandReadFile(char *filepath, u8 **buffer, u32 *filesize) +{ + s32 Fd; + int ret; + + if (buffer == NULL) + { + printf("NULL Pointer\n"); + return -1; + } + + Fd = ISFS_Open(filepath, ISFS_OPEN_READ); + if (Fd < 0) + { + printf("ISFS_Open %s failed %d\n", filepath, Fd); + return Fd; + } + + fstats *status; + status = (fstats *)memalign(32, ((sizeof(fstats))+31)&(~31)); + if (status == NULL) + { + printf("Out of memory for status\n"); + return -1; + } + + ret = ISFS_GetFileStats(Fd, status); + if (ret < 0) + { + printf("ISFS_GetFileStats failed %d\n", ret); + ISFS_Close(Fd); + free(status); + return -1; + } + + *buffer = (u8 *)memalign(32, ((status->file_length)+31)&(~31)); + if (*buffer == NULL) + { + printf("Out of memory for buffer\n"); + ISFS_Close(Fd); + free(status); + return -1; + } + + ret = ISFS_Read(Fd, *buffer, status->file_length); + if (ret < 0) + { + printf("ISFS_Read failed %d\n", ret); + ISFS_Close(Fd); + free(status); + free(*buffer); + return ret; + } + + ISFS_Close(Fd); + + *filesize = status->file_length; + free(status); + + if (*filesize > 0) + { + DCFlushRange(*buffer, *filesize); + ICInvalidateRange(*buffer, *filesize); + } + + return 0; +} + +s32 GetTMD(u64 TicketID, signed_blob **Output, u32 *Length) +{ + signed_blob* TMD = NULL; + + u32 TMD_Length; + s32 ret; + + /* Retrieve TMD length */ + ret = ES_GetStoredTMDSize(TicketID, &TMD_Length); + if (ret < 0) + return ret; + + /* Allocate memory */ + TMD = (signed_blob*)memalign(32, (TMD_Length+31)&(~31)); + if (!TMD) + return IPC_ENOMEM; + + /* Retrieve TMD */ + ret = ES_GetStoredTMD(TicketID, TMD, TMD_Length); + if (ret < 0) + { + free(TMD); + return ret; + } + + /* Set values */ + *Output = TMD; + *Length = TMD_Length; + + return 0; +} + +int check_priiloader() { + char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(0x20); + static u64 titleId ATTRIBUTE_ALIGN(32) = 0x0000000100000002LL; + int ret = 0; + tmd *ptmd = NULL; + u32 TMD_size = 0; + signed_blob *stmd = NULL; + u32 i = 0; + u32 filesize = 0; + u8 *buffer = NULL; + const char *checkStr = "priiloader"; + int retValue = -1; + + ret = GetTMD(titleId, &stmd, &TMD_size); + + if (ret < 0) + goto end; + + if (!stmd) + { + ret = -1; + + goto end; + } + + ptmd = (tmd*)SIGNATURE_PAYLOAD(stmd); + + for (i = 0; i < ptmd->num_contents; i++) + { + if (ptmd->contents[i].index == ptmd->boot_index) + { + sprintf(filepath, "/title/%08x/%08x/content/%08x.app" , 0x00000001, 0x00000002, ptmd->contents[i].cid); + ret = NandReadFile(filepath, &buffer, &filesize); + if (ret < 0 || filesize < 0) { + retValue = -2; + goto end; + } + break; + } + } + + for (i = 0; i < filesize - strlen(checkStr); i++) + { + if (!strncmp((char*)buffer + i, checkStr, strlen(checkStr))) + { + retValue = 1; + + break; + } + } + +end: + free(buffer); + + free(stmd); + ptmd = NULL; + + priiloader = retValue; + return retValue; + +} // Check if this is an IOS stub (according to WiiBrew.org) bool IsKnownStub(u32 noIOS, s32 noRevision) @@ -228,6 +392,16 @@ int GetAppIOS(std::string foldername) return selectedIos; } +int get_priiloader() +{ + return priiloader; +} + +void set_priiloader(int choice) +{ + priiloader = choice; +} + int get_bootmii() { return bootmii; @@ -246,4 +420,4 @@ int get_nandemu() void set_nandemu(int choice) { nandemu = choice; -} \ No newline at end of file +} diff --git a/source/Tools/SelectIos.h b/source/Tools/SelectIos.h index 9ae3730..2c50089 100644 --- a/source/Tools/SelectIos.h +++ b/source/Tools/SelectIos.h @@ -7,7 +7,12 @@ int previousIos(); int SelectedIOS(); int SearchAppIOS(std::string foldername); int GetAppIOS(std::string foldername); +int check_priiloader(); +s32 GetTMD(u64 TicketID, signed_blob **Output, u32 *Length); +s32 NandReadFile(char *filepath, u8 **buffer, u32 *filesize); +int get_priiloader(); int get_bootmii(); int get_nandemu(); +void set_priiloader(int choice); void set_bootmii(int choice); void set_nandemu(int choice); diff --git a/source/main.cpp b/source/main.cpp index e4222a4..f4789ca 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -208,6 +208,8 @@ main(int argc, char *argv[]) AvailableCategory.categories[0] = tr(Settings.category_name_all); check_device(); + check_priiloader(); + /* while(1) { WPAD_ScanPads(); @@ -236,7 +238,7 @@ main(int argc, char *argv[]) BootGameCubeHomebrew(); } else if(boot_buffer) - BootHomebrew(); + // BootHomebrew(); if(get_bootmii() == 2) IOS_ReloadIOS(254); @@ -255,7 +257,20 @@ main(int argc, char *argv[]) } } - if(PowerOff != -1) + if(get_priiloader() == 2) + { + *(vu32*)0x8132FFFB = 0x4461636f; + DCFlushRange((void*)0x8132FFFB, 4); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + } + + if(PowerOff == SYS_RETURNTOMENU) + { + *(vu32*)0x8132FFFB = 0x50756E65; + DCFlushRange((void*)0x8132FFFB, 4); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + } + else if(PowerOff != -1) SYS_ResetSystem(PowerOff, 0, 0); return 0; diff --git a/updates b/updates index 2988322..b810da3 100644 --- a/updates +++ b/updates @@ -7,9 +7,12 @@ (must be one of sd:/apps/NANDEmu-Boot/boot.dol usb:/apps/NANDEmu-Boot/boot.dol) HBF only allows to boot into Uniiloader if IOS253 is present + * Priiloader + returns to priiloader (regardless of autoboot setting) +- 'Return to System Menu' now ignores Priiloader and always enters System Menu - Basic (= non-working) support for Homebew on DVD - No longer show the HBC if it's installed -- changing pages in an empty category no longer crashes +- BUGFIX: changing pages in an empty category no longer crashes - Accessing devices formatted as EXT2/3/4 should now be noticeably faster - compiled with devkitppc 25-1 and libogc 1.8.10 (support for latest WiiMotes) - For theme designers: the following new icons have been added: