mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-02 06:53:39 +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 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;
|
||||
argData_s newProgramArgs;
|
||||
char* writeableString[0x400];
|
||||
unsigned int argChars = 0;
|
||||
unsigned int argNum = 0;
|
||||
bool fileExists;
|
||||
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));
|
||||
newProgramArgs.dst = (char*)&newProgramArgs.buf[1];
|
||||
if(appendPath){
|
||||
strcpy(writeableString, path);
|
||||
launchAddArg(&newProgramArgs, writeableString);
|
||||
strcpy(newProgramArgs.dst, path);
|
||||
newProgramArgs.dst += strlen(path) + 1;
|
||||
newProgramArgs.buf[0]++;
|
||||
|
||||
}
|
||||
if(args != NULL && args[0] != '\0'){
|
||||
strcpy(writeableString, args);
|
||||
launchAddArgsFromString(&newProgramArgs, writeableString);
|
||||
while(args[argNum] != NULL){
|
||||
strcpy(newProgramArgs.dst, args[argNum]);
|
||||
newProgramArgs.dst += strlen(args[argNum]) + 1;
|
||||
newProgramArgs.buf[0]++;
|
||||
argNum++;
|
||||
}
|
||||
|
||||
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
|
||||
//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(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);
|
||||
|
||||
#endif
|
@ -115,7 +115,7 @@ static int installCia(Handle ciaFile){
|
||||
return 1;
|
||||
}
|
||||
|
||||
int exec_cia(const char* path, const char* args){
|
||||
int exec_cia(const char* path, const char** args){
|
||||
struct stat sBuff;
|
||||
bool fileExists;
|
||||
bool inited;
|
||||
@ -175,38 +175,12 @@ int exec_cia(const char* path, const char* args){
|
||||
|
||||
param.argc = 0;
|
||||
argsLength = 0;
|
||||
if(args != NULL && args[0] != '\0'){
|
||||
bool inSingleQuotes = false;
|
||||
bool inDoubleQuotes = false;
|
||||
int argStringLength = strlen(args);
|
||||
|
||||
//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.args[argsLength] = args[argPtr];
|
||||
argsLength++;
|
||||
}
|
||||
else{
|
||||
if(!inSingleQuotes && !inDoubleQuotes && args[argPtr] == ' '){
|
||||
param.argc++;
|
||||
param.args[argsLength] = '\0';
|
||||
}
|
||||
else{
|
||||
param.args[argsLength] = args[argPtr];
|
||||
}
|
||||
|
||||
argsLength++;
|
||||
}
|
||||
}
|
||||
char* argLocation = param.args;
|
||||
while(args[param.argc] != NULL){
|
||||
strcpy(argLocation, args[param.argc]);
|
||||
argLocation += strlen(args[param.argc]) + 1;
|
||||
argsLength += strlen(args[param.argc]) + 1;
|
||||
param.argc++;
|
||||
}
|
||||
|
||||
res = APT_PrepareToDoApplicationJump(0, ciaInfo.titleID, 0x1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef 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
|
@ -1,95 +1,95 @@
|
||||
#pragma once
|
||||
|
||||
// C stdlib includes
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// 3DS includes
|
||||
#include <3ds.h>
|
||||
|
||||
|
||||
#define ENTRY_ARGBUFSIZE 0x400
|
||||
#define NUM_SERVICESTHATMATTER 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
StrId_Loading = 0,
|
||||
StrId_Directory,
|
||||
StrId_DefaultLongTitle,
|
||||
StrId_DefaultPublisher,
|
||||
StrId_IOError,
|
||||
StrId_CouldNotOpenFile,
|
||||
|
||||
StrId_NoAppsFound_Title,
|
||||
StrId_NoAppsFound_Msg,
|
||||
|
||||
StrId_Reboot,
|
||||
StrId_ReturnToHome,
|
||||
|
||||
StrId_TitleSelector,
|
||||
StrId_ErrorReadingTitleMetadata,
|
||||
StrId_NoTitlesFound,
|
||||
StrId_SelectTitle,
|
||||
|
||||
StrId_NoTargetTitleSupport,
|
||||
StrId_MissingTargetTitle,
|
||||
|
||||
StrId_NetLoader,
|
||||
StrId_NetLoaderUnavailable,
|
||||
StrId_NetLoaderOffline,
|
||||
StrId_NetLoaderError,
|
||||
StrId_NetLoaderActive,
|
||||
StrId_NetLoaderTransferring,
|
||||
|
||||
StrId_Max,
|
||||
} StrId;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* dst;
|
||||
u32 buf[ENTRY_ARGBUFSIZE/sizeof(u32)];
|
||||
} argData_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool scanned;
|
||||
u32 sectionSizes[3];
|
||||
bool servicesThatMatter[NUM_SERVICESTHATMATTER];
|
||||
} executableMetadata_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 num;
|
||||
u32 text_end;
|
||||
u32 data_address;
|
||||
u32 data_size;
|
||||
u32 processLinearOffset;
|
||||
u32 processHookAddress;
|
||||
u32 processAppCodeAddress;
|
||||
u32 processHookTidLow, processHookTidHigh;
|
||||
u32 mediatype;
|
||||
bool capabilities[0x10]; // {socuAccess, csndAccess, qtmAccess, nfcAccess, httpcAccess, reserved...}
|
||||
} memmap_header_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 src, dst, size;
|
||||
} memmap_entry_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
memmap_header_t header;
|
||||
memmap_entry_t map[];
|
||||
} memmap_t;
|
||||
|
||||
#define memmapSize(m) (sizeof(memmap_header_t) + sizeof(memmap_entry_t)*(m)->header.num)
|
||||
|
||||
|
||||
#include "launch.h"
|
||||
#pragma once
|
||||
|
||||
// C stdlib includes
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// 3DS includes
|
||||
#include <3ds.h>
|
||||
|
||||
|
||||
#define ENTRY_ARGBUFSIZE 0x400
|
||||
#define NUM_SERVICESTHATMATTER 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
StrId_Loading = 0,
|
||||
StrId_Directory,
|
||||
StrId_DefaultLongTitle,
|
||||
StrId_DefaultPublisher,
|
||||
StrId_IOError,
|
||||
StrId_CouldNotOpenFile,
|
||||
|
||||
StrId_NoAppsFound_Title,
|
||||
StrId_NoAppsFound_Msg,
|
||||
|
||||
StrId_Reboot,
|
||||
StrId_ReturnToHome,
|
||||
|
||||
StrId_TitleSelector,
|
||||
StrId_ErrorReadingTitleMetadata,
|
||||
StrId_NoTitlesFound,
|
||||
StrId_SelectTitle,
|
||||
|
||||
StrId_NoTargetTitleSupport,
|
||||
StrId_MissingTargetTitle,
|
||||
|
||||
StrId_NetLoader,
|
||||
StrId_NetLoaderUnavailable,
|
||||
StrId_NetLoaderOffline,
|
||||
StrId_NetLoaderError,
|
||||
StrId_NetLoaderActive,
|
||||
StrId_NetLoaderTransferring,
|
||||
|
||||
StrId_Max,
|
||||
} StrId;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* dst;
|
||||
u32 buf[ENTRY_ARGBUFSIZE/sizeof(u32)];
|
||||
} argData_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool scanned;
|
||||
u32 sectionSizes[3];
|
||||
bool servicesThatMatter[NUM_SERVICESTHATMATTER];
|
||||
} executableMetadata_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 num;
|
||||
u32 text_end;
|
||||
u32 data_address;
|
||||
u32 data_size;
|
||||
u32 processLinearOffset;
|
||||
u32 processHookAddress;
|
||||
u32 processAppCodeAddress;
|
||||
u32 processHookTidLow, processHookTidHigh;
|
||||
u32 mediatype;
|
||||
bool capabilities[0x10]; // {socuAccess, csndAccess, qtmAccess, nfcAccess, httpcAccess, reserved...}
|
||||
} memmap_header_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 src, dst, size;
|
||||
} memmap_entry_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
memmap_header_t header;
|
||||
memmap_entry_t map[];
|
||||
} memmap_t;
|
||||
|
||||
#define memmapSize(m) (sizeof(memmap_header_t) + sizeof(memmap_entry_t)*(m)->header.num)
|
||||
|
||||
|
||||
#include "launch.h"
|
||||
|
@ -1,66 +1,5 @@
|
||||
#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)
|
||||
{
|
||||
if (strncmp(path, "sdmc:/", 6) == 0)
|
||||
|
@ -23,7 +23,4 @@ typedef struct
|
||||
void (* useTitle)(u64 tid, u8 mediatype);
|
||||
} loaderFuncs_s;
|
||||
|
||||
size_t launchAddArg(argData_s* ad, const char* arg);
|
||||
void launchAddArgsFromString(argData_s* ad, char* arg);
|
||||
|
||||
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)
|
||||
{
|
||||
char gamePath[PATH_MAX];
|
||||
const char* argData[3];
|
||||
int args = 0;
|
||||
int error = 0;
|
||||
char args[0x300 - 0x4];
|
||||
|
||||
DEBUG_VAR(path);
|
||||
DEBUG_STR(path);
|
||||
|
||||
argData[0] = NULL;
|
||||
|
||||
args[0] = '\0';
|
||||
strcat(args, "\"");
|
||||
strcat(args, elf_path_cst);
|
||||
strcat(args, "\"");
|
||||
argData[args] = elf_path_cst;
|
||||
argData[args + 1] = NULL;
|
||||
args++;
|
||||
|
||||
RARCH_LOG("Attempt to load core: [%s].\n", path);
|
||||
#ifndef IS_SALAMANDER
|
||||
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT))
|
||||
{
|
||||
strcat(args, " \"");
|
||||
strcat(args, path_get(RARCH_PATH_CONTENT));
|
||||
strcat(args, "\"");
|
||||
strcpy(gamePath, path_get(RARCH_PATH_CONTENT));
|
||||
argData[args] = gamePath;
|
||||
argData[args + 1] = NULL;
|
||||
args++;
|
||||
RARCH_LOG("content path: [%s].\n", path_get(RARCH_PATH_CONTENT));
|
||||
}
|
||||
#endif
|
||||
@ -231,7 +235,7 @@ static void frontend_ctr_exec(const char* path, bool should_load_game)
|
||||
#endif
|
||||
if (envIsHomebrew())
|
||||
{
|
||||
exec_3dsx_no_path_in_args(path, args);
|
||||
exec_3dsx_no_path_in_args(path, argData);
|
||||
}
|
||||
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("\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
|
||||
|
Loading…
x
Reference in New Issue
Block a user