Extended read of int 0 × 13 (Ah = 0 × 42)

Source: Internet
Author: User

Link: http://www.mouseos.com/win7/int_0x13.html#42

1. Extended read of int 0x13 (Ah = 0x42)

The 0x42 function of int 0x13 reads n sectors from the disk to the buffer.

Entry parameters: Ah = 0x42, DL = disk number (0x80 is the hard disk), DS: SI = Buffer

The read Buffer structure, which is described as follows in C:

Struct buffer_packet
{
Short buffer_packet_size;/* struct's size (which can be 0x10 or 0x18 )*/
Short sectors;/* Number of Sectors Read */
Char * buffer;/* buffer address */
Long long start_sectors;/* start from which sector to read */
Long long * l_buffer;/* 64-bit buffer address */
} Buffer;

The buffer_packet structure can be 16 bytes or 24 bytes.

When buffer_packet_size is set to 0x10, the last l_buffer is invalid. When buffer_packet_size is set to 0x18, l_buffer needs to be provided.

Note:

Buffer address in the buffer_packet structure. It is a logical address, that is, segment: offset.

The offset value is placed in the lower word, and the segment value is placed in the higher word.

Remember!

 

The following is a typical usage from Windows 7 MBR.

Typical int 0x13 0th x 42 function usage:

/* Use the int 0x13 extended read 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/* use the 16 bytes structure, that is, no 64-bit buffer address */

00000077 b442 mov ah, 0x42
00000079 8a5600 mov DL, [bp + 0x0]/* hard disk = 0x80 */
2017007c 8bf4 mov Si, SP/* buffer_packet address (DS: Si )*/
2017007e CD13 int 0x13

 

 

2. Int 0x13 get disk parameters (Ah = 0x48)

The obtained disk parameters are stored in the provided buffer. These parameters include:

★Disk cylinders quantity
★Disk heads count
★Sectors per track
★Total number of sectors of a disk
★Number of bytes per slice

This Buffer structure is described in C as follows:

Struct driver_parameters
{
Short buf_size;/* size of the buffer structure */
Short flags;/* flag */
Int cylinders;/* Number of cylinders */
Int heads;/* Number of heads */
Int sectors_per_track;/* number of sectors per track */
Long long sectors;/* Total number of sectors on the disk */
Short bytes_per_sector;/* number of bytes per slice */

} Buffer;

The following is a typical usage of DBR from Windows 7:

Typical int 0x13 0th x 48 function usage:

2017008d 1E PUSH DS
2017008e 83ec18 sub sp, byte + 0x18/* Reserved 0x18 space */
00000091 681a00 push word 0x1a/* write the 1st words of the buffer, that is, buf_size = 0x1a */
00000094 b448 mov ah, 0x48
00000096 8a160e00 mov DL, [0xe]/* drive ID, that is, 0x80 */
2017009a 8bf4 mov Si, SP
2017009c 16 push SS
2017009d 1f pop DS
2017009e CD13 int 0x13/* Get Driver parameters */

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.