开发者

Bootloader help... why is USB drive booting even without boot signature?

开发者 https://www.devze.com 2023-02-22 22:08 出处:网络
I was reading this article about how to boot from a floppy disk: http://www.cs.umbc.edu/portal/help/nasm/boot.shtml

I was reading this article about how to boot from a floppy disk: http://www.cs.umbc.edu/portal/help/nasm/boot.shtml

I will give the code here:

; boot1.asm   stand alone program for floppy boot sector
; Compiled using            nasm -f bin boot1.asm
; Written to floppy with    dd if=boot1 of=/dev/fd0

; Boot record is loaded at 0000:7C00,
    ORG 7C00h
; load message address into SI register:
    LEA SI,[msg]
; screen function:
    MOV AH,0Eh
print:  MOV AL,[SI]         
    CMP AL,0         
    JZ done     ; zero byte at end of string
    INT 10h     ; write character to screen.    
        INC SI         
    JMP print

; wait for 'any key':
done:   MOV AH,0       
        INT 16h     ; waits for key press
            ; AL is ASCII code or zero
            ; AH is keyboard code

; st开发者_JAVA百科ore magic value at 0040h:0072h to reboot:
;       0000h - cold boot.
;       1234h - warm boot.
    MOV  AX,0040h
    MOV  DS,AX
    MOV  word[0072h],0000h   ; cold boot.
    JMP  0FFFFh:0000h    ; reboot!

msg     DB  'Welcome, I have control of the computer.',13,10
    DB  'Press any key to reboot.',13,10
    DB  '(after removing the floppy)',13,10,0
; end boot1

I assembled it using nasm and then copied it to a USB drive using dd. Then I restarted the system and it worked just fine. My problem is that why is this working even when we have not defined 0xaa55 at 511th byte? Please explain this to me. And also, what is cold reboot and warm reboot? Kindly give me a good link where I can learn in detail about the booting process...


EDITED: Thanks for you responses! but I found why this was happening in this case. It was that I had made this drive bootable sometime ago and the formatted it many times after that. Turns out that the format does not affect the MBR. So, when I printed the hex dump of the contents of the drive using lde, I found out the signature was still there. Now that I removed it, booting from the drive is showing the error "Operating System not found".


It depends on your computer's BIOS. A lot of BIOS implementations do not require the AA55 signature to boot floppy disks, and since a USB drive is neither a floppy disk or hard drive, it is up to the BIOS to decide which it should be treated as. I would guess that your BIOS does not require the signature for floppy disks and treats USB drives as floppy drives, which would mean it also does not require the signature for USB drives.

See Jim's comment for the difference between cold and warm boot.

0

精彩评论

暂无评论...
验证码 换一张
取 消