-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmbr.asm
More file actions
62 lines (51 loc) · 1.22 KB
/
mbr.asm
File metadata and controls
62 lines (51 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
; mbr.asm
; Copy bootkit to 0x80000 and jmp it
; in 16 bit read mode
bits 16
org 0x7c00
; The stack segment
%define STACKSEG 0x2000
; Loader code segment
%define BOOTKIT_SEGMENT 0x8000
; start is loaded at 0x7c00 and is jumped to with CS:IP 0:0x7c00
start:
jmp after_param
times 4 - ($-$$) nop
;================================================
; 参数,位于+4偏移处,以下内容要bootkit安装程序来填写
;================================================
mbr_param:
mbr_magic: db "BKS1" ; BootKit Stage 1
bootkit_dap:
db 0x10, 0x00 ; size & unused
dw 0x00 ; num_sectors
dw 0x00 ; dst_offset
dw BOOTKIT_SEGMENT ; dst_segment
dq 0x00 ; src_lba_addr
after_param:
cli
; set up %ds and %ss as offset from 0
xor ax, ax
mov ds, ax
mov ss, ax
mov sp, STACKSEG ; set temp stack
sti
; load bootkit from disk
mov si, bootkit_dap ; DS:SI = Data Accesss Packet
mov ax, 0x4280 ; AH=42h, AL=80h
int 0x13
jc die
; jmp to bootkit
push word BOOTKIT_SEGMENT
push word 0x0200
retf
die:
; Allow the user to press a key, then reboot
xor ax, ax
int 0x16
int 0x19
; int 0x19 should never return. In case it does anyway,
; invoke the BIOS reset code...
push 0xf000
push 0xfff0
retf