I've been experimenting with trying to make the 2.0 EBOOT loader a little more stable.
One of my main concerns is that I do very little in the way of memory management - just assuming that I can write to pretty much anywhere in the main user memory partition (0x08800000 + ).
It occurred to me that maybe I could allocate the memory I'm using, to avoid clashes with other code.
I used this code to experiment with allocating memory in the area I want, but just get SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED errors on every block:
char *lname = "testmem";
SceUID lblockid;
char *lptr = (char*)0x08900000L;
while ((unsigned long)lptr < 0x08A00000L)
{
lblockid = sceKernelAllocPartitionMemory(2, lname, 2, 0x1000, (void*)lptr);
if ((unsigned long)lblockid != 0x800200d9)
{
printf("Managed to alloc @ %08lX ID %08lX\n", lptr, lblockid);
}
lptr += 0x1000;
}
I also tried this code to identify the lowest address I can allocate:
lblockid = sceKernelAllocPartitionMemory(2, lname, 0, 0x1000, 0)
but the lowest address is gives me is around 0x09C00000, which isn't far short of my stack.
This is all on v2.0, and I don't have access to a 1.5 PSP to see if things are any different there.
What I was wondering is:
- is the heap always so high in the address space?
- is it really only about 2Mb in size?
It seems that, quite apart from trying to make things more stable in general, this might be the reason why some apps are crashing under the loader at the moment, especially some LUA scripts which seem to fail after loading a few images.
P.S. Any tips for locating blocks of memory that I could steal back from the system? I noticed that blockids are always offset from each other at a multiple of 0x8FE, but scanning around about 100 IDs either side of the ones I get from the alloc calls doesn't seem to yield any addresses that are significantly different.