How to use NTLDR(win xp's loader) to load my own 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.
Post Reply
yaocong
Posts: 22
Joined: Fri Sep 09, 2005 11:00 pm
Location: China
Contact:

How to use NTLDR(win xp's loader) to load my own kernel

Post by yaocong »

Hello,
Could you help me:
I want to use the NTLDR(windows xp's loader) to load my kernel,
but I do not know how to do it.
The difficult things are :
where does the ntldr load the kernel to,is it 0x0000:7c000?
what parameters will the ntldr transfer to the kernel.
what kind of KERNEL file format does the NTLDT need?

thank you if you give any ideas!
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

Google?

I very much doubt that Microsoft would release any technical info about NTLDR...They like to protect things..
niteice
Member
Member
Posts: 59
Joined: Tue Oct 03, 2006 3:49 pm

Post by niteice »

I'm not sure if it's possible to make NTLDR natively load your kernel unless you perfectly emulate ntoskrnl (check ReactOS for information on that).

However, it IS possible to make NTLDR boot a boot sector, either from an MBR or partition. Dump it to a file and add an entry for said file.
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

Hehe, It would be good to have NTLDR as a boot loader for hobby OS'es :) Ability to load protected mode, virtual memory, multitasking... :P by one bootloader :) It would be good idea to disassemb..., pardon, download ReactOS source and have the bootloader in our operating systems. But I still need something to do when in real mode, like detecting hardware, etc... :) NTDETECT.COM ? :D

inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
niteice
Member
Member
Posts: 59
Joined: Tue Oct 03, 2006 3:49 pm

Post by niteice »

Problem is, it does a lot of Windows-specific things besides loading the kernel - it loads the HAL, registry, and boot-time drivers, among other things.
Andrew275
Member
Member
Posts: 30
Joined: Tue Feb 27, 2007 2:29 pm
Contact:

Post by Andrew275 »

It's true, NTLDR is going to be too Windows-specific. Have you given any thought to using GRUB? It will put you in protected mode too, but it works with any kernel that implements the simple Multiboot Specification (well, it can load others too, but Multiboot will give you the best results).
My operating system: Desktop OS
Content management system/forum: Deluxe Portal
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

Anyone know what the boot.ini file is loaded by? is it the mbr bootsector or NTLDR?

if by mbr, then you could emulate your own NTLDR probably..
Andrew275
Member
Member
Posts: 30
Joined: Tue Feb 27, 2007 2:29 pm
Contact:

Post by Andrew275 »

NTLDR loads boot.ini. And I don't understand why you would want to try to emulate NTLDR, unless your sole purpose is to boot Windows.

NTLDR does things like load the HAL, the system registry hive, and certain NT drivers. None of these are going to be applicable unless you're trying to rewrite ReactOS.
My operating system: Desktop OS
Content management system/forum: Deluxe Portal
yaocong
Posts: 22
Joined: Fri Sep 09, 2005 11:00 pm
Location: China
Contact:

Post by yaocong »

I have succeeded iin loading my own os through windows xp's NTLDR.

look:
http://www.woos.cn/bbs/read.php?tid=2
Attachments
A running testing picture
A running testing picture
23_2_2e3ba096f3e9026.jpg (62.97 KiB) Viewed 6474 times
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

I have some code to load a img from a NTFS partion, if anyones interested, PM me, It's written in ASM though.
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Re: How to use NTLDR(win xp's loader) to load my own kernel

Post by inflater »

Okay, I've researched this a bit. Actually what you need is your bootsector (512 byte long) used to load your kernel. Mine starts from real mode so I modified NTLDR's boot.ini to load e.g. "DERRICK.BST", but it failed to actually load the kernel, because the bootsector was expecting to be raw-writed on a floppy disk (divide by zero error when computing bpb drive parameters). More better solution would be to create a special kind of bootsector for ntldr that would check for the boot drive, either floppy or hard disk. Then, read the first sector which contains the BPB and compute the values from there - and load the kernel :) heh. a bit complicated, but can be done.
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: How to use NTLDR(win xp's loader) to load my own kernel

Post by Dex »

As OS's that use NTLDR also most likely use NTFS, you would just need to write a simple NTFS read.
30-40 lines of asm code should do it.
Post Reply