main.asm
cseg segment para public 'code'
MyDriver proc far
assume cs:cseg, es:cseg, ds:cseg
NextDriver dd -1
Attribute dw 8000h
Strategy dw MyStrategy
Interrupt dw MyInterrupt
DriverName db 'MyDriver'
RhOffset dw ?
RhSegment dw ?
bootmsg db 'Hello, world!', 0dh, 0ah, '$'
CmdTable dw Init
MyStrategy:
mov cs:RhSegment, es
mov cs:RhOffset, bx
ret
MyInterrupt:
cld
push ds
push es
push ax
push bx
push cx
push dx
push di
push si
mov al, es:[bx]+2
cmp al, 0
jnz SkipCurRequest
rol al, 1
lea di, CmdTable
mov ah, 0
add di, ax
jmp word ptr[di]
Init:
lea dx, bootmsg
mov ah, 9
int 21h
lea ax, Exit
mov es:[bx]+0eh, ax
push cs
pop ax
mov es:[bx]+10h, ax
mov es:word ptr 3[bx], 0100h
jmp CompleteCmd
SkipCurRequest:
mov es:word ptr 3[bx], 8103h
jmp CompleteCmd
CompleteCmd:
mov bx, cs:RhOffset
mov es, cs:RhSegment
pop si
pop di
pop dx
pop cx
pop bx
pop ax
pop es
pop ds
ret
Exit:
MyDriver endp
cseg ends
end
編譯
C:> masm main.asm C:> link main.obj C:> exe2bin main.exe
P.S. 編譯程式記得在C:\編譯
開機自動載入驅動程式

使用Pause讓命令暫停執行,避免Debug Log被洗掉

完成

使用mem /d | more就可以看到MyDriver驅動程式