-made exit to neek2o more safe to use (codedumps should be gone)

This commit is contained in:
fix94.1 2012-08-22 19:09:21 +00:00
parent 6639e1977c
commit 4664af265f
7 changed files with 84 additions and 58 deletions

View File

@ -35,6 +35,8 @@
bool checked = false; bool checked = false;
bool neek = false; bool neek = false;
u32 kernelSize = 0;
void *Kernel = NULL;
bool neek2o(void) bool neek2o(void)
{ {
@ -48,6 +50,33 @@ bool neek2o(void)
return neek; return neek;
} }
bool Load_Neek2o_Kernel()
{
if(neek2o())
return true;
FILE *file = NULL;
file = fopen("usb1:/sneek/kernel.bin", "rb");
if(!file)
file = fopen("sd:/sneek/kernel.bin", "rb");
if(file)
{
fseek(file , 0 , SEEK_END);
kernelSize = ftell(file);
rewind(file);
Kernel = malloc(kernelSize);
if(!Kernel)
{
fclose(file);
return false;
}
fread(Kernel, 1, kernelSize, file);
fclose(file);
return true;
}
return false;
}
s32 Launch_nk(u64 TitleID, const char *nandpath) s32 Launch_nk(u64 TitleID, const char *nandpath)
{ {
if(neek2o()) if(neek2o())
@ -55,34 +84,14 @@ s32 Launch_nk(u64 TitleID, const char *nandpath)
SYS_ResetSystem(SYS_RESTART, 0, 0); SYS_ResetSystem(SYS_RESTART, 0, 0);
return 1; return 1;
} }
memcpy((void*)0x91000000, Kernel, kernelSize);
FILE *file = NULL; DCFlushRange((void*)0x91000000, kernelSize);
long fsize; free(Kernel);
file = fopen( "usb1:/sneek/kernel.bin", "rb" );
if(!file)
file = fopen( "sd:/sneek/kernel.bin", "rb" );
if(file)
{
fseek(file , 0 , SEEK_END);
fsize = ftell(file);
rewind(file);
fread((void *)0x91000000, 1, fsize, file);
DCFlushRange((void *)0x91000000, fsize);
}
else
return 0;
fclose(file);
memcfg *MC = (memcfg*)malloc(sizeof(memcfg)); memcfg *MC = (memcfg*)malloc(sizeof(memcfg));
if(MC == NULL) if(MC == NULL)
return 0; return 0;
memset(MC, 0, sizeof(memcfg)); memset(MC, 0, sizeof(memcfg));
MC->magic = 0x666c6f77; MC->magic = 0x666c6f77;
MC->titleid = TitleID; MC->titleid = TitleID;
@ -91,7 +100,6 @@ s32 Launch_nk(u64 TitleID, const char *nandpath)
strcpy(MC->nandpath, nandpath); strcpy(MC->nandpath, nandpath);
MC->config |= NCON_EXT_NAND_PATH; MC->config |= NCON_EXT_NAND_PATH;
} }
memcpy((void *)0x81200000, MC, sizeof(memcfg)); memcpy((void *)0x81200000, MC, sizeof(memcfg));
DCFlushRange((void *)(0x81200000), sizeof(memcfg)); DCFlushRange((void *)(0x81200000), sizeof(memcfg));
free(MC); free(MC);

View File

@ -25,6 +25,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
s32 Launch_nk(u64 TitleID, const char *nandpath); s32 Launch_nk(u64 TitleID, const char *nandpath);
bool Load_Neek2o_Kernel();
bool neek2o(void); bool neek2o(void);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -12,22 +12,24 @@
#include "mload.h" #include "mload.h"
#include "sys.h" #include "sys.h"
#include "channel/channel_launcher.h" #include "channel/channel_launcher.h"
#include "loader/nk.h"
#include "gecko/gecko.h" #include "gecko/gecko.h"
#include "memory/mem2.hpp" #include "memory/mem2.hpp"
#include "memory/memory.h" #include "memory/memory.h"
#include "wiiuse/wpad.h" #include "wiiuse/wpad.h"
/* Variables */ /* Variables */
static bool reset = false; bool reset = false;
static bool shutdown = false; bool shutdown = false;
bool exiting = false; bool exiting = false;
static bool priiloader_def = false; bool priiloader_def = false;
static bool return_to_hbc = false; bool return_to_hbc = false;
static bool return_to_menu = false; bool return_to_menu = false;
static bool return_to_priiloader = false; bool return_to_priiloader = false;
static bool return_to_disable = false; bool return_to_disable = false;
static bool return_to_bootmii = false; bool return_to_bootmii = false;
bool return_to_neek2o = false;
extern void __exception_closeall(); extern void __exception_closeall();
extern u32 __PADDisableRecalibration(s32 disable); extern u32 __PADDisableRecalibration(s32 disable);
@ -85,6 +87,7 @@ void Sys_ExitTo(int option)
return_to_priiloader = option == EXIT_TO_PRIILOADER; return_to_priiloader = option == EXIT_TO_PRIILOADER;
return_to_disable = option == EXIT_TO_DISABLE; return_to_disable = option == EXIT_TO_DISABLE;
return_to_bootmii = option == EXIT_TO_BOOTMII; return_to_bootmii = option == EXIT_TO_BOOTMII;
return_to_neek2o = option == EXIT_TO_NEEK2O;
//magic word to force wii menu in priiloader. //magic word to force wii menu in priiloader.
if(return_to_menu) if(return_to_menu)
@ -114,6 +117,12 @@ void Sys_Exit(void)
/* Shutdown Inputs */ /* Shutdown Inputs */
Close_Inputs(); Close_Inputs();
if(return_to_neek2o)
{
Launch_nk(0x1000144574641LL, NULL);
while(1);
}
WII_Initialize(); WII_Initialize();
if(return_to_menu || return_to_priiloader || priiloader_def) if(return_to_menu || return_to_priiloader || priiloader_def)
Sys_LoadMenu(); Sys_LoadMenu();

View File

@ -14,12 +14,16 @@ extern "C" {
#define RETURN_CHANNEL 0x0001000857494948ULL #define RETURN_CHANNEL 0x0001000857494948ULL
#define SYSTEM_MENU 0x0000000100000002ULL #define SYSTEM_MENU 0x0000000100000002ULL
#define PRIILOADER_DEF 0 enum
#define EXIT_TO_MENU 1 {
#define EXIT_TO_HBC 2 PRIILOADER_DEF = 0,
#define EXIT_TO_PRIILOADER 3 EXIT_TO_MENU,
#define EXIT_TO_DISABLE 4 EXIT_TO_HBC,
#define EXIT_TO_BOOTMII 5 EXIT_TO_PRIILOADER,
EXIT_TO_DISABLE,
EXIT_TO_BOOTMII,
EXIT_TO_NEEK2O,
};
/* Prototypes */ /* Prototypes */
void Sys_Init(void); void Sys_Init(void);

View File

@ -1087,12 +1087,13 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
if(useNK2o && !emu_disabled) if(useNK2o && !emu_disabled)
{ {
cleanup(true); if(!Load_Neek2o_Kernel())
if(!Launch_nk(gameTitle, emuPath.c_str()))
{ {
error(_t("errneek1", L"Cannot launch neek2o. Verify your neek2o setup")); error(_t("errneek1", L"Cannot launch neek2o. Verify your neek2o setup"));
Sys_LoadMenu(); Sys_LoadMenu();
} }
cleanup();
Launch_nk(gameTitle, emuPath.c_str());
while(1); while(1);
} }
else else

View File

@ -139,11 +139,13 @@ bool CMenu::_ExitTo(void)
} }
else if(m_btnMgr.selected(m_homeBtnExitToNeek)) else if(m_btnMgr.selected(m_homeBtnExitToNeek))
{ {
if(!Launch_nk(0x1000144574641LL, NULL)) if(!Load_Neek2o_Kernel())
{ {
error(sfmt("errneek1", L"Cannot launch neek2o. Verify your neek2o setup")); error(sfmt("errneek1", L"Cannot launch neek2o. Verify your neek2o setup"));
exitHandler(2); exitHandler(2);
} }
else
exitHandler(5);
break; break;
} }
} }

View File

@ -241,8 +241,9 @@ void CMenu::exitHandler(int ExitTo)
else else
Sys_ExitTo(EXIT_TO_HBC); Sys_ExitTo(EXIT_TO_HBC);
} }
else if(ExitTo == 5) //Neek2o kernel
Sys_ExitTo(EXIT_TO_NEEK2O);
} }
m_reload = (BTN_B_HELD || m_disable_exit); m_reload = (BTN_B_HELD || m_disable_exit);
if(m_exit) if(m_exit)
{ {