The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: mrburkett on July 11, 2005, 12:41:35 AM

Title: ReadFile error
Post by: mrburkett on July 11, 2005, 12:41:35 AM
Hi, Everybody,

In the enclosed snipped file, I am reading in 267 byte records, in ASCII.  The file is a 60mb with thousands of records.  Throught the first read, I get the first record stored in memory.  It test this record to see if I want to keep it or not, and if not, I discard it and loop back to get the next record.  For the first read, EAX contains a '1'.  But after jumping back and rereading for the second record, it fails and the EAX reads a '0'.

I do not know how to trouble shoot this.  Anybody have any suggestions?

Thanks,
Jim


[attachment deleted by admin]
Title: Re: ReadFile error
Post by: donkey on July 11, 2005, 01:34:30 AM
The attachment looks OK, what error are you getting with GetLastError ?
Title: Re: ReadFile error
Post by: raymond on July 11, 2005, 01:38:53 AM
The GetLastError would certainly help you to find the cause. Numerous things in your snipped code could be the culprit, such as overwriting the file handle, closing the file handle, etc. etc.

Raymond
Title: Re: ReadFile error
Post by: mrburkett on July 11, 2005, 02:03:26 AM
Using theOllyDbg, under the Registers Window, it does read LastErr "Error_Invalid_Handle(00006).

The snipped code is prior to the problem.  It just opens (Creates) new files.  But this is before the first read, which it does correctly.

..............................

Doing more investigating, using the memory dump, the file handle, hFile1, did, indeed, change, if I am reading it correctly.  The handle maintained its number until the second INVOKE ReadFile command.
Title: Re: ReadFile error
Post by: mrburkett on July 11, 2005, 03:27:37 AM
I found the error.  The hFile1 handle was being overwritten by the record that was being read into the buffer.  After moving the handle in the .data, it continued to show it being overwritten.  Come to find out, I am using WinASM and during assembly, it was not picking up the new change in my .inc file.  I deleted the .obj, .exe and started from scratch, it finally worked properly.

This has been a nice exercise with the OllyDbg.

Thanks,
Jim