News:

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

SetFilePointer returns ERROR_NOACCESS....

Started by piotrus, May 15, 2007, 02:45:53 PM

Previous topic - Next topic

piotrus

When I call SetFilePointer function I get ERROR_NOACCESS. :( What could be the reason?


...
invoke SetFilePointer,hDebugFile,1,NULL,FILE_BEGIN
...


I open a file using CreateFile. It returns NO_ERROR.
I call ReadFile afterwards and also everything`s ok.

P1

Try this:
invoke SetFilePointer, hErrorFile, 0, NULL, FILE_BEGIN

I am going to guess ( You have not supplied enough information to know. ), that this created file is empty and a move of 1 is ERROR_NOACCESS.

Welcome   :U

Regards, P1   :8)

sebart7

Each time when some API call failed and You arent sure why, You may get information about what hapened from system.
Put invoke GetLastError just after suspicious call and it will return ErrorDescription in EAX.
You may stop there (INT 3 or anything) to read whats in EAX then input returned value into ErrLook.exe,
It will show You error description in human readable form.
(You can find ErrLook.exe attached below in this post)


(...)
invoke SetFilePointer,hDebugFile,1,NULL,FILE_BEGIN
invoke GetLastError
int 3                                  ; here You enter debuger and check
                                       ; ErrorCode in EAX (it will tell You "why")



[attachment deleted by admin]

P1

Quote from: sebart7 on May 15, 2007, 07:17:54 PMEach time when some API call failed and You arent sure why
ERROR_NOACCESS = Error #998,  Invalid access to memory location.  This is from Win32 Error Codes of WIN32 API help file.

So I think he did already.

A+ for enthusiasm.   :U

Regards,  P1   :8)

P1

As a conditional quick and dirty debug technique, Try this:
ifdef g_Debug
    invoke GetTimeFormat,NULL,NULL,addr l_StartTime,addr szTPstring, addr szTime, 10h
    invoke OutputDebugString, addr szTime
endif   
Then use Dbgview by SysInternals/M$ to check debug output.

Regards,  P1   :8)

MichaelW

I suspect that the problem is related to this statement from the SetFilePointer documentation:

"The file handle must be created with the GENERIC_READ or GENERIC_WRITE access right."
eschew obfuscation