int 0×13 的擴充讀(ah = 0×42)

來源:互聯網
上載者:User

原文連結:http://www.mouseos.com/win7/int_0x13.html#42

1、 int 0x13 的擴充讀(ah = 0x42)

int 0x13 的 0x42 號功能從磁碟讀 n 個 sectors 到 buffer 中。

入口參數:ah = 0x42, dl = 磁碟號(0x80 為硬碟), ds:si = buffer

讀入的 buffer 結構,用 c 描述為:

struct buffer_packet
{
    short buffer_packet_size;         /* struct's size(可以為 0x10 或 0x18)*/
    short sectors;                    /* 讀多少個 sectors */
    char *buffer;                     /* buffer address */
    long long start_sectors;          /* 從哪個 sector 開始讀 */
    long long *l_buffer;              /* 64 位元的 buffer address */
} buffer;

這個 buffer_packet 結構大小可以為 16 bytes 或者 24 bytes

當 buffer_packet_size 設定為 0x10,最後的 l_buffer 無效。 buffer_packet_size 設為 0x18 時,l_buffer 需要提供。

注意:

   buffer_packet 結構裡的 buffer 地址,它是個邏輯地址,即:segment:offset

  低 word 放著 offset 值,高 word 放著 segment 值。

  切記!

 

 下面是摘自 windows 7 的 MBR 中的典型用法

典型的 int 0x13 第 0x42 號功能用法:

/* 以下是使用 int 0x13 擴充功能讀 disk */

00000061  666800000000      push dword 0x0
00000067  66FF7608          push dword [bp+0x8]   /* start sectors for read */
0000006B  680000            push word 0x0
0000006E  68007C            push word 0x7c00   /* buffer address */
00000071  680100            push word 0x1
00000074  681000            push word 0x10   /* 使用 16 bytes 的結構,即不需要 64 位元 buffer address */

00000077  B442              mov ah,0x42
00000079  8A5600            mov dl,[bp+0x0]      /* hard disk = 0x80 */
0000007C  8BF4              mov si,sp            /* buffer_packet 的 address(ds:si) */
0000007E  CD13              int 0x13            

 

 

2、 int 0x13 擷取磁碟參數(ah = 0x48)

擷取的磁碟參數儲存在提供的 buffer 裡,這些參數包括:

★ 磁碟的 cylinders 數量
★ 磁碟的 heads 數量
★ 每道的 sectors 數
★ 磁碟總共有多少扇區
★ 每個扇區有多少位元組

這個 buffer 結構,用 c 描述如下:

struct driver_parameters 
{
    short buf_size;              /* 緩衝區結構的大小 */
    short flags;                 /* 標誌 */
    int cylinders;               /* cylinders 數量 */
    int heads;                   /* heads 數量 */
    int sectors_per_track;       /* 每道的 sectors 數 */
    long long sectors;           /* 磁碟總共的 sectors 數 */
    short bytes_per_sector;      /* 每個扇區的 bytes 數 */

} buffer;

下面是摘自 windows 7 的 DBR 中的典型用法:

典型的 int 0x13 第 0x48 號功能用法:

0000008D  1E                push ds
0000008E  83EC18            sub sp,byte +0x18      /* 預留 0x18 個空間 */
00000091  681A00            push word 0x1a         /* 寫 buffer 的第 1 個 word ,即:buf_size = 0x1a */
00000094  B448              mov ah,0x48
00000096  8A160E00          mov dl,[0xe]           /* 磁碟機 ID,即:0x80 */
0000009A  8BF4              mov si,sp
0000009C  16                push ss
0000009D  1F                pop ds
0000009E  CD13              int 0x13               /* 擷取 driver 參數 */

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.