win7 sp1 mbr.asm

看到的记录

; Input MD5   : 526310D6B6734D0959C7ECFD0BF97E0D
; Input CRC32 : 0F847F65
; Load in 0000h:7C00h
; ss:sp = 0000h:0400h, ds = 0040h (BIOS  data area)
; Memory layout:

; 0000:0000 - 0000:0FFF: Interrupt vector table & BIOS data
; 0000:1000 - 0000:6FFF: Real mode stack area
; 0000:7000 - 0000:7FFF: Cmdline (multiboot)
; 0000:8000 - xxxx:xxxx: FreeLoader program & data area
; xxxx:xxxx - 7000:7FFF: Random memory allocation heap
; 7000:8000 - 7000:FFFF: Protected mode stack area
; 8000:0000 - 8000:FFFF: File system read buffer
; 9000:0000 - 9000:FFFF: Disk read buffer for BIOS Int 13h
; A000:0000 - FFFF:FFFF: reserved

org 7c00h
0600                 xor     ax, ax                ; ax = 0
0602                 mov     ss, ax                ; ss = 0
0604                 mov     sp, 7C00h             ; sp = 7C00h
0607                 mov     es, ax                ; es = 0
0609                 mov     ds, ax                ; ds = 0
060B                 mov     si, 7C00h             ; si = 7C00h
060E                 mov     di, 600h              ; di = 600h
0611                 mov     cx, 200h              ; cx = 200h
0614                 cld                           ; df = 0
0615                 rep movsb                     ; ds:si = es:di
0617                 push    ax
0618                 push    61Ch                  ; jump to 61Ch
061B                 retf
      ; ---------------------------------------------------------------------------
061C                 sti                           ; df = 1
061D                 mov     cx, 4                 ; cx = 4
0620                 mov     bp, 7BEh              ; bp = 7BEh
0623
      ;    0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15
      ;    BI SH SS SC ID EH ES EC L0 L1 L2 L3 S0 S1 S2 S3
      ;1BE 00 20 21 00 07 AA 28 82 00 08 00 00 00 00 20 00
      ;1CE 80 AA 29 82 07 FE FF FF 00 08 20 00 00 28 80 07
      ;1DE 00 FE FF FF 0F FE FF FF 00 38 A0 07 00 A8 A2 1D
      ;1EE 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      ;1FE 55 AA

0623 _CheckPTBHead:                                ; CODE XREF: seg000:0630j
0623                 cmp     byte ptr [bp+0], 0
0627                 jl      short loc_634         ; if bp < 0 jmp 634
0629                 jnz     _InvalidPTB           ; if bp != 0 jmp _InvalidPTB
062D                 add     bp, 10h               ; bp += 10h
0630                 loop    _CheckPTBHead               ; loop
0632                 int     18h                   ; TRANSFER TO ROM BASIC
0632                                               ; causes transfer to ROM-based BASIC (IBM-PC)
0632                                               ; often reboots a compatible      ; often has no effect at all
0634
0634 loc_634:                                      ; CODE XREF: seg000:0627j
0634                                               ; seg000:06AEj
0634                 mov     [bp+0], dl
0637                 push    bp
0638                 mov     byte ptr [bp+11h], 5
063C                 mov     byte ptr [bp+10h], 0
0640                 mov     ah, 41h
0642                 mov     bx, 55AAh
0645                 int     13h                   ; DISK - Check for INT 13h Extensions
0645                                               ; BX = 55AAh, DL = drive number
0645                                               ; Return: CF set if not supported
0645                                               ; AH = extensions version
0645                                               ; BX = AA55h
0645                                               ; CX = Interface support bit map
0647                 pop     bp
0648                 jb      short loc_659
064A                 cmp     bx, 0AA55h
064E                 jnz     short loc_659
0650                 test    cx, 1
0654                 jz      short loc_659
0656                 inc     byte ptr [bp+10h]
0659
0659 loc_659:                                      ; CODE XREF: seg000:0648j
0659                                               ; seg000:064Ej ...
0659                 pushad
065B                 cmp     byte ptr [bp+10h], 0
065F                 jz      short loc_687
0661                 push    large 0
0667                 push    large dword ptr [bp+8]
066B                 push    0
066E                 push    7C00h
0671                 push    1
0674                 push    10h
0677                 mov     ah, 42h
0679                 mov     dl, [bp+0]
067C                 mov     si, sp
067E                 int     13h                   ; DISK - IBM/MS Extension - EXTENDED READ (DL - drive, DS:SI - disk address packet)
0680                 lahf
0681                 add     sp, 10h
0684                 sahf
0685                 jmp     short loc_69B
0687       ; ---------------------------------------------------------------------------
0687
0687 loc_687:                                      ; CODE XREF: seg000:065Fj
0687                 mov     ax, 201h
068A                 mov     bx, 7C00h
068D                 mov     dl, [bp+0]
0690                 mov     dh, [bp+1]
0693                 mov     cl, [bp+2]
0696                 mov     ch, [bp+3]
0699                 int     13h                   ; DISK - READ SECTORS INTO MEMORY
0699                                               ; AL = number of sectors to read, CH = track, CL = sector
0699                                               ; DH = head, DL = drive, ES:BX -> buffer to fill
0699                                               ; Return: CF set on error, AH = status, AL = number of sectors read
069B
069B loc_69B:                                      ; CODE XREF: seg000:0685j
069B                 popad
069D                 jnb     short loc_6BB
069F                 dec     byte ptr [bp+11h]
06A2                 jnz     short loc_6B0
06A4                 cmp     byte ptr [bp+0], 80h
06A8                 jz      _ErrorLoadingOS
06AC                 mov     dl, 80h
06AE                 jmp     short loc_634
06B0       ; ---------------------------------------------------------------------------
06B0
06B0 loc_6B0:                                      ; CODE XREF: seg000:06A2j
06B0                 push    bp
06B1                 xor     ah, ah
06B3                 mov     dl, [bp+0]
06B6                 int     13h                   ; DISK - RESET DISK SYSTEM
06B6                                               ; DL = drive (if bit 7 is set both hard disks and floppy disks reset)
06B8                 pop     bp
06B9                 jmp     short loc_659
06BB       ; ---------------------------------------------------------------------------
06BB
06BB loc_6BB:                                      ; CODE XREF: seg000:069Dj
06BB                 cmp     word ptr ds:7DFEh, 0AA55h
06C1                 jnz     short _MissingOS
06C3                 push    word ptr [bp+0]
06C6                 call    sub_756
06C9                 jnz     short loc_6E2
06CB                 cli
06CC                 mov     al, 0D1h
06CE                 out     64h, al               ; 8042 keyboard controller command register.
06CE                                               ; Write output port (next byte to port 60h):
06CE                                               ; 7:  1=keyboard data line pulled low (inhibited)
06CE                                               ; 6:  1=keyboard clock line pulled low (inhibited)
06CE                                               ; 5:  enables IRQ 12 interrupt on mouse IBF
06CE                                               ; 4:  enables IRQ 1 interrupt on keyboard IBF
06CE                                               ; 3:  1=mouse clock line pulled low (inhibited)
06CE                                               ; 2:  1=mouse data line pulled low (inhibited)
06CE                                               ; 1:  A20 gate on/off
06CE                                               ; 0:  reset the PC (THIS BIT SHOULD ALWAYS BE SET TO 1)
06D0                 call    sub_756
06D3                 mov     al, 0DFh
06D5                 out     60h, al               ; 8042 keyboard controller data register.
06D7                 call    sub_756
06DA                 mov     al, 0FFh
06DC                 out     64h, al               ; 8042 keyboard controller command register.
06DC                                               ; Pulse output port.
06DC                                               ; Bits 0-3 indicate ports to pulse.
06DE                 call    sub_756
06E1                 sti
06E2
06E2 loc_6E2:                                      ; CODE XREF: seg000:06C9j
06E2                 mov     ax, 0BB00h
06E5                 int     1Ah                   ; Trusted Computing Group call - TCG_StatusCheck
06E5                                               ; Return: EAX = 0 if supported
06E5                                               ; EBX = 41504354h ('TCPA')
06E5                                               ; CH:CL = TCG BIOS Version
06E5                                               ; EDX = BIOS TCG Feature Flags
06E5                                               ; ESI = Pointer to Event Log
06E5                                               ;
06E7                 and     eax, eax
06EA                 jnz     short loc_727
06EC                 cmp     ebx, 41504354h
06F3                 jnz     short loc_727
06F5                 cmp     cx, 102h
06F9                 jb      short loc_727
06FB                 push    large 0BB07h
0701                 push    large 200h
0707                 push    large 8
070D                 push    ebx
070F                 push    ebx
0711                 push    ebp
0713                 push    large 0
0719                 push    large 7C00h
071F                 popad
0721                 push    0
0724                 pop     es
0725                 int     1Ah                   ; Trusted Computing Group call - TCG_StatusCheck
0725                                               ; Return: EAX = 0 if supported
0725                                               ; EBX = 41504354h ('TCPA')
0725                                               ; CH:CL = TCG BIOS Version
0725                                               ; EDX = BIOS TCG Feature Flags
0725                                               ; ESI = Pointer to Event Log
0725                                               ;
0727
0727 loc_727:                                      ; CODE XREF: seg000:06EAj
0727                                               ; seg000:06F3j ...
0727                 pop     dx
0728                 xor     dh, dh
072A                 jmp     far ptr 0:7C00h
072F       ; ---------------------------------------------------------------------------
072F                 int     18h                   ; TRANSFER TO ROM BASIC
072F                                               ; causes transfer to ROM-based BASIC (IBM-PC)
072F                                               ; often reboots a compatible      ; often has no effect at all
0731       ; Missing operating system
0731 _MissingOS:                                   ; CODE XREF: seg000:06C1j
0731                 mov     al, ds:byte_7B7       ; al = 9Ah
0734                 jmp     short _ShowMessage
0736       ; ---------------------------------------------------------------------------
0736       ; Error loading operating system
0736 _ErrorLoadingOS:                              ; CODE XREF: seg000:06A8j
0736                 mov     al, ds:byte_7B6       ; al = 7Bh
0739                 jmp     short _ShowMessage
073B       ; ---------------------------------------------------------------------------
073B       ; Invalid partition table
073B _InvalidPTB:                                  ; CODE XREF: seg000:0629j ax = 0
073B                 mov     al, ds:byte_7B5       ; al = 63h
073E
073E _ShowMessage:                                      ; CODE XREF: seg000:0734j
073E                                               ; seg000:0739j
073E                 xor     ah, ah                ; ah = 0
0740                 add     ax, 700h              ; ax = al + 700h
0743                 mov     si, ax                ; si = ax
0745
0745 _DisplayMessage:                              ; CODE XREF: seg000:0751j
0745                 lodsb
0746                 cmp     al, 0
0748                 jz      short _Halt
074A                 mov     bx, 7
074D                 mov     ah, 0Eh
074F                 int     10h                   ; - VIDEO - WRITE CHARACTER AND ADVANCE CURSOR (TTY WRITE)
074F                                               ; AL = character, BH = display page (alpha modes)
074F                                               ; BL = foreground color (graphics modes)
0751                 jmp     short _DisplayMessage
0753       ; ---------------------------------------------------------------------------
0753
0753 _Halt:                                        ; CODE XREF: seg000:0748j
0753                                               ; seg000:0754j
0753                 hlt
0754       ; ---------------------------------------------------------------------------
0754                 jmp     short _Halt
0756
0756       ; =============== S U B R O U T I N E =======================================
0756
0756
0756 sub_756         proc near                     ; CODE XREF: seg000:06C6p
0756                                               ; seg000:06D0p ...
0756                 sub     cx, cx
0758
0758 loc_758:                                      ; CODE XREF: sub_756+8j
0758                 in      al, 64h               ; 8042 keyboard controller status register
0758                                               ; 7:  PERR    1=parity error in data received from keyboard
0758                                               ;    +----------- AT Mode ----------+------------ PS/2 Mode ------------+
0758                                               ; 6: |RxTO    receive (Rx) timeout  | TO      general timeout (Rx or Tx)|
0758                                               ; 5: |TxTO    transmit (Tx) timeout | MOBF    mouse output buffer full  |
0758                                               ;    +------------------------------+-----------------------------------+
0758                                               ; 4:  INH     0=keyboard communications inhibited
0758                                               ; 3:  A2      0=60h was the port last written to, 1=64h was last
0758                                               ; 2:  SYS     distinguishes reset types: 0=cold reboot, 1=warm reboot
0758                                               ; 1:  IBF     1=input buffer full (keyboard can't accept data)
0758                                               ; 0:  OBF     1=output buffer full (data from keyboard is available)
075A                 jmp     short $+2
075C                 and     al, 2
075E                 loopne  loc_758
0760                 and     al, 2
0762                 retn
0762 sub_756         endp
0762
0762       ; ---------------------------------------------------------------------------
0763                 db  49h       ; I Invalid partition table
0764                 db  6Eh       ; n
0765                 db  76h       ; v
0766                 db  61h       ; a
0767                 db  6Ch       ; l
0768                 db  69h       ; i
0769                 db  64h       ; d
076A                 db  20h
076B                 db  70h       ; p
076C                 db  61h       ; a
076D                 db  72h       ; r
076E                 db  74h       ; t
076F                 db  69h       ; i
0770                 db  74h       ; t
0771                 db  69h       ; i
0772                 db  6Fh       ; o
0773                 db  6Eh       ; n
0774                 db  20h
0775                 db  74h       ; t
0776                 db  61h       ; a
0777                 db  62h       ; b
0778                 db  6Ch       ; l
0779                 db  65h       ; e
077A                 db    0
077B                 db  45h       ; E Error loading operating system
077C                 db  72h       ; r
077D                 db  72h       ; r
077E                 db  6Fh       ; o
077F                 db  72h       ; r
0780                 db  20h
0781                 db  6Ch       ; l
0782                 db  6Fh       ; o
0783                 db  61h       ; a
0784                 db  64h       ; d
0785                 db  69h       ; i
0786                 db  6Eh       ; n
0787                 db  67h       ; g
0788                 db  20h
0789                 db  6Fh       ; o
078A                 db  70h       ; p
078B                 db  65h       ; e
078C                 db  72h       ; r
078D                 db  61h       ; a
078E                 db  74h       ; t
078F                 db  69h       ; i
0790                 db  6Eh       ; n
0791                 db  67h       ; g
0792                 db  20h
0793                 db  73h       ; s
0794                 db  79h       ; y
0795                 db  73h       ; s
0796                 db  74h       ; t
0797                 db  65h       ; e
0798                 db  6Dh       ; m
0799                 db    0
079A                 db  4Dh       ; M Missing operating system
079B                 db  69h       ; i
079C                 db  73h       ; s
079D                 db  73h       ; s
079E                 db  69h       ; i
079F                 db  6Eh       ; n
07A0                 db  67h       ; g
07A1                 db  20h
07A2                 db  6Fh       ; o
07A3                 db  70h       ; p
07A4                 db  65h       ; e
07A5                 db  72h       ; r
07A6                 db  61h       ; a
07A7                 db  74h       ; t
07A8                 db  69h       ; i
07A9                 db  6Eh       ; n
07AA                 db  67h       ; g
07AB                 db  20h
07AC                 db  73h       ; s
07AD                 db  79h       ; y
07AE                 db  73h       ; s
07AF                 db  74h       ; t
07B0                 db  65h       ; e
07B1                 db  6Dh       ; m
07B2                 db    0
07B3                 db    0
07B4                 db    0
07B5 byte_7B5        db 63h                        ; DATA XREF: seg000:_InvalidPTBr
07B6 byte_7B6        db 7Bh                        ; DATA XREF: seg000:_ErrorLoadingOSr
07B7 byte_7B7        db 9Ah                        ; DATA XREF: seg000:_MissingOSr
07B8                 db    0
07B9                 db    0
07BA                 db    0
07BB                 db    0
07BC                 db    0
07BD                 db    0
07BE                 db    0       ; partition 1
07BF                 db    0
07C0                 db    0
07C1                 db    0
07C2                 db    0
07C3                 db    0
07C4                 db    0
07C5                 db    0
07C6                 db    0
07C7                 db    0
07C8                 db    0
07C9                 db    0
07CA                 db    0
07CB                 db    0
07CC                 db    0
07CD                 db    0
07CE                 db    0       ; partition 2
07CF                 db    0
07D0                 db    0
07D1                 db    0
07D2                 db    0
07D3                 db    0
07D4                 db    0
07D5                 db    0
07D6                 db    0
07D7                 db    0
07D8                 db    0
07D9                 db    0
07DA                 db    0
07DB                 db    0
07DC                 db    0
07DD                 db    0
07DE                 db    0       ; partition 3
07DF                 db    0
07E0                 db    0
07E1                 db    0
07E2                 db    0
07E3                 db    0
07E4                 db    0
07E5                 db    0
07E6                 db    0
07E7                 db    0
07E8                 db    0
07E9                 db    0
07EA                 db    0
07EB                 db    0
07EC                 db    0
07ED                 db    0
07EE                 db    0       ; partition 4
07EF                 db    0
07F0                 db    0
07F1                 db    0
07F2                 db    0
07F3                 db    0
07F4                 db    0
07F5                 db    0
07F6                 db    0
07F7                 db    0
07F8                 db    0
07F9                 db    0
07FA                 db    0
07FB                 db    0
07FC                 db    0
07FD                 db    0
07FE                 db  55h
07FF                 db 0AAh
07FF                 end
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值