Example #1
0
void ttyInit(void)
{
	SceUID uid;

	if(stdioTtyInit() < 0)
	{
		Kprintf("Could not initialise tty\n");
		return;
	}

	stdioInstallStdoutHandler(stdoutHandler);
	stdioInstallStderrHandler(stderrHandler);
	stdioInstallStdinHandler(inputHandler);
	/* Install a patch to prevent a naughty app from closing stdout */
	uid = refer_module_by_name("sceIOFileManager", NULL);
	if(uid >= 0)
	{
		apiHookByNid(uid, "IoFileMgrForUser", 0x810c4bc3, close_func);
		libsPatchFunction(uid, "IoFileMgrForKernel", 0x3c54e908, 0xFFFF);
	}
}
Example #2
0
void initialise(SceSize args, void *argp)
{
	struct ConfigContext ctx;
	const char *init_dir = "host0:/";
	int (*g_sceUmdActivate)(int, const char *);
	int argc;
	char *argv[MAX_ARGS];

	memset(&g_context, 0, sizeof(g_context));
	map_firmwarerev();
	exceptionInit();
	g_context.thevent = -1;
	parse_sceargs(args, argp, &argc, argv);

	if(argc > 0)
	{
		char *lastdir;

		g_context.bootfile = argv[0];
		lastdir = strrchr(argv[0], '/');
		if(lastdir != NULL)
		{
			memcpy(g_context.bootpath, argv[0], lastdir - argv[0] + 1);
		}
	}

	configLoad(g_context.bootpath, &ctx);

	if(ctx.pid)
	{
		g_context.pid = ctx.pid;
	}
	else
	{
		g_context.pid = HOSTFSDRIVER_PID;
	}

	ttyInit();
	init_usbhost(g_context.bootpath);

#if _PSP_FW_VERSION >= 200
	if(argc > 1)
	{
		init_dir = argv[1];
	}
#else
	{
		struct SavedContext *save = (struct SavedContext *) SAVED_ADDR;
		if(save->magic == SAVED_MAGIC)
		{
			init_dir = save->currdir;
			save->magic = 0;
			g_context.rebootkey = save->rebootkey;
		}
	}
#endif

	if(shellInit(init_dir) < 0)
	{
		sceKernelExitGame();
	}

	g_sceUmdActivate = (void*) libsFindExportByNid(refer_module_by_name("sceUmd_driver", NULL), 
			"sceUmdUser", 0xC6183D47);
	if(g_sceUmdActivate)
	{
		g_sceUmdActivate(1, "disc0:");
	}

	/* Hook sceKernelExitGame */
	apiHookByNid(refer_module_by_name("sceLoadExec", NULL), "LoadExecForUser", 0x05572A5F, exit_reset);

	unload_loader();

	psplinkPatchException();

	if(ctx.enableuser)
	{
		load_psplink_user(g_context.bootpath);
	}

	g_context.resetonexit = ctx.resetonexit;

	sceKernelRegisterDebugPutchar(NULL);
	enable_kprintf(1);
	debugHwInit();
	modLoad(g_context.bootpath);
}