Page 1 of 1
Loading PE files
Posted: Wed Sep 12, 2007 12:05 pm
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.
Posted: Wed Sep 12, 2007 12:52 pm
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
Posted: Wed Sep 12, 2007 12:59 pm
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.
Posted: Wed Sep 12, 2007 1:25 pm
by Crazed123
This really should have been in the OS development board.
Posted: Wed Sep 12, 2007 9:20 pm
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.
Posted: Fri Sep 14, 2007 9:18 pm
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.
Posted: Sat Sep 15, 2007 3:34 am
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.