From: Paul Gofman pgofman@codeweavers.com
--- dlls/kernel32/tests/file.c | 24 ++++++++++++++++++++++++ dlls/kernelbase/file.c | 3 ++- dlls/ntdll/unix/file.c | 12 +++++++----- 3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index df37eac068f..44c038d3656 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -2288,6 +2288,9 @@ static void test_LockFile(void) OVERLAPPED overlapped; int limited_LockFile; int limited_UnLockFile; + LARGE_INTEGER count, offset; + IO_STATUS_BLOCK iosb; + NTSTATUS status; BOOL ret;
handle = CreateFileA( filename, GENERIC_READ | GENERIC_WRITE, @@ -2306,6 +2309,17 @@ static void test_LockFile(void) ok( 0, "couldn't open file "%s" (err=%ld)\n", filename, GetLastError() ); goto cleanup; } + + count.QuadPart = 0; + offset.QuadPart = 0; + status = NtUnlockFile( handle, NULL, &count, &offset, NULL ); + ok( status == STATUS_ACCESS_VIOLATION, "got %#lx.\n", status ); + memset( &iosb, 0xcc, sizeof(iosb) ); + status = NtUnlockFile( handle, &iosb, &count, &offset, NULL ); + todo_wine_if(NT_ERROR(status)) ok( status == STATUS_RANGE_NOT_LOCKED, "got %#lx.\n", status ); + ok( iosb.Status == status, "got %lu.\n", iosb.Status); + ok( !iosb.Information, "got %Iu.\n", iosb.Information); + ok( WriteFile( handle, sillytext, strlen(sillytext), &written, NULL ), "write failed\n" );
ok( LockFile( handle, 0, 0, 0, 0 ), "LockFile failed\n" ); @@ -2329,6 +2343,16 @@ static void test_LockFile(void) ok( !UnlockFile( handle, 10, 0, 20, 0 ), "UnlockFile 10,20 again succeeded\n" ); ok( UnlockFile( handle, 5, 0, 5, 0 ), "UnlockFile 5,5 failed\n" );
+ ret = LockFile( handle, 5, 0, 5, 0 ); + ok( ret, "got error %lu.\n", GetLastError() ); + count.QuadPart = 5; + offset.QuadPart = 5; + memset( &iosb, 0xcc, sizeof(iosb) ); + status = NtUnlockFile( handle, &iosb, &count, &offset, NULL ); + ok( !status, "got %#lx.\n", status ); + ok( iosb.Status == status, "got %lu.\n", iosb.Status); + ok( !iosb.Information, "got %Iu.\n", iosb.Information); + overlapped.Offset = 100; overlapped.OffsetHigh = 0; overlapped.hEvent = 0; diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index faf53748e23..c02435c0dd3 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -3866,12 +3866,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH UnlockFile( HANDLE file, DWORD offset_low, DWORD o DWORD count_low, DWORD count_high ) { LARGE_INTEGER count, offset; + IO_STATUS_BLOCK io;
count.u.LowPart = count_low; count.u.HighPart = count_high; offset.u.LowPart = offset_low; offset.u.HighPart = offset_high; - return set_ntstatus( NtUnlockFile( file, NULL, &offset, &count, NULL )); + return set_ntstatus( NtUnlockFile( file, &io, &offset, &count, NULL )); }
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index 958ae9a6937..bb74b975c8a 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -6615,13 +6615,14 @@ NTSTATUS WINAPI NtUnlockFile( HANDLE handle, IO_STATUS_BLOCK *io_status, LARGE_I { unsigned int status;
- TRACE( "%p %s %s\n", - handle, wine_dbgstr_longlong(offset->QuadPart), wine_dbgstr_longlong(count->QuadPart) ); + TRACE( "%p %p %s %s\n", + handle, io_status, wine_dbgstr_longlong(offset->QuadPart), wine_dbgstr_longlong(count->QuadPart) );
- if (io_status || key) + io_status->Information = 0; + if (key) { FIXME("Unimplemented yet parameter\n"); - return STATUS_NOT_IMPLEMENTED; + return (io_status->Status = STATUS_NOT_IMPLEMENTED); }
SERVER_START_REQ( unlock_file ) @@ -6632,7 +6633,8 @@ NTSTATUS WINAPI NtUnlockFile( HANDLE handle, IO_STATUS_BLOCK *io_status, LARGE_I status = wine_server_call( req ); } SERVER_END_REQ; - return status; + + return (io_status->Status = status); }