PureBasic Forum
http://forums.purebasic.com/english/

HDD crash and int13 questions ...
http://forums.purebasic.com/english/viewtopic.php?f=35&t=53834
Page 1 of 1

Author:  marc_256 [ Tue Mar 05, 2013 11:24 pm ]
Post subject:  HDD crash and int13 questions ...

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 ---> viewtopic.php?f=17&t=50999

After that, I installed a new backup USB HDD

1 x 2 TB of backup data (USB External Case)
Here ---> viewtopic.php?f=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,

Author:  wilbert [ Wed Mar 06, 2013 7:11 am ]
Post subject:  Re: HDD crash and int13 questions ...

INT13 works for DOS, not for Windows.
PureBasic will be of no help in this case.

Author:  Ramihyn_ [ Thu Mar 07, 2013 4:04 pm ]
Post subject:  Re: HDD crash and int13 questions ...

You would also need the boot sector, the ntldr file and some configuration file which is used by ntldr. But then if some system files become corrupt, you also need to save them - windows does not deal well with corrupt system files ;)

The NTFS file system is quite complex, INT13 is outdated and even extended INT13 does not support the latest HD sizes anymore. It would require a lot work to store the MFT, because it is a (special) file inside the NTFS filesystem. Due to all the different BIOS/Interface problems, it would probably be the easiest to write a linux tool and let linux worry about the physical access layer. You could do that with purebasic and use a live-CD linux like Knoppix to run it from an USB stick.

But IMHO it would make much more sense to simply do file based backups of your sources (changes) onto some remote server (web/ftp/cloud etc.), a local NAS (raid-5 for example) or an USB stick/drive. That way you wouldnt need to worry about complex file system structures (or their inconsistencies) and could even recover your sources if your house burned down ;)

Plus you should once in a while do an image backup with a software like Acronis trueimage.

Author:  Nituvious [ Sat Mar 30, 2013 8:18 pm ]
Post subject:  Re: HDD crash and int13 questions ...

You can use BitBucket for verson control. You can also keep your projects private if you want.

Author:  NoahPhense [ Mon Jul 22, 2013 7:26 pm ]
Post subject:  Re: HDD crash and int13 questions ...

I use Ghost, runs everyday at 10AM to an external HDD. Love it, and I can mount the dailys anytime to retrieve just one file. Or rebuild my entire system with an HDD swap in less than 15 minutes.

** mom always said, "If you fail to plan, you plan to fail..." :D

Author:  marc_256 [ Thu Jul 25, 2013 7:34 am ]
Post subject:  Re: HDD crash and int13 questions ...

hi NoahPhense,

thanks for the answer.

Quote:
** mom always said, "If you fail to plan, you plan to fail..." :D


yep, I'ts right

Marc

Author:  infratec [ Mon Aug 19, 2013 12:40 pm ]
Post subject:  Re: HDD crash and int13 questions ...

Hi, I know I'm late, but...

Have you already tried clonezilla ?
It saves your disk to an image, like 'ghost' but free.

Bernd

Author:  NoahPhense [ Mon Aug 19, 2013 1:07 pm ]
Post subject:  Re: HDD crash and int13 questions ...

infratec wrote:
Hi, I know I'm late, but...

Have you already tried clonezilla ?
It saves your disk to an image, like 'ghost' but free.

Bernd


I'll have to look that one up for friends and family. I like Ghost cause it runs as a service and creates backups daily, incrementally. While windows is running.

I dual boot with Linux as well and Ghost backs up that partition as well.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/