Page 1 of 1

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

Posted: Tue Jul 10, 2007 8:57 pm
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!

Posted: Tue Jul 10, 2007 10:04 pm
by earlz
Google?

I very much doubt that Microsoft would release any technical info about NTLDR...They like to protect things..

Posted: Tue Jul 10, 2007 10:12 pm
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.

Posted: Wed Jul 11, 2007 8:12 am
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

Posted: Wed Jul 11, 2007 8:39 am
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.

Posted: Wed Jul 11, 2007 1:14 pm
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).

Posted: Wed Jul 11, 2007 8:32 pm
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..

Posted: Wed Jul 11, 2007 8:50 pm
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.

Posted: Sun Jul 29, 2007 7:46 pm
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

Posted: Mon Jul 30, 2007 8:18 am
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.

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

Posted: Mon Sep 15, 2008 4:02 am
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.

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

Posted: Mon Sep 15, 2008 7:48 am
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.