News:

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

SetFilePointerEx

Started by colinr, February 18, 2012, 10:38:58 PM

Previous topic - Next topic

colinr

I am trying to get the SetFilePointerEx function to work, without luck!

The file has been opened correctly.

The file I want to seek into may exceed 4GB, therefore, I need to pass a 64bit value as the seek location.

When I try to assemble the code, using WinASM and MASM32, I get an error, 'too few arguments to invoke'.

Here is a little snippet of the code I am using.

Thanks in advance, Colin.

.data?
liDistanceToMove LARGE_INTEGER <>

.code
;;Eax contains the handle of the opened file.
invoke SetFilePointerEx,eax,addr liDistanceToMove,NULL,FILE_BEGIN

bomz

Quotemov ebx, LowOrderWord
HalfSize:
cmp ebx, 2147483647
jb EndSize
invoke SetFilePointer,Handle_Write,2147483647,0,FILE_CURRENT
sub ebx, 2147483647
jmp short HalfSize
EndSize:               
invoke SetFilePointer,Handle_Write,ebx,HighOrderWord,FILE_CURRENT
invoke SetEndOfFile, Handle_Write
invoke SetFilePointer,Handle_Write,0,0,FILE_BEGIN

RotateRight

Are you sure about addr liDistanceToMove

iDistanceToMove -
The number of bytes to move the file pointer. A positive value moves the pointer forward in the file and a negative value moves the file pointer backward.

Value or pointer?

qWord

hi,
the LARG_INTEGER structure is passed by value and not by reference:
invoke SetFilePointerEx,eax,DWORD ptr liDistanceToMove[0],DWORD ptr liDistanceToMove[4],NULL,FILE_BEGIN

BTW: the ADDR operator overwrites the content of EAX.
FPU in a trice: SmplMath
It's that simple!

colinr

Quote from: RotateRight on February 18, 2012, 11:01:09 PM
Are you sure about addr liDistanceToMove

iDistanceToMove -
The number of bytes to move the file pointer. A positive value moves the pointer forward in the file and a negative value moves the file pointer backward.

Value or pointer?


I assumed a pointer to a 64bit value, as it would not be possible to seek beyond 4GB into a file without multiple seeks.

Apparently SetFilePointerEx is easier to use than SetFilePointer!

colinr

Quote from: qWord on February 18, 2012, 11:04:52 PM
hi,
the LARG_INTEGER structure is passed by value and not by reference:
invoke SetFilePointerEx,eax,DWORD ptr liDistanceToMove[0],DWORD ptr liDistanceToMove[4],NULL,FILE_BEGIN

BTW: the ADDR operator overwrites the content of EAX.

Thanks Qword, that does now seem to make more sense.