1 /* Unit test suite for Ntdll file functions
3 * Copyright 2007 Jeff Latimer
4 * Copyright 2007 Andrey Turkin
5 * Copyright 2008 Jeff Zaroyko
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * We use function pointers here as there is no import library for NTDLL on
30 /* Define WIN32_NO_STATUS so MSVC does not give us duplicate macro
31 * definition errors when we get to winnt.h
33 #define WIN32_NO_STATUS
35 #include "wine/test.h"
38 #ifndef IO_COMPLETION_ALL_ACCESS
39 #define IO_COMPLETION_ALL_ACCESS 0x001F0003
42 static NTSTATUS (WINAPI *pRtlFreeUnicodeString)( PUNICODE_STRING );
43 static VOID (WINAPI *pRtlInitUnicodeString)( PUNICODE_STRING, LPCWSTR );
44 static BOOL (WINAPI *pRtlDosPathNameToNtPathName_U)( LPCWSTR, PUNICODE_STRING, PWSTR*, CURDIR* );
45 static NTSTATUS (WINAPI *pNtCreateMailslotFile)( PHANDLE, ULONG, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK,
46 ULONG, ULONG, ULONG, PLARGE_INTEGER );
47 static NTSTATUS (WINAPI *pNtDeleteFile)(POBJECT_ATTRIBUTES ObjectAttributes);
48 static NTSTATUS (WINAPI *pNtReadFile)(HANDLE hFile, HANDLE hEvent,
49 PIO_APC_ROUTINE apc, void* apc_user,
50 PIO_STATUS_BLOCK io_status, void* buffer, ULONG length,
51 PLARGE_INTEGER offset, PULONG key);
52 static NTSTATUS (WINAPI *pNtWriteFile)(HANDLE hFile, HANDLE hEvent,
53 PIO_APC_ROUTINE apc, void* apc_user,
54 PIO_STATUS_BLOCK io_status,
55 const void* buffer, ULONG length,
56 PLARGE_INTEGER offset, PULONG key);
57 static NTSTATUS (WINAPI *pNtCancelIoFile)(HANDLE hFile, PIO_STATUS_BLOCK io_status);
58 static NTSTATUS (WINAPI *pNtCancelIoFileEx)(HANDLE hFile, PIO_STATUS_BLOCK iosb, PIO_STATUS_BLOCK io_status);
59 static NTSTATUS (WINAPI *pNtClose)( PHANDLE );
61 static NTSTATUS (WINAPI *pNtCreateIoCompletion)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, ULONG);
62 static NTSTATUS (WINAPI *pNtOpenIoCompletion)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES);
63 static NTSTATUS (WINAPI *pNtQueryIoCompletion)(HANDLE, IO_COMPLETION_INFORMATION_CLASS, PVOID, ULONG, PULONG);
64 static NTSTATUS (WINAPI *pNtRemoveIoCompletion)(HANDLE, PULONG_PTR, PULONG_PTR, PIO_STATUS_BLOCK, PLARGE_INTEGER);
65 static NTSTATUS (WINAPI *pNtSetIoCompletion)(HANDLE, ULONG_PTR, ULONG_PTR, NTSTATUS, ULONG);
66 static NTSTATUS (WINAPI *pNtSetInformationFile)(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FILE_INFORMATION_CLASS);
67 static NTSTATUS (WINAPI *pNtQueryInformationFile)(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FILE_INFORMATION_CLASS);
69 static inline BOOL is_signaled( HANDLE obj )
71 return WaitForSingleObject( obj, 0 ) == 0;
74 #define PIPENAME "\\\\.\\pipe\\ntdll_tests_file.c"
75 #define TEST_BUF_LEN 3
77 static BOOL create_pipe( HANDLE *read, HANDLE *write, ULONG flags, ULONG size )
79 *read = CreateNamedPipe(PIPENAME, PIPE_ACCESS_INBOUND | flags, PIPE_TYPE_BYTE | PIPE_WAIT,
80 1, size, size, NMPWAIT_USE_DEFAULT_WAIT, NULL);
81 ok(*read != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
83 *write = CreateFileA(PIPENAME, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
84 ok(*write != INVALID_HANDLE_VALUE, "CreateFile failed (%d)\n", GetLastError());
89 static HANDLE create_temp_file( ULONG flags )
91 char buffer[MAX_PATH];
94 GetTempFileNameA( ".", "foo", 0, buffer );
95 handle = CreateFileA(buffer, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
96 flags | FILE_FLAG_DELETE_ON_CLOSE, 0);
97 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
98 return (handle == INVALID_HANDLE_VALUE) ? 0 : handle;
101 #define CVALUE_FIRST 0xfffabbcc
102 #define CKEY_FIRST 0x1030341
103 #define CKEY_SECOND 0x132E46
105 ULONG_PTR completionKey;
106 IO_STATUS_BLOCK ioSb;
107 ULONG_PTR completionValue;
109 static long get_pending_msgs(HANDLE h)
114 res = pNtQueryIoCompletion( h, IoCompletionBasicInformation, &a, sizeof(a), &req );
115 ok( res == STATUS_SUCCESS, "NtQueryIoCompletion failed: %x\n", res );
116 if (res != STATUS_SUCCESS) return -1;
117 ok( req == sizeof(a), "Unexpected response size: %x\n", req );
121 static BOOL get_msg(HANDLE h)
123 LARGE_INTEGER timeout = {{-10000000*3}};
124 DWORD res = pNtRemoveIoCompletion( h, &completionKey, &completionValue, &ioSb, &timeout);
125 ok( res == STATUS_SUCCESS, "NtRemoveIoCompletion failed: %x\n", res );
126 if (res != STATUS_SUCCESS)
128 completionKey = completionValue = 0;
129 memset(&ioSb, 0, sizeof(ioSb));
136 static void WINAPI apc( void *arg, IO_STATUS_BLOCK *iosb, ULONG reserved )
140 trace( "apc called block %p iosb.status %x iosb.info %lu\n",
141 iosb, U(*iosb).Status, iosb->Information );
143 ok( !reserved, "reserved is not 0: %x\n", reserved );
146 static void delete_file_test(void)
149 OBJECT_ATTRIBUTES attr;
150 UNICODE_STRING nameW;
151 WCHAR pathW[MAX_PATH];
152 WCHAR pathsubW[MAX_PATH];
153 static const WCHAR testdirW[] = {'n','t','d','e','l','e','t','e','f','i','l','e',0};
154 static const WCHAR subdirW[] = {'\\','s','u','b',0};
156 ret = GetTempPathW(MAX_PATH, pathW);
159 ok(0, "couldn't get temp dir\n");
162 if (ret + sizeof(testdirW)/sizeof(WCHAR)-1 + sizeof(subdirW)/sizeof(WCHAR)-1 >= MAX_PATH)
164 ok(0, "MAX_PATH exceeded in constructing paths\n");
168 lstrcatW(pathW, testdirW);
169 lstrcpyW(pathsubW, pathW);
170 lstrcatW(pathsubW, subdirW);
172 ret = CreateDirectoryW(pathW, NULL);
173 ok(ret == TRUE, "couldn't create directory ntdeletefile\n");
174 if (!pRtlDosPathNameToNtPathName_U(pathW, &nameW, NULL, NULL))
176 ok(0,"RtlDosPathNametoNtPathName_U failed\n");
180 attr.Length = sizeof(attr);
181 attr.RootDirectory = 0;
182 attr.Attributes = OBJ_CASE_INSENSITIVE;
183 attr.ObjectName = &nameW;
184 attr.SecurityDescriptor = NULL;
185 attr.SecurityQualityOfService = NULL;
187 /* test NtDeleteFile on an empty directory */
188 ret = pNtDeleteFile(&attr);
189 ok(ret == STATUS_SUCCESS, "NtDeleteFile should succeed in removing an empty directory\n");
190 ret = RemoveDirectoryW(pathW);
191 ok(ret == FALSE, "expected to fail removing directory, NtDeleteFile should have removed it\n");
193 /* test NtDeleteFile on a non-empty directory */
194 ret = CreateDirectoryW(pathW, NULL);
195 ok(ret == TRUE, "couldn't create directory ntdeletefile ?!\n");
196 ret = CreateDirectoryW(pathsubW, NULL);
197 ok(ret == TRUE, "couldn't create directory subdir\n");
198 ret = pNtDeleteFile(&attr);
199 ok(ret == STATUS_SUCCESS, "expected NtDeleteFile to ret STATUS_SUCCESS\n");
200 ret = RemoveDirectoryW(pathsubW);
201 ok(ret == TRUE, "expected to remove directory ntdeletefile\\sub\n");
202 ret = RemoveDirectoryW(pathW);
203 ok(ret == TRUE, "expected to remove directory ntdeletefile, NtDeleteFile failed.\n");
205 pRtlFreeUnicodeString( &nameW );
208 static void read_file_test(void)
210 const char text[] = "foobar";
211 HANDLE handle, read, write;
213 IO_STATUS_BLOCK iosb, iosb2;
217 LARGE_INTEGER offset;
218 HANDLE event = CreateEventA( NULL, TRUE, FALSE, NULL );
222 if (!create_pipe( &read, &write, FILE_FLAG_OVERLAPPED, 4096 )) return;
224 /* try read with no data */
225 U(iosb).Status = 0xdeadbabe;
226 iosb.Information = 0xdeadbeef;
227 ok( is_signaled( read ), "read handle is not signaled\n" );
228 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
229 ok( status == STATUS_PENDING, "wrong status %x\n", status );
230 ok( !is_signaled( read ), "read handle is signaled\n" );
231 ok( !is_signaled( event ), "event is signaled\n" );
232 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
233 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
234 ok( !apc_count, "apc was called\n" );
235 WriteFile( write, buffer, 1, &written, NULL );
236 /* iosb updated here by async i/o */
237 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
238 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
239 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
240 ok( !is_signaled( read ), "read handle is signaled\n" );
241 ok( is_signaled( event ), "event is not signaled\n" );
242 ok( !apc_count, "apc was called\n" );
244 SleepEx( 1, FALSE ); /* non-alertable sleep */
245 ok( !apc_count, "apc was called\n" );
246 SleepEx( 1, TRUE ); /* alertable sleep */
247 ok( apc_count == 1, "apc not called\n" );
249 /* with no event, the pipe handle itself gets signaled */
251 U(iosb).Status = 0xdeadbabe;
252 iosb.Information = 0xdeadbeef;
253 ok( !is_signaled( read ), "read handle is not signaled\n" );
254 status = pNtReadFile( read, 0, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
255 ok( status == STATUS_PENDING, "wrong status %x\n", status );
256 ok( !is_signaled( read ), "read handle is signaled\n" );
257 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
258 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
259 ok( !apc_count, "apc was called\n" );
260 WriteFile( write, buffer, 1, &written, NULL );
261 /* iosb updated here by async i/o */
262 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
263 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
264 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
265 ok( is_signaled( read ), "read handle is signaled\n" );
266 ok( !apc_count, "apc was called\n" );
268 SleepEx( 1, FALSE ); /* non-alertable sleep */
269 ok( !apc_count, "apc was called\n" );
270 SleepEx( 1, TRUE ); /* alertable sleep */
271 ok( apc_count == 1, "apc not called\n" );
273 /* now read with data ready */
275 U(iosb).Status = 0xdeadbabe;
276 iosb.Information = 0xdeadbeef;
278 WriteFile( write, buffer, 1, &written, NULL );
279 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
280 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
281 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
282 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
283 ok( is_signaled( event ), "event is not signaled\n" );
284 ok( !apc_count, "apc was called\n" );
285 SleepEx( 1, FALSE ); /* non-alertable sleep */
286 ok( !apc_count, "apc was called\n" );
287 SleepEx( 1, TRUE ); /* alertable sleep */
288 ok( apc_count == 1, "apc not called\n" );
290 /* try read with no data */
292 U(iosb).Status = 0xdeadbabe;
293 iosb.Information = 0xdeadbeef;
294 ok( is_signaled( event ), "event is not signaled\n" ); /* check that read resets the event */
295 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
296 ok( status == STATUS_PENDING, "wrong status %x\n", status );
297 ok( !is_signaled( event ), "event is signaled\n" );
298 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
299 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
300 ok( !apc_count, "apc was called\n" );
301 WriteFile( write, buffer, 1, &written, NULL );
302 /* partial read is good enough */
303 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
304 ok( is_signaled( event ), "event is signaled\n" );
305 ok( U(iosb).Status == 0, "wrong status %x\n", U(iosb).Status );
306 ok( iosb.Information == 1, "wrong info %lu\n", iosb.Information );
307 ok( !apc_count, "apc was called\n" );
308 SleepEx( 1, TRUE ); /* alertable sleep */
309 ok( apc_count == 1, "apc was not called\n" );
311 /* read from disconnected pipe */
313 U(iosb).Status = 0xdeadbabe;
314 iosb.Information = 0xdeadbeef;
315 CloseHandle( write );
316 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
317 ok( status == STATUS_PIPE_BROKEN, "wrong status %x\n", status );
318 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
319 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
320 ok( !is_signaled( event ), "event is signaled\n" );
321 ok( !apc_count, "apc was called\n" );
322 SleepEx( 1, TRUE ); /* alertable sleep */
323 ok( !apc_count, "apc was called\n" );
326 /* read from closed handle */
328 U(iosb).Status = 0xdeadbabe;
329 iosb.Information = 0xdeadbeef;
331 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 1, NULL, NULL );
332 ok( status == STATUS_INVALID_HANDLE, "wrong status %x\n", status );
333 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
334 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
335 ok( is_signaled( event ), "event is signaled\n" ); /* not reset on invalid handle */
336 ok( !apc_count, "apc was called\n" );
337 SleepEx( 1, TRUE ); /* alertable sleep */
338 ok( !apc_count, "apc was called\n" );
340 /* disconnect while async read is in progress */
341 if (!create_pipe( &read, &write, FILE_FLAG_OVERLAPPED, 4096 )) return;
343 U(iosb).Status = 0xdeadbabe;
344 iosb.Information = 0xdeadbeef;
345 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
346 ok( status == STATUS_PENDING, "wrong status %x\n", status );
347 ok( !is_signaled( event ), "event is signaled\n" );
348 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
349 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
350 ok( !apc_count, "apc was called\n" );
351 CloseHandle( write );
352 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
353 ok( U(iosb).Status == STATUS_PIPE_BROKEN, "wrong status %x\n", U(iosb).Status );
354 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
355 ok( is_signaled( event ), "event is signaled\n" );
356 ok( !apc_count, "apc was called\n" );
357 SleepEx( 1, TRUE ); /* alertable sleep */
358 ok( apc_count == 1, "apc was not called\n" );
361 if (!create_pipe( &read, &write, FILE_FLAG_OVERLAPPED, 4096 )) return;
362 ok(DuplicateHandle(GetCurrentProcess(), read, GetCurrentProcess(), &handle, 0, TRUE, DUPLICATE_SAME_ACCESS),
363 "Failed to duplicate handle: %d\n", GetLastError());
366 U(iosb).Status = 0xdeadbabe;
367 iosb.Information = 0xdeadbeef;
368 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
369 ok( status == STATUS_PENDING, "wrong status %x\n", status );
370 ok( !is_signaled( event ), "event is signaled\n" );
371 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
372 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
373 ok( !apc_count, "apc was called\n" );
374 /* Cancel by other handle */
375 status = pNtCancelIoFile( read, &iosb2 );
376 ok(status == STATUS_SUCCESS, "failed to cancel by different handle: %x\n", status);
377 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
378 ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
379 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
380 ok( is_signaled( event ), "event is signaled\n" );
381 todo_wine ok( !apc_count, "apc was called\n" );
382 SleepEx( 1, TRUE ); /* alertable sleep */
383 ok( apc_count == 1, "apc was not called\n" );
386 U(iosb).Status = 0xdeadbabe;
387 iosb.Information = 0xdeadbeef;
388 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
389 ok( status == STATUS_PENDING, "wrong status %x\n", status );
390 ok( !is_signaled( event ), "event is signaled\n" );
391 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
392 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
393 ok( !apc_count, "apc was called\n" );
394 /* Close queued handle */
396 SleepEx( 1, TRUE ); /* alertable sleep */
397 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
398 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
399 status = pNtCancelIoFile( read, &iosb2 );
400 ok(status == STATUS_INVALID_HANDLE, "cancelled by closed handle?\n");
401 status = pNtCancelIoFile( handle, &iosb2 );
402 ok(status == STATUS_SUCCESS, "failed to cancel: %x\n", status);
403 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
404 ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
405 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
406 ok( is_signaled( event ), "event is signaled\n" );
407 todo_wine ok( !apc_count, "apc was called\n" );
408 SleepEx( 1, TRUE ); /* alertable sleep */
409 ok( apc_count == 1, "apc was not called\n" );
410 CloseHandle( handle );
411 CloseHandle( write );
413 if (pNtCancelIoFileEx)
415 /* Basic Cancel Ex */
416 if (!create_pipe( &read, &write, FILE_FLAG_OVERLAPPED, 4096 )) return;
419 U(iosb).Status = 0xdeadbabe;
420 iosb.Information = 0xdeadbeef;
421 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
422 ok( status == STATUS_PENDING, "wrong status %x\n", status );
423 ok( !is_signaled( event ), "event is signaled\n" );
424 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
425 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
426 ok( !apc_count, "apc was called\n" );
427 status = pNtCancelIoFileEx( read, &iosb, &iosb2 );
428 ok(status == STATUS_SUCCESS, "Failed to cancel I/O\n");
429 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
430 ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
431 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
432 ok( is_signaled( event ), "event is signaled\n" );
433 todo_wine ok( !apc_count, "apc was called\n" );
434 SleepEx( 1, TRUE ); /* alertable sleep */
435 ok( apc_count == 1, "apc was not called\n" );
439 U(iosb).Status = 0xdeadbabe;
440 iosb.Information = 0xdeadbeef;
441 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
442 ok( status == STATUS_PENDING, "wrong status %x\n", status );
443 ok( !is_signaled( event ), "event is signaled\n" );
444 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
445 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
446 ok( !apc_count, "apc was called\n" );
447 status = pNtReadFile( read, event, apc, &apc_count, &iosb, buffer, 2, NULL, NULL );
448 ok( status == STATUS_PENDING, "wrong status %x\n", status );
449 ok( !is_signaled( event ), "event is signaled\n" );
450 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
451 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
452 ok( !apc_count, "apc was called\n" );
453 status = pNtCancelIoFileEx( read, &iosb, &iosb2 );
454 ok(status == STATUS_SUCCESS, "Failed to cancel I/O\n");
455 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
456 ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
457 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
458 ok( is_signaled( event ), "event is signaled\n" );
459 todo_wine ok( !apc_count, "apc was called\n" );
460 SleepEx( 1, TRUE ); /* alertable sleep */
461 ok( apc_count == 2, "apc was not called\n" );
464 CloseHandle( write );
467 /* now try a real file */
468 if (!(handle = create_temp_file( FILE_FLAG_OVERLAPPED ))) return;
470 U(iosb).Status = 0xdeadbabe;
471 iosb.Information = 0xdeadbeef;
474 status = pNtWriteFile( handle, event, apc, &apc_count, &iosb, text, strlen(text), &offset, NULL );
475 ok( status == STATUS_SUCCESS || status == STATUS_PENDING, "wrong status %x\n", status );
476 ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
477 ok( iosb.Information == strlen(text), "wrong info %lu\n", iosb.Information );
478 ok( is_signaled( event ), "event is signaled\n" );
479 ok( !apc_count, "apc was called\n" );
480 SleepEx( 1, TRUE ); /* alertable sleep */
481 ok( apc_count == 1, "apc was not called\n" );
484 U(iosb).Status = 0xdeadbabe;
485 iosb.Information = 0xdeadbeef;
488 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, strlen(text) + 10, &offset, NULL );
489 ok( status == STATUS_SUCCESS ||
490 status == STATUS_PENDING, /* vista */
491 "wrong status %x\n", status );
492 ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
493 ok( iosb.Information == strlen(text), "wrong info %lu\n", iosb.Information );
494 ok( is_signaled( event ), "event is signaled\n" );
495 ok( !apc_count, "apc was called\n" );
496 SleepEx( 1, TRUE ); /* alertable sleep */
497 ok( apc_count == 1, "apc was not called\n" );
499 /* read beyond eof */
501 U(iosb).Status = 0xdeadbabe;
502 iosb.Information = 0xdeadbeef;
503 offset.QuadPart = strlen(text) + 2;
504 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, &offset, NULL );
505 if (status == STATUS_PENDING) /* vista */
507 ok( U(iosb).Status == STATUS_END_OF_FILE, "wrong status %x\n", U(iosb).Status );
508 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
509 ok( is_signaled( event ), "event is signaled\n" );
510 ok( !apc_count, "apc was called\n" );
511 SleepEx( 1, TRUE ); /* alertable sleep */
512 ok( apc_count == 1, "apc was not called\n" );
516 ok( status == STATUS_END_OF_FILE, "wrong status %x\n", status );
517 ok( U(iosb).Status == 0xdeadbabe, "wrong status %x\n", U(iosb).Status );
518 ok( iosb.Information == 0xdeadbeef, "wrong info %lu\n", iosb.Information );
519 ok( !is_signaled( event ), "event is signaled\n" );
520 ok( !apc_count, "apc was called\n" );
521 SleepEx( 1, TRUE ); /* alertable sleep */
522 ok( !apc_count, "apc was called\n" );
524 CloseHandle( handle );
526 /* now a non-overlapped file */
527 if (!(handle = create_temp_file(0))) return;
529 U(iosb).Status = 0xdeadbabe;
530 iosb.Information = 0xdeadbeef;
532 status = pNtWriteFile( handle, event, apc, &apc_count, &iosb, text, strlen(text), &offset, NULL );
533 ok( status == STATUS_END_OF_FILE ||
534 status == STATUS_SUCCESS ||
535 status == STATUS_PENDING, /* vista */
536 "wrong status %x\n", status );
537 ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
538 ok( iosb.Information == strlen(text), "wrong info %lu\n", iosb.Information );
539 ok( is_signaled( event ), "event is signaled\n" );
540 ok( !apc_count, "apc was called\n" );
541 SleepEx( 1, TRUE ); /* alertable sleep */
542 ok( apc_count == 1, "apc was not called\n" );
545 U(iosb).Status = 0xdeadbabe;
546 iosb.Information = 0xdeadbeef;
549 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, strlen(text) + 10, &offset, NULL );
550 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
551 ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
552 ok( iosb.Information == strlen(text), "wrong info %lu\n", iosb.Information );
553 ok( is_signaled( event ), "event is signaled\n" );
554 ok( !apc_count, "apc was called\n" );
555 SleepEx( 1, TRUE ); /* alertable sleep */
556 todo_wine ok( !apc_count, "apc was called\n" );
558 /* read beyond eof */
560 U(iosb).Status = 0xdeadbabe;
561 iosb.Information = 0xdeadbeef;
562 offset.QuadPart = strlen(text) + 2;
564 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, &offset, NULL );
565 ok( status == STATUS_END_OF_FILE, "wrong status %x\n", status );
566 todo_wine ok( U(iosb).Status == STATUS_END_OF_FILE, "wrong status %x\n", U(iosb).Status );
567 todo_wine ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
568 todo_wine ok( is_signaled( event ), "event is not signaled\n" );
569 ok( !apc_count, "apc was called\n" );
570 SleepEx( 1, TRUE ); /* alertable sleep */
571 ok( !apc_count, "apc was called\n" );
573 CloseHandle( handle );
575 CloseHandle( event );
578 static void nt_mailslot_test(void)
581 ACCESS_MASK DesiredAccess;
582 OBJECT_ATTRIBUTES attr;
586 ULONG MaxMessageSize;
587 LARGE_INTEGER TimeOut;
588 IO_STATUS_BLOCK IoStatusBlock;
591 WCHAR buffer1[] = { '\\','?','?','\\','M','A','I','L','S','L','O','T','\\',
592 'R',':','\\','F','R','E','D','\0' };
594 TimeOut.QuadPart = -1;
596 pRtlInitUnicodeString(&str, buffer1);
597 InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL);
598 CreateOptions = MailslotQuota = MaxMessageSize = 0;
599 DesiredAccess = GENERIC_READ;
602 * Check for NULL pointer handling
604 rc = pNtCreateMailslotFile(NULL, DesiredAccess,
605 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
607 ok( rc == STATUS_ACCESS_VIOLATION ||
608 rc == STATUS_INVALID_PARAMETER, /* win2k3 */
609 "rc = %x not STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER\n", rc);
612 * Test to see if the Timeout can be NULL
614 hslot = (HANDLE)0xdeadbeef;
615 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
616 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
618 ok( rc == STATUS_SUCCESS ||
619 rc == STATUS_INVALID_PARAMETER, /* win2k3 */
620 "rc = %x not STATUS_SUCCESS or STATUS_INVALID_PARAMETER\n", rc);
621 ok( hslot != 0, "Handle is invalid\n");
623 if ( rc == STATUS_SUCCESS ) rc = pNtClose(hslot);
626 * Test that the length field is checked properly
629 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
630 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
632 todo_wine ok( rc == STATUS_INVALID_PARAMETER, "rc = %x not c000000d STATUS_INVALID_PARAMETER\n", rc);
634 if (rc == STATUS_SUCCESS) pNtClose(hslot);
636 attr.Length = sizeof(OBJECT_ATTRIBUTES)+1;
637 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
638 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
640 todo_wine ok( rc == STATUS_INVALID_PARAMETER, "rc = %x not c000000d STATUS_INVALID_PARAMETER\n", rc);
642 if (rc == STATUS_SUCCESS) pNtClose(hslot);
645 * Test handling of a NULL unicode string in ObjectName
647 InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL);
648 attr.ObjectName = NULL;
649 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
650 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
652 ok( rc == STATUS_OBJECT_PATH_SYNTAX_BAD ||
653 rc == STATUS_INVALID_PARAMETER,
654 "rc = %x not STATUS_OBJECT_PATH_SYNTAX_BAD or STATUS_INVALID_PARAMETER\n", rc);
656 if (rc == STATUS_SUCCESS) pNtClose(hslot);
661 InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL);
662 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
663 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
665 ok( rc == STATUS_SUCCESS, "Create MailslotFile failed rc = %x\n", rc);
666 ok( hslot != 0, "Handle is invalid\n");
668 rc = pNtClose(hslot);
669 ok( rc == STATUS_SUCCESS, "NtClose failed\n");
672 static void test_iocp_setcompletion(HANDLE h)
677 res = pNtSetIoCompletion( h, CKEY_FIRST, CVALUE_FIRST, STATUS_INVALID_DEVICE_REQUEST, 3 );
678 ok( res == STATUS_SUCCESS, "NtSetIoCompletion failed: %x\n", res );
680 count = get_pending_msgs(h);
681 ok( count == 1, "Unexpected msg count: %ld\n", count );
685 ok( completionKey == CKEY_FIRST, "Invalid completion key: %lx\n", completionKey );
686 ok( ioSb.Information == 3, "Invalid ioSb.Information: %ld\n", ioSb.Information );
687 ok( U(ioSb).Status == STATUS_INVALID_DEVICE_REQUEST, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
688 ok( completionValue == CVALUE_FIRST, "Invalid completion value: %lx\n", completionValue );
691 count = get_pending_msgs(h);
692 ok( !count, "Unexpected msg count: %ld\n", count );
695 static void test_iocp_fileio(HANDLE h)
697 static const char pipe_name[] = "\\\\.\\pipe\\iocompletiontestnamedpipe";
699 IO_STATUS_BLOCK iosb;
700 FILE_COMPLETION_INFORMATION fci = {h, CKEY_SECOND};
701 HANDLE hPipeSrv, hPipeClt;
704 hPipeSrv = CreateNamedPipeA( pipe_name, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 4, 1024, 1024, 1000, NULL );
705 ok( hPipeSrv != INVALID_HANDLE_VALUE, "Cannot create named pipe\n" );
706 if (hPipeSrv != INVALID_HANDLE_VALUE )
708 hPipeClt = CreateFileA( pipe_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL );
709 ok( hPipeClt != INVALID_HANDLE_VALUE, "Cannot connect to pipe\n" );
710 if (hPipeClt != INVALID_HANDLE_VALUE)
712 res = pNtSetInformationFile( hPipeSrv, &iosb, &fci, sizeof(fci), FileCompletionInformation );
713 ok( res == STATUS_INVALID_PARAMETER, "Unexpected NtSetInformationFile on non-overlapped handle: %x\n", res );
714 CloseHandle(hPipeClt);
716 CloseHandle( hPipeSrv );
719 hPipeSrv = CreateNamedPipeA( pipe_name, PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 4, 1024, 1024, 1000, NULL );
720 ok( hPipeSrv != INVALID_HANDLE_VALUE, "Cannot create named pipe\n" );
721 if (hPipeSrv == INVALID_HANDLE_VALUE )
724 hPipeClt = CreateFileA( pipe_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL );
725 ok( hPipeClt != INVALID_HANDLE_VALUE, "Cannot connect to pipe\n" );
726 if (hPipeClt != INVALID_HANDLE_VALUE)
729 BYTE send_buf[TEST_BUF_LEN], recv_buf[TEST_BUF_LEN];
733 NTSTATUS res = pNtSetInformationFile( hPipeSrv, &iosb, &fci, sizeof(fci), FileCompletionInformation );
734 ok( res == STATUS_SUCCESS, "NtSetInformationFile failed: %x\n", res );
735 ok( U(iosb).Status == STATUS_SUCCESS, "iosb.Status invalid: %x\n", U(iosb).Status );
737 memset( send_buf, 0, TEST_BUF_LEN );
738 memset( recv_buf, 0xde, TEST_BUF_LEN );
739 count = get_pending_msgs(h);
740 ok( !count, "Unexpected msg count: %ld\n", count );
741 ReadFile( hPipeSrv, recv_buf, TEST_BUF_LEN, &read, &o);
742 count = get_pending_msgs(h);
743 ok( !count, "Unexpected msg count: %ld\n", count );
744 WriteFile( hPipeClt, send_buf, TEST_BUF_LEN, &read, NULL );
748 ok( completionKey == CKEY_SECOND, "Invalid completion key: %lx\n", completionKey );
749 ok( ioSb.Information == 3, "Invalid ioSb.Information: %ld\n", ioSb.Information );
750 ok( U(ioSb).Status == STATUS_SUCCESS, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
751 ok( completionValue == (ULONG_PTR)&o, "Invalid completion value: %lx\n", completionValue );
752 ok( !memcmp( send_buf, recv_buf, TEST_BUF_LEN ), "Receive buffer (%x %x %x) did not match send buffer (%x %x %x)\n", recv_buf[0], recv_buf[1], recv_buf[2], send_buf[0], send_buf[1], send_buf[2] );
754 count = get_pending_msgs(h);
755 ok( !count, "Unexpected msg count: %ld\n", count );
757 memset( send_buf, 0, TEST_BUF_LEN );
758 memset( recv_buf, 0xde, TEST_BUF_LEN );
759 WriteFile( hPipeClt, send_buf, 2, &read, NULL );
760 count = get_pending_msgs(h);
761 ok( !count, "Unexpected msg count: %ld\n", count );
762 ReadFile( hPipeSrv, recv_buf, 2, &read, &o);
763 count = get_pending_msgs(h);
764 ok( count == 1, "Unexpected msg count: %ld\n", count );
767 ok( completionKey == CKEY_SECOND, "Invalid completion key: %lx\n", completionKey );
768 ok( ioSb.Information == 2, "Invalid ioSb.Information: %ld\n", ioSb.Information );
769 ok( U(ioSb).Status == STATUS_SUCCESS, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
770 ok( completionValue == (ULONG_PTR)&o, "Invalid completion value: %lx\n", completionValue );
771 ok( !memcmp( send_buf, recv_buf, 2 ), "Receive buffer (%x %x) did not match send buffer (%x %x)\n", recv_buf[0], recv_buf[1], send_buf[0], send_buf[1] );
774 ReadFile( hPipeSrv, recv_buf, TEST_BUF_LEN, &read, &o);
775 CloseHandle( hPipeSrv );
776 count = get_pending_msgs(h);
777 ok( count == 1, "Unexpected msg count: %ld\n", count );
780 ok( completionKey == CKEY_SECOND, "Invalid completion key: %lx\n", completionKey );
781 ok( ioSb.Information == 0, "Invalid ioSb.Information: %ld\n", ioSb.Information );
782 /* wine sends wrong status here */
783 todo_wine ok( U(ioSb).Status == STATUS_PIPE_BROKEN, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
784 ok( completionValue == (ULONG_PTR)&o, "Invalid completion value: %lx\n", completionValue );
788 CloseHandle( hPipeClt );
791 static void test_file_basic_information(void)
794 FILE_BASIC_INFORMATION fbi;
797 int attrib_mask = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NORMAL;
799 if (!(h = create_temp_file(0))) return;
801 /* Check default first */
802 memset(&fbi, 0, sizeof(fbi));
803 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
804 ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);
805 ok ( (fbi.FileAttributes & FILE_ATTRIBUTE_ARCHIVE) == FILE_ATTRIBUTE_ARCHIVE,
806 "attribute %x not expected\n", fbi.FileAttributes );
809 /* Clear fbi to avoid setting times */
810 memset(&fbi, 0, sizeof(fbi));
811 fbi.FileAttributes = FILE_ATTRIBUTE_SYSTEM;
812 res = pNtSetInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
813 ok ( res == STATUS_SUCCESS, "can't set system attribute\n");
815 memset(&fbi, 0, sizeof(fbi));
816 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
817 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
818 todo_wine ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM\n", fbi.FileAttributes );
821 memset(&fbi, 0, sizeof(fbi));
822 fbi.FileAttributes = FILE_ATTRIBUTE_HIDDEN;
823 res = pNtSetInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
824 ok ( res == STATUS_SUCCESS, "can't set system attribute\n");
826 memset(&fbi, 0, sizeof(fbi));
827 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
828 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
829 todo_wine ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN\n", fbi.FileAttributes );
831 /* Check NORMAL last of all (to make sure we can clear attributes) */
832 memset(&fbi, 0, sizeof(fbi));
833 fbi.FileAttributes = FILE_ATTRIBUTE_NORMAL;
834 res = pNtSetInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
835 ok ( res == STATUS_SUCCESS, "can't set normal attribute\n");
837 memset(&fbi, 0, sizeof(fbi));
838 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
839 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
840 todo_wine ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_NORMAL, "attribute %x not 0\n", fbi.FileAttributes );
845 static void test_file_all_information(void)
848 /* FileAllInformation, like FileNameInformation, has a variable-length pathname
849 * buffer at the end. Vista objects with STATUS_BUFFER_OVERFLOW if you
850 * don't leave enough room there.
853 FILE_ALL_INFORMATION fai;
858 int attrib_mask = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NORMAL;
860 if (!(h = create_temp_file(0))) return;
862 /* Check default first */
863 res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
864 ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);
865 ok ( (fai_buf.fai.BasicInformation.FileAttributes & FILE_ATTRIBUTE_ARCHIVE) == FILE_ATTRIBUTE_ARCHIVE,
866 "attribute %x not expected\n", fai_buf.fai.BasicInformation.FileAttributes );
869 /* Clear fbi to avoid setting times */
870 memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
871 fai_buf.fai.BasicInformation.FileAttributes = FILE_ATTRIBUTE_SYSTEM;
872 res = pNtSetInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
873 ok ( res == STATUS_INVALID_INFO_CLASS || res == STATUS_NOT_IMPLEMENTED, "shouldn't be able to set FileAllInformation, res %x\n", res);
874 res = pNtSetInformationFile(h, &io, &fai_buf.fai.BasicInformation, sizeof fai_buf.fai.BasicInformation, FileBasicInformation);
875 ok ( res == STATUS_SUCCESS, "can't set system attribute\n");
877 memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
878 res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
879 ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);
880 todo_wine ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM\n", fai_buf.fai.BasicInformation.FileAttributes );
883 memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
884 fai_buf.fai.BasicInformation.FileAttributes = FILE_ATTRIBUTE_HIDDEN;
885 res = pNtSetInformationFile(h, &io, &fai_buf.fai.BasicInformation, sizeof fai_buf.fai.BasicInformation, FileBasicInformation);
886 ok ( res == STATUS_SUCCESS, "can't set system attribute\n");
888 memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
889 res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
890 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
891 todo_wine ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN\n", fai_buf.fai.BasicInformation.FileAttributes );
893 /* Check NORMAL last of all (to make sure we can clear attributes) */
894 memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
895 fai_buf.fai.BasicInformation.FileAttributes = FILE_ATTRIBUTE_NORMAL;
896 res = pNtSetInformationFile(h, &io, &fai_buf.fai.BasicInformation, sizeof fai_buf.fai.BasicInformation, FileBasicInformation);
897 ok ( res == STATUS_SUCCESS, "can't set normal attribute\n");
899 memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
900 res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
901 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
902 todo_wine ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_NORMAL, "attribute %x not FILE_ATTRIBUTE_NORMAL\n", fai_buf.fai.BasicInformation.FileAttributes );
907 static void test_file_both_information(void)
910 FILE_BOTH_DIR_INFORMATION fbi;
914 if (!(h = create_temp_file(0))) return;
916 memset(&fbi, 0, sizeof(fbi));
917 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBothDirectoryInformation);
918 ok ( res == STATUS_INVALID_INFO_CLASS || res == STATUS_NOT_IMPLEMENTED, "shouldn't be able to query FileBothDirectoryInformation, res %x\n", res);
923 static void test_iocompletion(void)
925 HANDLE h = INVALID_HANDLE_VALUE;
928 res = pNtCreateIoCompletion( &h, IO_COMPLETION_ALL_ACCESS, NULL, 0);
930 ok( res == 0, "NtCreateIoCompletion anonymous failed: %x\n", res );
931 ok( h && h != INVALID_HANDLE_VALUE, "Invalid handle returned\n" );
933 if ( h && h != INVALID_HANDLE_VALUE)
935 test_iocp_setcompletion(h);
943 HMODULE hntdll = GetModuleHandleA("ntdll.dll");
946 skip("not running on NT, skipping test\n");
950 pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
951 pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
952 pRtlDosPathNameToNtPathName_U = (void *)GetProcAddress(hntdll, "RtlDosPathNameToNtPathName_U");
953 pNtCreateMailslotFile = (void *)GetProcAddress(hntdll, "NtCreateMailslotFile");
954 pNtDeleteFile = (void *)GetProcAddress(hntdll, "NtDeleteFile");
955 pNtReadFile = (void *)GetProcAddress(hntdll, "NtReadFile");
956 pNtWriteFile = (void *)GetProcAddress(hntdll, "NtWriteFile");
957 pNtCancelIoFile = (void *)GetProcAddress(hntdll, "NtCancelIoFile");
958 pNtCancelIoFileEx = (void *)GetProcAddress(hntdll, "NtCancelIoFileEx");
959 pNtClose = (void *)GetProcAddress(hntdll, "NtClose");
960 pNtCreateIoCompletion = (void *)GetProcAddress(hntdll, "NtCreateIoCompletion");
961 pNtOpenIoCompletion = (void *)GetProcAddress(hntdll, "NtOpenIoCompletion");
962 pNtQueryIoCompletion = (void *)GetProcAddress(hntdll, "NtQueryIoCompletion");
963 pNtRemoveIoCompletion = (void *)GetProcAddress(hntdll, "NtRemoveIoCompletion");
964 pNtSetIoCompletion = (void *)GetProcAddress(hntdll, "NtSetIoCompletion");
965 pNtSetInformationFile = (void *)GetProcAddress(hntdll, "NtSetInformationFile");
966 pNtQueryInformationFile = (void *)GetProcAddress(hntdll, "NtQueryInformationFile");
972 test_file_basic_information();
973 test_file_all_information();
974 test_file_both_information();