flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [fasmg] windows lseek

Author
Thread Post new topic Reply to topic
Mike Gonta



Joined: 26 Dec 2010
Posts: 243
Mike Gonta 25 May 2017, 21:56
Code:
invoke SetFilePointer, ebx, eax, [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

https://mikegonta.com
Post 25 May 2017, 21:56
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 25 May 2017, 22:06
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: 243
Mike Gonta 26 May 2017, 12:16
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

https://mikegonta.com
Post 26 May 2017, 12:16
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 26 May 2017, 14:12
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: 243
Mike Gonta 26 May 2017, 14:34
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

https://mikegonta.com
Post 26 May 2017, 14:34
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 26 May 2017, 14:51
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.