LockFileEx: forward overlapped->hEvent to NtLockFile
LockFile: zero overlapped->hEvent
Modified: trunk/reactos/lib/kernel32/file/lock.c

Modified: trunk/reactos/lib/kernel32/file/lock.c
--- trunk/reactos/lib/kernel32/file/lock.c	2005-03-09 08:12:30 UTC (rev 13899)
+++ trunk/reactos/lib/kernel32/file/lock.c	2005-03-09 22:20:41 UTC (rev 13900)
@@ -39,6 +39,7 @@
    
 	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 @@
 	   DWORD dwReserved,
 	   DWORD nNumberOfBytesToLockLow,
 	   DWORD nNumberOfBytesToLockHigh,
-	   LPOVERLAPPED lpOverlapped
+	   LPOVERLAPPED lpOverlapped /* required! */
 	   )
 {
    LARGE_INTEGER BytesToLock;	
@@ -66,7 +67,7 @@
    NTSTATUS errCode;
    LARGE_INTEGER Offset;
    
-   if(dwReserved != 0) 
+   if(dwReserved != 0 || lpOverlapped==NULL) 
      {      
 	SetLastError(ERROR_INVALID_PARAMETER);
 	return FALSE;
@@ -91,9 +92,9 @@
    BytesToLock.u.HighPart = nNumberOfBytesToLockHigh;
    
    errCode = NtLockFile(hFile,
+         lpOverlapped->hEvent,
 			NULL,
 			NULL,
-			NULL,
 			(PIO_STATUS_BLOCK)lpOverlapped,
 			&Offset,
 			&BytesToLock,
@@ -124,13 +125,13 @@
 	   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,23 +145,18 @@
 	DWORD dwReserved,
 	DWORD nNumberOfBytesToUnLockLow,
 	DWORD nNumberOfBytesToUnLockHigh,
-	LPOVERLAPPED lpOverlapped
+	LPOVERLAPPED lpOverlapped /* required! */
 	)
 {
    LARGE_INTEGER BytesToUnLock;
    LARGE_INTEGER StartAddress;
    NTSTATUS errCode;
    
-   if(dwReserved != 0) 
+   if(dwReserved != 0 || lpOverlapped == NULL) 
      {
 	SetLastError(ERROR_INVALID_PARAMETER);
 	return FALSE;
      }
-   if ( lpOverlapped == NULL ) 
-     {
-	SetLastError(ERROR_INVALID_PARAMETER);
-	return FALSE;
-     }
    
    BytesToUnLock.u.LowPart = nNumberOfBytesToUnLockLow;
    BytesToUnLock.u.HighPart = nNumberOfBytesToUnLockHigh;