int 13 磁盘编号规则 驱动器号

 

先看int 13对磁盘的一个操作说明:

INT 13H,AH=00H 软、硬盘控制器复位

说明:
  此功能复位磁盘(软盘和硬盘)控制器板和磁盘驱动器,它在磁盘控制器芯片上完成复位操场作并在磁盘进行所需的操作之前做一系列用于磁盘校准的磁盘操作。
  当磁盘I/O功能调用出现错误时,需要调用此功能,此刻复位功能将使BIOS像该磁盘重新插入一样检查驱动器中磁盘状态,并将磁头校准使之在应该在的位置上。
  此功能调用不影响软盘或硬盘上的数据。
入口参数:
  AH=00H  指明调用复位磁盘功能。
  DL    需要复位的驱动器号。
返回参数:
  若产生错误,进位标志CF=1,错误码在AH寄存器。

这里的DL是驱动器的编号

 

编号法则为:磁盘的第一个分区为0,第二个为1,依次类推。

若为硬盘,则第7位置位(我也搞不清楚这个7是如何算的,就是最高位。第一个分区,也就是若是硬盘则设成0x80,软盘则为0x00)

 

参考:http://support.microsoft.com/kb/62571/zh-cn

 

You can use the following algorithm to convert any logical drive letter (ASCII) to the drive numbers that Interrupt 13H uses:

  1. Identify the block device with Interrupt 21H IOCTL function 44H, subfunction 0dH, minor code 60H (Get Device Parameters), as either a floppy disk drive or a hard disk drive by checking the returned parameter block "device type" field byte at offset +1. A value of 0-4 or 7 indicates that it is a floppy disk drive. A value of 5 indicates that it is a hard disk drive.
  2. If the device is a floppy disk drive, subtract 1 from the BL drive number input to the function Get Device Parameters to make it zero based, or take the uppercase ASCII logical drive letter and subtract the value of "A". For example:
          Drive letter "A" - "A" = 0,  "B" - "A" = 1, and so on
    						
  3. If the device is a hard disk drive, you need to interpret the hard disk partition table to differentiate between a primary partition and a logical partition because the ordering of logical drive numbers does not necessarily reflect the physical order and corresponding BIOS physical drive number.

    For more information, query on the following keywords:
    prod(msdos) and driver.sys and order
    Once you know how MS-DOS assigns logical drive letters on system initialization, you need to address the correct physical hard disk and compute the offset (starting sector number) of any logical drive by using the starting sector values supplied in the hard disk's partition table. These starting sector numbers would be supplied to the BIOS Int 13H function to access those sectors representing a logical drive. "Advanced MS-DOS Programming" by Ray Duncan has more information on the boot record and partition tables.
       Example
       -------
    
       HD 1: Bios# 80H      HD 2: Bios# 81H      HD X: Bios# X...
    
       C: (primary)         E: (logical)
       -----------          -----------
       D: (logical)         F: (logical)
    						
    To access logical drive D, address HD 1: Bios# 80H, but sectors starting at logical partition D:.

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值