;GoodFlag1 equ 0bh
;HideFlag1 equ 1bh
;GoodFlag2 equ 0ch
;HideFlag2 equ 1ch
;GoodFlag3 equ 0eh
;HideFlag3 equ 1eh
ORIGIN EQU 7C00H ; Origin of bootstrap LOADER
BIO_MEM EQU 0413H ; BIOS Memory size =640(KB)
BIO_CLK EQU 046CH ; BIOS Clock (1/18.2 seconds)
DSK_PARMS EQU 1EH*4 ;POINTER TO DRIVE PARAMETERS
KEY_BOOTHIDDEN EQU 41H ;Scancode: F7=41H, F11=85H, F12=86H
KEY_BOOTFLOPPY EQU 3FH ;Scancode: F5=3FH
KEY_ESCAPE EQU 01H ;Scancode: ESC=01H
BOOTHIDDENFLAG EQU 80h
ORG 0000h
START:
; WARNING -- Don change this to a short jmp
jmp short main ; Jump to start of code
nop
; ==========================================================================
; Start of BPB area of the boot record
OemName DB "MSDOS"
OsVersion DB "5.0" ; DOS version number
BPB:
BytesPerSector DW 512 ; Size of a physical sector
SecsPerClust DB 1 ; Sectors per allocation unit
ReservedSecs DW 1 ; Number of reserved sectors
NumFats DB 2 ; Number of fats
NumDirEntries DW 00E0h ; Number of direc entries
TotalSectors DW 0B40H ; Number of sectors - number of hidden
; sectors (0 when 32 bit sector number)
MediaByte DB 0F0H ; MediaByte byte
NumFatSecs DW 9 ; Number of fat sectors
SecPerTrack DW 18 ; Sectors per track
NumHeads DW 2 ; Number of drive heads
HiddenSecs DD 0 ; Number of hidden sectors
BigTotalSecs DD 0 ; 32 bit version of number of sectors
BootDrv DB 0h
CurrentHead DB 0h ; Current Head
ExtBootSig DB 41
SerialNum DD 20050628h
VolumeLabel DB "YISIR_LOADER"
FatId DB "FAT12"
; =========================================================================
; First thing is to reset the stack to a better and more known
; place. The ROM may change, but wed like to get the stack
; in the correct place.
main:
cli ;Stop interrupts till stack ok
xor AX,AX
mov ds,ax
mov es,ax
mov SS,AX ;Work in stack just below this routine
mov ax,ORIGIN
mov sp,ax
sti
PUSH AX
;Show message
mov ax,1301h
mov bx,000ah
mov cx,MyMsgLen
mov dx,1500h
mov bp,MyMsg+ORIGIN
int 10h
;Hide the cursor
mov ah,1
mov cx,2000h
int 10h
;Wait 10 seconds
mov si, BIO_CLK
mov edx, dword [si]
mov ecx, edx
add edx, 159 ;18.2*10 seconds
ReadKB:
;Change 5 bytes with install option
;Case Option: /f Boot from floppy disk directly, do not waiting 8 seconds
;31H D2H xor dx,dx
;E9H xxH 00H jmp BiosMemory
;
;Case Option: /b Boot from HIDDEN parition derectly (activate it and load it)
;31H D2H xor dx,dx
;E9H xxH 00H jmp Key_F7
;
;Case Default: Show message and wait 8 second
mov ah, 11h ;Get keyboard status
int 16h
jz NoKeyPress
mov ah,10h ;Read a key (In old code, AH=0, can not read F11/F12...)
int 16h
xor dx,dx
cmp ah, KEY_ESCAPE
jz DX_HD ;Press ESC to BOOT from Harddisk
cmp ah, KEY_BOOTFLOPPY
jnz RKB_1
mov dh, 0ffh ;dh=0 Install INT13, else do not Install. Now DX=FF00H
jmp BiosMemory
RKB_1:
cmp ah, KEY_BOOTHIDDEN
jnz BiosMemory
Key_F7:
;If press Hot key, Boot From Hidden Partition. Now DX=0001H
;modify CH=80h in Int13 procedure
mov byte[ORIGIN+2+BootHiddenCode], BOOTHIDDENFLAG
jmp DX_HD
NoKeyPress:
cmp ecx, dword [si]
jae L_0
test cl,1
jz L_0
mov ax,0e3eh ; write ">" to show progressing
mov bx,0004h
int 10h
L_0:
mov ecx, dword [si]
cmp edx,ecx
jae ReadKB
mov dh,0ffh ;Do not install INT13. Now DX=FF00
DX_HD:
mov dl,080h ;Boot from HD.
;DH=0 Install INT13, DH=FFH do not Install
;DL=0 Boot Floppy, DL=80H Boot HD
;Now:
; ESC DX=FF80, F5 DX=FF00H, F7 DX=0080H, ANYKEY DX=0000H, TIMEOUT DX=FF80H
BiosMemory:
;Show the cursor
mov ah,1
mov cx,0d0eh
int 10h
;BIOS MEMORY - 2KB
mov bx,BIO_MEM ;bx=280H (KB)
mov ax,word [bx]
dec ax
cmp dh,0
jnz L_1
mov word [bx],ax ;If DH=FF, Do not install
L_1:
;Move to High Memory. ex. 9fc0:0000
shl ax,6 ;ax=9fc0h SEG of top memory
mov es,ax ;es=9fc0h
pop si ;si=7c00h
push es ;ready to RETF
xor di,di ;di=0
cld
mov cx,100h
repnz movsw ;move code to 9fc0:0000
cmp dh,0
jnz L_2 ;If DH=0ffh, Do not install
;modify Int13
mov si,4ch ;Int13 13h*4
mov di,OLDINT13
;Save Old
mov eax,[si]
mov [es:di],eax
; cmp dh,0
; jnz L_2 ;If DH=0ffh, Do not install
push es
pop ax
shl eax,16
mov ax, MyInt13
mov [si],eax
L_2: ;Jump to high address, 9fc0:00xx
push ds
pop es
mov bx,word Entre2
push bx ;push 9fc0:Entre2
retf ;跳到高端执行
Entre2:
cmp dl,0 ;If DX <> 0, Load HD-MBR
jnz L_3
ReadFD: ;Read old boot sector from Floppy H1 T79 S18
mov cx,4f12h
mov dx,0100h
jmp RunInt13
L_3: ;Read from Harddisk H0 T0 S1 MBR
mov cx,1
mov dx,80h
RunInt13:
mov ax,0201h
mov bx,ORIGIN
push ds
push bx
int 13h
retf
; 2005-9-1
; 这里是原来用的花哨技巧代码,就是它们导致使用F7启动不了隐藏分区。因为这里读到的是原始的MBR
; pushf ;int 13h
; push ds
; push bx
; ------------------------------------------
;Jump to Old INT 13H
JmpFarInt13:
DB 0eah ;JMP far OLDINT13
OLDINT13 DW 0,0
;End of Install-code
;Partition Flag Table normal and hidden
FlagTable:
dw 0111h, 0414h, 0616h, 0717h, 0b1bh, 0c1ch, 0e1eh
FlagTableEnd:
;My INT13h code
MyInt13:
cmp ah,2 ;Is Read?
jz Func2
cmp ah,42h ;Is ExtRead?
jz Func42
JmpOldInt13:
jmp JmpFarInt13
Func2:
CMP DX,0080H ;Is Harddisk and Head 0?
jnz JmpOldInt13
cmp cx,0001H ;Is Track 0 Sector 1?
jnz JmpOldInt13
pushf ;Simulate INT operator
push cs
CALL JmpFarInt13 ;Call old INT13
jc exit ;Flase then Exit
push bx
push es
jmp EditFlag
Func42:
cmp dl,80h ;Is Harddisk
jnz JmpOldInt13
push eax
xor eax,eax
cmp dword [si+8],eax ;Is Sector 0, Low 32bit
jnz ExitFunc42
cmp dword [si+12],eax ;Is Sector 0, Hight 32bit
jnz ExitFunc42
pop eax
pushf ;Simulate INT operator
push cs
CALL JmpFarInt13 ;Call old INT13
jc exit ;If flase then Exit
push bx
push es
mov bx, [si+4] ; Fix BX,ES like Int13h Func02
mov es, [si+6]
jmp EditFlag
ExitFunc42:
pop eax
jmp JmpOldInt13
EditFlag:
push ax
push cx
push si
ado_cn1
- 粉丝: 3
- 资源: 13
最新资源
- 毕设和企业适用springboot企业数据监控平台类及食品配送管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及文化旅游信息平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及物联网监控平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及数据管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及物流管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及线上图书馆源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及虚拟现实体验平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及音频处理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及在线系统源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及员工管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据智能分析平台类及广告分析平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据监控平台类及智慧交通调度平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据智能分析平台类及仓库管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据智能分析平台类及家庭健康管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据智能分析平台类及交通运输管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业数据智能分析平台类及机器人控制平台源码+论文+视频.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈