Loading PE 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
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Loading PE files

Post by einsteinjunior »

Hito everyone out there,

I just wish to know if someone has an idea on how the windows memory management system functions :is it a flat adress space memory management or segmented?
I alsowish to know if it is possible to load PE files in a flat memory model and how it can be done.
If someone has any suggestion on a better executable file format loadable using a flat memory model ,then i will be grateful.
Thanks.
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 »

Windows (at least '95 and later), use a flat memory model with paging. If you have that, you can load PE files (or another common file format like ELF).

I suggest you read the various documentation on PE files on how they are loaded to come up with your own implementation. Google is your friend
"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 ]
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Hi thanks,

The problem is that since they are talking about sections in the PE file format documentation from microsoft,i was sure that there was usee of segmentation.And also since windows can Run 16 bit applications ,i though its the case since they say in Intel manuals that paging should be enabled for you to use 16 bit code.
I will try ELF.Thanks.
Crazed123
Member
Member
Posts: 248
Joined: Thu Oct 21, 2004 11:00 pm

Post by Crazed123 »

This really should have been in the OS development board.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Sure i have code for DexOS that show how to load a PE and how to make it a flat mode, there code for fasm and VC++ 6, PM me if you want it.
Jeffrey
Posts: 20
Joined: Fri Jul 27, 2007 1:35 pm
Location: Virginia, USA

Post by Jeffrey »

What you may be mistaking for segmentation in the PE format is the section size alignment, which is nothing more than the capability to take a specific section, reduce its required executable size to only the size of its content, and then upon execution have the Windows loader align the sections size to a specific alignment and the execute the process.

Some good resources on a PE loader can be found in the ReactOS sources, the article "Mysteries of the Windows 2000 Loader" on the Microsoft website, and of course, the PE specifications on the Microsoft website. Google.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Jeffrey wrote:What you may be mistaking for segmentation in the PE format is the section size alignment, which is nothing more than the capability to take a specific section, reduce its required executable size to only the size of its content, and then upon execution have the Windows loader align the sections size to a specific alignment and the execute the process.
The section alignment also helps keep the final binary page-aligned, which makes loading it into memory (and mapping it) much easier.
Post Reply