I need to be able to read raw hard disk bytes with a bootstrap
I've been trying this for 1 year now and can't seem to find anything useful (yeah, I know I suck). I've made a C++ application with WinAPI which allows me to read and write raw disk bytes with CreateFile(). However, now I need to do it with assembly so the program runs as a bootloader. It will interact with the user, but that part I can handle.
I found that all tutorials talk about bootloaders and bootstraps loaded from a floppy disk, not a hard disk, and when I change the parameters for a hard disk it doesn't work.
I no longer know what to do, I've created and got rid of countless bootloaders until now because I couldn't make them work. Does anyone know of any code or tutorial that will allow me to read the MBR 512 bytes with a bootstrap and store them in a variable? That's where I'm stuck, I can't read them from the hard disk, much less store them in a variable (which I will then use teletype to print it to the screen).
I am using 16 bits assembly and emu8086 as compiler. Tried to look if one could make a bootloader with 32 bits assembly, but found no tutorial on 32 bits bootstraps.
The original INT 13h was for a real-mode system. Once the operating system has booted into the OS these days, unless you are running MS-DOS/FreeDOS, et al, you will be running in protected mode. You need to check your OS documentation to see if INT 13h will still work for you. You set up some registers for the sector to read, and possibly the address to read the disc into (normally that would be fixed in a real-mode boot loader), execute the interrupt, and there you are. FWIW, the last time I wrote a bootloader (real mode) was in 1986 or 1987. I'd have to pull out my old IBM PC BIOS docs to see what needs to be done for sure...
Ah, don't worry. It does work, my code. Its just that I thought it didn't work because I couldn't see what I was reading from the hard disk when I tried to print it to the screen. In shorts, my code wasn't the correct way of prinitng what I had, but it was reading.
So yup, it does work for a couple of sectors. Let me add that there are limits in real mode and if one wants to read past those limits, one needs to enter protected mode.