Fix running from browser_hax, still broken when using payload multi loader

This commit is contained in:
Maschell 2020-12-15 22:29:45 +01:00
parent 82352eae9f
commit 7a663a151a
6 changed files with 31 additions and 52 deletions

View File

@ -68,7 +68,7 @@ EXPORT_DECL(int, OSTryLockMutex, void* mutex);
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EXPORT_DECL(u64, OSGetTitleID, void); EXPORT_DECL(u64, OSGetTitleID, void);
EXPORT_DECL(void, OSGetArgcArgv, int* argc, char*** argv); EXPORT_DECL(void, OSGetArgcArgv, int* argc, char*** argv);
EXPORT_DECL(void, __Exit, void); EXPORT_DECL(void, __Exit, int);
EXPORT_DECL(void, OSSavesDone_ReadyToRelease, void); EXPORT_DECL(void, OSSavesDone_ReadyToRelease, void);
EXPORT_DECL(void, OSFatal, const char* msg); EXPORT_DECL(void, OSFatal, const char* msg);
EXPORT_DECL(void, OSSetExceptionCallback, u8 exceptionType, exception_callback newCallback); EXPORT_DECL(void, OSSetExceptionCallback, u8 exceptionType, exception_callback newCallback);
@ -155,7 +155,7 @@ void InitOSFunctionPointers(void)
OS_FIND_EXPORT(coreinit_handle, __os_snprintf); OS_FIND_EXPORT(coreinit_handle, __os_snprintf);
OS_FIND_EXPORT(coreinit_handle, __gh_errno_ptr); OS_FIND_EXPORT(coreinit_handle, __gh_errno_ptr);
OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit); OSDynLoad_FindExport(coreinit_handle, 0, "exit", &__Exit);
OS_FIND_EXPORT(coreinit_handle, OSScreenInit); OS_FIND_EXPORT(coreinit_handle, OSScreenInit);
OS_FIND_EXPORT(coreinit_handle, OSScreenShutdown); OS_FIND_EXPORT(coreinit_handle, OSScreenShutdown);

View File

@ -32,6 +32,8 @@
extern "C" { extern "C" {
#endif #endif
#define BUS_SPEED 248625000 #define BUS_SPEED 248625000
#define SECS_TO_TICKS(sec) (((unsigned long long)(sec)) * (BUS_SPEED/4)) #define SECS_TO_TICKS(sec) (((unsigned long long)(sec)) * (BUS_SPEED/4))
#define MILLISECS_TO_TICKS(msec) (SECS_TO_TICKS(msec) / 1000) #define MILLISECS_TO_TICKS(msec) (SECS_TO_TICKS(msec) / 1000)
@ -40,6 +42,9 @@ extern "C" {
#define usleep(usecs) OSSleepTicks(MICROSECS_TO_TICKS(usecs)) #define usleep(usecs) OSSleepTicks(MICROSECS_TO_TICKS(usecs))
#define sleep(secs) OSSleepTicks(SECS_TO_TICKS(secs)) #define sleep(secs) OSSleepTicks(SECS_TO_TICKS(secs))
#define os_usleep(usecs) OSSleepTicks(MICROSECS_TO_TICKS(usecs))
#define os_sleep(secs) OSSleepTicks(SECS_TO_TICKS(secs))
#define FLUSH_DATA_BLOCK(addr) asm volatile("dcbf 0, %0; sync" : : "r"(((addr) & ~31))) #define FLUSH_DATA_BLOCK(addr) asm volatile("dcbf 0, %0; sync" : : "r"(((addr) & ~31)))
#define INVAL_DATA_BLOCK(addr) asm volatile("dcbi 0, %0; sync" : : "r"(((addr) & ~31))) #define INVAL_DATA_BLOCK(addr) asm volatile("dcbi 0, %0; sync" : : "r"(((addr) & ~31)))
@ -110,7 +115,7 @@ extern int (* OSTryLockMutex)(void* mutex);
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
extern u64 (* OSGetTitleID)(void); extern u64 (* OSGetTitleID)(void);
extern void (* OSGetArgcArgv)(int* argc, char*** argv); extern void (* OSGetArgcArgv)(int* argc, char*** argv);
extern void (* __Exit)(void); extern void (* __Exit)(int);
extern void (* OSSavesDone_ReadyToRelease)(void); extern void (* OSSavesDone_ReadyToRelease)(void);
extern void (* OSFatal)(const char* msg); extern void (* OSFatal)(const char* msg);
extern void (* DCFlushRange)(const void *addr, u32 length); extern void (* DCFlushRange)(const void *addr, u32 length);

View File

@ -114,7 +114,7 @@ int _start(int argc, char **argv) {
unsigned int bufferU32 = 0x4E800421; unsigned int bufferU32 = 0x4E800421;
KernelWriteU32(repl_addr,bufferU32,&private_data); KernelWriteU32(repl_addr,bufferU32,&private_data);
return Menu_Main(); return Menu_Main(argc, argv);
} }
/* Write a 32-bit word with kernel permissions */ /* Write a 32-bit word with kernel permissions */

View File

@ -43,10 +43,7 @@ bool CheckRunning() {
return true; return true;
} }
int Menu_Main(int argc, char ** argv){
int Menu_Main(void)
{
//!---------INIT--------- //!---------INIT---------
InitOSFunctionPointers(); InitOSFunctionPointers();
InitSysFunctionPointers(); InitSysFunctionPointers();
@ -55,60 +52,37 @@ int Menu_Main(void)
InitVPadFunctionPointers(); InitVPadFunctionPointers();
InitProcUIFunctionPointers(); InitProcUIFunctionPointers();
u64 currenTitleId = OSGetTitleID();
VPADInit();
/*int forceMenu = 0;
{
VPADData vpad;
int vpadError = -1;
VPADRead(0, &vpad, 1, &vpadError);
if(vpadError == 0)
{
forceMenu = (vpad.btns_d | vpad.btns_h) & VPAD_BUTTON_B;
}
}*/
//mount_sd_fat("sd");
cfw_config_t config; cfw_config_t config;
default_config(&config); default_config(&config);
//read_config(&config);
int launch = 1; //int launch = 1;
ShowMenu(&config);
//if(forceMenu || config.directLaunch == 0)
//{
launch = ShowMenu(&config);
//}
ExecuteIOSExploit(&config); ExecuteIOSExploit(&config);
if ( if (
OSGetTitleID() == 0x000500101004A200L || // mii maker eur OSGetTitleID() == 0x000500101004A200L || // mii maker eur
OSGetTitleID() == 0x000500101004A100L || // mii maker usa OSGetTitleID() == 0x000500101004A100L || // mii maker usa
OSGetTitleID() == 0x000500101004A000L) { // mii maker jpn OSGetTitleID() == 0x000500101004A000L) { // mii maker jpn
// restart mii maker. // restart mii maker.
OSForceFullRelaunch(); OSForceFullRelaunch();
SYSLaunchMenu(); SYSLaunchMenu();
exit(0); return ( (int (*)(int, char **))(*(unsigned int*)0x1005E040) )(argc, argv);
} else {
ProcUIInit(OSSavesDone_ReadyToRelease);
OSForceFullRelaunch();
SYSLaunchMenu();
while (CheckRunning()) {
// wait.
OSSleepTicks(MILLISECS_TO_TICKS(100));
}
ProcUIShutdown();
return 0;
} }
ProcUIInit(OSSavesDone_ReadyToRelease);
OSForceFullRelaunch();
SYSLaunchMenu();
while (CheckRunning()) {
log_printf_("check");
// wait.
OSSleepTicks(MILLISECS_TO_TICKS(100));
}
ProcUIShutdown();
log_printf_("exit");
return 0; return 0;
} }

View File

@ -11,7 +11,7 @@ extern "C" {
#endif #endif
//! C wrapper for our C++ functions //! C wrapper for our C++ functions
int Menu_Main(void); int Menu_Main(int argc, char ** argv);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -265,7 +265,7 @@ int ShowMenu(cfw_config_t * currentConfig)
initScreen = 0; initScreen = 0;
} }
usleep(20000); os_usleep(20000);
} }
OSScreenShutdown(); OSScreenShutdown();