diff --git a/rostests/winetests/ntdll/change.c b/rostests/winetests/ntdll/change.c index 1e74ee6a1fa..fc9a18185a9 100644 --- a/rostests/winetests/ntdll/change.c +++ b/rostests/winetests/ntdll/change.c @@ -99,19 +99,19 @@ static void test_ntncdf(void) r = pNtNotifyChangeDirectoryFile(hdir,hEvent,NULL,NULL,&iosb,buffer,sizeof buffer,filter,0); ok(r==STATUS_PENDING, "should return status pending\n"); - r = WaitForSingleObject( hEvent, 0 ); + r = WaitForSingleObject( hEvent, 100 ); ok( r == STATUS_TIMEOUT, "should timeout\n" ); - r = WaitForSingleObject( hdir, 0 ); + r = WaitForSingleObject( hdir, 100 ); ok( r == STATUS_TIMEOUT, "should timeout\n" ); r = CreateDirectoryW( subdir, NULL ); ok( r == TRUE, "failed to create directory\n"); - r = WaitForSingleObject( hdir, 0 ); + r = WaitForSingleObject( hdir, 100 ); ok( r == STATUS_TIMEOUT, "should timeout\n" ); - r = WaitForSingleObject( hEvent, 0 ); + r = WaitForSingleObject( hEvent, 100 ); ok( r == WAIT_OBJECT_0, "event should be ready\n" ); ok( U(iosb).Status == STATUS_SUCCESS, "information wrong\n"); @@ -299,7 +299,7 @@ static void test_ntncdf_async(void) CloseHandle(hdir); ok(U(iosb).Status == STATUS_SUCCESS, "status wrong\n"); - todo_wine ok(U(iosb2).Status == STATUS_CANCELLED, "status wrong\n"); + ok(U(iosb2).Status == STATUS_CANCELLED, "status wrong %x\n",U(iosb2).Status); ok(iosb.Information == 0, "info wrong\n"); ok(iosb2.Information == 0, "info wrong\n"); diff --git a/rostests/winetests/ntdll/file.c b/rostests/winetests/ntdll/file.c index 83c17fd4c04..0acc7cf574d 100644 --- a/rostests/winetests/ntdll/file.c +++ b/rostests/winetests/ntdll/file.c @@ -111,6 +111,16 @@ static inline BOOL is_signaled( HANDLE obj ) return WaitForSingleObject( obj, 0 ) == WAIT_OBJECT_0; } +static const char* debugstr_longlong(ULONGLONG ll) +{ + static char str[17]; + if (sizeof(ll) > sizeof(unsigned long) && ll >> 32) + sprintf(str, "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll); + else + sprintf(str, "%lx", (unsigned long)ll); + return str; +} + #define PIPENAME "\\\\.\\pipe\\ntdll_tests_file.c" #define TEST_BUF_LEN 3 @@ -685,7 +695,7 @@ static void read_file_test(void) ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status ); ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information ); ok( is_signaled( event ), "event is signaled\n" ); - todo_wine ok( !apc_count, "apc was called\n" ); + ok( !apc_count, "apc was called\n" ); SleepEx( 1, TRUE ); /* alertable sleep */ ok( apc_count == 1, "apc was not called\n" ); @@ -711,7 +721,7 @@ static void read_file_test(void) ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status ); ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information ); ok( is_signaled( event ), "event is signaled\n" ); - todo_wine ok( !apc_count, "apc was called\n" ); + ok( !apc_count, "apc was called\n" ); SleepEx( 1, TRUE ); /* alertable sleep */ ok( apc_count == 1, "apc was not called\n" ); CloseHandle( handle ); @@ -737,7 +747,7 @@ static void read_file_test(void) ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status ); ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information ); ok( is_signaled( event ), "event is signaled\n" ); - todo_wine ok( !apc_count, "apc was called\n" ); + ok( !apc_count, "apc was called\n" ); SleepEx( 1, TRUE ); /* alertable sleep */ ok( apc_count == 1, "apc was not called\n" ); @@ -763,7 +773,7 @@ static void read_file_test(void) ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status ); ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information ); ok( is_signaled( event ), "event is signaled\n" ); - todo_wine ok( !apc_count, "apc was called\n" ); + ok( !apc_count, "apc was called\n" ); SleepEx( 1, TRUE ); /* alertable sleep */ ok( apc_count == 2, "apc was not called\n" ); @@ -1232,6 +1242,62 @@ static void test_iocp_fileio(HANDLE h) CloseHandle( hPipeClt ); } +static void test_file_full_size_information(void) +{ + IO_STATUS_BLOCK io; + FILE_FS_FULL_SIZE_INFORMATION ffsi; + FILE_FS_SIZE_INFORMATION fsi; + HANDLE h; + NTSTATUS res; + + if(!(h = create_temp_file(0))) return ; + + memset(&ffsi,0,sizeof(ffsi)); + memset(&fsi,0,sizeof(fsi)); + + /* Assume No Quota Settings configured on Wine Testbot */ + res = pNtQueryVolumeInformationFile(h, &io, &ffsi, sizeof ffsi, FileFsFullSizeInformation); + ok(res == STATUS_SUCCESS, "cannot get attributes, res %x\n", res); + res = pNtQueryVolumeInformationFile(h, &io, &fsi, sizeof fsi, FileFsSizeInformation); + ok(res == STATUS_SUCCESS, "cannot get attributes, res %x\n", res); + + /* Test for FileFsSizeInformation */ + ok(fsi.TotalAllocationUnits.QuadPart > 0, + "[fsi] TotalAllocationUnits expected positive, got 0x%s\n", + debugstr_longlong(fsi.TotalAllocationUnits.QuadPart)); + ok(fsi.AvailableAllocationUnits.QuadPart > 0, + "[fsi] AvailableAllocationUnits expected positive, got 0x%s\n", + debugstr_longlong(fsi.AvailableAllocationUnits.QuadPart)); + + /* Assume file system is NTFS */ + ok(fsi.BytesPerSector == 512, "[fsi] BytesPerSector expected 512, got %d\n",fsi.BytesPerSector); + ok(fsi.SectorsPerAllocationUnit == 8, "[fsi] SectorsPerAllocationUnit expected 8, got %d\n",fsi.SectorsPerAllocationUnit); + + ok(ffsi.TotalAllocationUnits.QuadPart > 0, + "[ffsi] TotalAllocationUnits expected positive, got negative value 0x%s\n", + debugstr_longlong(ffsi.TotalAllocationUnits.QuadPart)); + ok(ffsi.CallerAvailableAllocationUnits.QuadPart > 0, + "[ffsi] CallerAvailableAllocationUnits expected positive, got negative value 0x%s\n", + debugstr_longlong(ffsi.CallerAvailableAllocationUnits.QuadPart)); + ok(ffsi.ActualAvailableAllocationUnits.QuadPart > 0, + "[ffsi] ActualAvailableAllocationUnits expected positive, got negative value 0x%s\n", + debugstr_longlong(ffsi.ActualAvailableAllocationUnits.QuadPart)); + ok(ffsi.TotalAllocationUnits.QuadPart == fsi.TotalAllocationUnits.QuadPart, + "[ffsi] TotalAllocationUnits error fsi:0x%s, ffsi:0x%s\n", + debugstr_longlong(fsi.TotalAllocationUnits.QuadPart), + debugstr_longlong(ffsi.TotalAllocationUnits.QuadPart)); + ok(ffsi.CallerAvailableAllocationUnits.QuadPart == fsi.AvailableAllocationUnits.QuadPart, + "[ffsi] CallerAvailableAllocationUnits error fsi:0x%s, ffsi: 0x%s\n", + debugstr_longlong(fsi.AvailableAllocationUnits.QuadPart), + debugstr_longlong(ffsi.CallerAvailableAllocationUnits.QuadPart)); + + /* Assume file system is NTFS */ + ok(ffsi.BytesPerSector == 512, "[ffsi] BytesPerSector expected 512, got %d\n",ffsi.BytesPerSector); + ok(ffsi.SectorsPerAllocationUnit == 8, "[ffsi] SectorsPerAllocationUnit expected 8, got %d\n",ffsi.SectorsPerAllocationUnit); + + CloseHandle( h ); +} + static void test_file_basic_information(void) { IO_STATUS_BLOCK io; @@ -1382,11 +1448,12 @@ static void test_file_disposition_information(void) { char tmp_path[MAX_PATH], buffer[MAX_PATH + 16]; DWORD dirpos; - HANDLE handle, handle2; + HANDLE handle, handle2, mapping; NTSTATUS res; IO_STATUS_BLOCK io; FILE_DISPOSITION_INFORMATION fdi; BOOL fileDeleted; + void *ptr; GetTempPathA( MAX_PATH, tmp_path ); @@ -1550,6 +1617,72 @@ static void test_file_disposition_information(void) todo_wine ok( !fileDeleted, "Directory shouldn't have been deleted\n" ); RemoveDirectoryA( buffer ); + + /* cannot set disposition on file with file mapping opened */ + GetTempFileNameA( tmp_path, "dis", 0, buffer ); + handle = CreateFileA(buffer, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" ); + mapping = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 64 * 1024, "DelFileTest" ); + ok( mapping != NULL, "failed to create file mapping\n"); + fdi.DoDeleteFile = TRUE; + res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation ); + ok( res == STATUS_CANNOT_DELETE, "unexpected FileDispositionInformation result (expected STATUS_CANNOT_DELETE, got %x)\n", res ); + CloseHandle( handle ); + fileDeleted = GetFileAttributesA( buffer ) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND; + ok( !fileDeleted, "File shouldn't have been deleted\n" ); + CloseHandle( mapping ); + DeleteFileA( buffer ); + + /* can set disposition on file with file mapping closed */ + GetTempFileNameA( tmp_path, "dis", 0, buffer ); + handle = CreateFileA(buffer, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" ); + mapping = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 64 * 1024, "DelFileTest" ); + ok( mapping != NULL, "failed to create file mapping\n"); + CloseHandle( mapping ); + fdi.DoDeleteFile = TRUE; + res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation ); + ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res ); + CloseHandle( handle ); + fileDeleted = GetFileAttributesA( buffer ) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND; + ok( fileDeleted, "File should have been deleted\n" ); + DeleteFileA( buffer ); + + /* cannot set disposition on file which is mapped to memory */ + GetTempFileNameA( tmp_path, "dis", 0, buffer ); + handle = CreateFileA(buffer, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" ); + mapping = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 64 * 1024, "DelFileTest" ); + ok( mapping != NULL, "failed to create file mapping\n"); + ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 ); + ok( ptr != NULL, "MapViewOfFile failed\n"); + CloseHandle( mapping ); + fdi.DoDeleteFile = TRUE; + res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation ); + ok( res == STATUS_CANNOT_DELETE, "unexpected FileDispositionInformation result (expected STATUS_CANNOT_DELETE, got %x)\n", res ); + CloseHandle( handle ); + fileDeleted = GetFileAttributesA( buffer ) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND; + ok( !fileDeleted, "File shouldn't have been deleted\n" ); + UnmapViewOfFile( ptr ); + DeleteFileA( buffer ); + + /* can set disposition on file which is mapped to memory and unmapped again */ + GetTempFileNameA( tmp_path, "dis", 0, buffer ); + handle = CreateFileA(buffer, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" ); + mapping = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 64 * 1024, "DelFileTest" ); + ok( mapping != NULL, "failed to create file mapping\n"); + ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 ); + ok( ptr != NULL, "MapViewOfFile failed\n"); + CloseHandle( mapping ); + UnmapViewOfFile( ptr ); + fdi.DoDeleteFile = TRUE; + res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation ); + ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res ); + CloseHandle( handle ); + fileDeleted = GetFileAttributesA( buffer ) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND; + ok( fileDeleted, "File should have been deleted\n" ); + DeleteFileA( buffer ); } static void test_iocompletion(void) @@ -2496,7 +2629,6 @@ static void test_read_write(void) ret = ReadFile(hfile, buf, 0, &bytes, &ovl); /* ReadFile return value depends on Windows version and testing it is not practical */ if (!ret) -todo_wine ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError()); ret = GetLastError(); ok(bytes == 0, "bytes %u\n", bytes); @@ -2527,7 +2659,6 @@ todo_wine ret = ReadFile(hfile, NULL, 0, &bytes, &ovl); /* ReadFile return value depends on Windows version and testing it is not practical */ if (!ret) -todo_wine ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError()); ret = GetLastError(); ok(bytes == 0, "bytes %u\n", bytes); @@ -2676,6 +2807,8 @@ todo_wine { ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError()); ok(bytes == 0, "bytes %u\n", bytes); + ret = WaitForSingleObject(hfile, 3000); + ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret); } else ok(bytes == 4, "bytes %u\n", bytes); ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal); @@ -2707,6 +2840,8 @@ todo_wine { ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError()); ok(bytes == 0, "bytes %u\n", bytes); + ret = WaitForSingleObject(hfile, 3000); + ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret); } else ok(bytes == 14, "bytes %u\n", bytes); ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal); @@ -2951,6 +3086,7 @@ START_TEST(file) test_file_all_information(); test_file_both_information(); test_file_name_information(); + test_file_full_size_information(); test_file_all_name_information(); test_file_disposition_information(); test_query_volume_information_file(); diff --git a/rostests/winetests/ntdll/om.c b/rostests/winetests/ntdll/om.c index ef7c9cbfe8f..83b63d86894 100644 --- a/rostests/winetests/ntdll/om.c +++ b/rostests/winetests/ntdll/om.c @@ -688,8 +688,8 @@ static void test_query_object(void) len = 0; status = pNtQueryObject( handle, ObjectTypeInformation, buffer, 0, &len ); - todo_wine ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - todo_wine ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); + ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); len = 0; status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(UNICODE_STRING), &len ); @@ -698,8 +698,8 @@ static void test_query_object(void) len = 0; status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(OBJECT_TYPE_INFORMATION), &len ); - todo_wine ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - todo_wine ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); + ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); len = 0; status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len ); @@ -720,17 +720,17 @@ static void test_query_object(void) len = 0; memset( buffer, 0, sizeof(buffer) ); status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len ); - todo_wine ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status ); - todo_wine ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len ); + ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status ); + ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len ); str = (UNICODE_STRING *)buffer; - todo_wine ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR), "unexpected len %u\n", len ); - todo_wine ok( str->Buffer && !memcmp( str->Buffer, type_event, sizeof(type_file) ), + ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( str->Buffer && !memcmp( str->Buffer, type_event, sizeof(type_event) ), "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer ); len -= sizeof(WCHAR); status = pNtQueryObject( handle, ObjectTypeInformation, buffer, len, &len ); - todo_wine ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); - todo_wine ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status ); + ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len ); pNtClose( handle ); @@ -775,12 +775,12 @@ static void test_query_object(void) len = 0; memset( buffer, 0, sizeof(buffer) ); status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len ); - todo_wine ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status ); - todo_wine ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len ); + ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status ); + ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len ); str = (UNICODE_STRING *)buffer; expected_len = sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR); - todo_wine ok( len >= expected_len, "unexpected len %u\n", len ); - todo_wine ok( str->Buffer && !memcmp( str->Buffer, type_file, sizeof(type_file) ), + ok( len >= expected_len, "unexpected len %u\n", len ); + ok( str->Buffer && !memcmp( str->Buffer, type_file, sizeof(type_file) ), "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer ); pNtClose( handle ); @@ -1032,6 +1032,101 @@ static void test_keyed_events(void) NtClose( event ); } +static void test_null_device(void) +{ + OBJECT_ATTRIBUTES attr; + IO_STATUS_BLOCK iosb; + UNICODE_STRING str; + NTSTATUS status; + DWORD num_bytes; + OVERLAPPED ov; + char buf[64]; + HANDLE null; + BOOL ret; + + memset(buf, 0xAA, sizeof(buf)); + memset(&ov, 0, sizeof(ov)); + ov.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL); + + pRtlCreateUnicodeStringFromAsciiz(&str, "\\Device\\Null"); + InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL); + status = pNtOpenSymbolicLinkObject(&null, SYMBOLIC_LINK_QUERY, &attr); + ok(status == STATUS_OBJECT_TYPE_MISMATCH, + "expected STATUS_OBJECT_TYPE_MISMATCH, got %08x\n", status); + + status = pNtOpenFile(&null, GENERIC_READ | GENERIC_WRITE, &attr, &iosb, + FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN); + ok(status == STATUS_SUCCESS, + "expected STATUS_SUCCESS, got %08x\n", status); + + SetLastError(0xdeadbeef); + ret = WriteFile(null, buf, sizeof(buf), &num_bytes, NULL); + todo_wine + ok(!ret, "WriteFile unexpectedly succeeded\n"); + todo_wine + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = ReadFile(null, buf, sizeof(buf), &num_bytes, NULL); + todo_wine + ok(!ret, "ReadFile unexpectedly succeeded\n"); + todo_wine + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError()); + + num_bytes = 0xdeadbeef; + SetLastError(0xdeadbeef); + ret = WriteFile(null, buf, sizeof(buf), &num_bytes, &ov); + if (ret || GetLastError() != ERROR_IO_PENDING) + { + ok(ret, "WriteFile failed with error %u\n", GetLastError()); + } + else + { + num_bytes = 0xdeadbeef; + ret = GetOverlappedResult(null, &ov, &num_bytes, TRUE); + ok(ret, "GetOverlappedResult failed with error %u\n", GetLastError()); + } + ok(num_bytes == sizeof(buf), "expected num_bytes = %u, got %u\n", + (DWORD)sizeof(buf), num_bytes); + + num_bytes = 0xdeadbeef; + SetLastError(0xdeadbeef); + ret = ReadFile(null, buf, sizeof(buf), &num_bytes, &ov); + if (ret || GetLastError() != ERROR_IO_PENDING) + { + ok(!ret, "ReadFile unexpectedly succeeded\n"); + } + else + { + num_bytes = 0xdeadbeef; + ret = GetOverlappedResult(null, &ov, &num_bytes, TRUE); + ok(!ret, "GetOverlappedResult unexpectedly succeeded\n"); + } + ok(GetLastError() == ERROR_HANDLE_EOF, + "expected ERROR_HANDLE_EOF, got %u\n", GetLastError()); + + pNtClose(null); + + null = CreateFileA("\\\\.\\Null", GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + ok(null == INVALID_HANDLE_VALUE, "CreateFileA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, + "expected ERROR_FILE_NOT_FOUND, got %u\n", GetLastError()); + + null = CreateFileA("\\\\.\\Device\\Null", GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + ok(null == INVALID_HANDLE_VALUE, "CreateFileA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_PATH_NOT_FOUND, + "expected ERROR_PATH_NOT_FOUND, got %u\n", GetLastError()); + + pRtlFreeUnicodeString(&str); + CloseHandle(ov.hEvent); +} + START_TEST(om) { HMODULE hntdll = GetModuleHandleA("ntdll.dll"); @@ -1081,4 +1176,5 @@ START_TEST(om) test_type_mismatch(); test_event(); test_keyed_events(); + test_null_device(); } diff --git a/rostests/winetests/ntdll/pipe.c b/rostests/winetests/ntdll/pipe.c index 4002f3f741c..d1bd3d1eeac 100644 --- a/rostests/winetests/ntdll/pipe.c +++ b/rostests/winetests/ntdll/pipe.c @@ -469,12 +469,10 @@ static void test_cancelio(void) ok(res == STATUS_PENDING, "NtFsControlFile returned %x\n", res); res = pNtCancelIoFile(hPipe, &cancel_sb); - todo_wine ok(!res, "NtCancelIoFile returned %x\n", res); + ok(!res, "NtCancelIoFile returned %x\n", res); - todo_wine { - ok(U(iosb).Status == STATUS_CANCELLED, "Wrong iostatus %x\n", U(iosb).Status); - ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n"); - } + ok(U(iosb).Status == STATUS_CANCELLED, "Wrong iostatus %x\n", U(iosb).Status); + ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n"); ok(!ioapc_called, "IOAPC ran too early\n"); diff --git a/rostests/winetests/ntdll/port.c b/rostests/winetests/ntdll/port.c index 43c854bbe9d..e5bb3edc281 100644 --- a/rostests/winetests/ntdll/port.c +++ b/rostests/winetests/ntdll/port.c @@ -115,7 +115,7 @@ static UNICODE_STRING port; static HMODULE hntdll = 0; static NTSTATUS (WINAPI *pNtCompleteConnectPort)(HANDLE); static NTSTATUS (WINAPI *pNtAcceptConnectPort)(PHANDLE,ULONG,PLPC_MESSAGE,ULONG, - ULONG,PLPC_SECTION_READ); + PLPC_SECTION_WRITE,PLPC_SECTION_READ); static NTSTATUS (WINAPI *pNtReplyPort)(HANDLE,PLPC_MESSAGE); static NTSTATUS (WINAPI *pNtReplyWaitReceivePort)(PHANDLE,PULONG,PLPC_MESSAGE, PLPC_MESSAGE); @@ -182,7 +182,7 @@ static void ProcessConnectionRequest(union lpc_message *LpcMessage, PHANDLE pAcc ok(!*LpcMessage->msg.Data, "Expected empty string!\n"); } - status = pNtAcceptConnectPort(pAcceptPortHandle, 0, &LpcMessage->msg, 1, 0, NULL); + status = pNtAcceptConnectPort(pAcceptPortHandle, 0, &LpcMessage->msg, 1, NULL, NULL); ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status); status = pNtCompleteConnectPort(*pAcceptPortHandle); diff --git a/rostests/winetests/ntdll/reg.c b/rostests/winetests/ntdll/reg.c index a7910bb7a64..5fc86b5f754 100755 --- a/rostests/winetests/ntdll/reg.c +++ b/rostests/winetests/ntdll/reg.c @@ -709,7 +709,7 @@ static void test_NtQueryLicenseKey(void) type = 0xdead; len = 0xbeef; status = pNtQueryLicenseValue(&name, &type, buffer, sizeof(buffer), &len); - ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "NtQueryLicenseValue unexpected suceeded\n"); + ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "NtQueryLicenseValue unexpected succeeded\n"); ok(type == 0xdead, "expected unmodified value for type, got %u\n", type); ok(len == 0xbeef, "expected unmodified value for len, got %u\n", len); @@ -1509,8 +1509,8 @@ START_TEST(reg) test_RtlpNtQueryValueKey(); test_NtFlushKey(); test_NtQueryKey(); - test_NtQueryValueKey(); test_NtQueryLicenseKey(); + test_NtQueryValueKey(); test_long_value_name(); test_NtDeleteKey(); test_symlinks(); diff --git a/rostests/winetests/ntdll/rtl.c b/rostests/winetests/ntdll/rtl.c index a6328655073..bf2c22e0128 100755 --- a/rostests/winetests/ntdll/rtl.c +++ b/rostests/winetests/ntdll/rtl.c @@ -64,6 +64,7 @@ static inline USHORT __my_ushort_swap(USHORT s) /* Function ptrs for ntdll calls */ static HMODULE hntdll = 0; static PVOID (WINAPI *pWinSqmStartSession)(PVOID unknown1, DWORD unknown2, DWORD unknown3); +static BOOL (WINAPI *pWinSqmIsOptedIn)(void); static NTSTATUS (WINAPI *pWinSqmEndSession)(PVOID unknown1); static SIZE_T (WINAPI *pRtlCompareMemory)(LPCVOID,LPCVOID,SIZE_T); static SIZE_T (WINAPI *pRtlCompareMemoryUlong)(PULONG, SIZE_T, ULONG); @@ -125,6 +126,7 @@ static void InitFunctionPtrs(void) ok(hntdll != 0, "LoadLibrary failed\n"); if (hntdll) { pWinSqmStartSession = (void *)GetProcAddress(hntdll, "WinSqmStartSession"); + pWinSqmIsOptedIn = (void *)GetProcAddress(hntdll, "WinSqmIsOptedIn"); pWinSqmEndSession = (void *)GetProcAddress(hntdll, "WinSqmEndSession"); pRtlCompareMemory = (void *)GetProcAddress(hntdll, "RtlCompareMemory"); pRtlCompareMemoryUlong = (void *)GetProcAddress(hntdll, "RtlCompareMemoryUlong"); @@ -211,6 +213,8 @@ static void test_WinSqm(void) args = 3 - call_stdcall_func3( pWinSqmStartSession, NULL, 0, 0 ) / 4; ok(args == 3, "WinSqmStartSession expected to take %d arguments instead of 3\n", args); + args = 3 - call_stdcall_func3( pWinSqmIsOptedIn, NULL, 0, 0 ) / 4; + ok(args == 0, "WinSqmIsOptedIn expected to take %d arguments instead of 0\n", args); args = 3 - call_stdcall_func3( pWinSqmEndSession, NULL, 0, 0 ) / 4; ok(args == 1, "WinSqmEndSession expected to take %d arguments instead of 1\n", args);