change threads stack pointer

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
bbtgp32465
Posts: 23
Joined: Fri Sep 18, 2009 3:33 pm

change threads stack pointer

Post by bbtgp32465 »

Is there a way to change a kernel threads stack pointer? Iv tried using assembly and it just crashes the psp every time. I need about 2MB of stack.

Or would expanding the kernel partition work? iv tried using sctrlHENSetMemory to allocate 6MB to partition 8, my prx loaded fine but the stack was still allocated in partition 1 so that defeated the purpose.

thanks.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

Someone might be able to help you, but can I ask why you would need such a huge stack and whether it might be possible to rethink your algorithm, either to do a recursive job in an iterative way or to use the heap instead?

Jim
bbtgp32465
Posts: 23
Joined: Fri Sep 18, 2009 3:33 pm

Post by bbtgp32465 »

Well, a couple of threads back i started to try and reverse the ipl so i could get the kernel keys for psar dumper. (It isn't going to well =P)

So iv taken to loading the ipl in vram, patching some of the nasty parts that would cause a crash and executing the decryption parts like

sceDecypt1((void*)0xBFC00040, 0x280, (void*)seed1, (void*)seed2, (void*)main_bin, 0x8180);

Code: Select all

	memset((void*)0x44000000, 0, 0x00200000);
	SceUID fd = sceIoOpen("host0:/ipl.mem", PSP_O_RDONLY, 0777);
	int size = sceIoLseek32(fd, 0, SEEK_END);
	sceIoLseek32(fd, 0, SEEK_SET);
	sceIoRead(fd, (void*)_VRAM(0x040EC000), size);
	sceIoClose(fd);
For this function i believe i need kernel mode and a huge stack because it freezes the psp when i run it. or maybe im just completely wrong and i cant run code from vram.

I have a couple more ideas but this was the easiest on the list. The next one is writing a program to rebase the ipl in user mode and modify sceMtInit etc to run. And after that is to write a program to generate an assembly version of the ipl that i can include in my project. Thats all for now
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

You cannot change your stack pointer easily because if your thread context gets switched the thread manager will kill you because it thinks you blew your stack.

You might be able to get away with disabling interrupts while running the ipl code, with interrupts off the threads cannot context switch and you would _get away with it_ :)
Post Reply