Exemple #1
0
int initialise(SceSize args, void *argp)
{
	int len;
	int fd;
	Elf32_Ehdr hdr;

	memset(&g_context, 0, sizeof(g_context));
	if(argp == NULL)
	{
		return 0;
	}

	len = strlen((char*) argp)+1;
	argp += len;
	args -= len;
	if(args <= 0)
	{
		return 0;
	}

	g_context.argp = argp;
	g_context.args = args;

	fd = sceIoOpen((char*) argp, PSP_O_RDONLY, 0777);
	if(fd < 0)
	{
		printf("%s does not exist\n", (char*) argp);
		return 0;
	}

	len = sceIoRead(fd, &hdr, sizeof(hdr));

	sceIoClose(fd);
	if(len != sizeof(hdr))
	{
		printf("Could not read in ELF header\n");
		return 0;
	}

	if(hdr.e_magic != ELF_MAGIC)
	{
		printf("Invalid ELF magic\n");
		return 0;
	}

	if(hdr.e_type == ELF_MIPS_TYPE)
	{
		g_context.elf = 1;
	}
	else if(hdr.e_type != ELF_PRX_TYPE)
	{
		printf("Invalid ELF type code\n");
		return 0;
	}

	g_context.uid = sceKernelLoadModule(argp, 0, NULL);
	sceIoClose(fd);

	if(g_context.uid < 0)
	{
		printf("Could not load module %s (0x%08X)\n", (char*) argp, g_context.uid);
		return 0;
	}


	if(!psplinkReferModule(g_context.uid, &g_context.info))
	{
		printf("Could not refer module info\n");
		return 0;
	}

	g_context.ctx.regs.epc = g_context.info.entry_addr;
	g_context.ctx.regs.cause = 9 << 2;

	printf("Loaded %s - UID 0x%08X, Entry 0x%08X\n", (char*)argp, g_context.uid, g_context.info.entry_addr);

	return 1;
}
Exemple #2
0
int initialise(SceSize args, void *argp)
{
	int len;
	int fd;
	Elf32_Ehdr hdr;

	memset(&g_context, 0, sizeof(g_context));
	if(argp == NULL)
	{
		return 0;
	}

	len = strlen((char*) argp)+1;
	argp += len;
	args -= len;
	if(args <= 0)
	{
		return 0;
	}

	g_context.argp = argp;
	g_context.args = args;

	fd = sceIoOpen((char*) argp, PSP_O_RDONLY, 0777);
	if(fd < 0)
	{
		printf("%s does not exist\n", (char*) argp);
		return 0;
	}

	len = sceIoRead(fd, &hdr, sizeof(hdr));

	sceIoClose(fd);
	if(len != sizeof(hdr))
	{
		printf("Could not read in ELF header\n");
		return 0;
	}

	if(hdr.e_magic != ELF_MAGIC)
	{
		printf("Invalid ELF magic\n");
		return 0;
	}

	if(hdr.e_type == ELF_MIPS_TYPE)
	{
		g_context.elf = 1;
	}
	else if(hdr.e_type != ELF_PRX_TYPE)
	{
		printf("Invalid ELF type code\n");
		return 0;
	}

	g_context.uid = sceKernelLoadModule(argp, 0, NULL);
	sceIoClose(fd);

	if(g_context.uid < 0)
	{
		printf("Could not load module %s (0x%08X)\n", (char*) argp, g_context.uid);
		return 0;
	}


	if(!psplinkReferModule(g_context.uid, &g_context.info))
	{
		printf("Could not refer module info\n");
		return 0;
	}

	g_context.ctx.regs.epc = g_context.info.entry_addr;
	g_context.ctx.regs.cause = 9 << 2;

	printf("Loaded %s - UID 0x%08X, Entry 0x%08X\n", (char*)argp, g_context.uid, g_context.info.entry_addr);
        
        int t_pommel;
        
        int t_result = sceSysconGetPommelVersion(&t_pommel);
        
        if ((t_pommel >= 0x123) && (t_result == 0)) // If PSP 2000 or newer allow 64MB to be peeked and poked instead of 32MB
            g_userend = 0x0C000000;
        else
            g_userend = 0x0A000000;

	return 1;
}