msvcrt: Avoid the use of SetFilePointerEx in _lseeki64.

This commit is contained in:
Andrew Nguyen 2011-04-20 01:17:48 -05:00 committed by Alexandre Julliard
parent 0a23fc7b29
commit 6329d0d47d
1 changed files with 6 additions and 3 deletions

View File

@ -863,7 +863,7 @@ void msvcrt_free_io(void)
__int64 CDECL MSVCRT__lseeki64(int fd, __int64 offset, int whence) __int64 CDECL MSVCRT__lseeki64(int fd, __int64 offset, int whence)
{ {
HANDLE hand = msvcrt_fdtoh(fd); HANDLE hand = msvcrt_fdtoh(fd);
LARGE_INTEGER ofs, ret; LARGE_INTEGER ofs;
TRACE(":fd (%d) handle (%p)\n",fd,hand); TRACE(":fd (%d) handle (%p)\n",fd,hand);
if (hand == INVALID_HANDLE_VALUE) 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_CUR)?"SEEK_CUR":
(whence==SEEK_END)?"SEEK_END":"UNKNOWN"); (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; 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); MSVCRT_fdesc[fd].wxflag &= ~(WX_ATEOF|WX_READEOF);
/* FIXME: What if we seek _to_ EOF - is EOF set? */ /* FIXME: What if we seek _to_ EOF - is EOF set? */
return ret.QuadPart; return ofs.QuadPart;
} }
TRACE(":error-last error (%d)\n",GetLastError()); TRACE(":error-last error (%d)\n",GetLastError());
msvcrt_set_errno(GetLastError()); msvcrt_set_errno(GetLastError());