From 67bd23556648e5e7a4068a155c7e70ab67e57612 Mon Sep 17 00:00:00 2001 From: Gunnar Dalsnes Date: Wed, 9 Mar 2005 22:20:41 +0000 Subject: [PATCH] LockFileEx: forward overlapped->hEvent to NtLockFile LockFile: zero overlapped->hEvent svn path=/trunk/; revision=13900 --- reactos/lib/kernel32/file/lock.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/reactos/lib/kernel32/file/lock.c b/reactos/lib/kernel32/file/lock.c index 97cc4a07918..797f51498ee 100644 --- a/reactos/lib/kernel32/file/lock.c +++ b/reactos/lib/kernel32/file/lock.c @@ -39,6 +39,7 @@ LockFile( Overlapped.Offset = dwFileOffsetLow; Overlapped.OffsetHigh = dwFileOffsetHigh; + Overlapped.hEvent = NULL; dwReserved = 0; return LockFileEx(hFile, LOCKFILE_FAIL_IMMEDIATELY|LOCKFILE_EXCLUSIVE_LOCK,dwReserved,nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, &Overlapped ) ; @@ -57,7 +58,7 @@ LockFileEx( DWORD dwReserved, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, - LPOVERLAPPED lpOverlapped + LPOVERLAPPED lpOverlapped /* required! */ ) { LARGE_INTEGER BytesToLock; @@ -66,7 +67,7 @@ LockFileEx( NTSTATUS errCode; LARGE_INTEGER Offset; - if(dwReserved != 0) + if(dwReserved != 0 || lpOverlapped==NULL) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; @@ -91,7 +92,7 @@ LockFileEx( BytesToLock.u.HighPart = nNumberOfBytesToLockHigh; errCode = NtLockFile(hFile, - NULL, + lpOverlapped->hEvent, NULL, NULL, (PIO_STATUS_BLOCK)lpOverlapped, @@ -124,13 +125,13 @@ UnlockFile( DWORD nNumberOfBytesToUnlockHigh ) { - DWORD dwReserved; OVERLAPPED Overlapped; + DWORD dwReserved; Overlapped.Offset = dwFileOffsetLow; Overlapped.OffsetHigh = dwFileOffsetHigh; - dwReserved = 0; - return UnlockFileEx(hFile, dwReserved, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh, &Overlapped); - + dwReserved = 0; + + return UnlockFileEx(hFile, dwReserved, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh, &Overlapped); } @@ -144,19 +145,14 @@ UnlockFileEx( DWORD dwReserved, DWORD nNumberOfBytesToUnLockLow, DWORD nNumberOfBytesToUnLockHigh, - LPOVERLAPPED lpOverlapped + LPOVERLAPPED lpOverlapped /* required! */ ) { LARGE_INTEGER BytesToUnLock; LARGE_INTEGER StartAddress; NTSTATUS errCode; - if(dwReserved != 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - if ( lpOverlapped == NULL ) + if(dwReserved != 0 || lpOverlapped == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE;