Page 1 of 1

Windows PE loading

Posted: Mon Oct 29, 2007 10:55 am
by adw3221
Hey all, for the i386 port of my OS I have a start up file that is loaded by the bootloader and then executes some 16-bit code before moving onto 32-bit protected mode. Now the 16-bit section is linked into a MZ executeable but for the 32-bit portion I decicded to use the Windows PE format. Now since I have have "two" executeables in one I decided to put the 16-bit code in the "stub" and the 32-bit code in the PE area however I'm running into some issues.

First off is the alignment. PE files were designed for a page enviroment so alignment is key. Now the 32-bit protion sets up the paging enviroment and then calls the main kernel so I'm still operating in just protected mode. Also the base address is 0x40000 but I have that set at 0x0 for now. The PE file is attached onto the 16-bit section so I need the MZ code to call it (when it switches into protected mode) and the 32-bit code to run. Fixups are going to be an issue.

Alot of the documents only talk about loading it into a 32-bit paged envrioment but can anyone tell me things I should look for or anything else?

Posted: Wed Oct 31, 2007 7:10 am
by Dex
In DexOS, we need a relocatable file format, one of our member's written some code to load PE files, it well commented, so it may help you ?.