News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ReadFile error

Started by mrburkett, July 11, 2005, 12:41:35 AM

Previous topic - Next topic

mrburkett

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]

donkey

The attachment looks OK, what error are you getting with GetLastError ?
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

raymond

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
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

mrburkett

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.

mrburkett

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