diff --git a/Cia_shortcut/Gateway_cia.bin b/Cia_shortcut/Gateway_cia.bin new file mode 100644 index 0000000..e727d8f Binary files /dev/null and b/Cia_shortcut/Gateway_cia.bin differ diff --git a/Makefile b/Makefile index ca89022..f514f7e 100644 --- a/Makefile +++ b/Makefile @@ -32,11 +32,11 @@ SOURCES := source DATA := data INCLUDES := include -VERSION := v1.1 +VERSION := v1.2 -APP_TITLE := hblauncher_loader $(VERSION) -APP_DESCRIPTION := This boots the hblauncher-payload. -APP_AUTHOR := yellows8 +APP_TITLE := Gateway CIA $(VERSION) +APP_DESCRIPTION := This is a shortcut to launch Gateway +APP_AUTHOR := Gateway #--------------------------------------------------------------------------------- # options for code generation @@ -135,7 +135,7 @@ $(BUILD): #--------------------------------------------------------------------------------- clean: @echo clean ... - @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(OUTPUT).cia Resources/hblauncher_loader.icn Resources/hblauncher_loader.bnr + @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(OUTPUT).cia Resources/Gateway_cia.icn Resources/Gateway_cia.bnr #--------------------------------------------------------------------------------- @@ -154,15 +154,15 @@ endif $(OUTPUT).elf : $(OFILES) -../Resources/hblauncher_loader.icn : $(APP_ICON) - @bannertool makesmdh -i "$(APP_ICON)" -o "$@" -s "$(APP_TITLE)" -l "$(APP_TITLE)" -p "$(APP_AUTHOR)" +../Resources/Gateway_cia.icn : $(APP_ICON) + ../bannertool makesmdh -i "$(APP_ICON)" -o "$@" -s "$(APP_TITLE)" -l "$(APP_TITLE)" -p "$(APP_AUTHOR)" -../Resources/hblauncher_loader.bnr : ../banner.png - @bannertool makebanner -i "$<" -ca ../Resources/hblauncher_loader.cwav -o "$@" +../Resources/Gateway_cia.bnr : + ../bannertool makebanner -i "$<" -ca ../Resources/Gateway_cia.cwav -o "$@" -ci ../Resources/Gateway_cia.cgfx -o "$@" -$(OUTPUT).cia : $(OUTPUT).elf ../Resources/hblauncher_loader.icn ../Resources/hblauncher_loader.bnr - @makerom -f cia -o "$@" -elf $(OUTPUT).elf -rsf ../Resources/hblauncher_loader.rsf -icon ../Resources/hblauncher_loader.icn -banner ../Resources/hblauncher_loader.bnr -exefslogo -ver 1040 - @echo "built ... hblauncher_loader.cia" +$(OUTPUT).cia : $(OUTPUT).elf ../Resources/Gateway_cia.icn ../Resources/Gateway_cia.bnr + ../makerom -f cia -o "$@" -elf $(OUTPUT).elf -rsf ../Resources/Gateway_cia.rsf -icon ../Resources/Gateway_cia.icn -banner ../Resources/Gateway_cia.bnr -exefslogo -ver 1040 + @echo "built ... Gateway_cia.cia" #--------------------------------------------------------------------------------- # you need a rule like this for each extension you use as binary data diff --git a/README.md b/README.md index 84d456a..4c23fd4 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,3 @@ -This is a 3DS homebrew application intended for running under a NCCH(which can be installed via .cia), for booting the *hax payloads. https://smealum.github.io/3ds/ - -This app was mostly finished in October 2015, this was finally released on November 25, 2015, due to the custom logo being finished. - -This will first attempt to load the payload from SD, if that isn't successful it will then automatically download the payload for your system with HTTP. SD payload loading can be skipped if you hold down the X button. If you don't hold down the Y button, this will write the downloaded payload from HTTP to SD, if it actually downloaded it via HTTP. - -The exact filepath used for the SD payload depends on your system. Since this app can handle writing the payload here itself, writing the payload here manually isn't really needed. Example SD filepath with New3DS 10.1.0-27U: "/hblauncherloader_otherapp_payload_NEW-10-1-0-27-USA.bin". The Old3DS filepath for the same system-version and region as that example is the same, except that "OLD" is used instead of "NEW". - -If you want to manually build this, you'll need this: https://github.com/Steveice10/bannertool - -Credits: -* 3DSGuy for originally converting the CWAV used by this app's banner, years ago(which seems to be originally from the Wii HBC banner audio?). -* @Substance12 For the icon/banner(#4). - +This is just a CIA shortcut that opens Gateway Launcher. +Run make and then put gate.3dsx onto the root of your SD card along with the Cia_shortcut folder. +Also put the Gateway_cia.cia file and install it on your sysNAND. diff --git a/Resources/Gateway_cia.cgfx b/Resources/Gateway_cia.cgfx new file mode 100644 index 0000000..02aea46 Binary files /dev/null and b/Resources/Gateway_cia.cgfx differ diff --git a/Resources/Gateway_cia.cwav b/Resources/Gateway_cia.cwav new file mode 100644 index 0000000..7a1f8cf Binary files /dev/null and b/Resources/Gateway_cia.cwav differ diff --git a/Resources/hblauncher_loader.rsf b/Resources/Gateway_cia.rsf similarity index 98% rename from Resources/hblauncher_loader.rsf rename to Resources/Gateway_cia.rsf index 2ed17b6..d38da0f 100644 --- a/Resources/hblauncher_loader.rsf +++ b/Resources/Gateway_cia.rsf @@ -1,5 +1,5 @@ BasicInfo: - Title : Gateway Launcher + Title : Gateway CIA ProductCode : 3DS Chaos Logo : Homebrew @@ -9,7 +9,7 @@ RomFs: TitleInfo: Category : Application - UniqueId : 0xd921e + UniqueId : 0xd921d Option: UseOnSD : true # true if App is to be installed to SD diff --git a/Resources/hblauncher_loader.cwav b/Resources/hblauncher_loader.cwav deleted file mode 100644 index fd185d2..0000000 Binary files a/Resources/hblauncher_loader.cwav and /dev/null differ diff --git a/banner.png b/banner.png deleted file mode 100644 index 030af98..0000000 Binary files a/banner.png and /dev/null differ diff --git a/bannertool.exe b/bannertool.exe new file mode 100644 index 0000000..1c61d24 Binary files /dev/null and b/bannertool.exe differ diff --git a/gate.3dsx b/gate.3dsx new file mode 100644 index 0000000..0aacfa7 Binary files /dev/null and b/gate.3dsx differ diff --git a/icon.png b/icon.png index 70bb483..7b8952b 100644 Binary files a/icon.png and b/icon.png differ diff --git a/makerom.exe b/makerom.exe new file mode 100644 index 0000000..bcf254d Binary files /dev/null and b/makerom.exe differ diff --git a/source/Gateway_cia.c b/source/Gateway_cia.c new file mode 100644 index 0000000..ccb5ed6 --- /dev/null +++ b/source/Gateway_cia.c @@ -0,0 +1,270 @@ +#include +#include +#include +#include +#include +#include +#include <3ds.h> + +extern u32 PAYLOAD_TEXTADDR[]; +extern u32 PAYLOAD_TEXTMAXSIZE; + +extern Handle gspGpuHandle; + +u8 *filebuffer; +u32 filebuffer_maxsize; + +char regionids_table[7][4] = {//http://3dbrew.org/wiki/Nandrw/sys/SecureInfo_A +"JPN", +"USA", +"EUR", +"JPN", //"AUS" +"CHN", +"KOR", +"TWN" +}; + +void gxlowcmd_4(u32* inadr, u32* outadr, u32 size, u32 width0, u32 height0, u32 width1, u32 height1, u32 flags) +{ + GX_TextureCopy(inadr, width0 | (height0<<16), outadr, width1 | (height1<<16), size, flags); +} + +Result gsp_flushdcache(u8* adr, u32 size) +{ + return GSPGPU_FlushDataCache(adr, size); +} + +Result loadsd_payload(char *filepath, u32 *payloadsize) +{ + struct stat filestats; + FILE *f; + size_t readsize=0; + + if(stat(filepath, &filestats)==-1)return errno; + + *payloadsize = filestats.st_size; + + if(filestats.st_size==0 || filestats.st_size>PAYLOAD_TEXTMAXSIZE) + { + printf("Invalid SD payload size: 0x%08x.\n", (unsigned int)filestats.st_size); + return -3; + } + + f = fopen(filepath, "r"); + if(f==NULL)return errno; + + readsize = fread(filebuffer, 1, filestats.st_size, f); + fclose(f); + + if(readsize!=filestats.st_size) + { + printf("fread() failed with the SD payload.\n"); + return -2; + } + + return 0; +} + +Result savesd_payload(char *filepath, u32 payloadsize) +{ + FILE *f; + size_t writesize=0; + + unlink(filepath); + + f = fopen(filepath, "w+"); + if(f==NULL) + { + printf("Failed to open the SD payload for writing.\n"); + return errno; + } + + writesize = fwrite(filebuffer, 1, payloadsize, f); + fclose(f); + + if(writesize!=payloadsize) + { + printf("fwrite() failed with the SD payload.\n"); + return -2; + } + + return 0; +} + +Result load_gateway() +{ + Result ret = 0; + u8 region=0; + u8 new3dsflag = 0; + + OS_VersionBin nver_versionbin; + OS_VersionBin cver_versionbin; + + u32 payloadsize = 0, payloadsize_aligned = 0; + u32 payload_src = 0; + + char payload_sysver[32]; + char payloadurl[0x80]; + char payload_sdpath[0x80]; + + void (*funcptr)(u32*, u32*) = NULL; + u32 *paramblk = NULL; + + memset(&nver_versionbin, 0, sizeof(OS_VersionBin)); + memset(&cver_versionbin, 0, sizeof(OS_VersionBin)); + + memset(payload_sysver, 0, sizeof(payload_sysver)); + memset(payloadurl, 0, sizeof(payloadurl)); + memset(payload_sdpath, 0, sizeof(payload_sdpath)); + + ret = cfguInit(); + if(ret!=0) + { + printf("Failed to init cfgu: 0x%08x.\n", (unsigned int)ret); + return ret; + } + ret = CFGU_SecureInfoGetRegion(®ion); + if(ret!=0) + { + printf("Failed to get region from cfgu: 0x%08x.\n", (unsigned int)ret); + return ret; + } + if(region>=7) + { + printf("Region value from cfgu is invalid: 0x%02x.\n", (unsigned int)region); + ret = -9; + return ret; + } + cfguExit(); + + APT_CheckNew3DS(&new3dsflag); + + snprintf(payload_sdpath, sizeof(payload_sdpath)-1, "sdmc:/Cia_shortcut/Gateway_cia.bin", payload_sysver); + + memset(filebuffer, 0, filebuffer_maxsize); + + printf("Loading payload on SD, with the following filepath: \n", payload_sdpath); + ret = loadsd_payload(payload_sdpath, &payloadsize); + + if(ret==0) + { + payload_src = 0; + } + else + { + printf("Can't find \n"); + } + + printf("Initializing payload data etc...\n"); + + payloadsize_aligned = (payloadsize + 0xfff) & ~0xfff; + if(payloadsize_aligned > PAYLOAD_TEXTMAXSIZE) + { + printf("Invalid payload size: 0x%08x.\n", (unsigned int)payloadsize); + ret = -3; + return ret; + } + + memcpy(PAYLOAD_TEXTADDR, filebuffer, payloadsize_aligned); + memset(filebuffer, 0, filebuffer_maxsize); + + ret = svcFlushProcessDataCache(0xffff8001, PAYLOAD_TEXTADDR, payloadsize_aligned);//Flush dcache for the payload which was copied into .text. Since that area was never executed, icache shouldn't be an issue. + if(ret!=0) + { + printf("svcFlushProcessDataCache failed: 0x%08x.\n", (unsigned int)ret); + return ret; + } + + paramblk = linearMemAlign(0x10000, 0x1000); + if(paramblk==NULL) + { + ret = 0xfe; + printf("Failed to alloc the paramblk.\n"); + return ret; + } + + memset(paramblk, 0, 0x10000); + + paramblk[0x1c>>2] = (u32)gxlowcmd_4; + paramblk[0x20>>2] = (u32)gsp_flushdcache; + paramblk[0x48>>2] = 0x8d;//flags + paramblk[0x58>>2] = (u32)&gspGpuHandle; + + printf("Jumping into the payload...\n"); + + funcptr = (void*)PAYLOAD_TEXTADDR; + funcptr(paramblk, (u32*)(0x10000000-0x1000)); + + ret = 0xff; + printf("The payload returned back into the app.\n"); + + return ret; +} + +int main(int argc, char **argv) +{ + Result ret = 0; + u32 pos; + Handle kproc_handledup=0; + + // Initialize services + gfxInitDefault(); + + consoleInit(GFX_BOTTOM, NULL); + + printf("Gateway Cia\n", VERSION); + + ret = svcDuplicateHandle(&kproc_handledup, 0xffff8001); + if(ret!=0)printf("svcDuplicateHandle() with the current proc-handle failed: 0x%08x.\n", (unsigned int)ret); + + if(ret==0) + { + for(pos=0; pos> 2], 0x0, 0x1000, MEMOP_PROT, MEMPERM_READ | MEMPERM_WRITE | MEMPERM_EXECUTE); + if(ret!=0) + { + printf("svcControlProcessMemory with pos=0x%x failed: 0x%08x.\n", (unsigned int)pos, (unsigned int)ret); + break; + } + } + } + + if(ret==0) + { + filebuffer_maxsize = PAYLOAD_TEXTMAXSIZE; + + filebuffer = (u8*)malloc(filebuffer_maxsize); + if(filebuffer==NULL) + { + printf("Failed to allocate memory.\n"); + ret = -1; + } + else + { + memset(filebuffer, 0, filebuffer_maxsize); + } + } + + ret = load_gateway(); + + free(filebuffer); + + if(ret!=0 && ret!=0xd8a0a046)printf("An error occured\n"); + + printf("Press the START button to exit.\n"); + // Main loop + while (aptMainLoop()) + { + gspWaitForVBlank(); + hidScanInput(); + + u32 kDown = hidKeysDown(); + if (kDown & KEY_START) + break; + } + + // Exit services + gfxExit(); + return 0; +} diff --git a/source/hblauncher_loader.c b/source/hblauncher_loader.c deleted file mode 100644 index 838c11d..0000000 --- a/source/hblauncher_loader.c +++ /dev/null @@ -1,461 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include <3ds.h> - -extern u32 PAYLOAD_TEXTADDR[]; -extern u32 PAYLOAD_TEXTMAXSIZE; - -extern Handle gspGpuHandle; - -u8 *filebuffer; -u32 filebuffer_maxsize; - -char regionids_table[7][4] = {//http://3dbrew.org/wiki/Nandrw/sys/SecureInfo_A -"JPN", -"USA", -"EUR", -"JPN", //"AUS" -"CHN", -"KOR", -"TWN" -}; - -void gxlowcmd_4(u32* inadr, u32* outadr, u32 size, u32 width0, u32 height0, u32 width1, u32 height1, u32 flags) -{ - GX_TextureCopy(inadr, width0 | (height0<<16), outadr, width1 | (height1<<16), size, flags); -} - -Result gsp_flushdcache(u8* adr, u32 size) -{ - return GSPGPU_FlushDataCache(adr, size); -} - -Result http_getactual_payloadurl(char *requrl, char *outurl, u32 outurl_maxsize) -{ - Result ret=0; - httpcContext context; - - ret = httpcOpenContext(&context, HTTPC_METHOD_GET, requrl, 1); - if(ret!=0)return ret; - - ret = httpcAddRequestHeaderField(&context, "User-Agent", "hblauncher_loader/"VERSION); - if(ret!=0) - { - httpcCloseContext(&context); - return ret; - } - - ret = httpcBeginRequest(&context); - if(ret!=0) - { - httpcCloseContext(&context); - return ret; - } - - ret = httpcGetResponseHeader(&context, "Location", outurl, outurl_maxsize); - - httpcCloseContext(&context); - - return 0; -} - -Result http_download_payload(char *url, u32 *payloadsize) -{ - Result ret=0; - u32 statuscode=0; - u32 contentsize=0; - httpcContext context; - - ret = httpcOpenContext(&context, HTTPC_METHOD_GET, url, 1); - if(ret!=0)return ret; - - ret = httpcAddRequestHeaderField(&context, "User-Agent", "hblauncher_loader/"VERSION); - if(ret!=0) - { - httpcCloseContext(&context); - return ret; - } - - ret = httpcBeginRequest(&context); - if(ret!=0) - { - httpcCloseContext(&context); - return ret; - } - - ret = httpcGetResponseStatusCode(&context, &statuscode, 0); - if(ret!=0) - { - httpcCloseContext(&context); - return ret; - } - - if(statuscode!=200) - { - printf("Error: server returned HTTP statuscode %u.\n", (unsigned int)statuscode); - httpcCloseContext(&context); - return -2; - } - - ret=httpcGetDownloadSizeState(&context, NULL, &contentsize); - if(ret!=0) - { - httpcCloseContext(&context); - return ret; - } - - if(contentsize==0 || contentsize>PAYLOAD_TEXTMAXSIZE) - { - printf("Invalid HTTP content-size: 0x%08x.\n", (unsigned int)contentsize); - ret = -3; - httpcCloseContext(&context); - return ret; - } - - ret = httpcDownloadData(&context, filebuffer, contentsize, NULL); - if(ret!=0) - { - httpcCloseContext(&context); - return ret; - } - - httpcCloseContext(&context); - - *payloadsize = contentsize; - - return 0; -} - -Result loadsd_payload(char *filepath, u32 *payloadsize) -{ - struct stat filestats; - FILE *f; - size_t readsize=0; - - if(stat(filepath, &filestats)==-1)return errno; - - *payloadsize = filestats.st_size; - - if(filestats.st_size==0 || filestats.st_size>PAYLOAD_TEXTMAXSIZE) - { - printf("Invalid SD payload size: 0x%08x.\n", (unsigned int)filestats.st_size); - return -3; - } - - f = fopen(filepath, "r"); - if(f==NULL)return errno; - - readsize = fread(filebuffer, 1, filestats.st_size, f); - fclose(f); - - if(readsize!=filestats.st_size) - { - printf("fread() failed with the SD payload.\n"); - return -2; - } - - return 0; -} - -Result savesd_payload(char *filepath, u32 payloadsize) -{ - FILE *f; - size_t writesize=0; - - unlink(filepath); - - f = fopen(filepath, "w+"); - if(f==NULL) - { - printf("Failed to open the SD payload for writing.\n"); - return errno; - } - - writesize = fwrite(filebuffer, 1, payloadsize, f); - fclose(f); - - if(writesize!=payloadsize) - { - printf("fwrite() failed with the SD payload.\n"); - return -2; - } - - return 0; -} - -Result load_hblauncher() -{ - Result ret = 0; - u8 region=0; - u8 new3dsflag = 0; - - OS_VersionBin nver_versionbin; - OS_VersionBin cver_versionbin; - - u32 payloadsize = 0, payloadsize_aligned = 0; - u32 payload_src = 0; - - char payload_sysver[32]; - char payloadurl[0x80]; - char payload_sdpath[0x80]; - - void (*funcptr)(u32*, u32*) = NULL; - u32 *paramblk = NULL; - - memset(&nver_versionbin, 0, sizeof(OS_VersionBin)); - memset(&cver_versionbin, 0, sizeof(OS_VersionBin)); - - memset(payload_sysver, 0, sizeof(payload_sysver)); - memset(payloadurl, 0, sizeof(payloadurl)); - memset(payload_sdpath, 0, sizeof(payload_sdpath)); - - printf("Getting system-version/system-info etc...\n"); - - ret = cfguInit(); - if(ret!=0) - { - printf("Failed to init cfgu: 0x%08x.\n", (unsigned int)ret); - return ret; - } - ret = CFGU_SecureInfoGetRegion(®ion); - if(ret!=0) - { - printf("Failed to get region from cfgu: 0x%08x.\n", (unsigned int)ret); - return ret; - } - if(region>=7) - { - printf("Region value from cfgu is invalid: 0x%02x.\n", (unsigned int)region); - ret = -9; - return ret; - } - cfguExit(); - - APT_CheckNew3DS(&new3dsflag); - - ret = osGetSystemVersionData(&nver_versionbin, &cver_versionbin); - if(ret!=0) - { - printf("Failed to load the system-version: 0x%08x.\n", (unsigned int)ret); - return ret; - } - - snprintf(payload_sysver, sizeof(payload_sysver)-1, "%s-%d-%d-%d-%d-%s", new3dsflag?"NEW":"OLD", cver_versionbin.mainver, cver_versionbin.minor, cver_versionbin.build, nver_versionbin.mainver, regionids_table[region]); - snprintf(payloadurl, sizeof(payloadurl)-1, "http://smea.mtheall.com/get_payload.php?version=%s", payload_sysver); - snprintf(payload_sdpath, sizeof(payload_sdpath)-1, "sdmc:/hblauncherloader_otherapp_payload_%s.bin", payload_sysver); - - printf("Detected system-version: %s %d.%d.%d-%d %s\n", new3dsflag?"New3DS":"Old3DS", cver_versionbin.mainver, cver_versionbin.minor, cver_versionbin.build, nver_versionbin.mainver, regionids_table[region]); - - memset(filebuffer, 0, filebuffer_maxsize); - - hidScanInput(); - - if((hidKeysHeld() & KEY_X) == 0) - { - printf("Since the X button isn't pressed, this will now check for the otherapp payload on SD, with the following filepath: %s\n", payload_sdpath); - ret = loadsd_payload(payload_sdpath, &payloadsize); - } - else - { - printf("Skipping SD payload load-attempt since the X button is pressed.\n"); - ret = 1; - } - - if(ret==0) - { - printf("The otherapp payload for this app already exists on SD, that will be used instead of downloading the payload via HTTP.\n"); - payload_src = 0; - } - else - { - printf("Requesting the actual payload URL with HTTP...\n"); - ret = http_getactual_payloadurl(payloadurl, payloadurl, sizeof(payloadurl)); - if(ret!=0) - { - printf("Failed to request the actual payload URL: 0x%08x.\n", (unsigned int)ret); - if(ret==0xd8a0a046) - { - printf("No usable Internet-connection is likely available.\n"); - } - else - { - printf("If the server isn't down, and the HTTP request was actually done, this may mean your system-version or region isn't supported by the hblauncher-payload currently.\n"); - } - return ret; - } - - printf("Downloading the actual payload with HTTP...\n"); - ret = http_download_payload(payloadurl, &payloadsize); - if(ret!=0) - { - printf("Failed to download the actual payload with HTTP: 0x%08x.\n", (unsigned int)ret); - if(ret==0xd8a0a046) - { - printf("No usable Internet-connection is likely available.\n"); - } - else - { - printf("If the server isn't down, and the HTTP request was actually done, this may mean your system-version or region isn't supported by the hblauncher-payload currently.\n"); - } - return ret; - } - - if(ret==0)payload_src = 1; - } - - printf("Initializing payload data etc...\n"); - - payloadsize_aligned = (payloadsize + 0xfff) & ~0xfff; - if(payloadsize_aligned > PAYLOAD_TEXTMAXSIZE) - { - printf("Invalid payload size: 0x%08x.\n", (unsigned int)payloadsize); - ret = -3; - return ret; - } - - if(payload_src) - { - hidScanInput(); - - if(!(hidKeysHeld() & KEY_Y)) - { - printf("Saving the downloaded payload to SD since the Y button isn't pressed...\n"); - ret = savesd_payload(payload_sdpath, payloadsize); - - if(ret!=0) - { - printf("Payload saving failed: 0x%08x.\n", (unsigned int)ret); - } - else - { - printf("Payload saving was successful.\n"); - } - } - else - { - printf("Skipping saving the downloaded payload to SD since the Y button is pressed.\n"); - } - } - - memcpy(PAYLOAD_TEXTADDR, filebuffer, payloadsize_aligned); - memset(filebuffer, 0, filebuffer_maxsize); - - ret = svcFlushProcessDataCache(0xffff8001, PAYLOAD_TEXTADDR, payloadsize_aligned);//Flush dcache for the payload which was copied into .text. Since that area was never executed, icache shouldn't be an issue. - if(ret!=0) - { - printf("svcFlushProcessDataCache failed: 0x%08x.\n", (unsigned int)ret); - return ret; - } - - paramblk = linearMemAlign(0x10000, 0x1000); - if(paramblk==NULL) - { - ret = 0xfe; - printf("Failed to alloc the paramblk.\n"); - return ret; - } - - httpcExit(); - - memset(paramblk, 0, 0x10000); - - paramblk[0x1c>>2] = (u32)gxlowcmd_4; - paramblk[0x20>>2] = (u32)gsp_flushdcache; - paramblk[0x48>>2] = 0x8d;//flags - paramblk[0x58>>2] = (u32)&gspGpuHandle; - - printf("Jumping into the payload...\n"); - - funcptr = (void*)PAYLOAD_TEXTADDR; - funcptr(paramblk, (u32*)(0x10000000-0x1000)); - - ret = 0xff; - printf("The payload returned back into the app, this should *never* happen with the actual hblauncher-payload.\n"); - - return ret; -} - -int main(int argc, char **argv) -{ - Result ret = 0; - u32 pos; - Handle kproc_handledup=0; - - // Initialize services - gfxInitDefault(); - - consoleInit(GFX_BOTTOM, NULL); - - printf("hblauncher_loader %s by yellows8.\n", VERSION); - - ret = svcDuplicateHandle(&kproc_handledup, 0xffff8001); - if(ret!=0)printf("svcDuplicateHandle() with the current proc-handle failed: 0x%08x.\n", (unsigned int)ret); - - if(ret==0) - { - for(pos=0; pos> 2], 0x0, 0x1000, MEMOP_PROT, MEMPERM_READ | MEMPERM_WRITE | MEMPERM_EXECUTE); - if(ret!=0) - { - printf("svcControlProcessMemory with pos=0x%x failed: 0x%08x.\n", (unsigned int)pos, (unsigned int)ret); - break; - } - } - } - - ret = httpcInit(0); - if(ret!=0) - { - printf("Failed to initialize HTTPC: 0x%08x.\n", (unsigned int)ret); - if(ret==0xd8e06406) - { - printf("The HTTPC service is inaccessible.\n"); - } - } - - if(ret==0) - { - filebuffer_maxsize = PAYLOAD_TEXTMAXSIZE; - - filebuffer = (u8*)malloc(filebuffer_maxsize); - if(filebuffer==NULL) - { - printf("Failed to allocate memory.\n"); - ret = -1; - } - else - { - memset(filebuffer, 0, filebuffer_maxsize); - } - } - - ret = load_hblauncher(); - - free(filebuffer); - - httpcExit(); - - if(ret!=0 && ret!=0xd8a0a046)printf("An error occured, please report this to here if it persists(or comment on an already existing issue if needed), with an image of your 3DS system: https://github.com/yellows8/hblauncher_loader/issues\n"); - - printf("Press the START button to exit.\n"); - // Main loop - while (aptMainLoop()) - { - gspWaitForVBlank(); - hidScanInput(); - - u32 kDown = hidKeysDown(); - if (kDown & KEY_START) - break; - } - - // Exit services - gfxExit(); - return 0; -} -