Using interrupt calls to get list of disk partitions 
Author Message
 Using interrupt calls to get list of disk partitions

|I know this info is located in the MBR, and below is the MBR layout ^^^^
|(which all makes sense to me), but which int to use for reading the MBR is
|escaping me (or is it just a basic read from sector?), and how to form the
|assembly constructs is not my forte.

You should use the BIOS INT13 disk interrupt.

    mov    si,0003h  ;Retry max three times
RetryLoop:
    mov    ah,02h    ;Read N sector(s)
    mov    al,01h    ;One sector
    mov    cl,01h    ;First sector
    mov    ch,00h    ;First track
    mov    dh,00h    ;First head
    mov    dl,80h    ;First harddisk (81h=2nd,.., etc. 00h=1st floppy,...)
    mov    bx,seg SectorBuffer
    mov    es,bx
    mov    bx,offset SectorBuffer
    int    13h
    jnc    short Ok
    xor    ah,ah    ;Reset disk drive
    int    13h
    dec    si
    jnz    short RetryLoop
    jmp    Error
Ok:

"SectorBuffer" should be 512 bytes and if you read it from a floppy
disk, SectorBuffer+Size_To_Read-1 should not cross a 64k physical page
because the BIOS uses DMA to read from the floppy.

Test it like this:

    mov    ax,seg SectorBuffer
    shl    ax,04h
    add    ax,offset SectorBuffer+SizeToReadInBytes-1
    jc     Error
;Everything's ok



Sat, 07 Jul 2001 03:00:00 GMT  
 Using interrupt calls to get list of disk partitions
Hi,
mov cx,1     ;head 0, sector 1
mov dx,80h  ;Disk 0, head 0 (81h for disk 2)
les bx,dest ;Destination pointer es:bx
mov ax,201h ;Ah=2 for read, al=1 --> read 1 sector
int 13h  ;Read mbr
.....
This assembly code will read the MBR.

Ruud


Quote:
> Hello very smart people,

> Could someone please help me understand how to get a list of existing
> partitions on a hard disk (similar to FDISK in DOS but programmatically
> through interrupts)?
> Any help would be greatly appreciated!

> Glenn



Sat, 07 Jul 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using keyboard and disk without using interrupts

2. creating disk partitions using the mbr etc...

3. Quickest way to kill Hard Disk Partitions

4. Writing partition data directly to disk

5. DPT - Disk partition Table help

6. inter49[a-f].zip Ralf Brown's listing of interrupt calls

7. .zip Ralf Brown's listing of interrupt calls]

8. New Partition-Table at big Disks.

9. inter49[a-f].zip Ralf Brown's listing of interrupt calls

10. .zip Ralf Brown's listing of interrupt calls]

11. OS writing: detecting which disk was used as boot disk

12. Calling interrupts from within interrupts????????

 

 
Powered by phpBB® Forum Software