Page 1 of 1

How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 3:13 am
by zrhbob
Normally, NTLDR could chainload boot files (i.e a 512 bytes boot sector file). And when the file is larger than 512bytes, NTLDR only loads the first 512bytes to memory.

But if the boot file meets some special requirements, NTLDR will load the entire file, even if it is very large. And GRUB4DOS is a good example: GRLDR.MBR is 9KB, and it could be loaded by NTLDR directly.

It is said that two of the requirements are:
1. The boot file must be larger than 8kb (16 sectors)
2. The second sector of the boot file must be a series of NOPs, follow by a JMP, to the very start of the boot file.

But still, NTLDR only loads the first 512bytes of my boot file, so there might be some other requirements to the boot file.
Any suggestions?

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 5:05 am
by halofreak1990
This may be a silly question, but why are you trying to have NTLDR load your boot file?
Is there something NTLDR can do that GRUB can't?

Otherwise, I'd say save yourself the pain and just use GRUB.

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 6:04 am
by Griwes
And I would just save myself a pain and just write a proper bootloader from scratch, so you can just both chainload it and boot using BIOS only.

As a matter of fact, I did this before and I really like having full control over PC during boot.

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 6:30 am
by zrhbob
halofreak1990 wrote:This may be a silly question, but why are you trying to have NTLDR load your boot file?
Is there something NTLDR can do that GRUB can't?
Actually, some of my friends decided to try my OS, and currently I use GRUB or just BIOS to load my OS. But my friends do not know what GRUB is, and refuse to install it.
So having my OS able to be loaded by NTLDR, as well as GRUB, would make it easier for users who do not use GRUB to try my OS.

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 6:31 am
by egos
zrhbob, be quiet. NTLDR loads 512 bytes in any way. grldr.mbr's starting code loads the rest of itself (using dirty trick).
zrhbob wrote:Actually, some of my friends decided to try my OS, and currently I use GRUB or just BIOS to load my OS. But my friends do not know what GRUB is, and refuse to install it.
So having my OS able to be loaded by NTLDR, as well as GRUB, would make it easier for users who do not use GRUB to try my OS.
Do you have Live CD/flash drive with your OS?

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 6:52 am
by zrhbob
I'm sorry, but please forgive my poor English, I am not going to be mad :D

According to the author of GRUB4DOS, NTLDR will load the entire file as long as the file meets the requirement

See
http://bbs.znpc.net/forum.php?mod=viewthread&tid=6176

In this page, the authors of GRUB4DOS are discussing how to make grldrstart.s smaller and stronger. The author said that NTLDR loads the first 16 sectors of GRLDR, then the first 16sectors load the rest of GRLDR. And NTLDR loads the entire 18 sectors of GRLDR.MBR to memory.

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 7:12 am
by egos
Translate, please :x If you are so mistrustful, ask your question to the authors of GRUB4DOS.

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 7:59 am
by trinopoty
What I would suggest is:
Make NTLDR load your boot-sector and make your boot-sector load everything else. It will work like BIOS loaded you.

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 10:13 am
by bluemoon
Distribute a premature OS to friends and let them run on real machine may not be a good idea (You/your friend may damage something in the progress).
I would recommend let your friend try it on an emulator first, it's much more acceptable even for strangers, and zero-risk.

If you are asking your friend for testing environment, make sure they acknowledge the risk involved and do it the way you planed/supported (e.g. boot on grub).

Ok, back to the topic, NTLDR is not designed to load non-windows OS, so if you are looking for a way to have NTLDR load your boot loader it is not a reliable solution.
The usual way is have a boot manager sit before the chain, and have the boot manager chain-load "your OS" or NTLDR; note that however such boot manager not necessary resident on local harddisk, it can be on a bootable removable media (CD, USB) - I suggest you look into grub on CD/USB, or even simpler, boot your OS on USB (with BIOS HDD emulations).

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 10:34 am
by egos
I have checked what NTLDR does. Additionally to first sector loaded into memory at 7C00h it loads first 16 sectors into memory at 0D000h and jumps to 0D00h:256h.

Re: How to make NTLDR load boot files larger than 512bytes?

Posted: Sun Oct 14, 2012 8:25 pm
by zrhbob
Thank you, egos! I'll have a try.