flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Compiler Internals > [fasmg] windows lseek

Author
Thread Post new topic Reply to topic
Mike Gonta



Joined: 26 Dec 2010
Posts: 202

[fasmg] windows lseek


Code:
invoke SetFilePointerebxeax, [position_high], ecx

The third parameter to SetFilePointer should be a pointer to position_high or NULL.

_________________
Mike Gonta
look and see - many look but few see

http://mikegonta.com
Post 25 May 2017, 21:56
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6685
Location: Kraków, Poland

Thank you for spotting this. It shows that I never tested it with really large files.
Post 25 May 2017, 22:06
View user's profile Send private message Visit poster's website Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 202


Code:
lseek:
; in: ebx = file handle, cl = method, edx:eax = offset
; out: edx:eax = new offset from the beginning of file, cf set on error
; preserves: ebx, esi, edi
        movzx   ecx,cl
        mov     [position_high],edx
        invoke  SetFilePointer,ebx,eax,position_high,ecx
        cmp     eax,-1
        je      interface_error
        mov     edx,[position_high]
        clc
        retn


MSDN wrote:
If the return value is INVALID_SET_FILE_POINTER and if lpDistanceToMoveHigh is non-NULL, an application must call
GetLastError to determine whether or not the function has succeeded or failed.

SetFilePointerEx is similar to the Linux sys_llseek parameters and might be a better fit.

_________________
Mike Gonta
look and see - many look but few see

http://mikegonta.com
Post 26 May 2017, 12:16
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6685
Location: Kraków, Poland

Good catch! Corrected, thank you again.
Post 26 May 2017, 14:12
View user's profile Send private message Visit poster's website Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 202

With SetFilePointerEx it's similar to fasmg (Linux) lseek.

Code:
  position qd ?
lseek:
; in: ebx = file handle, cl = method, edx:eax = offset
; out: edx:eax = new offset from the beginning of file, cf set on error
; preserves: ebx, esi, edi
  movzx ecx,cl
  invoke SetFilePointerEx,ebx,eax,edx,position,ecx
  test eax,eax
  jz interface_error
  mov eax, [position]
  mov edx, [position+4]
  clc
  retn


_________________
Mike Gonta
look and see - many look but few see

http://mikegonta.com
Post 26 May 2017, 14:34
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6685
Location: Kraków, Poland

I'm OK with SetFilePointer, it just needed these corrections.
Post 26 May 2017, 14:51
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2017, Tomasz Grysztar.