驅動程式的檔頭資訊是用來設定Callback副程式以及描述驅動程式的屬性
| 欄位 | 長度 | 描述 |
|---|---|---|
| NextDriver | 4 Bytes | 指向下一個驅動程式的位置,如果沒有下層驅動程式,設定-1即可 |
| Attribute | 2 Bytes | 描述驅動程式的屬性 |
| Strategy | 2 Bytes | Callback副程式 |
| Interrupt | 2 Bytes | Callback副程式 |
| DriverName | 8 Bytes | 驅動程式的名稱,可以使用mem /d指令查看,不足8個字元時,其餘要補上空白字元 |
Attribute的欄位屬性
| 位元 | 說明 |
|---|---|
| 0 | 0 - Not Standard Input Device 1 - Standard Input Device |
| 1 | 0 - Not Standard Output Device 1 - Standard Output Device |
| 2 | 0 - Not NUL Device 1 - NUL Device |
| 3 | 0 - Not Clock Device 1 - Clock Device |
| 4 | 0 - 1 - Fast Console I/O |
| 5 | 0 - 1 - Reserved |
| 6 | 0 - 1 - Generic IOCTL |
| 7 | 0 - 1 - IOCTL Query |
| 8 | 0 - 1 - Reserved |
| 9 | 0 - 1 - Reserved |
| 10 | 0 - 1 - Reserved |
| 11 | 0 - Not Support Removable Media 1 - Supports Removable Media |
| 12 | 0 - 1 - Reserved |
| 13 | 0 - IBM Format Block Device 1 - Non-IBM Format Block Device |
| 14 | 0 - Not Support IOCTL 1 - Supports IOCTL |
| 15 | 0 - Block Device 1 - Character Device |
範例如下:
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'
MyStrategy:
ret
MyInterrupt:
ret
MyDriver endp
cseg ends
end
系統呼叫驅動程式是採取兩個階段的呼叫方式,所謂兩個階段的意思就是,系統會先呼叫Strategy Callback副程式並且把要傳遞給驅動程式的資料放在ES:BX位址,所以,Strategy Callback副程式就類似預處理動作,呼叫完Strategy Callback副程式後,系統接著呼叫Interrupt Callback副程式,當Interrupt Callback副程式被呼叫時,驅動程式本身就必需去參考剛剛Strategy Callback副程式儲存的ES:BX資料,這樣驅動程式就會知道系統要它去執行什麼樣的Command,而ES:BX資料就是所謂的I/O Request Packet(IRP)