s32 main (void) { // Initialize services srvInit(); aptInit(); hidInit(NULL); gfxInitDefault(); fsInit(); sdmcInit(); hbInit(); qtmInit(); Handle fileHandle; u32 bytesRead; FS_archive sdmcArchive=(FS_archive){ARCH_SDMC, (FS_path){PATH_EMPTY, 1, (u8*)""}}; FS_path filePath=FS_makePath(PATH_CHAR, "/rxTools.dat"); Result ret=FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE); if(ret) goto EXIT; FSFILE_Read(fileHandle, &bytesRead, 0x20000, 0x14400000, 320*1024); FSFILE_Close(fileHandle); consoleInit(GFX_BOTTOM, NULL); if (brahma_init()) { quick_boot_firm(1); printf("[!] Quickload failed\n"); brahma_exit(); } else { printf("* BRAHMA *\n\n[!]Not enough memory\n"); wait_any_key(); } EXIT: hbExit(); sdmcExit(); fsExit(); gfxExit(); hidExit(); aptExit(); srvExit(); // Return to hbmenu return 0; }
s32 main(void) { // Initialize services srvInit(); aptInit(); hidInit(NULL); gfxInitDefault(); gfxSet3D(true); fsInit(); sdmcInit(); hbInit(); qtmInit(); gfxSwapBuffers(); Handle fileHandle; u32 bytesRead; FS_archive sdmcArchive = (FS_archive){ ARCH_SDMC, (FS_path){ PATH_EMPTY, 1, (u8*)"" } }; FS_path filePath = FS_makePath(PATH_CHAR, "/" CODE_PATH); Result ret = FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE); if (ret) goto EXIT; FSFILE_Read(fileHandle, &bytesRead, 0x14000, 0x14400000, 320 * 1024); FSFILE_Close(fileHandle); if (brahma_init()) { quick_boot_firm(1); brahma_exit(); } EXIT: hbExit(); sdmcExit(); fsExit(); gfxExit(); hidExit(); aptExit(); srvExit(); // Return to hbmenu return 0; }
int main() { // Initialize services srvInit(); aptInit(); hidInit(NULL); gfxInitDefault(); fsInit(); sdmcInit(); hbInit(); qtmInit(); hidScanInput(); u32 kDown = hidKeysDown(); u32 kHeld = hidKeysHeld(); //Load the configuration loadConfiguration(); //Check kernel version getSystemVersion(); //checks if the CFW has to boot right away or open the GUI if(auto_boot == '2') auto_boot = '2'; //here it checks if the "force GUI" is set, and preservs it if it is set else if(kHeld & KEY_L) auto_boot = '0'; //here it will start the GUI only this time else auto_boot = '1'; //here it won't show the GUI //checks if the CFW has to disable firmlaunch if (kHeld & KEY_R && firmlaunch == '0') firmlaunch = '2'; //here we enable the firmlaunch only this time else if (kHeld & KEY_R && firmlaunch == '1')firmlaunch = '3'; //here we disable the firmlaunch only this time //Then we save the configuration saveConfiguration(); //Proceeds to launch the loader.bin bootCFW_FirstStage(); }
/** * \brief Initialize Heartbeat Data Structure to Default values * * Use defined values for ping threshold and stale threshold * \returns * A pointer to a block of memory containing the heartbeat data structure */ HeartbeatStatus *hbInitDefault(void) { // Init with standard ping threshold for the device return hbInit(ping_thres_default, stale_thres_default); }
int main(int argc, char **argv) { srvInit(); aptInit(); gfxInit(); acInit(); initCfgu(); ptmInit(); hidInit(NULL); irrstInit(NULL); fsInit(); hbInit(); Handle fileHandle; u64 size; u32 bytesRead; int restore; // Set main script char path[256]; if (argc > 0){ int latest_slash = 0; int i=5; while (argv[0][i] != '\0'){ if (argv[0][i] == '/'){ latest_slash = i; } i++; } strcpy(path,&argv[0][5]); path[latest_slash-5] = 0; strcpy(start_dir,path); strcpy(cur_dir,path); // Set current dir }else{ strcpy(start_dir,"/"); strcpy(cur_dir,"/"); // Set current dir for GW Mode } while(aptMainLoop()) { restore=0; char error[256]; errMsg = runScript((const char*)index_lua, true); if (errMsg != NULL); { // Fake error to force interpreter shutdown if (strstr(errMsg, "lpp_exit_04")){ break; } strcpy(error,"Error: "); strcat(error,errMsg); strcat(error,"\n\nPress A to restart\nPress B to exit"); } while (restore==0){ gspWaitForVBlank(); RefreshScreen(); ClearScreen(0); ClearScreen(1); DebugOutput(error); hidScanInput(); if(hidKeysDown() & KEY_A){ strcpy(cur_dir,start_dir); restore=1; }else if(hidKeysDown() & KEY_B){ restore=2; } gfxFlushBuffers(); gfxSwapBuffers(); } if (restore==2){ break; } } fsExit(); irrstExit(); hidExit(); ptmExit(); hbExit(); acExit(); exitCfgu(); gfxExit(); aptExit(); srvExit(); return 0; }
int main(int argc, char **argv) { srvInit(); aptInit(); gfxInitDefault(); acInit(); cfguInit(); httpcInit(); ptmuInit(); hidInit(); irrstInit(); aptOpenSession(); Result ret=APT_SetAppCpuTimeLimit(30); aptCloseSession(); fsInit(); ftp_state = false; isTopLCDOn = true; isBottomLCDOn = true; Handle fileHandle; u64 size; u32 bytesRead; int restore; // Check user build and enables kernel access if (nsInit()==0){ CIA_MODE = true; nsExit(); }else CIA_MODE = false; isNinjhax2 = false; if (!hbInit()) khaxInit(); else isNinjhax2 = true; // Select Audio System (csnd:SND preferred) if (csndInit() == 0){ csndAccess = true; csndExit(); }else csndAccess = false; // Init Audio-Device int i = 0; for (i=0;i < 32; i++){ audioChannels[i] = false; if (!isNinjhax2 && (i < 0x08)) audioChannels[i] = true; else if (csndAccess && (i < 0x08)) audioChannels[i] = true; } // Set main script char path[256]; if (argc > 0){ int latest_slash = 0; int i=5; while (argv[0][i] != '\0'){ if (argv[0][i] == '/') latest_slash = i; i++; } strcpy(path,&argv[0][5]); path[latest_slash-5] = 0; strcpy(start_dir,path); strcpy(cur_dir,path); // Set current dir strcat(path,"/index.lua"); }else{ strcpy(start_dir,"/"); strcpy(cur_dir,"/"); // Set current dir for GW Mode strcpy(path,"/index.lua"); } while(aptMainLoop()) { restore=0; char error[2048]; // Load main script FS_Path filePath=fsMakePath(PATH_ASCII, path); FS_Archive script=(FS_Archive){ARCHIVE_SDMC, (FS_Path){PATH_EMPTY, 1, (u8*)""}}; Result ret = FSUSER_OpenFileDirectly(&fileHandle, script, filePath, FS_OPEN_READ, 0x00000000); if (!ret){ FSFILE_GetSize(fileHandle, &size); buffer = (unsigned char*)(malloc((size+1) * sizeof (char))); FSFILE_Read(fileHandle, &bytesRead, 0x0, buffer, size); buffer[size]=0; FSFILE_Close(fileHandle); svcCloseHandle(fileHandle); errMsg = runScript((const char*)buffer, true); free(buffer); }else errMsg = "index.lua file not found."; // Force LCDs power on if ((!isTopLCDOn) || (!isBottomLCDOn)){ gspLcdInit(); if (!isTopLCDOn) GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_TOP); if (!isBottomLCDOn) GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTTOM); gspLcdExit(); isTopLCDOn = true; isBottomLCDOn = true; } // Fake error to force interpreter shutdown if (strstr(errMsg, "lpp_exit_04")) break; if (ftp_state) ftp_exit(); ftp_state = false; int connfd; while (restore==0){ gspWaitForVBlank(); RefreshScreen(); ClearScreen(0); ClearScreen(1); strcpy(error,"Error: "); strcat(error,errMsg); if (ftp_state){ u32 ip=(u32)gethostid(); char ip_address[64]; strcat(error,"\n\nPress A to restart\nPress B to exit\nPress Y to enable FTP server\n\nFTP state: ON\nIP: "); sprintf(ip_address,"%lu.%lu.%lu.%lu", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF); strcat(error,ip_address); strcat(error,"\nPort: 5000"); if(connfd<0)connfd=ftp_getConnection(); else{ int ret=ftp_frame(connfd); if(ret==1) connfd=-1; } }else strcat(error,"\n\nPress A to restart\nPress B to exit\nPress Y to enable FTP server\n\nFTP state: OFF"); DebugOutput(error); hidScanInput(); if(hidKeysDown() & KEY_A){ strcpy(cur_dir,start_dir); restore=1; }else if(hidKeysDown() & KEY_B){ restore=2; }else if(hidKeysDown() & KEY_Y){ if (!ftp_state){ u32 wifiStatus; if ((u32)ACU_GetWifiStatus(&wifiStatus) != 0xE0A09D2E){ if (wifiStatus != 0){ ftp_init(); connfd = -1; ftp_state = true; } } } } gfxFlushBuffers(); gfxSwapBuffers(); } if (ftp_state) ftp_exit(); if (isCSND){ if (csndAccess) csndExit(); else ndspExit(); isCSND = false; } if (restore==2){ break; } }