mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 08:37:41 +00:00
Remove quote parsing
This commit is contained in:
parent
8617690499
commit
ce0d8bb5e0
@ -13,10 +13,11 @@ extern const loaderFuncs_s loader_Rosalina;
|
|||||||
static void (*launch_3dsx)(const char* path, argData_s* args, executableMetadata_s* em);
|
static void (*launch_3dsx)(const char* path, argData_s* args, executableMetadata_s* em);
|
||||||
|
|
||||||
|
|
||||||
static int exec_3dsx_actual(const char* path, const char* args, bool appendPath){
|
static int exec_3dsx_actual(const char* path, const char** args, bool appendPath){
|
||||||
struct stat sBuff;
|
struct stat sBuff;
|
||||||
argData_s newProgramArgs;
|
argData_s newProgramArgs;
|
||||||
char* writeableString[0x400];
|
unsigned int argChars = 0;
|
||||||
|
unsigned int argNum = 0;
|
||||||
bool fileExists;
|
bool fileExists;
|
||||||
bool inited;
|
bool inited;
|
||||||
|
|
||||||
@ -39,12 +40,16 @@ static int exec_3dsx_actual(const char* path, const char* args, bool appendPath)
|
|||||||
memset(newProgramArgs.buf, '\0', sizeof(newProgramArgs.buf));
|
memset(newProgramArgs.buf, '\0', sizeof(newProgramArgs.buf));
|
||||||
newProgramArgs.dst = (char*)&newProgramArgs.buf[1];
|
newProgramArgs.dst = (char*)&newProgramArgs.buf[1];
|
||||||
if(appendPath){
|
if(appendPath){
|
||||||
strcpy(writeableString, path);
|
strcpy(newProgramArgs.dst, path);
|
||||||
launchAddArg(&newProgramArgs, writeableString);
|
newProgramArgs.dst += strlen(path) + 1;
|
||||||
|
newProgramArgs.buf[0]++;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(args != NULL && args[0] != '\0'){
|
while(args[argNum] != NULL){
|
||||||
strcpy(writeableString, args);
|
strcpy(newProgramArgs.dst, args[argNum]);
|
||||||
launchAddArgsFromString(&newProgramArgs, writeableString);
|
newProgramArgs.dst += strlen(args[argNum]) + 1;
|
||||||
|
newProgramArgs.buf[0]++;
|
||||||
|
argNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
inited = loader_Rosalina.init();
|
inited = loader_Rosalina.init();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
//since 3dsx programs are not guaranteed access to the OS, the 3dsx bootloader run by the exploit must run the next program
|
//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 have no extra threads running when this is called, these limits do not apply to exec_cia
|
//your program must have no extra threads running when this is called, these limits do not apply to exec_cia
|
||||||
int exec_3dsx_no_path_in_args(const char* path, const char* args);
|
int exec_3dsx_no_path_in_args(const char* path, const char** args);
|
||||||
int exec_3dsx(const char* path, const char* args);
|
int exec_3dsx(const char* path, const char** args);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -115,7 +115,7 @@ static int installCia(Handle ciaFile){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int exec_cia(const char* path, const char* args){
|
int exec_cia(const char* path, const char** args){
|
||||||
struct stat sBuff;
|
struct stat sBuff;
|
||||||
bool fileExists;
|
bool fileExists;
|
||||||
bool inited;
|
bool inited;
|
||||||
@ -175,38 +175,12 @@ int exec_cia(const char* path, const char* args){
|
|||||||
|
|
||||||
param.argc = 0;
|
param.argc = 0;
|
||||||
argsLength = 0;
|
argsLength = 0;
|
||||||
if(args != NULL && args[0] != '\0'){
|
char* argLocation = param.args;
|
||||||
bool inSingleQuotes = false;
|
while(args[param.argc] != NULL){
|
||||||
bool inDoubleQuotes = false;
|
strcpy(argLocation, args[param.argc]);
|
||||||
int argStringLength = strlen(args);
|
argLocation += strlen(args[param.argc]) + 1;
|
||||||
|
argsLength += strlen(args[param.argc]) + 1;
|
||||||
//build argument list like a terminal command on linux
|
|
||||||
for(unsigned int argPtr = 0; argPtr <= argStringLength; argPtr++){
|
|
||||||
if(args[argPtr] == '\''){
|
|
||||||
inSingleQuotes = !inSingleQuotes;
|
|
||||||
}
|
|
||||||
else if(args[argPtr] == '\"'){
|
|
||||||
inDoubleQuotes = !inDoubleQuotes;
|
|
||||||
}
|
|
||||||
else if(args[argPtr] == '\0'){
|
|
||||||
//last character in a valid arg string, end of last arg
|
|
||||||
if(param.args[0] != '\0')
|
|
||||||
param.argc++;
|
param.argc++;
|
||||||
param.args[argsLength] = args[argPtr];
|
|
||||||
argsLength++;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(!inSingleQuotes && !inDoubleQuotes && args[argPtr] == ' '){
|
|
||||||
param.argc++;
|
|
||||||
param.args[argsLength] = '\0';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
param.args[argsLength] = args[argPtr];
|
|
||||||
}
|
|
||||||
|
|
||||||
argsLength++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = APT_PrepareToDoApplicationJump(0, ciaInfo.titleID, 0x1);
|
res = APT_PrepareToDoApplicationJump(0, ciaInfo.titleID, 0x1);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef EXEC_CIA_H
|
#ifndef EXEC_CIA_H
|
||||||
#define EXEC_CIA_H
|
#define EXEC_CIA_H
|
||||||
|
|
||||||
int exec_cia(const char* path, const char* args);
|
int exec_cia(const char* path, const char** args);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,66 +1,5 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
size_t launchAddArg(argData_s* ad, const char* arg)
|
|
||||||
{
|
|
||||||
size_t len = strlen(arg)+1;
|
|
||||||
if ((ad->dst+len) >= (char*)(ad+1)) return len; // Overflow
|
|
||||||
ad->buf[0]++;
|
|
||||||
strcpy(ad->dst, arg);
|
|
||||||
ad->dst += len;
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
void launchAddArgsFromString(argData_s* ad, char* arg)
|
|
||||||
{
|
|
||||||
char c, *pstr, *str=arg, *endarg = arg+strlen(arg);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = *str++;
|
|
||||||
} while ((c == ' ' || c == '\t') && str < endarg);
|
|
||||||
|
|
||||||
pstr = str-1;
|
|
||||||
|
|
||||||
if (c == '\"')
|
|
||||||
{
|
|
||||||
pstr++;
|
|
||||||
while(*str++ != '\"' && str < endarg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (c == '\'')
|
|
||||||
{
|
|
||||||
pstr++;
|
|
||||||
while(*str++ != '\'' && str < endarg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = *str++;
|
|
||||||
} while (c != ' ' && c != '\t' && str < endarg);
|
|
||||||
}
|
|
||||||
|
|
||||||
str--;
|
|
||||||
|
|
||||||
if (str == (endarg - 1))
|
|
||||||
{
|
|
||||||
if(*str == '\"' || *str == '\'')
|
|
||||||
*(str++) = 0;
|
|
||||||
else
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*(str++) = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
launchAddArg(ad, pstr);
|
|
||||||
|
|
||||||
} while(str<endarg);
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle launchOpenFile(const char* path)
|
Handle launchOpenFile(const char* path)
|
||||||
{
|
{
|
||||||
if (strncmp(path, "sdmc:/", 6) == 0)
|
if (strncmp(path, "sdmc:/", 6) == 0)
|
||||||
|
@ -23,7 +23,4 @@ typedef struct
|
|||||||
void (* useTitle)(u64 tid, u8 mediatype);
|
void (* useTitle)(u64 tid, u8 mediatype);
|
||||||
} loaderFuncs_s;
|
} loaderFuncs_s;
|
||||||
|
|
||||||
size_t launchAddArg(argData_s* ad, const char* arg);
|
|
||||||
void launchAddArgsFromString(argData_s* ad, char* arg);
|
|
||||||
|
|
||||||
Handle launchOpenFile(const char* path);
|
Handle launchOpenFile(const char* path);
|
@ -182,24 +182,28 @@ static void frontend_ctr_deinit(void* data)
|
|||||||
|
|
||||||
static void frontend_ctr_exec(const char* path, bool should_load_game)
|
static void frontend_ctr_exec(const char* path, bool should_load_game)
|
||||||
{
|
{
|
||||||
|
char gamePath[PATH_MAX];
|
||||||
|
const char* argData[3];
|
||||||
|
int args = 0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
char args[0x300 - 0x4];
|
|
||||||
|
|
||||||
DEBUG_VAR(path);
|
DEBUG_VAR(path);
|
||||||
DEBUG_STR(path);
|
DEBUG_STR(path);
|
||||||
|
|
||||||
args[0] = '\0';
|
argData[0] = NULL;
|
||||||
strcat(args, "\"");
|
|
||||||
strcat(args, elf_path_cst);
|
argData[args] = elf_path_cst;
|
||||||
strcat(args, "\"");
|
argData[args + 1] = NULL;
|
||||||
|
args++;
|
||||||
|
|
||||||
RARCH_LOG("Attempt to load core: [%s].\n", path);
|
RARCH_LOG("Attempt to load core: [%s].\n", path);
|
||||||
#ifndef IS_SALAMANDER
|
#ifndef IS_SALAMANDER
|
||||||
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT))
|
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT))
|
||||||
{
|
{
|
||||||
strcat(args, " \"");
|
strcpy(gamePath, path_get(RARCH_PATH_CONTENT));
|
||||||
strcat(args, path_get(RARCH_PATH_CONTENT));
|
argData[args] = gamePath;
|
||||||
strcat(args, "\"");
|
argData[args + 1] = NULL;
|
||||||
|
args++;
|
||||||
RARCH_LOG("content path: [%s].\n", path_get(RARCH_PATH_CONTENT));
|
RARCH_LOG("content path: [%s].\n", path_get(RARCH_PATH_CONTENT));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -231,7 +235,7 @@ static void frontend_ctr_exec(const char* path, bool should_load_game)
|
|||||||
#endif
|
#endif
|
||||||
if (envIsHomebrew())
|
if (envIsHomebrew())
|
||||||
{
|
{
|
||||||
exec_3dsx_no_path_in_args(path, args);
|
exec_3dsx_no_path_in_args(path, argData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -242,7 +246,7 @@ static void frontend_ctr_exec(const char* path, bool should_load_game)
|
|||||||
RARCH_LOG("Do not force quit before then or your memory card may be corrupted!\n");
|
RARCH_LOG("Do not force quit before then or your memory card may be corrupted!\n");
|
||||||
RARCH_LOG("\n");
|
RARCH_LOG("\n");
|
||||||
RARCH_LOG("\n");
|
RARCH_LOG("\n");
|
||||||
exec_cia(path, args);
|
exec_cia(path, argData);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);//couldnt launch new core, but context is corrupt so we have to quit
|
exit(0);//couldnt launch new core, but context is corrupt so we have to quit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user