Merge pull request #2863 from aliaspider/master
(3DS) fixes argc/argv related crashes
This commit is contained in:
commit
7f6ff3ba84
26
Makefile.ctr
26
Makefile.ctr
|
@ -34,7 +34,10 @@ OBJS += ctr/ctr_svchax.o
|
||||||
ifeq ($(GRIFFIN_BUILD), 1)
|
ifeq ($(GRIFFIN_BUILD), 1)
|
||||||
OBJS += griffin/griffin.o
|
OBJS += griffin/griffin.o
|
||||||
else
|
else
|
||||||
OBJS += libretro-common/file/file_extract.o
|
CFLAGS += -DHAVE_COMPRESSION
|
||||||
|
OBJS += libretro-common/file/archive_file.o
|
||||||
|
OBJS += libretro-common/file/archive_file_zlib.o
|
||||||
|
OBJS += libretro-common/encodings/encoding_utf.o
|
||||||
OBJS += verbosity.o
|
OBJS += verbosity.o
|
||||||
OBJS += performance.o
|
OBJS += performance.o
|
||||||
OBJS += libretro-common/compat/compat_getopt.o
|
OBJS += libretro-common/compat/compat_getopt.o
|
||||||
|
@ -43,13 +46,13 @@ else
|
||||||
OBJS += libretro-common/compat/compat_fnmatch.o
|
OBJS += libretro-common/compat/compat_fnmatch.o
|
||||||
OBJS += libretro-common/memmap/memalign.o
|
OBJS += libretro-common/memmap/memalign.o
|
||||||
OBJS += libretro-common/file/config_file.o
|
OBJS += libretro-common/file/config_file.o
|
||||||
OBJS += libretro-common/file/config_file_userdata.o
|
OBJS += config_file_userdata.o
|
||||||
OBJS += core_options.o
|
OBJS += core_options.o
|
||||||
OBJS += cheats.o
|
OBJS += cheats.o
|
||||||
OBJS += libretro-common/hash/rhash.o
|
OBJS += libretro-common/hash/rhash.o
|
||||||
OBJS += gfx/video_context_driver.o
|
OBJS += gfx/video_context_driver.o
|
||||||
OBJS += gfx/drivers_context/gfx_null_ctx.o
|
OBJS += gfx/drivers_context/gfx_null_ctx.o
|
||||||
OBJS += gfx/image/image.o
|
OBJS += gfx/video_texture_image.o
|
||||||
OBJS += libretro-common/formats/tga/rtga.o
|
OBJS += libretro-common/formats/tga/rtga.o
|
||||||
OBJS += libretro-common/formats/png/rpng.o
|
OBJS += libretro-common/formats/png/rpng.o
|
||||||
OBJS += libretro-common/formats/png/rpng_encode.o
|
OBJS += libretro-common/formats/png/rpng_encode.o
|
||||||
|
@ -77,8 +80,9 @@ else
|
||||||
OBJS += gfx/video_state_tracker.o
|
OBJS += gfx/video_state_tracker.o
|
||||||
OBJS += libretro-common/queues/fifo_queue.o
|
OBJS += libretro-common/queues/fifo_queue.o
|
||||||
OBJS += audio/audio_resampler_driver.o
|
OBJS += audio/audio_resampler_driver.o
|
||||||
OBJS += audio/drivers_resampler/sinc.o
|
OBJS += audio/drivers_resampler/sinc_resampler.o
|
||||||
OBJS += audio/drivers_resampler/nearest.o
|
OBJS += audio/drivers_resampler/nearest_resampler.o
|
||||||
|
OBJS += audio/drivers_resampler/null_resampler.o
|
||||||
OBJS += audio/drivers_resampler/cc_resampler.o
|
OBJS += audio/drivers_resampler/cc_resampler.o
|
||||||
OBJS += camera/drivers/nullcamera.o
|
OBJS += camera/drivers/nullcamera.o
|
||||||
OBJS += location/drivers/nulllocation.o
|
OBJS += location/drivers/nulllocation.o
|
||||||
|
@ -86,7 +90,7 @@ else
|
||||||
OBJS += audio/drivers/ctr_dsp_audio.o
|
OBJS += audio/drivers/ctr_dsp_audio.o
|
||||||
OBJS += audio/drivers/nullaudio.o
|
OBJS += audio/drivers/nullaudio.o
|
||||||
OBJS += gfx/video_driver.o
|
OBJS += gfx/video_driver.o
|
||||||
OBJS += gfx/video_common.o
|
OBJS += gfx/video_coord_array.o
|
||||||
OBJS += input/input_driver.o
|
OBJS += input/input_driver.o
|
||||||
OBJS += audio/audio_driver.o
|
OBJS += audio/audio_driver.o
|
||||||
OBJS += camera/camera_driver.o
|
OBJS += camera/camera_driver.o
|
||||||
|
@ -129,7 +133,6 @@ else
|
||||||
OBJS += list_special.o
|
OBJS += list_special.o
|
||||||
OBJS += libretro-common/lists/string_list.o
|
OBJS += libretro-common/lists/string_list.o
|
||||||
OBJS += libretro-common/string/stdstring.o
|
OBJS += libretro-common/string/stdstring.o
|
||||||
OBJS += file_ops.o
|
|
||||||
OBJS += libretro-common/file/nbio/nbio_stdio.o
|
OBJS += libretro-common/file/nbio/nbio_stdio.o
|
||||||
OBJS += libretro-common/lists/file_list.o
|
OBJS += libretro-common/lists/file_list.o
|
||||||
OBJS += libretro-common/queues/message_queue.o
|
OBJS += libretro-common/queues/message_queue.o
|
||||||
|
@ -146,7 +149,8 @@ else
|
||||||
OBJS += libretro_version_1.o
|
OBJS += libretro_version_1.o
|
||||||
OBJS += retroarch.o
|
OBJS += retroarch.o
|
||||||
OBJS += runloop.o
|
OBJS += runloop.o
|
||||||
OBJS += tasks/tasks.o
|
OBJS += libretro-common/queues/task_queue.o
|
||||||
|
OBJS += tasks/tasks_internal.o
|
||||||
OBJS += msg_hash.o
|
OBJS += msg_hash.o
|
||||||
OBJS += intl/msg_hash_de.o
|
OBJS += intl/msg_hash_de.o
|
||||||
OBJS += intl/msg_hash_es.o
|
OBJS += intl/msg_hash_es.o
|
||||||
|
@ -160,8 +164,9 @@ else
|
||||||
OBJS += movie.o
|
OBJS += movie.o
|
||||||
OBJS += record/record_driver.o
|
OBJS += record/record_driver.o
|
||||||
OBJS += record/drivers/record_null.o
|
OBJS += record/drivers/record_null.o
|
||||||
OBJS += tasks/task_decompress.o
|
OBJS += tasks/task_content.o
|
||||||
OBJS += tasks/task_file_transfer.o
|
OBJS += tasks/task_file_transfer.o
|
||||||
|
OBJS += tasks/task_decompress.o
|
||||||
OBJS += screenshot.o
|
OBJS += screenshot.o
|
||||||
OBJS += playlist.o
|
OBJS += playlist.o
|
||||||
OBJS += menu/menu_driver.o
|
OBJS += menu/menu_driver.o
|
||||||
|
@ -171,6 +176,7 @@ else
|
||||||
OBJS += menu/menu_entries.o
|
OBJS += menu/menu_entries.o
|
||||||
OBJS += menu/menu_setting.o
|
OBJS += menu/menu_setting.o
|
||||||
OBJS += menu/menu_cbs.o
|
OBJS += menu/menu_cbs.o
|
||||||
|
OBJS += menu/menu_content.o
|
||||||
OBJS += menu/cbs/menu_cbs_ok.o
|
OBJS += menu/cbs/menu_cbs_ok.o
|
||||||
OBJS += menu/cbs/menu_cbs_cancel.o
|
OBJS += menu/cbs/menu_cbs_cancel.o
|
||||||
OBJS += menu/cbs/menu_cbs_select.o
|
OBJS += menu/cbs/menu_cbs_select.o
|
||||||
|
@ -219,8 +225,6 @@ else
|
||||||
OBJS += deps/zlib/trees.o
|
OBJS += deps/zlib/trees.o
|
||||||
OBJS += deps/zlib/uncompr.o
|
OBJS += deps/zlib/uncompr.o
|
||||||
OBJS += deps/zlib/zutil.o
|
OBJS += deps/zlib/zutil.o
|
||||||
OBJS += deps/zlib/ioapi.o
|
|
||||||
OBJS += deps/zlib/unzip.o
|
|
||||||
OBJS += audio/audio_utils.o
|
OBJS += audio/audio_utils.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include "ctr_debug.h"
|
#include "ctr_debug.h"
|
||||||
|
|
||||||
#define CTR_APPMEMALLOC_PTR ((u32*)0x1FF80040)
|
#define CTR_APPMEMALLOC_PTR ((u32*)0x1FF80040)
|
||||||
|
@ -60,7 +61,8 @@ void __attribute__((weak)) __libctru_init(void (*retAddr)(void))
|
||||||
__system_initArgv();
|
__system_initArgv();
|
||||||
|
|
||||||
}
|
}
|
||||||
void __system_allocateHeaps() {
|
void __system_allocateHeaps()
|
||||||
|
{
|
||||||
u32 tmp = 0;
|
u32 tmp = 0;
|
||||||
|
|
||||||
MemInfo stack_memInfo;
|
MemInfo stack_memInfo;
|
||||||
|
@ -135,48 +137,46 @@ int __system_argc;
|
||||||
char** __system_argv;
|
char** __system_argv;
|
||||||
extern const char* __system_arglist;
|
extern const char* __system_arglist;
|
||||||
|
|
||||||
//extern char* fake_heap_start;
|
|
||||||
extern char* fake_heap_end;
|
|
||||||
|
|
||||||
void __system_initArgv()
|
void __system_initArgv()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char* temp = __system_arglist;
|
struct
|
||||||
|
|
||||||
// Check if the argument list is present
|
|
||||||
if (!temp)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Retrieve argc
|
|
||||||
__system_argc = *(u32*)temp;
|
|
||||||
temp += sizeof(u32);
|
|
||||||
|
|
||||||
// Find the end of the argument data
|
|
||||||
for (i = 0; i < __system_argc; i ++)
|
|
||||||
{
|
{
|
||||||
for (; *temp; temp ++);
|
u32 argc;
|
||||||
temp ++;
|
char args[];
|
||||||
|
}*arg_struct = (void*)__system_arglist;
|
||||||
|
|
||||||
|
__system_argc = 0;
|
||||||
|
|
||||||
|
if (arg_struct)
|
||||||
|
__system_argc = arg_struct->argc;
|
||||||
|
|
||||||
|
if (__system_argc)
|
||||||
|
{
|
||||||
|
__system_argv = (char**) malloc((__system_argc + 1) * sizeof(char**));
|
||||||
|
__system_argv[0] = arg_struct->args;
|
||||||
|
for (i = 1; i < __system_argc; i++)
|
||||||
|
__system_argv[i] = __system_argv[i - 1] + strlen(__system_argv[i - 1]) + 1;
|
||||||
|
|
||||||
|
i = __system_argc - 1;
|
||||||
|
__system_argc = 1;
|
||||||
|
while (i)
|
||||||
|
{
|
||||||
|
if(__system_argv[i] && isalnum(__system_argv[i][0])
|
||||||
|
&& strncmp(__system_argv[i], "3dslink:/", 9))
|
||||||
|
{
|
||||||
|
__system_argv[1] = __system_argv[i];
|
||||||
|
__system_argc = 2;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
i--;
|
||||||
// Reserve heap memory for argv data
|
}
|
||||||
u32 argSize = temp - __system_arglist - sizeof(u32);
|
}
|
||||||
// __system_argv = (char**)fake_heap_start;
|
else
|
||||||
// fake_heap_start += sizeof(char**)*(__system_argc + 1);
|
|
||||||
// char* argCopy = fake_heap_start;
|
|
||||||
// fake_heap_start += argSize;
|
|
||||||
|
|
||||||
__system_argv = malloc(sizeof(char**)*(__system_argc + 1) + argSize);
|
|
||||||
char* argCopy = (char*)__system_argv + sizeof(char**)*(__system_argc + 1);
|
|
||||||
|
|
||||||
|
|
||||||
// Fill argv array
|
|
||||||
memcpy(argCopy, &__system_arglist[4], argSize);
|
|
||||||
temp = argCopy;
|
|
||||||
for (i = 0; i < __system_argc; i ++)
|
|
||||||
{
|
{
|
||||||
__system_argv[i] = (char*)temp;
|
__system_argc = 1;
|
||||||
for (; *temp; temp ++);
|
__system_argv = (char**) malloc(sizeof(char**) * 2);
|
||||||
temp ++;
|
__system_argv[0] = "sdmc:/retroarch/retroarch";
|
||||||
}
|
}
|
||||||
__system_argv[__system_argc] = NULL;
|
__system_argv[__system_argc] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,8 @@ void __attribute__((noreturn)) __ctru_exit(int rc)
|
||||||
__libctru_exit(rc);
|
__libctru_exit(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef union{
|
typedef union
|
||||||
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
unsigned description : 10;
|
unsigned description : 10;
|
||||||
|
@ -238,6 +239,7 @@ void wait_for_input(void)
|
||||||
|
|
||||||
if (kDown & KEY_SELECT)
|
if (kDown & KEY_SELECT)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
select_pressed = true;
|
select_pressed = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -80,27 +80,6 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[],
|
||||||
"filters", sizeof(g_defaults.dir.remap));
|
"filters", sizeof(g_defaults.dir.remap));
|
||||||
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
|
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
|
||||||
"retroarch.cfg", sizeof(g_defaults.path.config));
|
"retroarch.cfg", sizeof(g_defaults.path.config));
|
||||||
|
|
||||||
#ifndef IS_SALAMANDER
|
|
||||||
/* clean-up argc/argv */
|
|
||||||
if(*argc)
|
|
||||||
{
|
|
||||||
int i = *argc - 1;
|
|
||||||
*argc = 0;
|
|
||||||
while (i)
|
|
||||||
{
|
|
||||||
if(argv[i] && isalnum(argv[i][0])
|
|
||||||
&& strncmp(argv[i], "3dslink:/", 9))
|
|
||||||
{
|
|
||||||
argv[1] = argv[i];
|
|
||||||
argv[2] = NULL;
|
|
||||||
*argc = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void frontend_ctr_deinit(void *data)
|
static void frontend_ctr_deinit(void *data)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
#include <retro_miscellaneous.h>
|
||||||
|
|
||||||
#include "menu_input.h"
|
#include "menu_input.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue