-made homebrew booting more safe, shouldnt blackscreen

or codedump anymore
This commit is contained in:
fix94.1 2012-05-19 16:06:06 +00:00
parent b0e0b005b3
commit 8643cdfa5a
6 changed files with 44 additions and 68 deletions

View File

@ -24,8 +24,6 @@ static u8 *homebrewbuffer = EXECUTE_ADDR;
static u32 homebrewsize = 0;
static vector<string> Arguments;
bool bootHB;
bool IsDollZ (u8 *buff)
{
u8 dollz_stamp[] = {0x3C};
@ -40,27 +38,11 @@ bool IsDollZ (u8 *buff)
void AddBootArgument(const char * argv)
{
std::string arg(argv);
string arg(argv);
Arguments.push_back(arg);
}
int CopyHomebrewMemory(u8 *temp, u32 pos, u32 len)
{
homebrewsize += len;
memcpy(homebrewbuffer+pos, temp, len);
DCFlushRange(homebrewbuffer+pos, len);
return 1;
}
void FreeHomebrewBuffer()
{
homebrewbuffer = EXECUTE_ADDR;
homebrewsize = 0;
Arguments.clear();
}
int LoadHomebrew(const char * filepath)
int LoadHomebrew(const char *filepath)
{
if(!filepath)
return -1;
@ -73,15 +55,7 @@ int LoadHomebrew(const char * filepath)
u32 filesize = ftell(file);
rewind(file);
if(filesize > 33554431)
return -3;
bool good_read = fread(homebrewbuffer, 1, filesize, file) == filesize;
if (!good_read)
{
fclose(file);
return -4;
}
fread(homebrewbuffer, 1, filesize, file);
fclose(file);
homebrewsize += filesize;
@ -129,9 +103,6 @@ static int SetupARGV(struct __argv * args)
int BootHomebrew()
{
if(homebrewsize == 0)
return -1;
struct __argv args;
if (!IsDollZ(homebrewbuffer))
SetupARGV(&args);
@ -139,13 +110,16 @@ int BootHomebrew()
memcpy(BOOTER_ADDR, app_booter_bin, app_booter_bin_size);
DCFlushRange(BOOTER_ADDR, app_booter_bin_size);
entrypoint entry = (entrypoint) BOOTER_ADDR;
entrypoint entry = (entrypoint)BOOTER_ADDR;
memmove(ARGS_ADDR, &args, sizeof(args));
DCFlushRange(ARGS_ADDR, sizeof(args) + args.length);
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
/* Shutdown IOS subsystems */
u32 level = IRQ_Disable();
__IOS_ShutdownSubsystems();
__exception_closeall();
entry();
IRQ_Restore(level);
return 0;
}

View File

@ -1,10 +1,8 @@
#ifndef _BOOTHOMEBREW_H_
#define _BOOTHOMEBREW_H_
extern bool bootHB;
int BootHomebrew();
int CopyHomebrewMemory(u8 *temp, u32 pos, u32 len);
void AddBootArgument(const char * arg);
void FreeHomebrewBuffer();
int LoadHomebrew(const char * filepath);
int BootHomebrew();
void AddBootArgument(const char * arg);
int LoadHomebrew(const char * filepath);
#endif

View File

@ -136,11 +136,6 @@ int main(int argc, char **argv)
ret = menu.main();
}
}
if (bootHB)
{
//IOS_ReloadIOS(58);
BootHomebrew();
}
Open_Inputs(); //reinit wiimote
} while (ret == 1);

View File

@ -134,7 +134,6 @@ CMenu::CMenu(CVideo &vid) :
m_exit = false;
m_initialCoverStatusComplete = false;
m_reload = false;
bootHB = false;
m_gamesound_changed = false;
m_base_font_size = 0;
m_current_view = COVERFLOW_USB;

View File

@ -32,8 +32,10 @@
using namespace std;
extern "C" {extern u8 currentPartition;}
extern bool bootHB;
extern "C"
{
extern u8 currentPartition;
}
class CMenu
{

View File

@ -515,7 +515,8 @@ void CMenu::_game(bool launch)
gprintf("Launching game %s\n", id.c_str());
_launch(hdr);
if(m_exit || bootHB) break;
if(m_exit)
break;
_hideWaitMessage();
launch = false;
@ -768,29 +769,36 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML)
void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
{
Nand::Instance()->Disable_Emu();
m_reload = true;
gprintf("Filepath of homebrew: %s\n",filepath);
if(LoadHomebrew(filepath))
{
m_gcfg1.save(true);
m_gcfg2.save(true);
m_cat.save(true);
m_cfg.save(true);
AddBootArgument(filepath);
for(u32 i = 0; i < arguments.size(); ++i)
AddBootArgument(arguments[i].c_str());
m_gcfg1.save(true);
m_gcfg2.save(true);
m_cat.save(true);
m_cfg.save(true);
Playlog_Delete();
while(net_get_status() == -EBUSY)
usleep(100);
cleanup();
Close_Inputs();
USBStorage_Deinit();
m_vid.CheckWaitThread(true);
Playlog_Delete();
cleanup();
// wifi and sd gecko doesnt work anymore after cleanup
Close_Inputs();
m_vid.cleanup();
wiiLightOff();
__dsp_shutdown();
Nand::Instance()->Disable_Emu();
bootHB = true;
}
m_exit = true;
LoadHomebrew(filepath);
DeviceHandler::DestroyInstance();
USBStorage_Deinit();
AddBootArgument(filepath);
for(u32 i = 0; i < arguments.size(); ++i)
AddBootArgument(arguments[i].c_str());
gprintf("Booting Homebrew application...\n");
BootHomebrew();
}
int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id)