Implemented sceKernelLoadModule()

Note that it wasn't tested because all the games I tested had other problems (already implemented modules, encrypted modules, using different functions etc).
But code looks good so it'd probably need few (no?) fixes.
This commit is contained in:
Arthur Blot committed 2012-11-04 19:01:20 +01:00
1 parent 6f391515a6
commit 9be8be6b7f
6 files changed
+177 -100

No files matched your search

+14 -2
View File
@@ -77,6 +77,20 @@ bool ElfReader::LoadInto(u32 vaddr)
bRelocate = (header->e_type != ET_EXEC);
entryPoint = header->e_entry;
u32 totalSize = 0;
for (int i=0; i<header->e_phnum; i++)
{
Elf32_Phdr *p = segments + i;
if (p->p_type == PT_LOAD && p->p_vaddr + p->p_memsz > totalSize)
{
totalSize = p->p_vaddr + p->p_memsz;
}
}
if (vaddr)
vaddr = userMemory.AllocAt(vaddr, totalSize, "ELF");
else
vaddr = userMemory.Alloc(totalSize, false, "ELF");
if (bRelocate)
{
DEBUG_LOG(LOADER,"Relocatable module");
@@ -109,8 +123,6 @@ bool ElfReader::LoadInto(u32 vaddr)
u32 srcSize = p->p_filesz;
u32 dstSize = p->p_memsz;
userMemory.AllocAt(writeAddr, dstSize, "ELF");
memcpy(dst, src, srcSize);
if (srcSize < dstSize)
{