1

I have been given an end of term project to write an assembly code to read the MBR and save it to floppy. I think I managed to read it with INT 13h in DOS in a VirtualBox machine. The machine has only one hard disk with one partition with XP installed.

When I read the MBR and print it, it gives me a whole lot of junk and amongst the junk it says: Invalid partition table. Error loading operating system... just like in this website: http://mbr.adamsatoms.com

But my system boots fine. Did I read the MBR correctly. Is it really the MBR? Why does this happen? This is part of my code for reading if it helps:

        mov dx,80h ; hard disk first drive
        mov cx,1 ; Cylinder & Sector
        mov bx,ds
        mov es,bx
        mov bx,offset result
        mov ax,0201h ; function & sector to be read
        int 13h     
phuclv
  • 37,963
  • 15
  • 156
  • 475
Auxiliary
  • 2,687
  • 5
  • 37
  • 59

2 Answers2

4

You're seeing part of the boot loader. This is a piece of program stored in the first sectors of your drive, which' job it is to read the partition table and start booting the OS. If this fails, it shows the error messages for which you just found the source... The rest of the 'junk' will be code of the bootloader (in machine code), you'll need to disassemble it for it to make sense.

Wim
  • 11,091
  • 41
  • 58
4

It's normal, the "garbage" is the machine code that composes the MBR, and the various error strings are there to be displayed if the MBR code encounters some problems while trying to boot the PC. The full analysis of the MBR code is exactly at the page you said.

Matteo Italia
  • 123,740
  • 17
  • 206
  • 299
  • Thanks. Now I understand, so the error within the MBR is there for use if an error happens it doesn't mean there is an error right now. – Auxiliary Jan 02 '10 at 14:38