Where did I put the stack pointer of the exe files

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
flash
Member
Member
Posts: 29
Joined: Sun Feb 04, 2007 6:33 am

Where did I put the stack pointer of the exe files

Post by flash »

I'm writing a exe loader to play PE files

I read every sections that the program needs, and put them at the right positions.

But now I have a trouble, I don't know where I can put the stack pointer, the PE file seems to tell you the stack size only.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

I don't know if it helps but whenever a new program that I write in Win32 ASM, starts, the ESP register is set to 0x0012FFC4. It can be far from accurate but I just checked it in Win XP and 98 and every time I started the program, the stack pointer was set to that value.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

The location of the stack shouldn't matter - just put it somewhere where there's a hole in your virtual memory, and set ESP to point where you allocated the memory.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Post by iammisc »

i have hands-on experience with pe files(http://xpapi.sourceforge.net/) and loading them and you can put it anywhere; it doesn't matter, Just make sure the stack is big enough. Because you are not running Windows files all you have to do is make sure that you're programs that actually manipulate the stack directly(which they really shouldn't do) know where your kernel puts it.
Post Reply