I agree JJS, but that way you would still need to reference memory addresses, which would likely not be universal for any game, specially on p2, but also for newer firmware versions on p5.
JJS wrote:he main game module gets always relocated to the same address which puts the stub somewhere around 0x08A00000 and the additional libraries must be at the top of user memory (0x09D0000+)
That might be true for new games, but not for old ones which are all static (main game module), thus loaded at 0x08900000.
But yes, I do agree that you won't have to search the whole user memory (p2+p5) but it would be close to the whole thing IMHO. The more you narrow it, the most likely it will eventually fail with a given game.
Also an idea to detect stub descriptors more correctly: implementing a method that checks whether the library name pointed by the supposed stub descriptor is actually a valid string, something fast (and ugly) like
Code: Select all
// p = pointer_to_library_name_found_on_supposed_stub_descriptor
int is_libname(char* p)
{
return (p[0] >= 'A' && p[0] <= 'Z' && p[1] >= 'a' && p[1] <= 'z');
}
Of course we should check if other elements of the stub descriptors are valid as well (e.g. pointers can be masked with 0x0FFFFFFF if I'm not mistaken).
The main problem is recognizing a valid NID, since they're random (i know they're mostly SHA-1 of the original SCE function name, but this counts as good as random).