INT 13

导读:

  [edit]Overview

  Under real modeoperating systems such as MS-DOS, calling INT 0x13 would jump into the computer's BIOS code for Low Level Disk Services, which will carry out sector-based disk read or write for the program. In MS-DOS, it serves as a foundation for higher-level INT 21functions which deal with file systemaccess.

  Newer protected modeoperating systems such as Microsoft Windows NTderivatives (e.g. NT4, 2000 XP and 2003 Server) or Linuxwith dosemu, will intercept the call and pass it to the operating system's native disk I/O mechanism. Windows 9xand Windows for Workgroups 3.11could also bypass BIOS routines when using 32-bit File Access.

  The original BIOS real-mode INT 0x13 interface supports drives of sizes up to about 504 MB using what is commonly referred to as Physical CHS addressing. This limit originates from the hardware interface of the x86disk hardware. The BIOS used the CHS address given in the INT 0x13 call, and transmitted it directly to the hardware interface.

  This interface was later extended to support addressing of up to exactly 8064 MB using what is commonly referred to as Logical CHS addressing. This limit originates from a combination of the register value based calling convention used in the INT 0x13 interface, and the goal of maintaining backward compatibility. There were originally a number of BIOS that offered incompatible versions of this interface, but eventually the computer industry standardized on the interface developed in the Award BIOS. This limit uses 1024 cylinders, 256 heads, 63 sectors, and 512 byte blocks, giving roughly 7.875 GB of addressing (1024 * 256 * 63 * 512).

  To support even larger addressing modes, an interface known as INT13h Extensionswas introduced by Western Digitaland Phoenix Technologiesas part of BIOS Enhanced Disk Drive Services(EDD) standard. It uses 64-bit Logical Block Addressing(LBA) which allows addressing up to 8 ZB(the drive can also support 32-bit or 48-bit LBA which allows up to 2 TBor 128 PBrespectively). This is a packet interface, because it uses a pointer to a packetof information rather than the register based calling convention of the original INT 13 interface. This packet is a data structure that contains an interface version, data size, and LBAs.

  [edit]List of INT 13h services

  [edit]Drive Table

  DL = 00h 1st floppy disk ( "drive A:" )

  DL = 01h 2nd floppy disk ( "drive B:" )

  DL = 80h 1st hard disk

  DL = 81h 2nd hard disk

  [edit]Function Table

  AH = 00h Reset Disk Drives

  AH = 01h Check Drive Status

  AH = 02h Read Sectors From Drive

  AH = 03h Write Sectors To Drive

  AH = 04h Verify Sectors

  AH = 05h Format Track

  AH = 08h Read Drive Parameters

  AH = 09h HD Initialize Disk Controller

  AH = 0Ah HD Read Long Sectors From Drive

  AH = 0Bh HD Write Long Sectors To Drive

  AH = 0Ch HD Move Drive Head To Cylinder

  AH = 0Dh HD Reset Disk Drives

  AH = 0Eh PS/2 Controller Read Test

  AH = 0Fh PS/2 Controller Write Test

  AH = 10h HD Test Whether Drive Is Ready

  AH = 11h HD Recalibrate Drive

  AH = 12h PS/2 Controller RAM Test

  AH = 13h PS/2 Drive Test

  AH = 14h HD Controller Diagnostic

  AH = 15h Read Drive Type

  AH = 16h FD Detect Media Change

  AH = 17h FD Set Media Type For Format ( used by DOS versions <= 3.1 )

  AH = 18h FD Set Media Type For Format ( used by DOS versions >= 3.2 )

  AH = 41h EXT Test Whether Extensions Are Available

  AH = 42h EXT Read Sectors From Drive

  AH = 43h EXT Write Sectors To Drive

  AH = 44h EXT Verify Sectors

  AH = 45h EXT Lock/Unlock Drive

  AH = 46h EXT Eject Drive

  AH = 47h EXT Move Drive Head To Sector

  AH = 48h EXT Read Drive Parameters

  AH = 49h EXT Detect Media Change

  Second column is empty == function may be used both for floppy and hard disk.

  "FD" == for floppy disk only.

  "HD" == for hard disk only.

  "PS/2" == for hard disk on PS/2 system only.

  "EXT" == part of the Int 13h Extensions which were written in the 1990s to support hard drives with more than 8 GB.

  [edit]INT 13h AH=00h: Reset Disk Drives

   Parameters:

  AH 00h

  DL Drive Index

  [edit]INT 13h AH=01h: Check Drive Status

   Parameters:

  AH 01h

   Results:

  AL Return Code

  00h Success

  01h Invalid Command

  02h Cannot Find Address Mark

  03h Attempted Write On Write Protected Disk

  04h Sector Not Found

  05h Reset Failed

  [edit]INT 13h AH=02h: Read Sectors From Drive

   Parameters:

  AH 02h

  AL Sectors To Read Count

  CX Track + Sector / See remark

  DH Head

  DL Drive

  ES:BX Buffer Address Pointer

   Results:

  CF Set On Error, Clear If No Error

  AH Return Code

  AL Actual Sectors Read Count

   Remarks:

   Register CXcontains both the cylinder number (10 bits, possible values are 0 to 1023) and the sector number (6 bits, possible values are 1 to 63):

  

CX = ---CH--- ---CL---

cylinder : 76543210 98

sector : 543210



   Examples of translation:

  

Turbo Pascal:

CX := ( ( cylinder and 255 ) shl 8 ) or ( ( cylinder and 768 ) shr 2 ) or sector;

cylinder := hi ( CX ) or ( ( lo ( CX ) and 192 ) shl 2 );

sector := CX and 63;



  Addressing of Buffer should guarantee that the complete buffer is inside the given segment, i.e. ( BX + size_of_buffer ) <= 10000h. Otherwise the interrupt may fail with some BIOS or hardware versions.

   Example:Assume you want to read 16 sectors (= 2000h bytes) and your buffer starts at memory address 4FF00h. There are different ways to calculate the register values, e.g.:

  

ES = segment = 4F00h

BX = offset = 0F00h

sum = memory address = 4FF00h

would be a good choice because 0F00h + 2000h = 2F00h <= 10000h

ES = segment = 4000h

BX = offset = FF00h

sum = memory address = 4FF00h

would be nogood choice because FF00h + 2000h = 11F00h >10000h



  Function 02h of interrupt 13h may only read sectors of the first 16,450,560 sectors of your hard drive, to read sectors beyond the 8 GB limit you should use function 42h of Int 13h Extensions. Another alternate may be DOS interrupt 25h which reads sectors withina partition.

  [edit]INT 13h AH=08h: Read Drive Parameters

   Parameters:

  Registers

  AH 08h = function number for read_drive_parameters

  DL drive index (e.g. 1st HDD = 80h)

   Results:

  CF Set On Error, Clear If No Error

  AH Return Code

  DL number of hard disk drives

  DH logical last index of heads = number_of - 1 (because index starts with 0)

  CX logical last index of cylinders = number_of - 1 (because index starts with 0)

  logical last index of sectors per track = number_of (because index starts with 1)

   Remarks:

  Logical values of function 08h may/should differ from physical CHS values of function 48h.

  Result register CX contains both cylinders and sector/track values, see remark of function 02h.

  [edit]INT 13h AH=0Ah: Read Long Sectors From Drive

  The only difference between this function and function 02h (see above) is that function 0Ah reads 516 bytes per sector instead of only 512. The last 4 bytes contains the Error Correction Code ECC, a checksum of sector data.

  [edit]INT 13h AH=41h: Check Extensions Present

   Parameters:

  Registers

  AH 41h = function number for extensions check

  DL drive index (e.g. 1st HDD = 80h)

  BX 55AAh

   Results:

  CF Set On Not Present, Clear If Present

  AH Error Code or Major Version Number

  BX AA55h

  CX Interface support bitmask:

  1 - Device Access using the packet structure

  2 - Drive Locking and Ejecting

  4 - Enhanced Disk Drive Support (EDD)

  [edit]INT 13h AH=42h: Extended Read Sectors From Drive

   Parameters:

  Registers

  AH 42h = function number for extended read

  DL drive index (e.g. 1st HDD = 80h)

  DS:SI segment:offset pointer to the DAP, see below

  DAP : Disk Address Packet

  offset range size description

  00h 1 byte size of DAP = 16 = 10h

  01h 1 byte unused, should be zero

  02h 1 byte number of sectors to be read, 0..127 (= 7Fh)

  03h 1 byte unused, should be zero

  04h..07h 4 bytes segment:offset pointer to the memory buffer to which sectors will be transferred

  08h..0Fh 8 bytes absolute number of the start of the sectors to be read (1st sector of drive has number 0)

   Results:

  CF Set On Error, Clear If No Error

  AH Return Code

  [edit]INT 13h AH=48h: Extended Read Drive Parameters

   Parameters:

  Registers

  AH 48h = function number for extended_read_drive_parameters

  DL drive index (e.g. 1st HDD = 80h)

  DS:SI segment:offset pointer to Result Buffer, see below

  Result Buffer

  offset range size description

  00h..01h 2 bytes size of Result Buffer = 30 = 1Eh

  02h..03h 2 bytes information flags

  04h..07h 4 bytes physical number of cylinders = last index + 1 (because index starts with 0)

  08h..0Bh 4 bytes physical number of heads = last index + 1 (because index starts with 0)

  0Ch..0Fh 4 bytes physical number of sectors per track = last index (because index starts with 1)

  10h..17h 8 bytes absolute number of sectors = last index + 1 (because index starts with 0)

  18h..19h 2 bytes bytes per sector

  1Ah..1Dh 4 bytes optional pointer to Enhanced Disk Drive (EDD) configuration parameters

  which may be used for subsequent interrupt 13h Extension calls (if supported)

   Results:

  CF Set On Error, Clear If No Error



本文转自

http://getpastfilters.info/index.php?hl=f5&q=uggc%3A%2F%2Fra.jvxvcrqvn.bet%2Fjvxv%2FVAG_13
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对下面的C语言伪代码函数进行分析 推测关于该函数的使用环境和预期目的详细的函数功能等信息 并为这个函数取一个新的名字 ) _BYTE *__fastcall sub_74918(int a1, int a2, int a3, int a4) { int v6; // r2 void *v7; // r0 void *v8; // r1 void *v9; // r3 int v10; // r10 char *v11; // r0 int v12; // r8 unsigned int v13; // r5 int i; // r1 unsigned int j; // r2 _BYTE *result; // r0 int v17; // r4 int v18; // r9 int k; // r6 char *v20; // r1 unsigned __int8 v22; // [sp+9h] [bp-27h] unsigned __int8 v23; // [sp+Ah] [bp-26h] unsigned __int8 v24; // [sp+Bh] [bp-25h] char v25; // [sp+Ch] [bp-24h] char v26; // [sp+Dh] [bp-23h] char v27; // [sp+Eh] [bp-22h] char v28; // [sp+Fh] [bp-21h] if ( a3 ) { v6 = 56; v7 = off_D7060; v8 = off_D7064; v9 = &unk_EA328; } else { v7 = off_D7068; v8 = off_D706C; v9 = &unk_EA329; v6 = 131; } v10 = ((int (__fastcall *)(void *, void *, int, void *, int))loc_74AC4)(v7, v8, v6, v9, a4); v11 = (char *)malloc(1u); if ( !v11 ) return 0; v12 = 0; LABEL_6: v13 = 0; while ( a2 != v13 ) { *(&v22 + v13) = *(_BYTE *)(a1 + v13); if ( ++v13 == 3 ) { v25 = v22 >> 2; v28 = v24 & 0x3F; v26 = (v23 >> 4) | (16 * (v22 & 3)); v27 = (v24 >> 6) | (4 * (v23 & 0xF)); v11 = (char *)realloc(v11, v12 + 4); a2 -= 3; a1 += 3; for ( i = 0; i != 4; ++i ) v11[v12 + i] = *(_BYTE *)(v10 + (unsigned __int8)*(&v25 + i)); v12 += 4; goto LABEL_6; } } if ( v13 ) { for ( j = v13; j <= 2; ++j ) *(&v22 + j) = 0; v25 = v22 >> 2; v28 = v24 & 0x3F; v26 = (v23 >> 4) | (16 * (v22 & 3)); v17 = 0; v27 = (v24 >> 6) | (4 * (v23 & 0xF)); while ( v13 + 1 != v17 ) { v11 = (char *)realloc(v11, v12 + v17 + 1); v11[v12 + v17] = *(_BYTE *)(v10 + (unsigned __int8)*(&v25 + v17)); ++v17; } v18 = v12 + v17; for ( k = 0; v13 + k <= 2; ++k ) { v11 = (char *)realloc(v11, v18 + k + 1); v20 = &v11[k]; v20[v12 + v17] = 61; } v12 = v18 + k; } result = realloc(v11, v12 + 1); result[v12] = 0; return result; }
最新发布
02-21

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值