Andrew Nguyen : msvcrt: Avoid the use of SetFilePointerEx in _lseeki64.
Alexandre Julliard
julliard at winehq.org
Wed Apr 20 11:05:19 CDT 2011
Module: wine
Branch: master
Commit: 6329d0d47da7391baa545669f9028ff2ac4bc4a4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6329d0d47da7391baa545669f9028ff2ac4bc4a4
Author: Andrew Nguyen <anguyen at codeweavers.com>
Date: Wed Apr 20 01:17:48 2011 -0500
msvcrt: Avoid the use of SetFilePointerEx in _lseeki64.
---
dlls/msvcrt/file.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index b8077d2..c1a7785 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -863,7 +863,7 @@ void msvcrt_free_io(void)
__int64 CDECL MSVCRT__lseeki64(int fd, __int64 offset, int whence)
{
HANDLE hand = msvcrt_fdtoh(fd);
- LARGE_INTEGER ofs, ret;
+ LARGE_INTEGER ofs;
TRACE(":fd (%d) handle (%p)\n",fd,hand);
if (hand == INVALID_HANDLE_VALUE)
@@ -881,13 +881,16 @@ __int64 CDECL MSVCRT__lseeki64(int fd, __int64 offset, int whence)
(whence==SEEK_CUR)?"SEEK_CUR":
(whence==SEEK_END)?"SEEK_END":"UNKNOWN");
+ /* The MoleBox protection scheme expects msvcrt to use SetFilePointer only,
+ * so a LARGE_INTEGER offset cannot be passed directly via SetFilePointerEx. */
ofs.QuadPart = offset;
- if (SetFilePointerEx(hand, ofs, &ret, whence))
+ if ((ofs.LowPart = SetFilePointer(hand, ofs.LowPart, &ofs.HighPart, whence)) != INVALID_SET_FILE_POINTER ||
+ GetLastError() == ERROR_SUCCESS)
{
MSVCRT_fdesc[fd].wxflag &= ~(WX_ATEOF|WX_READEOF);
/* FIXME: What if we seek _to_ EOF - is EOF set? */
- return ret.QuadPart;
+ return ofs.QuadPart;
}
TRACE(":error-last error (%d)\n",GetLastError());
msvcrt_set_errno(GetLastError());
More information about the wine-cvs
mailing list