The MASM Forum

General => The Workshop => Topic started by: hutch-- on January 06, 2014, 02:09:19 PM

Title: Silly problem with ANSI version of CreateFile().
Post by: hutch-- on January 06, 2014, 02:09:19 PM
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 ?
Title: Re: Silly problem with ANSI version of CreateFile().
Post by: dedndave on January 06, 2014, 04:04:18 PM
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 ?
Title: Re: Silly problem with ANSI version of CreateFile().
Post by: jj2007 on January 06, 2014, 06:10:34 PM
(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
Title: Re: Silly problem with ANSI version of CreateFile().
Post by: dedndave on January 07, 2014, 01:57:53 AM
well - we can spit-ball ideas and let him explore them   :P
Title: Re: Silly problem with ANSI version of CreateFile().
Post by: hutch-- on January 07, 2014, 01:18:26 PM
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)
Title: Re: Silly problem with ANSI version of CreateFile().
Post by: Adamanteus on January 08, 2014, 07:12:31 AM
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).
Title: Re: Silly problem with ANSI version of CreateFile().
Post by: hutch-- on January 09, 2014, 11:56:44 AM
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.
Title: Re: Silly problem with ANSI version of CreateFile().
Post by: dedndave on January 09, 2014, 04:21:56 PM
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
Title: Re: Silly problem with ANSI version of CreateFile().
Post by: hutch-- on January 09, 2014, 05:45:03 PM
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.