OSDev.org

The Place to Start for Operating System Developers
It is currently Tue May 07, 2024 4:04 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Where did I put the stack pointer of the exe files
PostPosted: Wed Feb 07, 2007 10:20 am 
Offline
Member
Member

Joined: Sun Feb 04, 2007 6:33 am
Posts: 29
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 12:05 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 25, 2006 3:55 am
Posts: 416
Location: Wisconsin
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 3:23 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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 ]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 6:54 pm 
Offline
Member
Member

Joined: Thu Nov 09, 2006 6:23 pm
Posts: 269
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], Bing [Bot], Google [Bot] and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group