Relocatable kernel

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.
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post by Tyler »

JAAman wrote:while winXP kernel is in a relocatable file, it is always loaded at the same address

however, vistas kernel is located at an address chosen randomly on each boot (iiuc)
Is it not possible to place the XP kernel at either 2Gb or 3Gb virtual address?
Jules
Member
Member
Posts: 30
Joined: Mon Jan 08, 2007 3:19 am
Location: UK

Post by Jules »

WinXP's kernel is defintely relocated during startup. The image file is based at 00400000 according to objdump, but on my system the image in memory is at 804d7000 (according to process explorer).
Jules
Member
Member
Posts: 30
Joined: Mon Jan 08, 2007 3:19 am
Location: UK

Post by Jules »

To elaborate, I'd guess XP's startup process is as follows:

* Boot sector loads NTLDR
* NTLDR loads kernel to 0x00400000 (i.e. 4MB) physical. Not sure why this address was chosen, but it's a reasonable one at least.
* Kernel begins executing at its physical address, but prior to initialising paging creates a copy of itself, relocating as it does, for some reason moving itself up by D7000 bytes (perhaps the length of the initialization code). The target address is either 0x804D7000 (normally) or 0xC04D7000 (if the /3GB boot switch is specified).
* After paging is initialised, kernel jumps to itself at the new address.

Just a guess, mind you.
Post Reply