View Full Version : Program To Boot Before Windows

06-03-2009, 05:53 AM
Hi everyone, so I'm interested in designing a program that would be capable of booting before everything else on the computer. What I mean is, something like a boot-time scan on an anti-virus program which can be scheduled to run at boot, in a sort of DOS style screen. My questions are as follows:

Would I need to edit the autoexec.bat / .nt file?
Will I need to compile my program without accessing any APIs requiring windows?
Can I use standard C++ with printf/scanf for input/output?
So basically: How exactly is this accomplished?

I'm academically interested in this because I've been programming C/C++ for a long time and never had to do this before. The thought popped into my head the other day and I can't stop wondering how it's done. How do I design and implement a program to run before windows?

06-04-2009, 10:25 PM
You could install the program to a separate partition and boot to this partition from the bootloader on the MBR. Then once you've done your scanning, you could "forward" the boot to the windows partition. Programming above the OS could be a little tricky... You could install a minimalist linux distro to the partition or work on a Linux from Scratch system and you should be able to use the same commands as normal.

06-05-2009, 01:50 AM
On Windows at least, there must be some standardized way of doing this. I've seen boot time defragmenters and such do it, what usually happens is they run shortly after the kernel is initialized but before the GUI is loaded. That way you can leverage having a working operating system to do whatever it is you need to do before a lot of the other components are loaded.

On Linux there are very few cases where this needs to be done. The reason for this is that programs are executed differently, the executable is loaded into memory and no longer requires the copy on the disk while it is running. This is actually pretty nice because it makes upgrading stuff so much easier. You can replace the binaries and then once you are done, just restart the program and you are running the new version.