Skip to main content
gamedev.net
🔒 Locked

Bootable Program

Started by KontosHarry Mar 1, 2011 at 10:35 PM 6 replies 2.8k views
Original Post
KontosHarry
KontosHarry
Hello, I have been serching the net without luck the last few days for making a Bootable Hello World Program. Something like an OS but much more simple.

In reality I am planning to create a recovery tool that replaces a file in the windows directoy.

Anyway, I have searched open source projects and programs that are bootable, but my real problem in this is how to make the code actually boot.

What I mean is, I have the code ready but how do I compile it as bootable and then burn the CD which will actually boots in that program?
The programming language I prefer is C++ but I could do with Assembly if needed...
Antheus
Antheus
From wiki:
A bootable device is defined as one that can be read from, and the last two bytes of the first sector contain the word 0xAA55 (also known as the boot signature). 250px-Binary_executable_file2.png magnify-clip.png A hex dump of FreeBSD's boot0 MBR Once the BIOS has found a bootable device it loads the boot sector to hexadecimal Segment:Offset address 0000:7C00 or 07C0:0000 (maps to the same ultimate address) and transfers execution to the boot code[/quote]So, put your code on that offset on disk.


But...

Why not just use a linux distro, mnt the windows partition and cp the file? It will take *much* less time than mucking about with all that mess.
Ravyne
Ravyne
Even if you succeed, creating a bootable set of bits is the easy part -- now you've got to be able to read and write the filesystem that is used to store the file in question, and perform all the low-level operations necessary to support them that.

This is what recovery discs are meant for, they come in Windows and Linux flavors.
throw table_exception("(? ???)? ? ???");
hughiecoles
hughiecoles
This is a great OS dev site to start with. Where it starts deviating is that the tutorial uses the FAT12 filesystem, so you're gonna have to learn the ins and outs of FAT32, NTFS, and/or exFAT. You'd essentially want to create a 2 stage boot loader, and a single application, but I suspect it'll get hairy at some point, so good luck.
--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
assainator
assainator
Keep in mind that when making a bootable program, you're on your own.
No debugging, no file handling, no heap, nothing. You have to do all this yourself. If you are to create a bootable program, You're creating, almost, a whole new OS.

Succes,
assainator
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

KontosHarry
KontosHarry
Thank you everyone for the ideas, and sorry for the late answer.


But...
Why not just use a linux distro, mnt the windows partition and cp the file? It will take *much* less time than mucking about with all that mess.


That would be easier and I am not opposed to it, but then I come to the problem of how to build and make bootable the distro.
I've found a program that works as like as I need, but I cannot build it as bootable.
http://www.pogostick.net/~pnh/ntpasswd/

All I have to do is change the function of the prorgam so that it will edit a diffrent file and in a diffrent way, which I have already done.
As it seems I need to compile it as bin or so to replace the one this program uses.
Thank you for the idea.
klems
klems

Thank you everyone for the ideas, and sorry for the late answer.

[quote name='Antheus' timestamp='1299019860' post='4780717']
But...
Why not just use a linux distro, mnt the windows partition and cp the file? It will take *much* less time than mucking about with all that mess.


That would be easier and I am not opposed to it, but then I come to the problem of how to build and make bootable the distro.
I've found a program that works as like as I need, but I cannot build it as bootable.
http://www.pogostick.net/~pnh/ntpasswd/

All I have to do is change the function of the prorgam so that it will edit a diffrent file and in a diffrent way, which I have already done.
As it seems I need to compile it as bin or so to replace the one this program uses.
Thank you for the idea.
[/quote]Every single Linux distro has bootable CD images, many of them also have bootable USB stick images. You don't need to build anything on your own, all you need to to is download and burn to CD/write to USB stick, and reboot.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.