flat assembler
Message board for the users of flat assembler.

Index > Windows > how to set file pointer to a position > 4gb?

Author
Thread Post new topic Reply to topic
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha
how to set file pointer to a position > 4gb?

_________________
Assembly Asker
Post 22 Mar 2009, 09:46
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
If you're using SetFilePointer, pass a non-null pointer-to-dword for lpDistanceToMoveHigh. It's a somewhat quirky API in the sense that the high part is pointer-to-dword rather than dword, but that's because the parameter is also used for output.
Post 22 Mar 2009, 10:11
View user's profile Send private message Visit poster's website Reply with quote
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha
Could you give me some example? Thanks!
Post 22 Mar 2009, 10:21
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Assuming you have your file position in EDX:EAX, something like the following...

Code:
mov [ofsHigh], edx
invoke SetFilePointer, [hFile], eax, addr ofsHigh, FILE_BEGIN
cmp eax, INVALID_SET_FILE_POINTER
jne @@succeeded
invoke GetLastError
cmp eax, NO_ERROR
je @@succeeded
; there was an error seeking, handle it...
@@succeeded:
    
Post 22 Mar 2009, 10:33
View user's profile Send private message Visit poster's website Reply with quote
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha
Thanks!

_________________
Assembly Asker
Post 22 Mar 2009, 13:52
View user's profile Send private message Reply with quote
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha
bty, how to load the high dword of a qword to 32bit register under 32bit model?
Post 22 Mar 2009, 15:17
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Code:
mov eax, [qword + 0] ; low part
mov edx, [qword + 4] ; high part    


Smile
Post 22 Mar 2009, 15:56
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Use SetFilePointerEx, it is much less confusing because it doesn't work in two different ways depending on how many bits of position data you pass in to it.
Post 22 Mar 2009, 22:37
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
comrade wrote:
Use SetFilePointerEx, it is much less confusing because it doesn't work in two different ways depending on how many bits of position data you pass in to it.
Not if you care about Win9x compatibility - but I guess a lot of people don't Smile

_________________
Image - carpe noctem
Post 22 Mar 2009, 23:37
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.