News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Silly problem with ANSI version of CreateFile().

Started by hutch--, January 06, 2014, 02:09:19 PM

Previous topic - Next topic

hutch--

I have written what should be a simple app to copy files from a DVD to a hard disk with variable block size and while it works correctly from disk fie to disk file, I keep getting an error when trying to open the same file on the DVD. Now its likely to be something really simple that I have forgotten to do.

Now I normally open unprotected files with FILE_ATTRIBUTE_NORMAL but I have tried a range of the others and keep getting the same error message, an invalid file handle. Has anyone got any ideas on what I am doing wrong ?

dedndave

they always seem to be "read only" - but i guess that would be a different error
have you "finalized" (closed) the writes to the DVD ?

jj2007

(GENERIC_READ or OPEN_EXISTING) And (NOTHING_ELSE) ;)

What are you actually using? Y'know with n00bs we often go into SHOUT MODE if they assume we can read their thoughts  :P

dedndave

well - we can spit-ball ideas and let him explore them   :P

hutch--

Solved, I think I had some of the parameters in the wrong place.


    FUNCTION = open_fileA(StrPtr(fname$), _
               %GENERIC_READ, _
               %FILE_SHARE_READ,0,%OPEN_EXISTING, _
               %FILE_ATTRIBUTE_ARCHIVE,0)

Adamanteus

That's going from differ attributes on CD file system and NTFS (it counted as for archive perpuses when writing on CD), so best way open file with no attributes, and looks something wrong on the system you used it (disk drivers maybe).

hutch--

Interesting result, I got it working on files on a DVD and it gets faster as the block read size increases but it does not work where I need it to work. When a file is damaged (usually a CRC error) it stops on the location in the file where the damage starts and the DVD reader keeps trying to read the damaged section over and over again.

What I was trying to do was copy the file until it reached the error section, make a preset number of retries then go to the next section and try and read that. This is why I was after a variable block size. The best of a very ordinary lot was Roadkil's Unstoppable copier which is generally a good tool but it cannot get past the damaged section either.

dedndave

some DVD sectors are supposed to yield an error - part of some protection schemes
DVD players just skip them - or, more likely, the IFO file never tells it to read the bad sectors
so - the best scheme is to decipher the IFO contents and read only the necessary parts of the VOB files

if you want to read them anyways, try reading the file sectors in reverse order, end to beginning

hutch--

I am already using a driver that solves this problem, its AnyDVD. Those old protection schemes have been redundant for years. This problem is related to DVDs that are up to 10 years old that I hire (just watched the early series of Spooks) and it can often be bad scratches but some suffer delamination of the plastic layer in and around the center hole and this usually means the last one or two VOB files will not play.

Usually the player will not play the damaged file at all but I have got some of them before the damage makes the file entirely unreadable and that sometimes gets you to the end of the story and you only miss the credits.