The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: piotrus on May 15, 2007, 02:45:53 PM

Title: SetFilePointer returns ERROR_NOACCESS....
Post by: piotrus on May 15, 2007, 02:45:53 PM
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.
Title: Re: SetFilePointer returns ERROR_NOACCESS....
Post by: P1 on May 15, 2007, 06:55:42 PM
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)
Title: Re: SetFilePointer returns ERROR_NOACCESS....
Post by: sebart7 on May 15, 2007, 07:17:54 PM
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]
Title: Re: SetFilePointer returns ERROR_NOACCESS....
Post by: P1 on May 15, 2007, 07:30:27 PM
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)
Title: Re: SetFilePointer returns ERROR_NOACCESS....
Post by: P1 on May 16, 2007, 05:28:19 PM
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)
Title: Re: SetFilePointer returns ERROR_NOACCESS....
Post by: MichaelW on May 16, 2007, 10:58:25 PM
I suspect that the problem is related to this statement from the  SetFilePointer documentation (http://msdn2.microsoft.com/en-us/library/aa365541.aspx):

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