HDD crash and int13 questions ...
Posted: Tue Mar 05, 2013 11:24 pm
Hi,
I'm developing a big 3D software, and I lost already 2 HDD with a lot of data in a 6 months time.
1 x 500 GB of data (IDE PATA)
Here ---> http://www.purebasic.fr/english/viewtop ... 17&t=50999
After that, I installed a new backup USB HDD
1 x 2 TB of backup data (USB External Case)
Here ---> http://www.purebasic.fr/english/viewtop ... =7&t=53795
Now I lost also this HDD, with the massage "MFT corrupted..."
I bought and tested a lot of backup/recover software with no good results.
SO... I started my own recover software... ??
and need some help of a ASM guru...
I did some asm programming in the past ?? but with 486 pc ... so long time ago ...
Here we go,
I like to read the important sectors (files) from all my HDD when I stop working at evening
and save it on my USB stick as backup.
c: MBR, MFT main, MFT backup, ...
D: MBR, MFT main, MFT backup, ...
E: MBR, MFT main, MFT backup, ...
F: MBR, MFT main, MFT backup, ...
Step 1: I like to read the MBR on the HDD via BIOS interrupt INT13
First one:
INT 13h AH=02h: Read Sectors From Drive
Parameters:
AH 02h
AL Sectors To Read Count
CX Track / Sector
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
Function = $02 ; 'Read Disk Sector' function
NumberSectors = $01
DiskBuffer = $0000
TrackNumber = $0001 ; Cylinder 0, Sector 1
SectorNumber = $01 ; Sector 1
HeadNumber = $00
;HardDisk = $80 ; value for 1st Hard disk
DriveNumber = $80 ; value for 1st Hard disk
32 bit example:
MOV EAX,0 ; Clear EAX register
MOV AH,Function ; set function 02 of INT13
MOV AL,NumberSectors ; set Number of sectors
LES BX,DiskBuffer ; set Disk Buffer Pointer
MOV CX,TrackNumber ; set Track Number
XCHG CH,CL ; swap data low and high
ROR CL,1 ; shift CL one place to right
ROR CL,1 ; shift CL one place to right
AND CL,SectorNumber ; sector 1
OR CL,(SectorNumber and 03Fh) ; max. 63 sectors
MOV DH,HeadNumber ; Plate 0 / Head 0 /
MOV DL,DriveNumber ; HDD 1
INT 013h
Or this one:
xor ax, ax ; clear ax register
mov es, ax ; ES <- 0
mov cx, 1 ; cylinder 0, sector 1
mov dx, 0080h ; DH = 0 (head), drive = 80h (0th hard disk)
mov bx, 5000h ; segment offset of the buffer
mov ax, 0201h ; AH = 02 (disk read), AL = 01 (number of sectors to read)
int 13h
Q1/ Is this a good asm begin ?
Q2/ How can I bring the data to PB editor gadget ?
thanks in advance,
Greetings,
Marc,
I'm developing a big 3D software, and I lost already 2 HDD with a lot of data in a 6 months time.
1 x 500 GB of data (IDE PATA)
Here ---> http://www.purebasic.fr/english/viewtop ... 17&t=50999
After that, I installed a new backup USB HDD
1 x 2 TB of backup data (USB External Case)
Here ---> http://www.purebasic.fr/english/viewtop ... =7&t=53795
Now I lost also this HDD, with the massage "MFT corrupted..."
I bought and tested a lot of backup/recover software with no good results.
SO... I started my own recover software... ??
and need some help of a ASM guru...
I did some asm programming in the past ?? but with 486 pc ... so long time ago ...
Here we go,
I like to read the important sectors (files) from all my HDD when I stop working at evening
and save it on my USB stick as backup.
c: MBR, MFT main, MFT backup, ...
D: MBR, MFT main, MFT backup, ...
E: MBR, MFT main, MFT backup, ...
F: MBR, MFT main, MFT backup, ...
Step 1: I like to read the MBR on the HDD via BIOS interrupt INT13
First one:
INT 13h AH=02h: Read Sectors From Drive
Parameters:
AH 02h
AL Sectors To Read Count
CX Track / Sector
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
Function = $02 ; 'Read Disk Sector' function
NumberSectors = $01
DiskBuffer = $0000
TrackNumber = $0001 ; Cylinder 0, Sector 1
SectorNumber = $01 ; Sector 1
HeadNumber = $00
;HardDisk = $80 ; value for 1st Hard disk
DriveNumber = $80 ; value for 1st Hard disk
32 bit example:
MOV EAX,0 ; Clear EAX register
MOV AH,Function ; set function 02 of INT13
MOV AL,NumberSectors ; set Number of sectors
LES BX,DiskBuffer ; set Disk Buffer Pointer
MOV CX,TrackNumber ; set Track Number
XCHG CH,CL ; swap data low and high
ROR CL,1 ; shift CL one place to right
ROR CL,1 ; shift CL one place to right
AND CL,SectorNumber ; sector 1
OR CL,(SectorNumber and 03Fh) ; max. 63 sectors
MOV DH,HeadNumber ; Plate 0 / Head 0 /
MOV DL,DriveNumber ; HDD 1
INT 013h
Or this one:
xor ax, ax ; clear ax register
mov es, ax ; ES <- 0
mov cx, 1 ; cylinder 0, sector 1
mov dx, 0080h ; DH = 0 (head), drive = 80h (0th hard disk)
mov bx, 5000h ; segment offset of the buffer
mov ax, 0201h ; AH = 02 (disk read), AL = 01 (number of sectors to read)
int 13h
Q1/ Is this a good asm begin ?
Q2/ How can I bring the data to PB editor gadget ?
thanks in advance,
Greetings,
Marc,