This commit is contained in:
meepingsnesroms 2018-05-09 18:23:35 -07:00
parent 5f234f0dd1
commit 1a6f572405
5 changed files with 43 additions and 20 deletions

View File

@ -45,22 +45,23 @@ int exec_3dsx(const char* path, const char* args){
inited = loader_Rosalina.init();
if(inited){
loader_Rosalina.launchFile(path, &newProgramArgs, NULL);
exit(0);
//exit(0);
}
inited = loader_Ninjhax2.init();
if(inited){
loader_Ninjhax2.launchFile(path, &newProgramArgs, NULL);
exit(0);
//exit(0);
}
inited = loader_Ninjhax1.init();
if(inited){
loader_Ninjhax1.launchFile(path, &newProgramArgs, NULL);
exit(0);
//exit(0);
}
//should never be reached
errno = ENOTSUP;
return -1;
//errno = ENOTSUP;
//return -1;
return 0;
}

View File

@ -1 +1,8 @@
#ifndef EXEC_3DSX_H
#define EXEC_3DSX_H
//since 3dsx programs are not guaranteed access to the OS, the 3dsx bootloader run by the exploit must run the next program
//your program must call this then exit gracefully to work, exit() also doesnt work
int exec_3dsx(const char* path, const char* args);
#endif

View File

@ -14,6 +14,15 @@ typedef struct{
}ciaParam;
static void errorAndQuit(const char* errorStr){
errorConf error;
errorInit(&error, ERROR_TEXT, CFG_LANGUAGE_EN);
errorText(&error, errorStr);
errorDisp(&error);
exit(0);
}
static int isCiaInstalled(u64 titleId){
u32 titlesToRetrieve;
u32 titlesRetrieved;
@ -71,6 +80,8 @@ static int installCia(Handle ciaFile){
failed = FSFILE_Write(outputHandle, &bytesWritten, fileOffset, transferBuffer, bytesRead, 0);
if(R_FAILED(failed)){
AM_CancelCIAInstall(outputHandle);
if(R_DESCRIPTION(failed) == RD_ALREADY_EXISTS)
return 1;
return -1;
}
@ -100,15 +111,6 @@ static u64 getCiaTitleId(Handle ciaFile){
return ciaInfo.titleID;
}
static void errorAndQuit(const char* errorStr){
errorConf error;
errorInit(&error, ERROR_TEXT, CFG_LANGUAGE_EN);
errorText(&error, errorStr);
errorDisp(&error);
exit(0);
}
int exec_cia(const char* path, const char* args){
struct stat sBuff;
bool fileExists;
@ -132,6 +134,7 @@ int exec_cia(const char* path, const char* args){
inited = R_SUCCEEDED(amInit()) && R_SUCCEEDED(fsInit());
if(inited){
Result res;
int error;
FS_Archive ciaArchive;
Handle ciaFile;
u64 titleId;
@ -202,8 +205,15 @@ int exec_cia(const char* path, const char* args){
}
res = APT_PrepareToDoApplicationJump(0, titleId, 0x1);
if(R_SUCCEEDED(res))
res = APT_DoApplicationJump(&param, sizeof(param.argc) + argsLength, __argv_hmac);
if(R_FAILED(res))
errorAndQuit("CIA cant run, cant prepare.");
res = APT_DoApplicationJump(&param, sizeof(param.argc) + argsLength, __argv_hmac);
if(R_FAILED(res))
errorAndQuit("CIA cant run, cant jump.");
//wait for application jump, for some reason its not instant
while(1);
}
//should never be reached

View File

@ -1 +1,6 @@
#ifndef EXEC_CIA_H
#define EXEC_CIA_H
int exec_cia(const char* path, const char* args);
#endif

View File

@ -182,6 +182,7 @@ static void frontend_ctr_deinit(void* data)
static void frontend_ctr_exec(const char* path, bool should_load_game)
{
int error = 0;
char args[0x300 - 0x4];
DEBUG_VAR(path);
@ -223,16 +224,15 @@ static void frontend_ctr_exec(const char* path, bool should_load_game)
}
}
#endif
int error;
if (envIsHomebrew())
error = exec_3dsx(path, args);
else
error = exec_cia(path, args);
if (error)
RARCH_LOG("Cant execute new core:%s.\n", strerror(errno));
}
svcSleepThread(INT64_MAX);
if (error)
RARCH_LOG("Cant execute new core:%s.\n", strerror(errno));
}
#ifndef IS_SALAMANDER