Article View: borland.public.cppbuilder.nativeapi
Article #8296Re: Sector
From: Andrue Cope [TeamB]
Date: Wed, 10 Nov 2004 14:08
Date: Wed, 10 Nov 2004 14:08
40 lines
2857 bytes
2857 bytes
Pedram wrote: > Hi > He is talking about bad SECTOR and its also my question how could I > read or write a physical or logical sector !! :-? That's what my solution does. Open the device using CreateFile() and read it using ReadFile(). Don't be put off by the word 'file' in the function names. Read the help and you'll find that CreateFile() can create a lot more than just files and in fact doesn't always create things. It should have been called OpenObjectForAccess() or somesuch. I've spent the last thirteen years developing data recovery software so I know /exactly/ how to read bad sectors from faulty media :) As regards working around bad sectors on floppy disks it depends what you want to do. If you just want to replace their content with '*' during reading then pay attention to the error code returned by ReadFile(). For performance reasons you need to be reading multiple sectors at a time initially (multiple of sectors per track would be good but not essential). This means that if you get an error you have to drop down to single sector reading (ie;ask for 512 bytes at a time) so that you can repeat the request to find out which part of the original bigger read had a problem. If you actually want to try and get the underlying data (ie;ignore CRC errors) then things get more complicated. Sometimes ReadFile() returns the FDC data anyway, othertimes it doesn't. My advice (based on how few people even use floppy disks these days) is to forget about it and just fill your buffer with '*'s on error. If you're tring to recover data from a floppy disk search the web for imaging/recovery tools that someone else has written. -- Andrue Cope [TeamB] [Bicester, Uk] http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<419221a9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<419121f3$1@newsgroups.borland.com> <4191d90f@newsgroups.borland.com> <41920bea@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2aacc4eb93e0b7a0 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address> Subject: Re: Sector Newsgroups: borland.public.cppbuilder.nativeapi References: <419121f3$1@newsgroups.borland.com> <4191d90f@newsgroups.borland.com> <41920bea@newsgroups.borland.com> Date: Wed, 10 Nov 2004 14:08:36 +0000 User-Agent: XanaNews/1.16.4.6 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 217.207.223.34 Message-ID: <419221a9$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1100095913 217.207.223.34 (10 Nov 2004 06:11:53 -0700) Lines: 40 X-Authenticated-User: acope Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail