1 /* Unit test suite for Ntdll file functions
3 * Copyright 2007 Jeff Latimer
4 * Copyright 2007 Andrey Turkin
5 * Copyright 2008 Jeff Zaroyko
6 * Copyright 2011 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * We use function pointers here as there is no import library for NTDLL on
31 /* Define WIN32_NO_STATUS so MSVC does not give us duplicate macro
32 * definition errors when we get to winnt.h
34 #define WIN32_NO_STATUS
36 #include "wine/test.h"
41 #ifndef IO_COMPLETION_ALL_ACCESS
42 #define IO_COMPLETION_ALL_ACCESS 0x001F0003
45 static BOOL (WINAPI
* pGetVolumePathNameW
)(LPCWSTR
, LPWSTR
, DWORD
);
46 static UINT (WINAPI
*pGetSystemWow64DirectoryW
)( LPWSTR
, UINT
);
48 static VOID (WINAPI
*pRtlFreeUnicodeString
)( PUNICODE_STRING
);
49 static VOID (WINAPI
*pRtlInitUnicodeString
)( PUNICODE_STRING
, LPCWSTR
);
50 static BOOL (WINAPI
*pRtlDosPathNameToNtPathName_U
)( LPCWSTR
, PUNICODE_STRING
, PWSTR
*, CURDIR
* );
51 static NTSTATUS (WINAPI
*pRtlWow64EnableFsRedirectionEx
)( ULONG
, ULONG
* );
53 static NTSTATUS (WINAPI
*pNtCreateMailslotFile
)( PHANDLE
, ULONG
, POBJECT_ATTRIBUTES
, PIO_STATUS_BLOCK
,
54 ULONG
, ULONG
, ULONG
, PLARGE_INTEGER
);
55 static NTSTATUS (WINAPI
*pNtCreateFile
)(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,PIO_STATUS_BLOCK
,PLARGE_INTEGER
,ULONG
,ULONG
,ULONG
,ULONG
,PVOID
,ULONG
);
56 static NTSTATUS (WINAPI
*pNtOpenFile
)(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,PIO_STATUS_BLOCK
,ULONG
,ULONG
);
57 static NTSTATUS (WINAPI
*pNtDeleteFile
)(POBJECT_ATTRIBUTES ObjectAttributes
);
58 static NTSTATUS (WINAPI
*pNtReadFile
)(HANDLE hFile
, HANDLE hEvent
,
59 PIO_APC_ROUTINE apc
, void* apc_user
,
60 PIO_STATUS_BLOCK io_status
, void* buffer
, ULONG length
,
61 PLARGE_INTEGER offset
, PULONG key
);
62 static NTSTATUS (WINAPI
*pNtWriteFile
)(HANDLE hFile
, HANDLE hEvent
,
63 PIO_APC_ROUTINE apc
, void* apc_user
,
64 PIO_STATUS_BLOCK io_status
,
65 const void* buffer
, ULONG length
,
66 PLARGE_INTEGER offset
, PULONG key
);
67 static NTSTATUS (WINAPI
*pNtCancelIoFile
)(HANDLE hFile
, PIO_STATUS_BLOCK io_status
);
68 static NTSTATUS (WINAPI
*pNtCancelIoFileEx
)(HANDLE hFile
, PIO_STATUS_BLOCK iosb
, PIO_STATUS_BLOCK io_status
);
69 static NTSTATUS (WINAPI
*pNtClose
)( PHANDLE
);
71 static NTSTATUS (WINAPI
*pNtCreateIoCompletion
)(PHANDLE
, ACCESS_MASK
, POBJECT_ATTRIBUTES
, ULONG
);
72 static NTSTATUS (WINAPI
*pNtOpenIoCompletion
)(PHANDLE
, ACCESS_MASK
, POBJECT_ATTRIBUTES
);
73 static NTSTATUS (WINAPI
*pNtQueryIoCompletion
)(HANDLE
, IO_COMPLETION_INFORMATION_CLASS
, PVOID
, ULONG
, PULONG
);
74 static NTSTATUS (WINAPI
*pNtRemoveIoCompletion
)(HANDLE
, PULONG_PTR
, PULONG_PTR
, PIO_STATUS_BLOCK
, PLARGE_INTEGER
);
75 static NTSTATUS (WINAPI
*pNtSetIoCompletion
)(HANDLE
, ULONG_PTR
, ULONG_PTR
, NTSTATUS
, SIZE_T
);
76 static NTSTATUS (WINAPI
*pNtSetInformationFile
)(HANDLE
, PIO_STATUS_BLOCK
, PVOID
, ULONG
, FILE_INFORMATION_CLASS
);
77 static NTSTATUS (WINAPI
*pNtQueryInformationFile
)(HANDLE
, PIO_STATUS_BLOCK
, PVOID
, ULONG
, FILE_INFORMATION_CLASS
);
78 static NTSTATUS (WINAPI
*pNtQueryDirectoryFile
)(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,
79 PVOID
,ULONG
,FILE_INFORMATION_CLASS
,BOOLEAN
,PUNICODE_STRING
,BOOLEAN
);
80 static NTSTATUS (WINAPI
*pNtQueryVolumeInformationFile
)(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FS_INFORMATION_CLASS
);
82 static inline BOOL
is_signaled( HANDLE obj
)
84 return WaitForSingleObject( obj
, 0 ) == WAIT_OBJECT_0
;
87 #define PIPENAME "\\\\.\\pipe\\ntdll_tests_file.c"
88 #define TEST_BUF_LEN 3
90 static BOOL
create_pipe( HANDLE
*read
, HANDLE
*write
, ULONG flags
, ULONG size
)
92 *read
= CreateNamedPipeA(PIPENAME
, PIPE_ACCESS_INBOUND
| flags
, PIPE_TYPE_BYTE
| PIPE_WAIT
,
93 1, size
, size
, NMPWAIT_USE_DEFAULT_WAIT
, NULL
);
94 ok(*read
!= INVALID_HANDLE_VALUE
, "CreateNamedPipe failed\n");
96 *write
= CreateFileA(PIPENAME
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, 0, 0);
97 ok(*write
!= INVALID_HANDLE_VALUE
, "CreateFile failed (%d)\n", GetLastError());
102 static HANDLE
create_temp_file( ULONG flags
)
104 char path
[MAX_PATH
], buffer
[MAX_PATH
];
107 GetTempPathA( MAX_PATH
, path
);
108 GetTempFileNameA( path
, "foo", 0, buffer
);
109 handle
= CreateFileA(buffer
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
110 flags
| FILE_FLAG_DELETE_ON_CLOSE
, 0);
111 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to create temp file\n" );
112 return (handle
== INVALID_HANDLE_VALUE
) ? 0 : handle
;
115 #define CVALUE_FIRST 0xfffabbcc
116 #define CKEY_FIRST 0x1030341
117 #define CKEY_SECOND 0x132E46
119 static ULONG_PTR completionKey
;
120 static IO_STATUS_BLOCK ioSb
;
121 static ULONG_PTR completionValue
;
123 static ULONG
get_pending_msgs(HANDLE h
)
128 res
= pNtQueryIoCompletion( h
, IoCompletionBasicInformation
, &a
, sizeof(a
), &req
);
129 ok( res
== STATUS_SUCCESS
, "NtQueryIoCompletion failed: %x\n", res
);
130 if (res
!= STATUS_SUCCESS
) return -1;
131 ok( req
== sizeof(a
), "Unexpected response size: %x\n", req
);
135 static BOOL
get_msg(HANDLE h
)
137 LARGE_INTEGER timeout
= {{-10000000*3}};
138 DWORD res
= pNtRemoveIoCompletion( h
, &completionKey
, &completionValue
, &ioSb
, &timeout
);
139 ok( res
== STATUS_SUCCESS
, "NtRemoveIoCompletion failed: %x\n", res
);
140 if (res
!= STATUS_SUCCESS
)
142 completionKey
= completionValue
= 0;
143 memset(&ioSb
, 0, sizeof(ioSb
));
150 static void WINAPI
apc( void *arg
, IO_STATUS_BLOCK
*iosb
, ULONG reserved
)
154 trace( "apc called block %p iosb.status %x iosb.info %lu\n",
155 iosb
, U(*iosb
).Status
, iosb
->Information
);
157 ok( !reserved
, "reserved is not 0: %x\n", reserved
);
160 static void create_file_test(void)
162 static const WCHAR systemrootW
[] = {'\\','S','y','s','t','e','m','R','o','o','t',
163 '\\','f','a','i','l','i','n','g',0};
164 static const WCHAR questionmarkInvalidNameW
[] = {'a','f','i','l','e','?',0};
165 static const WCHAR pipeInvalidNameW
[] = {'a','|','b',0};
168 WCHAR path
[MAX_PATH
];
169 OBJECT_ATTRIBUTES attr
;
171 UNICODE_STRING nameW
;
173 GetCurrentDirectoryW( MAX_PATH
, path
);
174 pRtlDosPathNameToNtPathName_U( path
, &nameW
, NULL
, NULL
);
175 attr
.Length
= sizeof(attr
);
176 attr
.RootDirectory
= 0;
177 attr
.ObjectName
= &nameW
;
178 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
179 attr
.SecurityDescriptor
= NULL
;
180 attr
.SecurityQualityOfService
= NULL
;
182 /* try various open modes and options on directories */
183 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
184 FILE_OPEN
, FILE_DIRECTORY_FILE
, NULL
, 0 );
185 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
188 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
189 FILE_CREATE
, FILE_DIRECTORY_FILE
, NULL
, 0 );
190 ok( status
== STATUS_OBJECT_NAME_COLLISION
|| status
== STATUS_ACCESS_DENIED
,
191 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
193 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
194 FILE_OPEN_IF
, FILE_DIRECTORY_FILE
, NULL
, 0 );
195 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
198 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
199 FILE_SUPERSEDE
, FILE_DIRECTORY_FILE
, NULL
, 0 );
200 ok( status
== STATUS_INVALID_PARAMETER
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
202 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
203 FILE_OVERWRITE
, FILE_DIRECTORY_FILE
, NULL
, 0 );
204 ok( status
== STATUS_INVALID_PARAMETER
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
206 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
207 FILE_OVERWRITE_IF
, FILE_DIRECTORY_FILE
, NULL
, 0 );
208 ok( status
== STATUS_INVALID_PARAMETER
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
210 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
211 FILE_OPEN
, 0, NULL
, 0 );
212 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
215 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
216 FILE_CREATE
, 0, NULL
, 0 );
217 ok( status
== STATUS_OBJECT_NAME_COLLISION
|| status
== STATUS_ACCESS_DENIED
,
218 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
220 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
221 FILE_OPEN_IF
, 0, NULL
, 0 );
222 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
225 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
226 FILE_SUPERSEDE
, 0, NULL
, 0 );
227 ok( status
== STATUS_OBJECT_NAME_COLLISION
|| status
== STATUS_ACCESS_DENIED
,
228 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
230 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
231 FILE_OVERWRITE
, 0, NULL
, 0 );
232 ok( status
== STATUS_OBJECT_NAME_COLLISION
|| status
== STATUS_ACCESS_DENIED
,
233 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
235 status
= pNtCreateFile( &dir
, GENERIC_READ
, &attr
, &io
, NULL
, 0, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
236 FILE_OVERWRITE_IF
, 0, NULL
, 0 );
237 ok( status
== STATUS_OBJECT_NAME_COLLISION
|| status
== STATUS_ACCESS_DENIED
,
238 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
240 pRtlFreeUnicodeString( &nameW
);
242 pRtlInitUnicodeString( &nameW
, systemrootW
);
243 attr
.Length
= sizeof(attr
);
244 attr
.RootDirectory
= NULL
;
245 attr
.ObjectName
= &nameW
;
246 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
247 attr
.SecurityDescriptor
= NULL
;
248 attr
.SecurityQualityOfService
= NULL
;
250 status
= pNtCreateFile( &dir
, FILE_APPEND_DATA
, &attr
, &io
, NULL
, FILE_ATTRIBUTE_NORMAL
, 0,
251 FILE_OPEN_IF
, FILE_SYNCHRONOUS_IO_NONALERT
, NULL
, 0 );
253 ok( status
== STATUS_INVALID_PARAMETER
,
254 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
256 /* Invalid chars in file/dirnames */
257 pRtlDosPathNameToNtPathName_U(questionmarkInvalidNameW
, &nameW
, NULL
, NULL
);
258 attr
.ObjectName
= &nameW
;
259 status
= pNtCreateFile(&dir
, GENERIC_READ
|SYNCHRONIZE
, &attr
, &io
, NULL
, 0,
260 FILE_SHARE_READ
, FILE_CREATE
,
261 FILE_DIRECTORY_FILE
|FILE_SYNCHRONOUS_IO_NONALERT
, NULL
, 0);
262 ok(status
== STATUS_OBJECT_NAME_INVALID
,
263 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
265 status
= pNtCreateFile(&file
, GENERIC_WRITE
|SYNCHRONIZE
, &attr
, &io
, NULL
, 0,
267 FILE_NON_DIRECTORY_FILE
|FILE_SYNCHRONOUS_IO_NONALERT
, NULL
, 0);
268 ok(status
== STATUS_OBJECT_NAME_INVALID
,
269 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
270 pRtlFreeUnicodeString(&nameW
);
272 pRtlDosPathNameToNtPathName_U(pipeInvalidNameW
, &nameW
, NULL
, NULL
);
273 attr
.ObjectName
= &nameW
;
274 status
= pNtCreateFile(&dir
, GENERIC_READ
|SYNCHRONIZE
, &attr
, &io
, NULL
, 0,
275 FILE_SHARE_READ
, FILE_CREATE
,
276 FILE_DIRECTORY_FILE
|FILE_SYNCHRONOUS_IO_NONALERT
, NULL
, 0);
277 ok(status
== STATUS_OBJECT_NAME_INVALID
,
278 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
280 status
= pNtCreateFile(&file
, GENERIC_WRITE
|SYNCHRONIZE
, &attr
, &io
, NULL
, 0,
282 FILE_NON_DIRECTORY_FILE
|FILE_SYNCHRONOUS_IO_NONALERT
, NULL
, 0);
283 ok(status
== STATUS_OBJECT_NAME_INVALID
,
284 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
285 pRtlFreeUnicodeString(&nameW
);
288 static void open_file_test(void)
291 HANDLE dir
, root
, handle
;
292 WCHAR path
[MAX_PATH
];
294 OBJECT_ATTRIBUTES attr
;
296 UNICODE_STRING nameW
;
300 len
= GetWindowsDirectoryW( path
, MAX_PATH
);
301 pRtlDosPathNameToNtPathName_U( path
, &nameW
, NULL
, NULL
);
302 attr
.Length
= sizeof(attr
);
303 attr
.RootDirectory
= 0;
304 attr
.ObjectName
= &nameW
;
305 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
306 attr
.SecurityDescriptor
= NULL
;
307 attr
.SecurityQualityOfService
= NULL
;
308 status
= pNtOpenFile( &dir
, SYNCHRONIZE
|FILE_LIST_DIRECTORY
, &attr
, &io
,
309 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_DIRECTORY_FILE
|FILE_SYNCHRONOUS_IO_NONALERT
);
310 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
311 pRtlFreeUnicodeString( &nameW
);
313 path
[3] = 0; /* root of the drive */
314 pRtlDosPathNameToNtPathName_U( path
, &nameW
, NULL
, NULL
);
315 status
= pNtOpenFile( &root
, GENERIC_READ
, &attr
, &io
,
316 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_DIRECTORY_FILE
);
317 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
318 pRtlFreeUnicodeString( &nameW
);
320 /* test opening system dir with RootDirectory set to windows dir */
321 GetSystemDirectoryW( path
, MAX_PATH
);
322 while (path
[len
] == '\\') len
++;
323 nameW
.Buffer
= path
+ len
;
324 nameW
.Length
= lstrlenW(path
+ len
) * sizeof(WCHAR
);
325 attr
.RootDirectory
= dir
;
326 status
= pNtOpenFile( &handle
, GENERIC_READ
, &attr
, &io
,
327 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_DIRECTORY_FILE
);
328 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
329 CloseHandle( handle
);
331 /* try uppercase name */
332 for (i
= len
; path
[i
]; i
++) if (path
[i
] >= 'a' && path
[i
] <= 'z') path
[i
] -= 'a' - 'A';
333 status
= pNtOpenFile( &handle
, GENERIC_READ
, &attr
, &io
,
334 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_DIRECTORY_FILE
);
335 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
336 CloseHandle( handle
);
338 /* try with leading backslash */
340 nameW
.Length
+= sizeof(WCHAR
);
341 status
= pNtOpenFile( &handle
, GENERIC_READ
, &attr
, &io
,
342 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_DIRECTORY_FILE
);
343 ok( status
== STATUS_INVALID_PARAMETER
||
344 status
== STATUS_OBJECT_NAME_INVALID
||
345 status
== STATUS_OBJECT_PATH_SYNTAX_BAD
,
346 "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
347 if (!status
) CloseHandle( handle
);
349 /* try with empty name */
351 status
= pNtOpenFile( &handle
, GENERIC_READ
, &attr
, &io
,
352 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_DIRECTORY_FILE
);
353 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
354 CloseHandle( handle
);
356 /* try open by file id */
358 while (!pNtQueryDirectoryFile( dir
, NULL
, NULL
, NULL
, &io
, data
, sizeof(data
),
359 FileIdBothDirectoryInformation
, TRUE
, NULL
, restart
))
361 FILE_ID_BOTH_DIRECTORY_INFORMATION
*info
= (FILE_ID_BOTH_DIRECTORY_INFORMATION
*)data
;
365 if (!info
->FileId
.QuadPart
) continue;
367 nameW
.Buffer
= (WCHAR
*)&info
->FileId
;
368 nameW
.Length
= sizeof(info
->FileId
);
369 info
->FileName
[info
->FileNameLength
/sizeof(WCHAR
)] = 0;
370 attr
.RootDirectory
= dir
;
371 /* We skip 'open' files by not specifying FILE_SHARE_WRITE */
372 status
= pNtOpenFile( &handle
, GENERIC_READ
, &attr
, &io
,
374 FILE_OPEN_BY_FILE_ID
|
375 ((info
->FileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ? FILE_DIRECTORY_FILE
: 0) );
376 ok( status
== STATUS_SUCCESS
|| status
== STATUS_ACCESS_DENIED
|| status
== STATUS_NOT_IMPLEMENTED
|| status
== STATUS_SHARING_VIOLATION
,
377 "open %s failed %x\n", wine_dbgstr_w(info
->FileName
), status
);
378 if (status
== STATUS_NOT_IMPLEMENTED
)
380 win_skip( "FILE_OPEN_BY_FILE_ID not supported\n" );
383 if (status
== STATUS_SHARING_VIOLATION
)
384 trace( "%s is currently open\n", wine_dbgstr_w(info
->FileName
) );
387 BYTE buf
[sizeof(FILE_ALL_INFORMATION
) + MAX_PATH
* sizeof(WCHAR
)];
389 if (!pNtQueryInformationFile( handle
, &io
, buf
, sizeof(buf
), FileAllInformation
))
391 FILE_ALL_INFORMATION
*fai
= (FILE_ALL_INFORMATION
*)buf
;
393 /* check that it's the same file/directory */
395 /* don't check the size for directories */
396 if (!(info
->FileAttributes
& FILE_ATTRIBUTE_DIRECTORY
))
397 ok( info
->EndOfFile
.QuadPart
== fai
->StandardInformation
.EndOfFile
.QuadPart
,
398 "mismatched file size for %s\n", wine_dbgstr_w(info
->FileName
));
400 ok( info
->CreationTime
.QuadPart
== fai
->BasicInformation
.CreationTime
.QuadPart
,
401 "mismatched creation time for %s\n", wine_dbgstr_w(info
->FileName
));
403 CloseHandle( handle
);
405 /* try same thing from drive root */
406 attr
.RootDirectory
= root
;
407 status
= pNtOpenFile( &handle
, GENERIC_READ
, &attr
, &io
,
408 FILE_SHARE_READ
|FILE_SHARE_WRITE
,
409 FILE_OPEN_BY_FILE_ID
|
410 ((info
->FileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ? FILE_DIRECTORY_FILE
: 0) );
411 ok( status
== STATUS_SUCCESS
|| status
== STATUS_NOT_IMPLEMENTED
,
412 "open %s failed %x\n", wine_dbgstr_w(info
->FileName
), status
);
413 if (!status
) CloseHandle( handle
);
421 static void delete_file_test(void)
424 OBJECT_ATTRIBUTES attr
;
425 UNICODE_STRING nameW
;
426 WCHAR pathW
[MAX_PATH
];
427 WCHAR pathsubW
[MAX_PATH
];
428 static const WCHAR testdirW
[] = {'n','t','d','e','l','e','t','e','f','i','l','e',0};
429 static const WCHAR subdirW
[] = {'\\','s','u','b',0};
431 ret
= GetTempPathW(MAX_PATH
, pathW
);
434 ok(0, "couldn't get temp dir\n");
437 if (ret
+ sizeof(testdirW
)/sizeof(WCHAR
)-1 + sizeof(subdirW
)/sizeof(WCHAR
)-1 >= MAX_PATH
)
439 ok(0, "MAX_PATH exceeded in constructing paths\n");
443 lstrcatW(pathW
, testdirW
);
444 lstrcpyW(pathsubW
, pathW
);
445 lstrcatW(pathsubW
, subdirW
);
447 ret
= CreateDirectoryW(pathW
, NULL
);
448 ok(ret
== TRUE
, "couldn't create directory ntdeletefile\n");
449 if (!pRtlDosPathNameToNtPathName_U(pathW
, &nameW
, NULL
, NULL
))
451 ok(0,"RtlDosPathNametoNtPathName_U failed\n");
455 attr
.Length
= sizeof(attr
);
456 attr
.RootDirectory
= 0;
457 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
458 attr
.ObjectName
= &nameW
;
459 attr
.SecurityDescriptor
= NULL
;
460 attr
.SecurityQualityOfService
= NULL
;
462 /* test NtDeleteFile on an empty directory */
463 ret
= pNtDeleteFile(&attr
);
464 ok(ret
== STATUS_SUCCESS
, "NtDeleteFile should succeed in removing an empty directory\n");
465 ret
= RemoveDirectoryW(pathW
);
466 ok(ret
== FALSE
, "expected to fail removing directory, NtDeleteFile should have removed it\n");
468 /* test NtDeleteFile on a non-empty directory */
469 ret
= CreateDirectoryW(pathW
, NULL
);
470 ok(ret
== TRUE
, "couldn't create directory ntdeletefile ?!\n");
471 ret
= CreateDirectoryW(pathsubW
, NULL
);
472 ok(ret
== TRUE
, "couldn't create directory subdir\n");
473 ret
= pNtDeleteFile(&attr
);
474 ok(ret
== STATUS_SUCCESS
, "expected NtDeleteFile to ret STATUS_SUCCESS\n");
475 ret
= RemoveDirectoryW(pathsubW
);
476 ok(ret
== TRUE
, "expected to remove directory ntdeletefile\\sub\n");
477 ret
= RemoveDirectoryW(pathW
);
478 ok(ret
== TRUE
, "expected to remove directory ntdeletefile, NtDeleteFile failed.\n");
480 pRtlFreeUnicodeString( &nameW
);
483 static void read_file_test(void)
485 const char text
[] = "foobar";
486 HANDLE handle
, read
, write
;
488 IO_STATUS_BLOCK iosb
, iosb2
;
492 LARGE_INTEGER offset
;
493 HANDLE event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
498 if (!create_pipe( &read
, &write
, FILE_FLAG_OVERLAPPED
, 4096 )) return;
500 /* try read with no data */
501 U(iosb
).Status
= 0xdeadbabe;
502 iosb
.Information
= 0xdeadbeef;
503 ok( is_signaled( read
), "read handle is not signaled\n" );
504 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 1, NULL
, NULL
);
505 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
506 ok( !is_signaled( read
), "read handle is signaled\n" );
507 ok( !is_signaled( event
), "event is signaled\n" );
508 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
509 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
510 ok( !apc_count
, "apc was called\n" );
511 ret
= WriteFile( write
, buffer
, 1, &written
, NULL
);
512 ok(ret
&& written
== 1, "WriteFile error %d\n", GetLastError());
513 /* iosb updated here by async i/o */
514 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
515 ok( U(iosb
).Status
== 0, "wrong status %x\n", U(iosb
).Status
);
516 ok( iosb
.Information
== 1, "wrong info %lu\n", iosb
.Information
);
517 ok( !is_signaled( read
), "read handle is signaled\n" );
518 ok( is_signaled( event
), "event is not signaled\n" );
519 ok( !apc_count
, "apc was called\n" );
521 SleepEx( 1, FALSE
); /* non-alertable sleep */
522 ok( !apc_count
, "apc was called\n" );
523 SleepEx( 1, TRUE
); /* alertable sleep */
524 ok( apc_count
== 1, "apc not called\n" );
526 /* with no event, the pipe handle itself gets signaled */
528 U(iosb
).Status
= 0xdeadbabe;
529 iosb
.Information
= 0xdeadbeef;
530 ok( !is_signaled( read
), "read handle is not signaled\n" );
531 status
= pNtReadFile( read
, 0, apc
, &apc_count
, &iosb
, buffer
, 1, NULL
, NULL
);
532 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
533 ok( !is_signaled( read
), "read handle is signaled\n" );
534 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
535 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
536 ok( !apc_count
, "apc was called\n" );
537 ret
= WriteFile( write
, buffer
, 1, &written
, NULL
);
538 ok(ret
&& written
== 1, "WriteFile error %d\n", GetLastError());
539 /* iosb updated here by async i/o */
540 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
541 ok( U(iosb
).Status
== 0, "wrong status %x\n", U(iosb
).Status
);
542 ok( iosb
.Information
== 1, "wrong info %lu\n", iosb
.Information
);
543 ok( is_signaled( read
), "read handle is signaled\n" );
544 ok( !apc_count
, "apc was called\n" );
546 SleepEx( 1, FALSE
); /* non-alertable sleep */
547 ok( !apc_count
, "apc was called\n" );
548 SleepEx( 1, TRUE
); /* alertable sleep */
549 ok( apc_count
== 1, "apc not called\n" );
551 /* now read with data ready */
553 U(iosb
).Status
= 0xdeadbabe;
554 iosb
.Information
= 0xdeadbeef;
556 ret
= WriteFile( write
, buffer
, 1, &written
, NULL
);
557 ok(ret
&& written
== 1, "WriteFile error %d\n", GetLastError());
558 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 1, NULL
, NULL
);
559 ok( status
== STATUS_SUCCESS
, "wrong status %x\n", status
);
560 ok( U(iosb
).Status
== 0, "wrong status %x\n", U(iosb
).Status
);
561 ok( iosb
.Information
== 1, "wrong info %lu\n", iosb
.Information
);
562 ok( is_signaled( event
), "event is not signaled\n" );
563 ok( !apc_count
, "apc was called\n" );
564 SleepEx( 1, FALSE
); /* non-alertable sleep */
565 ok( !apc_count
, "apc was called\n" );
566 SleepEx( 1, TRUE
); /* alertable sleep */
567 ok( apc_count
== 1, "apc not called\n" );
569 /* try read with no data */
571 U(iosb
).Status
= 0xdeadbabe;
572 iosb
.Information
= 0xdeadbeef;
573 ok( is_signaled( event
), "event is not signaled\n" ); /* check that read resets the event */
574 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, NULL
, NULL
);
575 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
576 ok( !is_signaled( event
), "event is signaled\n" );
577 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
578 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
579 ok( !apc_count
, "apc was called\n" );
580 ret
= WriteFile( write
, buffer
, 1, &written
, NULL
);
581 ok(ret
&& written
== 1, "WriteFile error %d\n", GetLastError());
582 /* partial read is good enough */
583 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
584 ok( is_signaled( event
), "event is signaled\n" );
585 ok( U(iosb
).Status
== 0, "wrong status %x\n", U(iosb
).Status
);
586 ok( iosb
.Information
== 1, "wrong info %lu\n", iosb
.Information
);
587 ok( !apc_count
, "apc was called\n" );
588 SleepEx( 1, TRUE
); /* alertable sleep */
589 ok( apc_count
== 1, "apc was not called\n" );
591 /* read from disconnected pipe */
593 U(iosb
).Status
= 0xdeadbabe;
594 iosb
.Information
= 0xdeadbeef;
595 CloseHandle( write
);
596 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 1, NULL
, NULL
);
597 ok( status
== STATUS_PIPE_BROKEN
, "wrong status %x\n", status
);
598 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
599 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
600 ok( !is_signaled( event
), "event is signaled\n" );
601 ok( !apc_count
, "apc was called\n" );
602 SleepEx( 1, TRUE
); /* alertable sleep */
603 ok( !apc_count
, "apc was called\n" );
606 /* read from closed handle */
608 U(iosb
).Status
= 0xdeadbabe;
609 iosb
.Information
= 0xdeadbeef;
611 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 1, NULL
, NULL
);
612 ok( status
== STATUS_INVALID_HANDLE
, "wrong status %x\n", status
);
613 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
614 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
615 ok( is_signaled( event
), "event is signaled\n" ); /* not reset on invalid handle */
616 ok( !apc_count
, "apc was called\n" );
617 SleepEx( 1, TRUE
); /* alertable sleep */
618 ok( !apc_count
, "apc was called\n" );
620 /* disconnect while async read is in progress */
621 if (!create_pipe( &read
, &write
, FILE_FLAG_OVERLAPPED
, 4096 )) return;
623 U(iosb
).Status
= 0xdeadbabe;
624 iosb
.Information
= 0xdeadbeef;
625 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, NULL
, NULL
);
626 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
627 ok( !is_signaled( event
), "event is signaled\n" );
628 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
629 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
630 ok( !apc_count
, "apc was called\n" );
631 CloseHandle( write
);
632 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
633 ok( U(iosb
).Status
== STATUS_PIPE_BROKEN
, "wrong status %x\n", U(iosb
).Status
);
634 ok( iosb
.Information
== 0, "wrong info %lu\n", iosb
.Information
);
635 ok( is_signaled( event
), "event is signaled\n" );
636 ok( !apc_count
, "apc was called\n" );
637 SleepEx( 1, TRUE
); /* alertable sleep */
638 ok( apc_count
== 1, "apc was not called\n" );
641 if (!create_pipe( &read
, &write
, FILE_FLAG_OVERLAPPED
, 4096 )) return;
642 ret
= DuplicateHandle(GetCurrentProcess(), read
, GetCurrentProcess(), &handle
, 0, TRUE
, DUPLICATE_SAME_ACCESS
);
643 ok(ret
, "Failed to duplicate handle: %d\n", GetLastError());
646 U(iosb
).Status
= 0xdeadbabe;
647 iosb
.Information
= 0xdeadbeef;
648 status
= pNtReadFile( handle
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, NULL
, NULL
);
649 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
650 ok( !is_signaled( event
), "event is signaled\n" );
651 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
652 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
653 ok( !apc_count
, "apc was called\n" );
654 /* Cancel by other handle */
655 status
= pNtCancelIoFile( read
, &iosb2
);
656 ok(status
== STATUS_SUCCESS
, "failed to cancel by different handle: %x\n", status
);
657 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
658 ok( U(iosb
).Status
== STATUS_CANCELLED
, "wrong status %x\n", U(iosb
).Status
);
659 ok( iosb
.Information
== 0, "wrong info %lu\n", iosb
.Information
);
660 ok( is_signaled( event
), "event is signaled\n" );
661 todo_wine
ok( !apc_count
, "apc was called\n" );
662 SleepEx( 1, TRUE
); /* alertable sleep */
663 ok( apc_count
== 1, "apc was not called\n" );
666 U(iosb
).Status
= 0xdeadbabe;
667 iosb
.Information
= 0xdeadbeef;
668 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, NULL
, NULL
);
669 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
670 ok( !is_signaled( event
), "event is signaled\n" );
671 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
672 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
673 ok( !apc_count
, "apc was called\n" );
674 /* Close queued handle */
676 SleepEx( 1, TRUE
); /* alertable sleep */
677 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
678 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
679 status
= pNtCancelIoFile( read
, &iosb2
);
680 ok(status
== STATUS_INVALID_HANDLE
, "cancelled by closed handle?\n");
681 status
= pNtCancelIoFile( handle
, &iosb2
);
682 ok(status
== STATUS_SUCCESS
, "failed to cancel: %x\n", status
);
683 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
684 ok( U(iosb
).Status
== STATUS_CANCELLED
, "wrong status %x\n", U(iosb
).Status
);
685 ok( iosb
.Information
== 0, "wrong info %lu\n", iosb
.Information
);
686 ok( is_signaled( event
), "event is signaled\n" );
687 todo_wine
ok( !apc_count
, "apc was called\n" );
688 SleepEx( 1, TRUE
); /* alertable sleep */
689 ok( apc_count
== 1, "apc was not called\n" );
690 CloseHandle( handle
);
691 CloseHandle( write
);
693 if (pNtCancelIoFileEx
)
695 /* Basic Cancel Ex */
696 if (!create_pipe( &read
, &write
, FILE_FLAG_OVERLAPPED
, 4096 )) return;
699 U(iosb
).Status
= 0xdeadbabe;
700 iosb
.Information
= 0xdeadbeef;
701 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, NULL
, NULL
);
702 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
703 ok( !is_signaled( event
), "event is signaled\n" );
704 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
705 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
706 ok( !apc_count
, "apc was called\n" );
707 status
= pNtCancelIoFileEx( read
, &iosb
, &iosb2
);
708 ok(status
== STATUS_SUCCESS
, "Failed to cancel I/O\n");
709 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
710 ok( U(iosb
).Status
== STATUS_CANCELLED
, "wrong status %x\n", U(iosb
).Status
);
711 ok( iosb
.Information
== 0, "wrong info %lu\n", iosb
.Information
);
712 ok( is_signaled( event
), "event is signaled\n" );
713 todo_wine
ok( !apc_count
, "apc was called\n" );
714 SleepEx( 1, TRUE
); /* alertable sleep */
715 ok( apc_count
== 1, "apc was not called\n" );
719 U(iosb
).Status
= 0xdeadbabe;
720 iosb
.Information
= 0xdeadbeef;
721 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, NULL
, NULL
);
722 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
723 ok( !is_signaled( event
), "event is signaled\n" );
724 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
725 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
726 ok( !apc_count
, "apc was called\n" );
727 status
= pNtReadFile( read
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, NULL
, NULL
);
728 ok( status
== STATUS_PENDING
, "wrong status %x\n", status
);
729 ok( !is_signaled( event
), "event is signaled\n" );
730 ok( U(iosb
).Status
== 0xdeadbabe, "wrong status %x\n", U(iosb
).Status
);
731 ok( iosb
.Information
== 0xdeadbeef, "wrong info %lu\n", iosb
.Information
);
732 ok( !apc_count
, "apc was called\n" );
733 status
= pNtCancelIoFileEx( read
, &iosb
, &iosb2
);
734 ok(status
== STATUS_SUCCESS
, "Failed to cancel I/O\n");
735 Sleep(1); /* FIXME: needed for wine to run the i/o apc */
736 ok( U(iosb
).Status
== STATUS_CANCELLED
, "wrong status %x\n", U(iosb
).Status
);
737 ok( iosb
.Information
== 0, "wrong info %lu\n", iosb
.Information
);
738 ok( is_signaled( event
), "event is signaled\n" );
739 todo_wine
ok( !apc_count
, "apc was called\n" );
740 SleepEx( 1, TRUE
); /* alertable sleep */
741 ok( apc_count
== 2, "apc was not called\n" );
744 CloseHandle( write
);
747 /* now try a real file */
748 if (!(handle
= create_temp_file( FILE_FLAG_OVERLAPPED
))) return;
750 U(iosb
).Status
= 0xdeadbabe;
751 iosb
.Information
= 0xdeadbeef;
754 status
= pNtWriteFile( handle
, event
, apc
, &apc_count
, &iosb
, text
, strlen(text
), &offset
, NULL
);
755 ok( status
== STATUS_SUCCESS
|| status
== STATUS_PENDING
, "wrong status %x\n", status
);
756 if (status
== STATUS_PENDING
) WaitForSingleObject( event
, 1000 );
757 ok( U(iosb
).Status
== STATUS_SUCCESS
, "wrong status %x\n", U(iosb
).Status
);
758 ok( iosb
.Information
== strlen(text
), "wrong info %lu\n", iosb
.Information
);
759 ok( is_signaled( event
), "event is signaled\n" );
760 ok( !apc_count
, "apc was called\n" );
761 SleepEx( 1, TRUE
); /* alertable sleep */
762 ok( apc_count
== 1, "apc was not called\n" );
765 U(iosb
).Status
= 0xdeadbabe;
766 iosb
.Information
= 0xdeadbeef;
769 status
= pNtReadFile( handle
, event
, apc
, &apc_count
, &iosb
, buffer
, strlen(text
) + 10, &offset
, NULL
);
770 ok( status
== STATUS_SUCCESS
||
771 status
== STATUS_PENDING
, /* vista */
772 "wrong status %x\n", status
);
773 if (status
== STATUS_PENDING
) WaitForSingleObject( event
, 1000 );
774 ok( U(iosb
).Status
== STATUS_SUCCESS
, "wrong status %x\n", U(iosb
).Status
);
775 ok( iosb
.Information
== strlen(text
), "wrong info %lu\n", iosb
.Information
);
776 ok( is_signaled( event
), "event is signaled\n" );
777 ok( !apc_count
, "apc was called\n" );
778 SleepEx( 1, TRUE
); /* alertable sleep */
779 ok( apc_count
== 1, "apc was not called\n" );
781 /* read beyond eof */
783 U(iosb
).Status
= 0xdeadbabe;
784 iosb
.Information
= 0xdeadbeef;
785 offset
.QuadPart
= strlen(text
) + 2;
786 status
= pNtReadFile( handle
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, &offset
, NULL
);
787 ok(status
== STATUS_PENDING
|| status
== STATUS_END_OF_FILE
/* before Vista */, "expected STATUS_PENDING or STATUS_END_OF_FILE, got %#x\n", status
);
788 if (status
== STATUS_PENDING
) /* vista */
790 WaitForSingleObject( event
, 1000 );
791 ok( U(iosb
).Status
== STATUS_END_OF_FILE
, "wrong status %x\n", U(iosb
).Status
);
792 ok( iosb
.Information
== 0, "wrong info %lu\n", iosb
.Information
);
793 ok( is_signaled( event
), "event is signaled\n" );
794 ok( !apc_count
, "apc was called\n" );
795 SleepEx( 1, TRUE
); /* alertable sleep */
796 ok( apc_count
== 1, "apc was not called\n" );
798 CloseHandle( handle
);
800 /* now a non-overlapped file */
801 if (!(handle
= create_temp_file(0))) return;
803 U(iosb
).Status
= 0xdeadbabe;
804 iosb
.Information
= 0xdeadbeef;
806 status
= pNtWriteFile( handle
, event
, apc
, &apc_count
, &iosb
, text
, strlen(text
), &offset
, NULL
);
807 ok( status
== STATUS_END_OF_FILE
||
808 status
== STATUS_SUCCESS
||
809 status
== STATUS_PENDING
, /* vista */
810 "wrong status %x\n", status
);
811 if (status
== STATUS_PENDING
) WaitForSingleObject( event
, 1000 );
812 ok( U(iosb
).Status
== STATUS_SUCCESS
, "wrong status %x\n", U(iosb
).Status
);
813 ok( iosb
.Information
== strlen(text
), "wrong info %lu\n", iosb
.Information
);
814 ok( is_signaled( event
), "event is signaled\n" );
815 ok( !apc_count
, "apc was called\n" );
816 SleepEx( 1, TRUE
); /* alertable sleep */
817 ok( apc_count
== 1, "apc was not called\n" );
820 U(iosb
).Status
= 0xdeadbabe;
821 iosb
.Information
= 0xdeadbeef;
824 status
= pNtReadFile( handle
, event
, apc
, &apc_count
, &iosb
, buffer
, strlen(text
) + 10, &offset
, NULL
);
825 ok( status
== STATUS_SUCCESS
, "wrong status %x\n", status
);
826 ok( U(iosb
).Status
== STATUS_SUCCESS
, "wrong status %x\n", U(iosb
).Status
);
827 ok( iosb
.Information
== strlen(text
), "wrong info %lu\n", iosb
.Information
);
828 ok( is_signaled( event
), "event is signaled\n" );
829 ok( !apc_count
, "apc was called\n" );
830 SleepEx( 1, TRUE
); /* alertable sleep */
831 todo_wine
ok( !apc_count
, "apc was called\n" );
833 /* read beyond eof */
835 U(iosb
).Status
= 0xdeadbabe;
836 iosb
.Information
= 0xdeadbeef;
837 offset
.QuadPart
= strlen(text
) + 2;
839 status
= pNtReadFile( handle
, event
, apc
, &apc_count
, &iosb
, buffer
, 2, &offset
, NULL
);
840 ok( status
== STATUS_END_OF_FILE
, "wrong status %x\n", status
);
841 ok( U(iosb
).Status
== STATUS_END_OF_FILE
, "wrong status %x\n", U(iosb
).Status
);
842 ok( iosb
.Information
== 0, "wrong info %lu\n", iosb
.Information
);
843 ok( is_signaled( event
), "event is not signaled\n" );
844 ok( !apc_count
, "apc was called\n" );
845 SleepEx( 1, TRUE
); /* alertable sleep */
846 ok( !apc_count
, "apc was called\n" );
848 CloseHandle( handle
);
850 CloseHandle( event
);
853 static void append_file_test(void)
855 static const char text
[6] = "foobar";
858 IO_STATUS_BLOCK iosb
;
859 LARGE_INTEGER offset
;
860 char path
[MAX_PATH
], buffer
[MAX_PATH
], buf
[16];
863 GetTempPathA( MAX_PATH
, path
);
864 GetTempFileNameA( path
, "foo", 0, buffer
);
866 handle
= CreateFileA(buffer
, FILE_WRITE_DATA
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
867 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateFile error %d\n", GetLastError());
870 iosb
.Information
= -1;
871 status
= pNtWriteFile(handle
, NULL
, NULL
, NULL
, &iosb
, text
, 2, NULL
, NULL
);
872 ok(status
== STATUS_SUCCESS
, "NtWriteFile error %#x\n", status
);
873 ok(U(iosb
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iosb
).Status
);
874 ok(iosb
.Information
== 2, "expected 2, got %lu\n", iosb
.Information
);
878 /* It is possible to open a file with only FILE_APPEND_DATA access flags.
879 It matches the O_WRONLY|O_APPEND open() posix behavior */
880 handle
= CreateFileA(buffer
, FILE_APPEND_DATA
, 0, NULL
, OPEN_EXISTING
, 0, 0);
881 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateFile error %d\n", GetLastError());
884 iosb
.Information
= -1;
886 status
= pNtWriteFile(handle
, NULL
, NULL
, NULL
, &iosb
, text
+ 2, 2, &offset
, NULL
);
887 ok(status
== STATUS_SUCCESS
, "NtWriteFile error %#x\n", status
);
888 ok(U(iosb
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iosb
).Status
);
889 ok(iosb
.Information
== 2, "expected 2, got %lu\n", iosb
.Information
);
891 ret
= SetFilePointer(handle
, 0, NULL
, FILE_CURRENT
);
892 ok(ret
== 4, "expected 4, got %u\n", ret
);
895 iosb
.Information
= -1;
897 status
= pNtWriteFile(handle
, NULL
, NULL
, NULL
, &iosb
, text
+ 4, 2, &offset
, NULL
);
898 ok(status
== STATUS_SUCCESS
, "NtWriteFile error %#x\n", status
);
899 ok(U(iosb
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iosb
).Status
);
900 ok(iosb
.Information
== 2, "expected 2, got %lu\n", iosb
.Information
);
902 ret
= SetFilePointer(handle
, 0, NULL
, FILE_CURRENT
);
903 ok(ret
== 6, "expected 6, got %u\n", ret
);
907 handle
= CreateFileA(buffer
, FILE_READ_DATA
| FILE_WRITE_DATA
| FILE_APPEND_DATA
, 0, NULL
, OPEN_EXISTING
, 0, 0);
908 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateFile error %d\n", GetLastError());
910 memset(buf
, 0, sizeof(buf
));
912 iosb
.Information
= -1;
914 status
= pNtReadFile(handle
, 0, NULL
, NULL
, &iosb
, buf
, sizeof(buf
), &offset
, NULL
);
915 ok(status
== STATUS_SUCCESS
, "NtReadFile error %#x\n", status
);
916 ok(U(iosb
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iosb
).Status
);
917 ok(iosb
.Information
== 6, "expected 6, got %lu\n", iosb
.Information
);
919 ok(memcmp(buf
, text
, 6) == 0, "wrong file contents: %s\n", buf
);
922 iosb
.Information
= -1;
924 status
= pNtWriteFile(handle
, NULL
, NULL
, NULL
, &iosb
, text
+ 3, 3, &offset
, NULL
);
925 ok(status
== STATUS_SUCCESS
, "NtWriteFile error %#x\n", status
);
926 ok(U(iosb
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iosb
).Status
);
927 ok(iosb
.Information
== 3, "expected 3, got %lu\n", iosb
.Information
);
929 memset(buf
, 0, sizeof(buf
));
931 iosb
.Information
= -1;
933 status
= pNtReadFile(handle
, 0, NULL
, NULL
, &iosb
, buf
, sizeof(buf
), &offset
, NULL
);
934 ok(status
== STATUS_SUCCESS
, "NtReadFile error %#x\n", status
);
935 ok(U(iosb
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iosb
).Status
);
936 ok(iosb
.Information
== 6, "expected 6, got %lu\n", iosb
.Information
);
938 ok(memcmp(buf
, "barbar", 6) == 0, "wrong file contents: %s\n", buf
);
944 static void nt_mailslot_test(void)
947 ACCESS_MASK DesiredAccess
;
948 OBJECT_ATTRIBUTES attr
;
952 ULONG MaxMessageSize
;
953 LARGE_INTEGER TimeOut
;
954 IO_STATUS_BLOCK IoStatusBlock
;
957 WCHAR buffer1
[] = { '\\','?','?','\\','M','A','I','L','S','L','O','T','\\',
958 'R',':','\\','F','R','E','D','\0' };
960 TimeOut
.QuadPart
= -1;
962 pRtlInitUnicodeString(&str
, buffer1
);
963 InitializeObjectAttributes(&attr
, &str
, OBJ_CASE_INSENSITIVE
, 0, NULL
);
964 CreateOptions
= MailslotQuota
= MaxMessageSize
= 0;
965 DesiredAccess
= GENERIC_READ
;
968 * Check for NULL pointer handling
970 rc
= pNtCreateMailslotFile(NULL
, DesiredAccess
,
971 &attr
, &IoStatusBlock
, CreateOptions
, MailslotQuota
, MaxMessageSize
,
973 ok( rc
== STATUS_ACCESS_VIOLATION
||
974 rc
== STATUS_INVALID_PARAMETER
, /* win2k3 */
975 "rc = %x not STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER\n", rc
);
978 * Test to see if the Timeout can be NULL
980 hslot
= (HANDLE
)0xdeadbeef;
981 rc
= pNtCreateMailslotFile(&hslot
, DesiredAccess
,
982 &attr
, &IoStatusBlock
, CreateOptions
, MailslotQuota
, MaxMessageSize
,
984 ok( rc
== STATUS_SUCCESS
||
985 rc
== STATUS_INVALID_PARAMETER
, /* win2k3 */
986 "rc = %x not STATUS_SUCCESS or STATUS_INVALID_PARAMETER\n", rc
);
987 ok( hslot
!= 0, "Handle is invalid\n");
989 if ( rc
== STATUS_SUCCESS
) pNtClose(hslot
);
992 * Test that the length field is checked properly
995 rc
= pNtCreateMailslotFile(&hslot
, DesiredAccess
,
996 &attr
, &IoStatusBlock
, CreateOptions
, MailslotQuota
, MaxMessageSize
,
998 todo_wine
ok( rc
== STATUS_INVALID_PARAMETER
, "rc = %x not c000000d STATUS_INVALID_PARAMETER\n", rc
);
1000 if (rc
== STATUS_SUCCESS
) pNtClose(hslot
);
1002 attr
.Length
= sizeof(OBJECT_ATTRIBUTES
)+1;
1003 rc
= pNtCreateMailslotFile(&hslot
, DesiredAccess
,
1004 &attr
, &IoStatusBlock
, CreateOptions
, MailslotQuota
, MaxMessageSize
,
1006 todo_wine
ok( rc
== STATUS_INVALID_PARAMETER
, "rc = %x not c000000d STATUS_INVALID_PARAMETER\n", rc
);
1008 if (rc
== STATUS_SUCCESS
) pNtClose(hslot
);
1011 * Test handling of a NULL unicode string in ObjectName
1013 InitializeObjectAttributes(&attr
, &str
, OBJ_CASE_INSENSITIVE
, 0, NULL
);
1014 attr
.ObjectName
= NULL
;
1015 rc
= pNtCreateMailslotFile(&hslot
, DesiredAccess
,
1016 &attr
, &IoStatusBlock
, CreateOptions
, MailslotQuota
, MaxMessageSize
,
1018 ok( rc
== STATUS_OBJECT_PATH_SYNTAX_BAD
||
1019 rc
== STATUS_INVALID_PARAMETER
,
1020 "rc = %x not STATUS_OBJECT_PATH_SYNTAX_BAD or STATUS_INVALID_PARAMETER\n", rc
);
1022 if (rc
== STATUS_SUCCESS
) pNtClose(hslot
);
1027 InitializeObjectAttributes(&attr
, &str
, OBJ_CASE_INSENSITIVE
, 0, NULL
);
1028 rc
= pNtCreateMailslotFile(&hslot
, DesiredAccess
,
1029 &attr
, &IoStatusBlock
, CreateOptions
, MailslotQuota
, MaxMessageSize
,
1031 ok( rc
== STATUS_SUCCESS
, "Create MailslotFile failed rc = %x\n", rc
);
1032 ok( hslot
!= 0, "Handle is invalid\n");
1034 rc
= pNtClose(hslot
);
1035 ok( rc
== STATUS_SUCCESS
, "NtClose failed\n");
1038 static void test_iocp_setcompletion(HANDLE h
)
1044 if (sizeof(size
) > 4) size
|= (ULONGLONG
)0x12345678 << 32;
1046 res
= pNtSetIoCompletion( h
, CKEY_FIRST
, CVALUE_FIRST
, STATUS_INVALID_DEVICE_REQUEST
, size
);
1047 ok( res
== STATUS_SUCCESS
, "NtSetIoCompletion failed: %x\n", res
);
1049 count
= get_pending_msgs(h
);
1050 ok( count
== 1, "Unexpected msg count: %d\n", count
);
1054 ok( completionKey
== CKEY_FIRST
, "Invalid completion key: %lx\n", completionKey
);
1055 ok( ioSb
.Information
== size
, "Invalid ioSb.Information: %lu\n", ioSb
.Information
);
1056 ok( U(ioSb
).Status
== STATUS_INVALID_DEVICE_REQUEST
, "Invalid ioSb.Status: %x\n", U(ioSb
).Status
);
1057 ok( completionValue
== CVALUE_FIRST
, "Invalid completion value: %lx\n", completionValue
);
1060 count
= get_pending_msgs(h
);
1061 ok( !count
, "Unexpected msg count: %d\n", count
);
1064 static void test_iocp_fileio(HANDLE h
)
1066 static const char pipe_name
[] = "\\\\.\\pipe\\iocompletiontestnamedpipe";
1068 IO_STATUS_BLOCK iosb
;
1069 FILE_COMPLETION_INFORMATION fci
= {h
, CKEY_SECOND
};
1070 HANDLE hPipeSrv
, hPipeClt
;
1073 hPipeSrv
= CreateNamedPipeA( pipe_name
, PIPE_ACCESS_INBOUND
, PIPE_TYPE_MESSAGE
| PIPE_READMODE_MESSAGE
| PIPE_WAIT
, 4, 1024, 1024, 1000, NULL
);
1074 ok( hPipeSrv
!= INVALID_HANDLE_VALUE
, "Cannot create named pipe\n" );
1075 if (hPipeSrv
!= INVALID_HANDLE_VALUE
)
1077 hPipeClt
= CreateFileA( pipe_name
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, FILE_FLAG_NO_BUFFERING
| FILE_FLAG_OVERLAPPED
, NULL
);
1078 ok( hPipeClt
!= INVALID_HANDLE_VALUE
, "Cannot connect to pipe\n" );
1079 if (hPipeClt
!= INVALID_HANDLE_VALUE
)
1081 U(iosb
).Status
= 0xdeadbeef;
1082 res
= pNtSetInformationFile( hPipeSrv
, &iosb
, &fci
, sizeof(fci
), FileCompletionInformation
);
1083 ok( res
== STATUS_INVALID_PARAMETER
, "Unexpected NtSetInformationFile on non-overlapped handle: %x\n", res
);
1084 ok( U(iosb
).Status
== STATUS_INVALID_PARAMETER
/* 98 */ || U(iosb
).Status
== 0xdeadbeef /* NT4+ */,
1085 "Unexpected iosb.Status on non-overlapped handle: %x\n", U(iosb
).Status
);
1086 CloseHandle(hPipeClt
);
1088 CloseHandle( hPipeSrv
);
1091 hPipeSrv
= CreateNamedPipeA( pipe_name
, PIPE_ACCESS_INBOUND
| FILE_FLAG_OVERLAPPED
, PIPE_TYPE_MESSAGE
| PIPE_READMODE_MESSAGE
| PIPE_WAIT
, 4, 1024, 1024, 1000, NULL
);
1092 ok( hPipeSrv
!= INVALID_HANDLE_VALUE
, "Cannot create named pipe\n" );
1093 if (hPipeSrv
== INVALID_HANDLE_VALUE
)
1096 hPipeClt
= CreateFileA( pipe_name
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, FILE_FLAG_NO_BUFFERING
| FILE_FLAG_OVERLAPPED
, NULL
);
1097 ok( hPipeClt
!= INVALID_HANDLE_VALUE
, "Cannot connect to pipe\n" );
1098 if (hPipeClt
!= INVALID_HANDLE_VALUE
)
1100 OVERLAPPED o
= {0,};
1101 BYTE send_buf
[TEST_BUF_LEN
], recv_buf
[TEST_BUF_LEN
];
1105 U(iosb
).Status
= 0xdeadbeef;
1106 res
= pNtSetInformationFile( hPipeSrv
, &iosb
, &fci
, sizeof(fci
), FileCompletionInformation
);
1107 ok( res
== STATUS_SUCCESS
, "NtSetInformationFile failed: %x\n", res
);
1108 ok( U(iosb
).Status
== STATUS_SUCCESS
, "iosb.Status invalid: %x\n", U(iosb
).Status
);
1110 memset( send_buf
, 0, TEST_BUF_LEN
);
1111 memset( recv_buf
, 0xde, TEST_BUF_LEN
);
1112 count
= get_pending_msgs(h
);
1113 ok( !count
, "Unexpected msg count: %ld\n", count
);
1114 ReadFile( hPipeSrv
, recv_buf
, TEST_BUF_LEN
, &read
, &o
);
1115 count
= get_pending_msgs(h
);
1116 ok( !count
, "Unexpected msg count: %ld\n", count
);
1117 WriteFile( hPipeClt
, send_buf
, TEST_BUF_LEN
, &read
, NULL
);
1121 ok( completionKey
== CKEY_SECOND
, "Invalid completion key: %lx\n", completionKey
);
1122 ok( ioSb
.Information
== 3, "Invalid ioSb.Information: %ld\n", ioSb
.Information
);
1123 ok( U(ioSb
).Status
== STATUS_SUCCESS
, "Invalid ioSb.Status: %x\n", U(ioSb
).Status
);
1124 ok( completionValue
== (ULONG_PTR
)&o
, "Invalid completion value: %lx\n", completionValue
);
1125 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] );
1127 count
= get_pending_msgs(h
);
1128 ok( !count
, "Unexpected msg count: %ld\n", count
);
1130 memset( send_buf
, 0, TEST_BUF_LEN
);
1131 memset( recv_buf
, 0xde, TEST_BUF_LEN
);
1132 WriteFile( hPipeClt
, send_buf
, 2, &read
, NULL
);
1133 count
= get_pending_msgs(h
);
1134 ok( !count
, "Unexpected msg count: %ld\n", count
);
1135 ReadFile( hPipeSrv
, recv_buf
, 2, &read
, &o
);
1136 count
= get_pending_msgs(h
);
1137 ok( count
== 1, "Unexpected msg count: %ld\n", count
);
1140 ok( completionKey
== CKEY_SECOND
, "Invalid completion key: %lx\n", completionKey
);
1141 ok( ioSb
.Information
== 2, "Invalid ioSb.Information: %ld\n", ioSb
.Information
);
1142 ok( U(ioSb
).Status
== STATUS_SUCCESS
, "Invalid ioSb.Status: %x\n", U(ioSb
).Status
);
1143 ok( completionValue
== (ULONG_PTR
)&o
, "Invalid completion value: %lx\n", completionValue
);
1144 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] );
1147 ReadFile( hPipeSrv
, recv_buf
, TEST_BUF_LEN
, &read
, &o
);
1148 CloseHandle( hPipeSrv
);
1149 count
= get_pending_msgs(h
);
1150 ok( count
== 1, "Unexpected msg count: %ld\n", count
);
1153 ok( completionKey
== CKEY_SECOND
, "Invalid completion key: %lx\n", completionKey
);
1154 ok( ioSb
.Information
== 0, "Invalid ioSb.Information: %ld\n", ioSb
.Information
);
1155 /* wine sends wrong status here */
1156 todo_wine
ok( U(ioSb
).Status
== STATUS_PIPE_BROKEN
, "Invalid ioSb.Status: %x\n", U(ioSb
).Status
);
1157 ok( completionValue
== (ULONG_PTR
)&o
, "Invalid completion value: %lx\n", completionValue
);
1161 CloseHandle( hPipeClt
);
1163 /* test associating a completion port with a handle after an async is queued */
1164 hPipeSrv
= CreateNamedPipeA( pipe_name
, PIPE_ACCESS_INBOUND
| FILE_FLAG_OVERLAPPED
, PIPE_TYPE_MESSAGE
| PIPE_READMODE_MESSAGE
| PIPE_WAIT
, 4, 1024, 1024, 1000, NULL
);
1165 ok( hPipeSrv
!= INVALID_HANDLE_VALUE
, "Cannot create named pipe\n" );
1166 if (hPipeSrv
== INVALID_HANDLE_VALUE
)
1168 hPipeClt
= CreateFileA( pipe_name
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, FILE_FLAG_NO_BUFFERING
| FILE_FLAG_OVERLAPPED
, NULL
);
1169 ok( hPipeClt
!= INVALID_HANDLE_VALUE
, "Cannot connect to pipe\n" );
1170 if (hPipeClt
!= INVALID_HANDLE_VALUE
)
1172 OVERLAPPED o
= {0,};
1173 BYTE send_buf
[TEST_BUF_LEN
], recv_buf
[TEST_BUF_LEN
];
1177 memset( send_buf
, 0, TEST_BUF_LEN
);
1178 memset( recv_buf
, 0xde, TEST_BUF_LEN
);
1179 count
= get_pending_msgs(h
);
1180 ok( !count
, "Unexpected msg count: %ld\n", count
);
1181 ReadFile( hPipeSrv
, recv_buf
, TEST_BUF_LEN
, &read
, &o
);
1183 U(iosb
).Status
= 0xdeadbeef;
1184 res
= pNtSetInformationFile( hPipeSrv
, &iosb
, &fci
, sizeof(fci
), FileCompletionInformation
);
1185 ok( res
== STATUS_SUCCESS
, "NtSetInformationFile failed: %x\n", res
);
1186 ok( U(iosb
).Status
== STATUS_SUCCESS
, "iosb.Status invalid: %x\n", U(iosb
).Status
);
1187 count
= get_pending_msgs(h
);
1188 ok( !count
, "Unexpected msg count: %ld\n", count
);
1190 WriteFile( hPipeClt
, send_buf
, TEST_BUF_LEN
, &read
, NULL
);
1194 ok( completionKey
== CKEY_SECOND
, "Invalid completion key: %lx\n", completionKey
);
1195 ok( ioSb
.Information
== 3, "Invalid ioSb.Information: %ld\n", ioSb
.Information
);
1196 ok( U(ioSb
).Status
== STATUS_SUCCESS
, "Invalid ioSb.Status: %x\n", U(ioSb
).Status
);
1197 ok( completionValue
== (ULONG_PTR
)&o
, "Invalid completion value: %lx\n", completionValue
);
1198 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] );
1200 count
= get_pending_msgs(h
);
1201 ok( !count
, "Unexpected msg count: %ld\n", count
);
1204 CloseHandle( hPipeSrv
);
1205 CloseHandle( hPipeClt
);
1208 static void test_file_basic_information(void)
1211 FILE_BASIC_INFORMATION fbi
;
1214 int attrib_mask
= FILE_ATTRIBUTE_SYSTEM
| FILE_ATTRIBUTE_HIDDEN
| FILE_ATTRIBUTE_NORMAL
;
1216 if (!(h
= create_temp_file(0))) return;
1218 /* Check default first */
1219 memset(&fbi
, 0, sizeof(fbi
));
1220 res
= pNtQueryInformationFile(h
, &io
, &fbi
, sizeof fbi
, FileBasicInformation
);
1221 ok ( res
== STATUS_SUCCESS
, "can't get attributes, res %x\n", res
);
1222 ok ( (fbi
.FileAttributes
& FILE_ATTRIBUTE_ARCHIVE
) == FILE_ATTRIBUTE_ARCHIVE
,
1223 "attribute %x not expected\n", fbi
.FileAttributes
);
1226 /* Clear fbi to avoid setting times */
1227 memset(&fbi
, 0, sizeof(fbi
));
1228 fbi
.FileAttributes
= FILE_ATTRIBUTE_SYSTEM
;
1229 U(io
).Status
= 0xdeadbeef;
1230 res
= pNtSetInformationFile(h
, &io
, &fbi
, sizeof fbi
, FileBasicInformation
);
1231 ok ( res
== STATUS_SUCCESS
, "can't set system attribute, NtSetInformationFile returned %x\n", res
);
1232 ok ( U(io
).Status
== STATUS_SUCCESS
, "can't set system attribute, io.Status is %x\n", U(io
).Status
);
1234 memset(&fbi
, 0, sizeof(fbi
));
1235 res
= pNtQueryInformationFile(h
, &io
, &fbi
, sizeof fbi
, FileBasicInformation
);
1236 ok ( res
== STATUS_SUCCESS
, "can't get attributes\n");
1237 todo_wine
ok ( (fbi
.FileAttributes
& attrib_mask
) == FILE_ATTRIBUTE_SYSTEM
, "attribute %x not FILE_ATTRIBUTE_SYSTEM\n", fbi
.FileAttributes
);
1240 memset(&fbi
, 0, sizeof(fbi
));
1241 fbi
.FileAttributes
= FILE_ATTRIBUTE_HIDDEN
;
1242 U(io
).Status
= 0xdeadbeef;
1243 res
= pNtSetInformationFile(h
, &io
, &fbi
, sizeof fbi
, FileBasicInformation
);
1244 ok ( res
== STATUS_SUCCESS
, "can't set system attribute, NtSetInformationFile returned %x\n", res
);
1245 ok ( U(io
).Status
== STATUS_SUCCESS
, "can't set system attribute, io.Status is %x\n", U(io
).Status
);
1247 memset(&fbi
, 0, sizeof(fbi
));
1248 res
= pNtQueryInformationFile(h
, &io
, &fbi
, sizeof fbi
, FileBasicInformation
);
1249 ok ( res
== STATUS_SUCCESS
, "can't get attributes\n");
1250 todo_wine
ok ( (fbi
.FileAttributes
& attrib_mask
) == FILE_ATTRIBUTE_HIDDEN
, "attribute %x not FILE_ATTRIBUTE_HIDDEN\n", fbi
.FileAttributes
);
1252 /* Check NORMAL last of all (to make sure we can clear attributes) */
1253 memset(&fbi
, 0, sizeof(fbi
));
1254 fbi
.FileAttributes
= FILE_ATTRIBUTE_NORMAL
;
1255 U(io
).Status
= 0xdeadbeef;
1256 res
= pNtSetInformationFile(h
, &io
, &fbi
, sizeof fbi
, FileBasicInformation
);
1257 ok ( res
== STATUS_SUCCESS
, "can't set normal attribute, NtSetInformationFile returned %x\n", res
);
1258 ok ( U(io
).Status
== STATUS_SUCCESS
, "can't set normal attribute, io.Status is %x\n", U(io
).Status
);
1260 memset(&fbi
, 0, sizeof(fbi
));
1261 res
= pNtQueryInformationFile(h
, &io
, &fbi
, sizeof fbi
, FileBasicInformation
);
1262 ok ( res
== STATUS_SUCCESS
, "can't get attributes\n");
1263 todo_wine
ok ( (fbi
.FileAttributes
& attrib_mask
) == FILE_ATTRIBUTE_NORMAL
, "attribute %x not 0\n", fbi
.FileAttributes
);
1268 static void test_file_all_information(void)
1271 /* FileAllInformation, like FileNameInformation, has a variable-length pathname
1272 * buffer at the end. Vista objects with STATUS_BUFFER_OVERFLOW if you
1273 * don't leave enough room there.
1276 FILE_ALL_INFORMATION fai
;
1281 int attrib_mask
= FILE_ATTRIBUTE_SYSTEM
| FILE_ATTRIBUTE_HIDDEN
| FILE_ATTRIBUTE_NORMAL
;
1283 if (!(h
= create_temp_file(0))) return;
1285 /* Check default first */
1286 res
= pNtQueryInformationFile(h
, &io
, &fai_buf
.fai
, sizeof fai_buf
, FileAllInformation
);
1287 ok ( res
== STATUS_SUCCESS
, "can't get attributes, res %x\n", res
);
1288 ok ( (fai_buf
.fai
.BasicInformation
.FileAttributes
& FILE_ATTRIBUTE_ARCHIVE
) == FILE_ATTRIBUTE_ARCHIVE
,
1289 "attribute %x not expected\n", fai_buf
.fai
.BasicInformation
.FileAttributes
);
1292 /* Clear fbi to avoid setting times */
1293 memset(&fai_buf
.fai
.BasicInformation
, 0, sizeof(fai_buf
.fai
.BasicInformation
));
1294 fai_buf
.fai
.BasicInformation
.FileAttributes
= FILE_ATTRIBUTE_SYSTEM
;
1295 U(io
).Status
= 0xdeadbeef;
1296 res
= pNtSetInformationFile(h
, &io
, &fai_buf
.fai
, sizeof fai_buf
, FileAllInformation
);
1297 ok ( res
== STATUS_INVALID_INFO_CLASS
|| broken(res
== STATUS_NOT_IMPLEMENTED
), "shouldn't be able to set FileAllInformation, res %x\n", res
);
1298 todo_wine
ok ( U(io
).Status
== 0xdeadbeef, "shouldn't be able to set FileAllInformation, io.Status is %x\n", U(io
).Status
);
1299 U(io
).Status
= 0xdeadbeef;
1300 res
= pNtSetInformationFile(h
, &io
, &fai_buf
.fai
.BasicInformation
, sizeof fai_buf
.fai
.BasicInformation
, FileBasicInformation
);
1301 ok ( res
== STATUS_SUCCESS
, "can't set system attribute, res: %x\n", res
);
1302 ok ( U(io
).Status
== STATUS_SUCCESS
, "can't set system attribute, io.Status: %x\n", U(io
).Status
);
1304 memset(&fai_buf
.fai
, 0, sizeof(fai_buf
.fai
));
1305 res
= pNtQueryInformationFile(h
, &io
, &fai_buf
.fai
, sizeof fai_buf
, FileAllInformation
);
1306 ok ( res
== STATUS_SUCCESS
, "can't get attributes, res %x\n", res
);
1307 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
);
1310 memset(&fai_buf
.fai
.BasicInformation
, 0, sizeof(fai_buf
.fai
.BasicInformation
));
1311 fai_buf
.fai
.BasicInformation
.FileAttributes
= FILE_ATTRIBUTE_HIDDEN
;
1312 U(io
).Status
= 0xdeadbeef;
1313 res
= pNtSetInformationFile(h
, &io
, &fai_buf
.fai
.BasicInformation
, sizeof fai_buf
.fai
.BasicInformation
, FileBasicInformation
);
1314 ok ( res
== STATUS_SUCCESS
, "can't set system attribute, res: %x\n", res
);
1315 ok ( U(io
).Status
== STATUS_SUCCESS
, "can't set system attribute, io.Status: %x\n", U(io
).Status
);
1317 memset(&fai_buf
.fai
, 0, sizeof(fai_buf
.fai
));
1318 res
= pNtQueryInformationFile(h
, &io
, &fai_buf
.fai
, sizeof fai_buf
, FileAllInformation
);
1319 ok ( res
== STATUS_SUCCESS
, "can't get attributes\n");
1320 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
);
1322 /* Check NORMAL last of all (to make sure we can clear attributes) */
1323 memset(&fai_buf
.fai
.BasicInformation
, 0, sizeof(fai_buf
.fai
.BasicInformation
));
1324 fai_buf
.fai
.BasicInformation
.FileAttributes
= FILE_ATTRIBUTE_NORMAL
;
1325 U(io
).Status
= 0xdeadbeef;
1326 res
= pNtSetInformationFile(h
, &io
, &fai_buf
.fai
.BasicInformation
, sizeof fai_buf
.fai
.BasicInformation
, FileBasicInformation
);
1327 ok ( res
== STATUS_SUCCESS
, "can't set system attribute, res: %x\n", res
);
1328 ok ( U(io
).Status
== STATUS_SUCCESS
, "can't set system attribute, io.Status: %x\n", U(io
).Status
);
1330 memset(&fai_buf
.fai
, 0, sizeof(fai_buf
.fai
));
1331 res
= pNtQueryInformationFile(h
, &io
, &fai_buf
.fai
, sizeof fai_buf
, FileAllInformation
);
1332 ok ( res
== STATUS_SUCCESS
, "can't get attributes\n");
1333 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
);
1338 static void test_file_both_information(void)
1341 FILE_BOTH_DIR_INFORMATION fbi
;
1345 if (!(h
= create_temp_file(0))) return;
1347 memset(&fbi
, 0, sizeof(fbi
));
1348 res
= pNtQueryInformationFile(h
, &io
, &fbi
, sizeof fbi
, FileBothDirectoryInformation
);
1349 ok ( res
== STATUS_INVALID_INFO_CLASS
|| res
== STATUS_NOT_IMPLEMENTED
, "shouldn't be able to query FileBothDirectoryInformation, res %x\n", res
);
1354 static void test_file_disposition_information(void)
1356 char tmp_path
[MAX_PATH
], buffer
[MAX_PATH
+ 16];
1358 HANDLE handle
, handle2
;
1361 FILE_DISPOSITION_INFORMATION fdi
;
1364 GetTempPathA( MAX_PATH
, tmp_path
);
1366 /* cannot set disposition on file not opened with delete access */
1367 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1368 handle
= CreateFileA(buffer
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
1369 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to create temp file\n" );
1370 res
= pNtQueryInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1371 ok( res
== STATUS_INVALID_INFO_CLASS
|| res
== STATUS_NOT_IMPLEMENTED
, "Unexpected NtQueryInformationFile result (expected STATUS_INVALID_INFO_CLASS, got %x)\n", res
);
1372 fdi
.DoDeleteFile
= TRUE
;
1373 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1375 ok( res
== STATUS_ACCESS_DENIED
, "unexpected FileDispositionInformation result (expected STATUS_ACCESS_DENIED, got %x)\n", res
);
1376 CloseHandle( handle
);
1377 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1378 ok( !fileDeleted
, "File shouldn't have been deleted\n" );
1379 DeleteFileA( buffer
);
1381 /* can set disposition on file opened with proper access */
1382 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1383 handle
= CreateFileA(buffer
, GENERIC_WRITE
| DELETE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
1384 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to create temp file\n" );
1385 fdi
.DoDeleteFile
= TRUE
;
1386 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1388 ok( res
== STATUS_SUCCESS
, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res
);
1389 CloseHandle( handle
);
1390 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1392 ok( fileDeleted
, "File should have been deleted\n" );
1393 DeleteFileA( buffer
);
1395 /* cannot set disposition on readonly file */
1396 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1397 handle
= CreateFileA(buffer
, GENERIC_WRITE
| DELETE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_READONLY
, 0);
1398 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to create temp file\n" );
1399 fdi
.DoDeleteFile
= TRUE
;
1400 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1402 ok( res
== STATUS_CANNOT_DELETE
, "unexpected FileDispositionInformation result (expected STATUS_CANNOT_DELETE, got %x)\n", res
);
1403 CloseHandle( handle
);
1404 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1405 ok( !fileDeleted
, "File shouldn't have been deleted\n" );
1406 SetFileAttributesA( buffer
, FILE_ATTRIBUTE_NORMAL
);
1407 DeleteFileA( buffer
);
1409 /* can set disposition on file and then reset it */
1410 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1411 handle
= CreateFileA(buffer
, GENERIC_WRITE
| DELETE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
1412 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to create temp file\n" );
1413 fdi
.DoDeleteFile
= TRUE
;
1414 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1416 ok( res
== STATUS_SUCCESS
, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res
);
1417 fdi
.DoDeleteFile
= FALSE
;
1418 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1420 ok( res
== STATUS_SUCCESS
, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res
);
1421 CloseHandle( handle
);
1422 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1423 ok( !fileDeleted
, "File shouldn't have been deleted\n" );
1424 DeleteFileA( buffer
);
1426 /* Delete-on-close flag doesn't change file disposition until a handle is closed */
1427 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1428 handle
= CreateFileA(buffer
, GENERIC_WRITE
| DELETE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, 0);
1429 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to create temp file\n" );
1430 fdi
.DoDeleteFile
= FALSE
;
1431 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1433 ok( res
== STATUS_SUCCESS
, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res
);
1434 CloseHandle( handle
);
1435 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1436 ok( fileDeleted
, "File should have been deleted\n" );
1437 DeleteFileA( buffer
);
1439 /* Delete-on-close flag sets disposition when a handle is closed and then it could be changed back */
1440 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1441 handle
= CreateFileA(buffer
, GENERIC_WRITE
| DELETE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, 0);
1442 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to create temp file\n" );
1443 ok( DuplicateHandle( GetCurrentProcess(), handle
, GetCurrentProcess(), &handle2
, 0, FALSE
, DUPLICATE_SAME_ACCESS
), "DuplicateHandle failed\n" );
1444 CloseHandle( handle
);
1445 fdi
.DoDeleteFile
= FALSE
;
1446 res
= pNtSetInformationFile( handle2
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1448 ok( res
== STATUS_SUCCESS
, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res
);
1449 CloseHandle( handle2
);
1450 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1451 ok( fileDeleted
, "File should have been deleted\n" );
1452 DeleteFileA( buffer
);
1454 /* can set disposition on a directory opened with proper access */
1455 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1456 DeleteFileA( buffer
);
1457 ok( CreateDirectoryA( buffer
, NULL
), "CreateDirectory failed\n" );
1458 handle
= CreateFileA(buffer
, DELETE
, 0, NULL
, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0);
1459 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to open a directory\n" );
1460 fdi
.DoDeleteFile
= TRUE
;
1461 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1463 ok( res
== STATUS_SUCCESS
, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res
);
1464 CloseHandle( handle
);
1465 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1467 ok( fileDeleted
, "Directory should have been deleted\n" );
1468 RemoveDirectoryA( buffer
);
1470 /* RemoveDirectory sets directory disposition and it can be undone */
1471 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1472 DeleteFileA( buffer
);
1473 ok( CreateDirectoryA( buffer
, NULL
), "CreateDirectory failed\n" );
1474 handle
= CreateFileA(buffer
, DELETE
, 0, NULL
, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0);
1475 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to open a directory\n" );
1476 RemoveDirectoryA( buffer
);
1477 fdi
.DoDeleteFile
= FALSE
;
1478 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1480 ok( res
== STATUS_SUCCESS
, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res
);
1481 CloseHandle( handle
);
1482 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1483 ok( !fileDeleted
, "Directory shouldn't have been deleted\n" );
1484 RemoveDirectoryA( buffer
);
1486 /* cannot set disposition on a non-empty directory */
1487 GetTempFileNameA( tmp_path
, "dis", 0, buffer
);
1488 DeleteFileA( buffer
);
1489 ok( CreateDirectoryA( buffer
, NULL
), "CreateDirectory failed\n" );
1490 handle
= CreateFileA(buffer
, DELETE
, 0, NULL
, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0);
1491 ok( handle
!= INVALID_HANDLE_VALUE
, "failed to open a directory\n" );
1492 dirpos
= lstrlenA( buffer
);
1493 lstrcpyA( buffer
+ dirpos
, "\\tst" );
1494 handle2
= CreateFileA(buffer
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
1495 CloseHandle( handle2
);
1496 fdi
.DoDeleteFile
= TRUE
;
1497 res
= pNtSetInformationFile( handle
, &io
, &fdi
, sizeof fdi
, FileDispositionInformation
);
1499 ok( res
== STATUS_DIRECTORY_NOT_EMPTY
, "unexpected FileDispositionInformation result (expected STATUS_DIRECTORY_NOT_EMPTY, got %x)\n", res
);
1500 DeleteFileA( buffer
);
1501 buffer
[dirpos
] = '\0';
1502 CloseHandle( handle
);
1503 fileDeleted
= GetFileAttributesA( buffer
) == INVALID_FILE_ATTRIBUTES
&& GetLastError() == ERROR_FILE_NOT_FOUND
;
1504 ok( !fileDeleted
, "Directory shouldn't have been deleted\n" );
1505 RemoveDirectoryA( buffer
);
1508 static void test_iocompletion(void)
1510 HANDLE h
= INVALID_HANDLE_VALUE
;
1513 res
= pNtCreateIoCompletion( &h
, IO_COMPLETION_ALL_ACCESS
, NULL
, 0);
1515 ok( res
== 0, "NtCreateIoCompletion anonymous failed: %x\n", res
);
1516 ok( h
&& h
!= INVALID_HANDLE_VALUE
, "Invalid handle returned\n" );
1518 if ( h
&& h
!= INVALID_HANDLE_VALUE
)
1520 test_iocp_setcompletion(h
);
1521 test_iocp_fileio(h
);
1526 static void test_file_name_information(void)
1528 WCHAR
*file_name
, *volume_prefix
, *expected
;
1529 FILE_NAME_INFORMATION
*info
;
1530 ULONG old_redir
= 1, tmp
;
1531 UINT file_name_size
;
1538 /* GetVolumePathName is not present before w2k */
1539 if (!pGetVolumePathNameW
) {
1540 win_skip("GetVolumePathNameW not found\n");
1544 file_name_size
= GetSystemDirectoryW( NULL
, 0 );
1545 file_name
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*file_name
) );
1546 volume_prefix
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*volume_prefix
) );
1547 expected
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*volume_prefix
) );
1549 len
= GetSystemDirectoryW( file_name
, file_name_size
);
1550 ok(len
== file_name_size
- 1,
1551 "GetSystemDirectoryW returned %u, expected %u.\n",
1552 len
, file_name_size
- 1);
1554 len
= pGetVolumePathNameW( file_name
, volume_prefix
, file_name_size
);
1555 ok(len
, "GetVolumePathNameW failed.\n");
1557 len
= lstrlenW( volume_prefix
);
1558 if (len
&& volume_prefix
[len
- 1] == '\\') --len
;
1559 memcpy( expected
, file_name
+ len
, (file_name_size
- len
- 1) * sizeof(WCHAR
) );
1560 expected
[file_name_size
- len
- 1] = '\0';
1562 /* A bit more than we actually need, but it keeps the calculation simple. */
1563 info_size
= sizeof(*info
) + (file_name_size
* sizeof(WCHAR
));
1564 info
= HeapAlloc( GetProcessHeap(), 0, info_size
);
1566 if (pRtlWow64EnableFsRedirectionEx
) pRtlWow64EnableFsRedirectionEx( TRUE
, &old_redir
);
1567 h
= CreateFileW( file_name
, GENERIC_READ
,
1568 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
1569 NULL
, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0 );
1570 if (pRtlWow64EnableFsRedirectionEx
) pRtlWow64EnableFsRedirectionEx( old_redir
, &tmp
);
1571 ok(h
!= INVALID_HANDLE_VALUE
, "Failed to open file.\n");
1573 hr
= pNtQueryInformationFile( h
, &io
, info
, sizeof(*info
) - 1, FileNameInformation
);
1574 ok(hr
== STATUS_INFO_LENGTH_MISMATCH
, "NtQueryInformationFile returned %#x.\n", hr
);
1576 memset( info
, 0xcc, info_size
);
1577 hr
= pNtQueryInformationFile( h
, &io
, info
, sizeof(*info
), FileNameInformation
);
1578 ok(hr
== STATUS_BUFFER_OVERFLOW
, "NtQueryInformationFile returned %#x, expected %#x.\n",
1579 hr
, STATUS_BUFFER_OVERFLOW
);
1580 ok(U(io
).Status
== STATUS_BUFFER_OVERFLOW
, "io.Status is %#x, expected %#x.\n",
1581 U(io
).Status
, STATUS_BUFFER_OVERFLOW
);
1582 ok(info
->FileNameLength
== lstrlenW( expected
) * sizeof(WCHAR
), "info->FileNameLength is %u\n", info
->FileNameLength
);
1583 ok(info
->FileName
[2] == 0xcccc, "info->FileName[2] is %#x, expected 0xcccc.\n", info
->FileName
[2]);
1584 ok(CharLowerW((LPWSTR
)(UINT_PTR
)info
->FileName
[1]) == CharLowerW((LPWSTR
)(UINT_PTR
)expected
[1]),
1585 "info->FileName[1] is %p, expected %p.\n",
1586 CharLowerW((LPWSTR
)(UINT_PTR
)info
->FileName
[1]), CharLowerW((LPWSTR
)(UINT_PTR
)expected
[1]));
1587 ok(io
.Information
== sizeof(*info
), "io.Information is %lu\n", io
.Information
);
1589 memset( info
, 0xcc, info_size
);
1590 hr
= pNtQueryInformationFile( h
, &io
, info
, info_size
, FileNameInformation
);
1591 ok(hr
== STATUS_SUCCESS
, "NtQueryInformationFile returned %#x, expected %#x.\n", hr
, STATUS_SUCCESS
);
1592 ok(U(io
).Status
== STATUS_SUCCESS
, "io.Status is %#x, expected %#x.\n", U(io
).Status
, STATUS_SUCCESS
);
1593 ok(info
->FileNameLength
== lstrlenW( expected
) * sizeof(WCHAR
), "info->FileNameLength is %u\n", info
->FileNameLength
);
1594 ok(info
->FileName
[info
->FileNameLength
/ sizeof(WCHAR
)] == 0xcccc, "info->FileName[len] is %#x, expected 0xcccc.\n",
1595 info
->FileName
[info
->FileNameLength
/ sizeof(WCHAR
)]);
1596 info
->FileName
[info
->FileNameLength
/ sizeof(WCHAR
)] = '\0';
1597 ok(!lstrcmpiW( info
->FileName
, expected
), "info->FileName is %s, expected %s.\n",
1598 wine_dbgstr_w( info
->FileName
), wine_dbgstr_w( expected
));
1599 ok(io
.Information
== FIELD_OFFSET(FILE_NAME_INFORMATION
, FileName
) + info
->FileNameLength
,
1600 "io.Information is %lu, expected %u.\n",
1601 io
.Information
, FIELD_OFFSET(FILE_NAME_INFORMATION
, FileName
) + info
->FileNameLength
);
1604 HeapFree( GetProcessHeap(), 0, info
);
1605 HeapFree( GetProcessHeap(), 0, expected
);
1606 HeapFree( GetProcessHeap(), 0, volume_prefix
);
1608 if (old_redir
|| !pGetSystemWow64DirectoryW
|| !(file_name_size
= pGetSystemWow64DirectoryW( NULL
, 0 )))
1610 skip("Not running on WoW64, skipping test.\n");
1611 HeapFree( GetProcessHeap(), 0, file_name
);
1615 h
= CreateFileW( file_name
, GENERIC_READ
,
1616 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
1617 NULL
, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0 );
1618 ok(h
!= INVALID_HANDLE_VALUE
, "Failed to open file.\n");
1619 HeapFree( GetProcessHeap(), 0, file_name
);
1621 file_name
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*file_name
) );
1622 volume_prefix
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*volume_prefix
) );
1623 expected
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*expected
) );
1625 len
= pGetSystemWow64DirectoryW( file_name
, file_name_size
);
1626 ok(len
== file_name_size
- 1,
1627 "GetSystemWow64DirectoryW returned %u, expected %u.\n",
1628 len
, file_name_size
- 1);
1630 len
= pGetVolumePathNameW( file_name
, volume_prefix
, file_name_size
);
1631 ok(len
, "GetVolumePathNameW failed.\n");
1633 len
= lstrlenW( volume_prefix
);
1634 if (len
&& volume_prefix
[len
- 1] == '\\') --len
;
1635 memcpy( expected
, file_name
+ len
, (file_name_size
- len
- 1) * sizeof(WCHAR
) );
1636 expected
[file_name_size
- len
- 1] = '\0';
1638 info_size
= sizeof(*info
) + (file_name_size
* sizeof(WCHAR
));
1639 info
= HeapAlloc( GetProcessHeap(), 0, info_size
);
1641 memset( info
, 0xcc, info_size
);
1642 hr
= pNtQueryInformationFile( h
, &io
, info
, info_size
, FileNameInformation
);
1643 ok(hr
== STATUS_SUCCESS
, "NtQueryInformationFile returned %#x, expected %#x.\n", hr
, STATUS_SUCCESS
);
1644 info
->FileName
[info
->FileNameLength
/ sizeof(WCHAR
)] = '\0';
1645 ok(!lstrcmpiW( info
->FileName
, expected
), "info->FileName is %s, expected %s.\n",
1646 wine_dbgstr_w( info
->FileName
), wine_dbgstr_w( expected
));
1649 HeapFree( GetProcessHeap(), 0, info
);
1650 HeapFree( GetProcessHeap(), 0, expected
);
1651 HeapFree( GetProcessHeap(), 0, volume_prefix
);
1652 HeapFree( GetProcessHeap(), 0, file_name
);
1655 static void test_file_all_name_information(void)
1657 WCHAR
*file_name
, *volume_prefix
, *expected
;
1658 FILE_ALL_INFORMATION
*info
;
1659 ULONG old_redir
= 1, tmp
;
1660 UINT file_name_size
;
1667 /* GetVolumePathName is not present before w2k */
1668 if (!pGetVolumePathNameW
) {
1669 win_skip("GetVolumePathNameW not found\n");
1673 file_name_size
= GetSystemDirectoryW( NULL
, 0 );
1674 file_name
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*file_name
) );
1675 volume_prefix
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*volume_prefix
) );
1676 expected
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*volume_prefix
) );
1678 len
= GetSystemDirectoryW( file_name
, file_name_size
);
1679 ok(len
== file_name_size
- 1,
1680 "GetSystemDirectoryW returned %u, expected %u.\n",
1681 len
, file_name_size
- 1);
1683 len
= pGetVolumePathNameW( file_name
, volume_prefix
, file_name_size
);
1684 ok(len
, "GetVolumePathNameW failed.\n");
1686 len
= lstrlenW( volume_prefix
);
1687 if (len
&& volume_prefix
[len
- 1] == '\\') --len
;
1688 memcpy( expected
, file_name
+ len
, (file_name_size
- len
- 1) * sizeof(WCHAR
) );
1689 expected
[file_name_size
- len
- 1] = '\0';
1691 /* A bit more than we actually need, but it keeps the calculation simple. */
1692 info_size
= sizeof(*info
) + (file_name_size
* sizeof(WCHAR
));
1693 info
= HeapAlloc( GetProcessHeap(), 0, info_size
);
1695 if (pRtlWow64EnableFsRedirectionEx
) pRtlWow64EnableFsRedirectionEx( TRUE
, &old_redir
);
1696 h
= CreateFileW( file_name
, GENERIC_READ
,
1697 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
1698 NULL
, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0 );
1699 if (pRtlWow64EnableFsRedirectionEx
) pRtlWow64EnableFsRedirectionEx( old_redir
, &tmp
);
1700 ok(h
!= INVALID_HANDLE_VALUE
, "Failed to open file.\n");
1702 hr
= pNtQueryInformationFile( h
, &io
, info
, sizeof(*info
) - 1, FileAllInformation
);
1703 ok(hr
== STATUS_INFO_LENGTH_MISMATCH
, "NtQueryInformationFile returned %#x, expected %#x.\n",
1704 hr
, STATUS_INFO_LENGTH_MISMATCH
);
1706 memset( info
, 0xcc, info_size
);
1707 hr
= pNtQueryInformationFile( h
, &io
, info
, sizeof(*info
), FileAllInformation
);
1708 ok(hr
== STATUS_BUFFER_OVERFLOW
, "NtQueryInformationFile returned %#x, expected %#x.\n",
1709 hr
, STATUS_BUFFER_OVERFLOW
);
1710 ok(U(io
).Status
== STATUS_BUFFER_OVERFLOW
, "io.Status is %#x, expected %#x.\n",
1711 U(io
).Status
, STATUS_BUFFER_OVERFLOW
);
1712 ok(info
->NameInformation
.FileNameLength
== lstrlenW( expected
) * sizeof(WCHAR
),
1713 "info->NameInformation.FileNameLength is %u\n", info
->NameInformation
.FileNameLength
);
1714 ok(info
->NameInformation
.FileName
[2] == 0xcccc,
1715 "info->NameInformation.FileName[2] is %#x, expected 0xcccc.\n", info
->NameInformation
.FileName
[2]);
1716 ok(CharLowerW((LPWSTR
)(UINT_PTR
)info
->NameInformation
.FileName
[1]) == CharLowerW((LPWSTR
)(UINT_PTR
)expected
[1]),
1717 "info->NameInformation.FileName[1] is %p, expected %p.\n",
1718 CharLowerW((LPWSTR
)(UINT_PTR
)info
->NameInformation
.FileName
[1]), CharLowerW((LPWSTR
)(UINT_PTR
)expected
[1]));
1719 ok(io
.Information
== sizeof(*info
), "io.Information is %lu\n", io
.Information
);
1721 memset( info
, 0xcc, info_size
);
1722 hr
= pNtQueryInformationFile( h
, &io
, info
, info_size
, FileAllInformation
);
1723 ok(hr
== STATUS_SUCCESS
, "NtQueryInformationFile returned %#x, expected %#x.\n", hr
, STATUS_SUCCESS
);
1724 ok(U(io
).Status
== STATUS_SUCCESS
, "io.Status is %#x, expected %#x.\n", U(io
).Status
, STATUS_SUCCESS
);
1725 ok(info
->NameInformation
.FileNameLength
== lstrlenW( expected
) * sizeof(WCHAR
),
1726 "info->NameInformation.FileNameLength is %u\n", info
->NameInformation
.FileNameLength
);
1727 ok(info
->NameInformation
.FileName
[info
->NameInformation
.FileNameLength
/ sizeof(WCHAR
)] == 0xcccc,
1728 "info->NameInformation.FileName[len] is %#x, expected 0xcccc.\n",
1729 info
->NameInformation
.FileName
[info
->NameInformation
.FileNameLength
/ sizeof(WCHAR
)]);
1730 info
->NameInformation
.FileName
[info
->NameInformation
.FileNameLength
/ sizeof(WCHAR
)] = '\0';
1731 ok(!lstrcmpiW( info
->NameInformation
.FileName
, expected
),
1732 "info->NameInformation.FileName is %s, expected %s.\n",
1733 wine_dbgstr_w( info
->NameInformation
.FileName
), wine_dbgstr_w( expected
));
1734 ok(io
.Information
== FIELD_OFFSET(FILE_ALL_INFORMATION
, NameInformation
.FileName
)
1735 + info
->NameInformation
.FileNameLength
,
1736 "io.Information is %lu\n", io
.Information
);
1739 HeapFree( GetProcessHeap(), 0, info
);
1740 HeapFree( GetProcessHeap(), 0, expected
);
1741 HeapFree( GetProcessHeap(), 0, volume_prefix
);
1743 if (old_redir
|| !pGetSystemWow64DirectoryW
|| !(file_name_size
= pGetSystemWow64DirectoryW( NULL
, 0 )))
1745 skip("Not running on WoW64, skipping test.\n");
1746 HeapFree( GetProcessHeap(), 0, file_name
);
1750 h
= CreateFileW( file_name
, GENERIC_READ
,
1751 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
1752 NULL
, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0 );
1753 ok(h
!= INVALID_HANDLE_VALUE
, "Failed to open file.\n");
1754 HeapFree( GetProcessHeap(), 0, file_name
);
1756 file_name
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*file_name
) );
1757 volume_prefix
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*volume_prefix
) );
1758 expected
= HeapAlloc( GetProcessHeap(), 0, file_name_size
* sizeof(*expected
) );
1760 len
= pGetSystemWow64DirectoryW( file_name
, file_name_size
);
1761 ok(len
== file_name_size
- 1,
1762 "GetSystemWow64DirectoryW returned %u, expected %u.\n",
1763 len
, file_name_size
- 1);
1765 len
= pGetVolumePathNameW( file_name
, volume_prefix
, file_name_size
);
1766 ok(len
, "GetVolumePathNameW failed.\n");
1768 len
= lstrlenW( volume_prefix
);
1769 if (len
&& volume_prefix
[len
- 1] == '\\') --len
;
1770 memcpy( expected
, file_name
+ len
, (file_name_size
- len
- 1) * sizeof(WCHAR
) );
1771 expected
[file_name_size
- len
- 1] = '\0';
1773 info_size
= sizeof(*info
) + (file_name_size
* sizeof(WCHAR
));
1774 info
= HeapAlloc( GetProcessHeap(), 0, info_size
);
1776 memset( info
, 0xcc, info_size
);
1777 hr
= pNtQueryInformationFile( h
, &io
, info
, info_size
, FileAllInformation
);
1778 ok(hr
== STATUS_SUCCESS
, "NtQueryInformationFile returned %#x, expected %#x.\n", hr
, STATUS_SUCCESS
);
1779 info
->NameInformation
.FileName
[info
->NameInformation
.FileNameLength
/ sizeof(WCHAR
)] = '\0';
1780 ok(!lstrcmpiW( info
->NameInformation
.FileName
, expected
), "info->NameInformation.FileName is %s, expected %s.\n",
1781 wine_dbgstr_w( info
->NameInformation
.FileName
), wine_dbgstr_w( expected
));
1784 HeapFree( GetProcessHeap(), 0, info
);
1785 HeapFree( GetProcessHeap(), 0, expected
);
1786 HeapFree( GetProcessHeap(), 0, volume_prefix
);
1787 HeapFree( GetProcessHeap(), 0, file_name
);
1790 static void test_query_volume_information_file(void)
1794 WCHAR path
[MAX_PATH
];
1795 OBJECT_ATTRIBUTES attr
;
1797 UNICODE_STRING nameW
;
1798 FILE_FS_VOLUME_INFORMATION
*ffvi
;
1799 BYTE buf
[sizeof(FILE_FS_VOLUME_INFORMATION
) + MAX_PATH
* sizeof(WCHAR
)];
1801 GetWindowsDirectoryW( path
, MAX_PATH
);
1802 pRtlDosPathNameToNtPathName_U( path
, &nameW
, NULL
, NULL
);
1803 attr
.Length
= sizeof(attr
);
1804 attr
.RootDirectory
= 0;
1805 attr
.ObjectName
= &nameW
;
1806 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
1807 attr
.SecurityDescriptor
= NULL
;
1808 attr
.SecurityQualityOfService
= NULL
;
1810 status
= pNtOpenFile( &dir
, SYNCHRONIZE
|FILE_LIST_DIRECTORY
, &attr
, &io
,
1811 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_DIRECTORY_FILE
|FILE_SYNCHRONOUS_IO_NONALERT
);
1812 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
1813 pRtlFreeUnicodeString( &nameW
);
1815 ZeroMemory( buf
, sizeof(buf
) );
1816 U(io
).Status
= 0xdadadada;
1817 io
.Information
= 0xcacacaca;
1819 status
= pNtQueryVolumeInformationFile( dir
, &io
, buf
, sizeof(buf
), FileFsVolumeInformation
);
1821 ffvi
= (FILE_FS_VOLUME_INFORMATION
*)buf
;
1825 ok(status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %d\n", status
);
1826 ok(U(io
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %d\n", U(io
).Status
);
1828 ok(io
.Information
== (FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION
, VolumeLabel
) + ffvi
->VolumeLabelLength
),
1829 "expected %d, got %lu\n", (FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION
, VolumeLabel
) + ffvi
->VolumeLabelLength
),
1832 ok(ffvi
->VolumeCreationTime
.QuadPart
!= 0, "Missing VolumeCreationTime\n");
1833 ok(ffvi
->VolumeSerialNumber
!= 0, "Missing VolumeSerialNumber\n");
1834 ok(ffvi
->SupportsObjects
== 1,"expected 1, got %d\n", ffvi
->SupportsObjects
);
1836 ok(ffvi
->VolumeLabelLength
== lstrlenW(ffvi
->VolumeLabel
) * sizeof(WCHAR
), "got %d\n", ffvi
->VolumeLabelLength
);
1838 trace("VolumeSerialNumber: %x VolumeLabelName: %s\n", ffvi
->VolumeSerialNumber
, wine_dbgstr_w(ffvi
->VolumeLabel
));
1843 static void test_query_attribute_information_file(void)
1847 WCHAR path
[MAX_PATH
];
1848 OBJECT_ATTRIBUTES attr
;
1850 UNICODE_STRING nameW
;
1851 FILE_FS_ATTRIBUTE_INFORMATION
*ffai
;
1852 BYTE buf
[sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + MAX_PATH
* sizeof(WCHAR
)];
1854 GetWindowsDirectoryW( path
, MAX_PATH
);
1855 pRtlDosPathNameToNtPathName_U( path
, &nameW
, NULL
, NULL
);
1856 attr
.Length
= sizeof(attr
);
1857 attr
.RootDirectory
= 0;
1858 attr
.ObjectName
= &nameW
;
1859 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
1860 attr
.SecurityDescriptor
= NULL
;
1861 attr
.SecurityQualityOfService
= NULL
;
1863 status
= pNtOpenFile( &dir
, SYNCHRONIZE
|FILE_LIST_DIRECTORY
, &attr
, &io
,
1864 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_DIRECTORY_FILE
|FILE_SYNCHRONOUS_IO_NONALERT
);
1865 ok( !status
, "open %s failed %x\n", wine_dbgstr_w(nameW
.Buffer
), status
);
1866 pRtlFreeUnicodeString( &nameW
);
1868 ZeroMemory( buf
, sizeof(buf
) );
1869 U(io
).Status
= 0xdadadada;
1870 io
.Information
= 0xcacacaca;
1872 status
= pNtQueryVolumeInformationFile( dir
, &io
, buf
, sizeof(buf
), FileFsAttributeInformation
);
1874 ffai
= (FILE_FS_ATTRIBUTE_INFORMATION
*)buf
;
1876 ok(status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %d\n", status
);
1877 ok(U(io
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %d\n", U(io
).Status
);
1878 ok(ffai
->FileSystemAttribute
!= 0, "Missing FileSystemAttribute\n");
1879 ok(ffai
->MaximumComponentNameLength
!= 0, "Missing MaximumComponentNameLength\n");
1880 ok(ffai
->FileSystemNameLength
!= 0, "Missing FileSystemNameLength\n");
1882 trace("FileSystemAttribute: %x MaximumComponentNameLength: %x FileSystemName: %s\n",
1883 ffai
->FileSystemAttribute
, ffai
->MaximumComponentNameLength
,
1884 wine_dbgstr_wn(ffai
->FileSystemName
, ffai
->FileSystemNameLength
/ sizeof(WCHAR
)));
1889 static void test_NtCreateFile(void)
1891 static const struct test_data
1893 DWORD disposition
, attrib_in
, status
, result
, attrib_out
, needs_cleanup
;
1896 /* 0*/{ FILE_CREATE
, FILE_ATTRIBUTE_READONLY
, 0, FILE_CREATED
, FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_READONLY
, FALSE
},
1897 /* 1*/{ FILE_CREATE
, 0, STATUS_OBJECT_NAME_COLLISION
, 0, 0, TRUE
},
1898 /* 2*/{ FILE_CREATE
, 0, 0, FILE_CREATED
, FILE_ATTRIBUTE_ARCHIVE
, FALSE
},
1899 /* 3*/{ FILE_OPEN
, FILE_ATTRIBUTE_READONLY
, 0, FILE_OPENED
, FILE_ATTRIBUTE_ARCHIVE
, TRUE
},
1900 /* 4*/{ FILE_OPEN
, FILE_ATTRIBUTE_READONLY
, STATUS_OBJECT_NAME_NOT_FOUND
, 0, 0, FALSE
},
1901 /* 5*/{ FILE_OPEN_IF
, 0, 0, FILE_CREATED
, FILE_ATTRIBUTE_ARCHIVE
, FALSE
},
1902 /* 6*/{ FILE_OPEN_IF
, FILE_ATTRIBUTE_READONLY
, 0, FILE_OPENED
, FILE_ATTRIBUTE_ARCHIVE
, TRUE
},
1903 /* 7*/{ FILE_OPEN_IF
, FILE_ATTRIBUTE_READONLY
, 0, FILE_CREATED
, FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_READONLY
, FALSE
},
1904 /* 8*/{ FILE_OPEN_IF
, 0, 0, FILE_OPENED
, FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_READONLY
, FALSE
},
1905 /* 9*/{ FILE_OVERWRITE
, 0, STATUS_ACCESS_DENIED
, 0, 0, TRUE
},
1906 /*10*/{ FILE_OVERWRITE
, 0, STATUS_OBJECT_NAME_NOT_FOUND
, 0, 0, FALSE
},
1907 /*11*/{ FILE_CREATE
, 0, 0, FILE_CREATED
, FILE_ATTRIBUTE_ARCHIVE
, FALSE
},
1908 /*12*/{ FILE_OVERWRITE
, FILE_ATTRIBUTE_READONLY
, 0, FILE_OVERWRITTEN
, FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_READONLY
, FALSE
},
1909 /*13*/{ FILE_OVERWRITE_IF
, 0, STATUS_ACCESS_DENIED
, 0, 0, TRUE
},
1910 /*14*/{ FILE_OVERWRITE_IF
, 0, 0, FILE_CREATED
, FILE_ATTRIBUTE_ARCHIVE
, FALSE
},
1911 /*15*/{ FILE_OVERWRITE_IF
, FILE_ATTRIBUTE_READONLY
, 0, FILE_OVERWRITTEN
, FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_READONLY
, FALSE
},
1912 /*16*/{ FILE_SUPERSEDE
, 0, 0, FILE_SUPERSEDED
, FILE_ATTRIBUTE_ARCHIVE
, FALSE
},
1913 /*17*/{ FILE_SUPERSEDE
, FILE_ATTRIBUTE_READONLY
, 0, FILE_SUPERSEDED
, FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_READONLY
, TRUE
},
1914 /*18*/{ FILE_SUPERSEDE
, 0, 0, FILE_CREATED
, FILE_ATTRIBUTE_ARCHIVE
, TRUE
}
1916 static const WCHAR fooW
[] = {'f','o','o',0};
1919 WCHAR path
[MAX_PATH
];
1920 OBJECT_ATTRIBUTES attr
;
1922 UNICODE_STRING nameW
;
1925 GetTempPathW(MAX_PATH
, path
);
1926 GetTempFileNameW(path
, fooW
, 0, path
);
1928 pRtlDosPathNameToNtPathName_U(path
, &nameW
, NULL
, NULL
);
1930 attr
.Length
= sizeof(attr
);
1931 attr
.RootDirectory
= NULL
;
1932 attr
.ObjectName
= &nameW
;
1933 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
1934 attr
.SecurityDescriptor
= NULL
;
1935 attr
.SecurityQualityOfService
= NULL
;
1937 for (i
= 0; i
< sizeof(td
)/sizeof(td
[0]); i
++)
1939 status
= pNtCreateFile(&handle
, GENERIC_READ
, &attr
, &io
, NULL
,
1940 td
[i
].attrib_in
, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
1941 td
[i
].disposition
, 0, NULL
, 0);
1943 ok(status
== td
[i
].status
, "%d: expected %#x got %#x\n", i
, td
[i
].status
, status
);
1947 ok(io
.Information
== td
[i
].result
,"%d: expected %#x got %#lx\n", i
, td
[i
].result
, io
.Information
);
1949 ret
= GetFileAttributesW(path
);
1950 ret
&= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
;
1951 /* FIXME: leave only 'else' case below once Wine is fixed */
1952 if (ret
!= td
[i
].attrib_out
)
1955 ok(ret
== td
[i
].attrib_out
, "%d: expected %#x got %#x\n", i
, td
[i
].attrib_out
, ret
);
1956 SetFileAttributesW(path
, td
[i
].attrib_out
);
1959 ok(ret
== td
[i
].attrib_out
, "%d: expected %#x got %#x\n", i
, td
[i
].attrib_out
, ret
);
1961 CloseHandle(handle
);
1964 if (td
[i
].needs_cleanup
)
1966 SetFileAttributesW(path
, FILE_ATTRIBUTE_ARCHIVE
);
1971 pRtlFreeUnicodeString( &nameW
);
1972 SetFileAttributesW(path
, FILE_ATTRIBUTE_ARCHIVE
);
1973 DeleteFileW( path
);
1976 static void test_read_write(void)
1978 static const char contents
[14] = "1234567890abcd";
1982 IO_STATUS_BLOCK iob
;
1983 DWORD ret
, bytes
, status
, off
;
1984 LARGE_INTEGER offset
;
1988 iob
.Information
= -1;
1989 offset
.QuadPart
= 0;
1990 status
= pNtReadFile(INVALID_HANDLE_VALUE
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
1991 ok(status
== STATUS_OBJECT_TYPE_MISMATCH
|| status
== STATUS_INVALID_HANDLE
, "expected STATUS_OBJECT_TYPE_MISMATCH, got %#x\n", status
);
1992 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
1993 ok(iob
.Information
== -1, "expected -1, got %lu\n", iob
.Information
);
1996 iob
.Information
= -1;
1997 offset
.QuadPart
= 0;
1998 status
= pNtWriteFile(INVALID_HANDLE_VALUE
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
1999 ok(status
== STATUS_OBJECT_TYPE_MISMATCH
|| status
== STATUS_INVALID_HANDLE
, "expected STATUS_OBJECT_TYPE_MISMATCH, got %#x\n", status
);
2000 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2001 ok(iob
.Information
== -1, "expected -1, got %lu\n", iob
.Information
);
2003 hfile
= create_temp_file(0);
2007 iob
.Information
= -1;
2008 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, NULL
, sizeof(contents
), NULL
, NULL
);
2009 ok(status
== STATUS_INVALID_USER_BUFFER
, "expected STATUS_INVALID_USER_BUFFER, got %#x\n", status
);
2010 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2011 ok(iob
.Information
== -1, "expected -1, got %lu\n", iob
.Information
);
2014 iob
.Information
= -1;
2015 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, NULL
, sizeof(contents
), NULL
, NULL
);
2016 ok(status
== STATUS_ACCESS_VIOLATION
, "expected STATUS_ACCESS_VIOLATION, got %#x\n", status
);
2017 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2018 ok(iob
.Information
== -1, "expected -1, got %lu\n", iob
.Information
);
2021 iob
.Information
= -1;
2022 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, contents
, 7, NULL
, NULL
);
2023 ok(status
== STATUS_SUCCESS
, "NtWriteFile error %#x\n", status
);
2024 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2025 ok(iob
.Information
== 7, "expected 7, got %lu\n", iob
.Information
);
2027 SetFilePointer(hfile
, 0, NULL
, FILE_BEGIN
);
2030 iob
.Information
= -1;
2031 offset
.QuadPart
= (LONGLONG
)-1 /* FILE_WRITE_TO_END_OF_FILE */;
2032 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, contents
+ 7, sizeof(contents
) - 7, &offset
, NULL
);
2033 ok(status
== STATUS_SUCCESS
, "NtWriteFile error %#x\n", status
);
2034 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2035 ok(iob
.Information
== sizeof(contents
) - 7, "expected sizeof(contents)-7, got %lu\n", iob
.Information
);
2037 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2038 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2041 SetLastError(0xdeadbeef);
2042 ret
= ReadFile(INVALID_HANDLE_VALUE
, buf
, 0, &bytes
, NULL
);
2043 ok(!ret
, "ReadFile should fail\n");
2044 ok(GetLastError() == ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
2045 ok(bytes
== 0, "bytes %u\n", bytes
);
2048 SetLastError(0xdeadbeef);
2049 ret
= ReadFile(hfile
, buf
, 0, &bytes
, NULL
);
2050 ok(ret
, "ReadFile error %d\n", GetLastError());
2051 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
2052 ok(bytes
== 0, "bytes %u\n", bytes
);
2055 SetLastError(0xdeadbeef);
2056 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, NULL
);
2057 ok(ret
, "ReadFile error %d\n", GetLastError());
2058 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
2059 ok(bytes
== 0, "bytes %u\n", bytes
);
2061 SetFilePointer(hfile
, 0, NULL
, FILE_BEGIN
);
2064 SetLastError(0xdeadbeef);
2065 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, NULL
);
2066 ok(ret
, "ReadFile error %d\n", GetLastError());
2067 ok(bytes
== sizeof(contents
), "bytes %u\n", bytes
);
2068 ok(!memcmp(contents
, buf
, sizeof(contents
)), "file contents mismatch\n");
2070 for (i
= -20; i
< -1; i
++)
2072 if (i
== -2) continue;
2075 iob
.Information
= -1;
2076 offset
.QuadPart
= (LONGLONG
)i
;
2077 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, contents
, sizeof(contents
), &offset
, NULL
);
2078 ok(status
== STATUS_INVALID_PARAMETER
, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i
, status
);
2079 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2080 ok(iob
.Information
== -1, "expected -1, got %ld\n", iob
.Information
);
2083 SetFilePointer(hfile
, sizeof(contents
) - 4, NULL
, FILE_BEGIN
);
2086 iob
.Information
= -1;
2087 offset
.QuadPart
= (LONGLONG
)-2 /* FILE_USE_FILE_POINTER_POSITION */;
2088 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, "DCBA", 4, &offset
, NULL
);
2089 ok(status
== STATUS_SUCCESS
, "NtWriteFile error %#x\n", status
);
2090 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2091 ok(iob
.Information
== 4, "expected 4, got %lu\n", iob
.Information
);
2093 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2094 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2097 iob
.Information
= -1;
2098 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), NULL
, NULL
);
2099 ok(status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", status
);
2100 ok(U(iob
).Status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", U(iob
).Status
);
2101 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2103 SetFilePointer(hfile
, 0, NULL
, FILE_BEGIN
);
2106 SetLastError(0xdeadbeef);
2107 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, NULL
);
2108 ok(ret
, "ReadFile error %d\n", GetLastError());
2109 ok(bytes
== sizeof(contents
), "bytes %u\n", bytes
);
2110 ok(!memcmp(contents
, buf
, sizeof(contents
) - 4), "file contents mismatch\n");
2111 ok(!memcmp(buf
+ sizeof(contents
) - 4, "DCBA", 4), "file contents mismatch\n");
2113 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2114 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2116 SetFilePointer(hfile
, 0, NULL
, FILE_BEGIN
);
2119 SetLastError(0xdeadbeef);
2120 ret
= WriteFile(hfile
, contents
, sizeof(contents
), &bytes
, NULL
);
2121 ok(ret
, "WriteFile error %d\n", GetLastError());
2122 ok(bytes
== sizeof(contents
), "bytes %u\n", bytes
);
2124 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2125 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2127 /* test reading beyond EOF */
2129 SetLastError(0xdeadbeef);
2130 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, NULL
);
2131 ok(ret
, "ReadFile error %d\n", GetLastError());
2132 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
2133 ok(bytes
== 0, "bytes %u\n", bytes
);
2136 SetLastError(0xdeadbeef);
2137 ret
= ReadFile(hfile
, buf
, 0, &bytes
, NULL
);
2138 ok(ret
, "ReadFile error %d\n", GetLastError());
2139 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
2140 ok(bytes
== 0, "bytes %u\n", bytes
);
2143 SetLastError(0xdeadbeef);
2144 ret
= ReadFile(hfile
, NULL
, 0, &bytes
, NULL
);
2145 ok(ret
, "ReadFile error %d\n", GetLastError());
2146 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
2147 ok(bytes
== 0, "bytes %u\n", bytes
);
2149 S(U(ovl
)).Offset
= sizeof(contents
);
2150 S(U(ovl
)).OffsetHigh
= 0;
2152 ovl
.InternalHigh
= -1;
2155 SetLastError(0xdeadbeef);
2156 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, &ovl
);
2157 ok(!ret
, "ReadFile should fail\n");
2158 ok(GetLastError() == ERROR_HANDLE_EOF
, "expected ERROR_HANDLE_EOF, got %d\n", GetLastError());
2159 ok(bytes
== 0, "bytes %u\n", bytes
);
2160 ok((NTSTATUS
)ovl
.Internal
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#lx\n", ovl
.Internal
);
2161 ok(ovl
.InternalHigh
== 0, "expected 0, got %lu\n", ovl
.InternalHigh
);
2163 S(U(ovl
)).Offset
= sizeof(contents
);
2164 S(U(ovl
)).OffsetHigh
= 0;
2166 ovl
.InternalHigh
= -1;
2169 SetLastError(0xdeadbeef);
2170 ret
= ReadFile(hfile
, buf
, 0, &bytes
, &ovl
);
2171 ok(ret
, "ReadFile error %d\n", GetLastError());
2172 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
2173 ok(bytes
== 0, "bytes %u\n", bytes
);
2174 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2175 ok(ovl
.InternalHigh
== 0, "expected 0, got %lu\n", ovl
.InternalHigh
);
2178 iob
.Information
= -1;
2179 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), NULL
, NULL
);
2180 ok(status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", status
);
2181 ok(U(iob
).Status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", U(iob
).Status
);
2182 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2185 iob
.Information
= -1;
2186 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, 0, NULL
, NULL
);
2187 ok(status
== STATUS_SUCCESS
, "NtReadFile error %#x\n", status
);
2188 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2189 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2192 iob
.Information
= -1;
2193 offset
.QuadPart
= sizeof(contents
);
2194 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
2195 ok(status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", status
);
2196 ok(U(iob
).Status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", U(iob
).Status
);
2197 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2200 iob
.Information
= -1;
2201 offset
.QuadPart
= sizeof(contents
);
2202 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, 0, &offset
, NULL
);
2203 ok(status
== STATUS_SUCCESS
, "NtReadFile error %#x\n", status
);
2204 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2205 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2208 iob
.Information
= -1;
2209 offset
.QuadPart
= (LONGLONG
)-2 /* FILE_USE_FILE_POINTER_POSITION */;
2210 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
2211 ok(status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", status
);
2212 ok(U(iob
).Status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", U(iob
).Status
);
2213 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2216 iob
.Information
= -1;
2217 offset
.QuadPart
= (LONGLONG
)-2 /* FILE_USE_FILE_POINTER_POSITION */;
2218 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, 0, &offset
, NULL
);
2219 ok(status
== STATUS_SUCCESS
, "NtReadFile error %#x\n", status
);
2220 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2221 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2223 for (i
= -20; i
< 0; i
++)
2225 if (i
== -2) continue;
2228 iob
.Information
= -1;
2229 offset
.QuadPart
= (LONGLONG
)i
;
2230 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
2231 ok(status
== STATUS_INVALID_PARAMETER
, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i
, status
);
2232 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2233 ok(iob
.Information
== -1, "expected -1, got %ld\n", iob
.Information
);
2236 SetFilePointer(hfile
, 0, NULL
, FILE_BEGIN
);
2239 SetLastError(0xdeadbeef);
2240 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, NULL
);
2241 ok(ret
, "ReadFile error %d\n", GetLastError());
2242 ok(bytes
== sizeof(contents
), "bytes %u\n", bytes
);
2243 ok(!memcmp(contents
, buf
, sizeof(contents
)), "file contents mismatch\n");
2245 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2246 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2249 iob
.Information
= -1;
2250 offset
.QuadPart
= 0;
2251 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
2252 ok(status
== STATUS_SUCCESS
, "NtReadFile error %#x\n", status
);
2253 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2254 ok(iob
.Information
== sizeof(contents
), "expected sizeof(contents), got %lu\n", iob
.Information
);
2255 ok(!memcmp(contents
, buf
, sizeof(contents
)), "file contents mismatch\n");
2257 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2258 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2261 iob
.Information
= -1;
2262 offset
.QuadPart
= sizeof(contents
) - 4;
2263 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, "DCBA", 4, &offset
, NULL
);
2264 ok(status
== STATUS_SUCCESS
, "NtWriteFile error %#x\n", status
);
2265 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2266 ok(iob
.Information
== 4, "expected 4, got %lu\n", iob
.Information
);
2268 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2269 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2272 iob
.Information
= -1;
2273 offset
.QuadPart
= 0;
2274 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
2275 ok(status
== STATUS_SUCCESS
, "NtReadFile error %#x\n", status
);
2276 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2277 ok(iob
.Information
== sizeof(contents
), "expected sizeof(contents), got %lu\n", iob
.Information
);
2278 ok(!memcmp(contents
, buf
, sizeof(contents
) - 4), "file contents mismatch\n");
2279 ok(!memcmp(buf
+ sizeof(contents
) - 4, "DCBA", 4), "file contents mismatch\n");
2281 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2282 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2284 S(U(ovl
)).Offset
= sizeof(contents
) - 4;
2285 S(U(ovl
)).OffsetHigh
= 0;
2288 SetLastError(0xdeadbeef);
2289 ret
= WriteFile(hfile
, "ABCD", 4, &bytes
, &ovl
);
2290 ok(ret
, "WriteFile error %d\n", GetLastError());
2291 ok(bytes
== 4, "bytes %u\n", bytes
);
2293 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2294 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2296 S(U(ovl
)).Offset
= 0;
2297 S(U(ovl
)).OffsetHigh
= 0;
2299 ovl
.InternalHigh
= -1;
2302 SetLastError(0xdeadbeef);
2303 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, &ovl
);
2304 ok(ret
, "ReadFile error %d\n", GetLastError());
2305 ok(bytes
== sizeof(contents
), "bytes %u\n", bytes
);
2306 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2307 ok(ovl
.InternalHigh
== sizeof(contents
), "expected sizeof(contents), got %lu\n", ovl
.InternalHigh
);
2308 ok(!memcmp(contents
, buf
, sizeof(contents
) - 4), "file contents mismatch\n");
2309 ok(!memcmp(buf
+ sizeof(contents
) - 4, "ABCD", 4), "file contents mismatch\n");
2311 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2312 ok(off
== sizeof(contents
), "expected sizeof(contents), got %u\n", off
);
2316 hfile
= create_temp_file(FILE_FLAG_OVERLAPPED
);
2320 SetLastError(0xdeadbeef);
2321 ret
= ReadFile(INVALID_HANDLE_VALUE
, buf
, 0, &bytes
, NULL
);
2322 ok(!ret
, "ReadFile should fail\n");
2323 ok(GetLastError() == ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
2324 ok(bytes
== 0, "bytes %u\n", bytes
);
2326 S(U(ovl
)).Offset
= 0;
2327 S(U(ovl
)).OffsetHigh
= 0;
2329 ovl
.InternalHigh
= -1;
2332 SetLastError(0xdeadbeef);
2333 /* ReadFile return value depends on Windows version and testing it is not practical */
2334 ReadFile(hfile
, buf
, 0, &bytes
, &ovl
);
2335 ok(bytes
== 0, "bytes %u\n", bytes
);
2336 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2337 ok(ovl
.InternalHigh
== 0, "expected 0, got %lu\n", ovl
.InternalHigh
);
2340 SetLastError(0xdeadbeef);
2341 ret
= WriteFile(hfile
, contents
, sizeof(contents
), &bytes
, NULL
);
2342 ok(!ret
, "WriteFile should fail\n");
2343 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
2344 ok(bytes
== 0, "bytes %u\n", bytes
);
2347 iob
.Information
= -1;
2348 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, contents
, sizeof(contents
), NULL
, NULL
);
2349 ok(status
== STATUS_INVALID_PARAMETER
, "expected STATUS_INVALID_PARAMETER, got %#x\n", status
);
2350 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2351 ok(iob
.Information
== -1, "expected -1, got %ld\n", iob
.Information
);
2353 for (i
= -20; i
< -1; i
++)
2356 iob
.Information
= -1;
2357 offset
.QuadPart
= (LONGLONG
)i
;
2358 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, contents
, sizeof(contents
), &offset
, NULL
);
2359 ok(status
== STATUS_INVALID_PARAMETER
, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i
, status
);
2360 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2361 ok(iob
.Information
== -1, "expected -1, got %ld\n", iob
.Information
);
2365 iob
.Information
= -1;
2366 offset
.QuadPart
= 0;
2367 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, contents
, sizeof(contents
), &offset
, NULL
);
2368 ok(status
== STATUS_PENDING
|| status
== STATUS_SUCCESS
/* before Vista */, "expected STATUS_PENDING or STATUS_SUCCESS, got %#x\n", status
);
2369 if (status
== STATUS_PENDING
)
2371 ret
= WaitForSingleObject(hfile
, 3000);
2372 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject error %d\n", ret
);
2374 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2375 ok(iob
.Information
== sizeof(contents
), "expected sizeof(contents), got %lu\n", iob
.Information
);
2377 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2378 ok(off
== 0, "expected 0, got %u\n", off
);
2381 SetLastError(0xdeadbeef);
2382 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, NULL
);
2383 ok(!ret
, "ReadFile should fail\n");
2384 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
2385 ok(bytes
== 0, "bytes %u\n", bytes
);
2388 iob
.Information
= -1;
2389 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), NULL
, NULL
);
2390 ok(status
== STATUS_INVALID_PARAMETER
, "expected STATUS_INVALID_PARAMETER, got %#x\n", status
);
2391 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2392 ok(iob
.Information
== -1, "expected -1, got %ld\n", iob
.Information
);
2394 for (i
= -20; i
< 0; i
++)
2397 iob
.Information
= -1;
2398 offset
.QuadPart
= (LONGLONG
)i
;
2399 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
2400 ok(status
== STATUS_INVALID_PARAMETER
, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i
, status
);
2401 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2402 ok(iob
.Information
== -1, "expected -1, got %ld\n", iob
.Information
);
2405 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2406 ok(off
== 0, "expected 0, got %u\n", off
);
2408 /* test reading beyond EOF */
2409 offset
.QuadPart
= sizeof(contents
);
2410 S(U(ovl
)).Offset
= offset
.u
.LowPart
;
2411 S(U(ovl
)).OffsetHigh
= offset
.u
.HighPart
;
2413 ovl
.InternalHigh
= -1;
2416 SetLastError(0xdeadbeef);
2417 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, &ovl
);
2418 ok(!ret
, "ReadFile should fail\n");
2419 ret
= GetLastError();
2420 ok(ret
== ERROR_IO_PENDING
|| ret
== ERROR_HANDLE_EOF
/* before Vista */, "expected ERROR_IO_PENDING or ERROR_HANDLE_EOF, got %d\n", ret
);
2421 ok(bytes
== 0, "bytes %u\n", bytes
);
2423 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2424 ok(off
== 0, "expected 0, got %u\n", off
);
2426 if (ret
== ERROR_IO_PENDING
)
2429 SetLastError(0xdeadbeef);
2430 ret
= GetOverlappedResult(hfile
, &ovl
, &bytes
, TRUE
);
2431 ok(!ret
, "GetOverlappedResult should report FALSE\n");
2432 ok(GetLastError() == ERROR_HANDLE_EOF
, "expected ERROR_HANDLE_EOF, got %d\n", GetLastError());
2433 ok(bytes
== 0, "expected 0, read %u\n", bytes
);
2434 ok((NTSTATUS
)ovl
.Internal
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#lx\n", ovl
.Internal
);
2435 ok(ovl
.InternalHigh
== 0, "expected 0, got %lu\n", ovl
.InternalHigh
);
2438 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2439 ok(off
== 0, "expected 0, got %u\n", off
);
2441 offset
.QuadPart
= sizeof(contents
);
2442 S(U(ovl
)).Offset
= offset
.u
.LowPart
;
2443 S(U(ovl
)).OffsetHigh
= offset
.u
.HighPart
;
2445 ovl
.InternalHigh
= -1;
2448 SetLastError(0xdeadbeef);
2449 ret
= ReadFile(hfile
, buf
, 0, &bytes
, &ovl
);
2450 /* ReadFile return value depends on Windows version and testing it is not practical */
2453 ok(GetLastError() == ERROR_IO_PENDING
, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
2454 ret
= GetLastError();
2455 ok(bytes
== 0, "bytes %u\n", bytes
);
2457 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2458 ok(off
== 0, "expected 0, got %u\n", off
);
2460 if (ret
== ERROR_IO_PENDING
)
2463 SetLastError(0xdeadbeef);
2464 ret
= GetOverlappedResult(hfile
, &ovl
, &bytes
, TRUE
);
2465 ok(ret
, "GetOverlappedResult should report TRUE\n");
2466 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
2467 ok(bytes
== 0, "expected 0, read %u\n", bytes
);
2468 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2469 ok(ovl
.InternalHigh
== 0, "expected 0, got %lu\n", ovl
.InternalHigh
);
2472 offset
.QuadPart
= sizeof(contents
);
2473 S(U(ovl
)).Offset
= offset
.u
.LowPart
;
2474 S(U(ovl
)).OffsetHigh
= offset
.u
.HighPart
;
2476 ovl
.InternalHigh
= -1;
2479 SetLastError(0xdeadbeef);
2480 ret
= ReadFile(hfile
, NULL
, 0, &bytes
, &ovl
);
2481 /* ReadFile return value depends on Windows version and testing it is not practical */
2484 ok(GetLastError() == ERROR_IO_PENDING
, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
2485 ret
= GetLastError();
2486 ok(bytes
== 0, "bytes %u\n", bytes
);
2488 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2489 ok(off
== 0, "expected 0, got %u\n", off
);
2491 if (ret
== ERROR_IO_PENDING
)
2494 SetLastError(0xdeadbeef);
2495 ret
= GetOverlappedResult(hfile
, &ovl
, &bytes
, TRUE
);
2496 ok(ret
, "GetOverlappedResult should report TRUE\n");
2497 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
2498 ok(bytes
== 0, "expected 0, read %u\n", bytes
);
2499 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2500 ok(ovl
.InternalHigh
== 0, "expected 0, got %lu\n", ovl
.InternalHigh
);
2504 iob
.Information
= -1;
2505 offset
.QuadPart
= sizeof(contents
);
2506 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
2507 if (status
== STATUS_PENDING
)
2509 ret
= WaitForSingleObject(hfile
, 3000);
2510 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject error %d\n", ret
);
2511 ok(U(iob
).Status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", U(iob
).Status
);
2512 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2516 ok(status
== STATUS_END_OF_FILE
, "expected STATUS_END_OF_FILE, got %#x\n", status
);
2517 ok(U(iob
).Status
== -1, "expected -1, got %#x\n", U(iob
).Status
);
2518 ok(iob
.Information
== -1, "expected -1, got %lu\n", iob
.Information
);
2521 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2522 ok(off
== 0, "expected 0, got %u\n", off
);
2525 iob
.Information
= -1;
2526 offset
.QuadPart
= sizeof(contents
);
2527 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, 0, &offset
, NULL
);
2528 if (status
== STATUS_PENDING
)
2530 ret
= WaitForSingleObject(hfile
, 3000);
2531 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject error %d\n", ret
);
2532 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2533 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2537 ok(status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", status
);
2538 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2539 ok(iob
.Information
== 0, "expected 0, got %lu\n", iob
.Information
);
2542 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2543 ok(off
== 0, "expected 0, got %u\n", off
);
2545 S(U(ovl
)).Offset
= 0;
2546 S(U(ovl
)).OffsetHigh
= 0;
2548 ovl
.InternalHigh
= -1;
2551 SetLastError(0xdeadbeef);
2552 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, &ovl
);
2553 /* ReadFile return value depends on Windows version and testing it is not practical */
2556 ok(GetLastError() == ERROR_IO_PENDING
, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
2557 ok(bytes
== 0, "bytes %u\n", bytes
);
2559 else ok(bytes
== 14, "bytes %u\n", bytes
);
2560 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2561 ok(ovl
.InternalHigh
== sizeof(contents
), "expected sizeof(contents), got %lu\n", ovl
.InternalHigh
);
2563 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2564 ok(off
== 0, "expected 0, got %u\n", off
);
2567 ret
= GetOverlappedResult(hfile
, &ovl
, &bytes
, TRUE
);
2568 ok(ret
, "GetOverlappedResult error %d\n", GetLastError());
2569 ok(bytes
== sizeof(contents
), "bytes %u\n", bytes
);
2570 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2571 ok(ovl
.InternalHigh
== sizeof(contents
), "expected sizeof(contents), got %lu\n", ovl
.InternalHigh
);
2572 ok(!memcmp(contents
, buf
, sizeof(contents
)), "file contents mismatch\n");
2574 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2575 ok(off
== 0, "expected 0, got %u\n", off
);
2577 SetFilePointer(hfile
, sizeof(contents
) - 4, NULL
, FILE_BEGIN
);
2578 SetEndOfFile(hfile
);
2579 SetFilePointer(hfile
, 0, NULL
, FILE_BEGIN
);
2582 iob
.Information
= -1;
2583 offset
.QuadPart
= (LONGLONG
)-1 /* FILE_WRITE_TO_END_OF_FILE */;
2584 status
= pNtWriteFile(hfile
, 0, NULL
, NULL
, &iob
, "DCBA", 4, &offset
, NULL
);
2585 ok(status
== STATUS_PENDING
|| status
== STATUS_SUCCESS
/* before Vista */, "expected STATUS_PENDING or STATUS_SUCCESS, got %#x\n", status
);
2586 if (status
== STATUS_PENDING
)
2588 ret
= WaitForSingleObject(hfile
, 3000);
2589 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject error %d\n", ret
);
2591 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2592 ok(iob
.Information
== 4, "expected 4, got %lu\n", iob
.Information
);
2594 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2595 ok(off
== 0, "expected 0, got %u\n", off
);
2598 iob
.Information
= -1;
2599 offset
.QuadPart
= 0;
2600 status
= pNtReadFile(hfile
, 0, NULL
, NULL
, &iob
, buf
, sizeof(buf
), &offset
, NULL
);
2601 ok(status
== STATUS_PENDING
|| status
== STATUS_SUCCESS
, "expected STATUS_PENDING or STATUS_SUCCESS, got %#x\n", status
);
2602 if (status
== STATUS_PENDING
)
2604 ret
= WaitForSingleObject(hfile
, 3000);
2605 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject error %d\n", ret
);
2607 ok(U(iob
).Status
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#x\n", U(iob
).Status
);
2608 ok(iob
.Information
== sizeof(contents
), "expected sizeof(contents), got %lu\n", iob
.Information
);
2610 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2611 ok(off
== 0, "expected 0, got %u\n", off
);
2613 ok(!memcmp(contents
, buf
, sizeof(contents
) - 4), "file contents mismatch\n");
2614 ok(!memcmp(buf
+ sizeof(contents
) - 4, "DCBA", 4), "file contents mismatch\n");
2616 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2617 ok(off
== 0, "expected 0, got %u\n", off
);
2619 S(U(ovl
)).Offset
= sizeof(contents
) - 4;
2620 S(U(ovl
)).OffsetHigh
= 0;
2622 ovl
.InternalHigh
= -1;
2625 SetLastError(0xdeadbeef);
2626 ret
= WriteFile(hfile
, "ABCD", 4, &bytes
, &ovl
);
2627 /* WriteFile return value depends on Windows version and testing it is not practical */
2630 ok(GetLastError() == ERROR_IO_PENDING
, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
2631 ok(bytes
== 0, "bytes %u\n", bytes
);
2633 else ok(bytes
== 4, "bytes %u\n", bytes
);
2634 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2635 ok(ovl
.InternalHigh
== 4, "expected 4, got %lu\n", ovl
.InternalHigh
);
2637 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2638 ok(off
== 0, "expected 0, got %u\n", off
);
2641 ret
= GetOverlappedResult(hfile
, &ovl
, &bytes
, TRUE
);
2642 ok(ret
, "GetOverlappedResult error %d\n", GetLastError());
2643 ok(bytes
== 4, "bytes %u\n", bytes
);
2644 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2645 ok(ovl
.InternalHigh
== 4, "expected 4, got %lu\n", ovl
.InternalHigh
);
2647 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2648 ok(off
== 0, "expected 0, got %u\n", off
);
2650 S(U(ovl
)).Offset
= 0;
2651 S(U(ovl
)).OffsetHigh
= 0;
2653 ovl
.InternalHigh
= -1;
2656 SetLastError(0xdeadbeef);
2657 ret
= ReadFile(hfile
, buf
, sizeof(buf
), &bytes
, &ovl
);
2658 /* ReadFile return value depends on Windows version and testing it is not practical */
2661 ok(GetLastError() == ERROR_IO_PENDING
, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
2662 ok(bytes
== 0, "bytes %u\n", bytes
);
2664 else ok(bytes
== 14, "bytes %u\n", bytes
);
2665 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2666 ok(ovl
.InternalHigh
== sizeof(contents
), "expected sizeof(contents), got %lu\n", ovl
.InternalHigh
);
2668 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2669 ok(off
== 0, "expected 0, got %u\n", off
);
2672 ret
= GetOverlappedResult(hfile
, &ovl
, &bytes
, TRUE
);
2673 ok(ret
, "GetOverlappedResult error %d\n", GetLastError());
2674 ok(bytes
== sizeof(contents
), "bytes %u\n", bytes
);
2675 ok((NTSTATUS
)ovl
.Internal
== STATUS_SUCCESS
, "expected STATUS_SUCCESS, got %#lx\n", ovl
.Internal
);
2676 ok(ovl
.InternalHigh
== sizeof(contents
), "expected sizeof(contents), got %lu\n", ovl
.InternalHigh
);
2677 ok(!memcmp(contents
, buf
, sizeof(contents
) - 4), "file contents mismatch\n");
2678 ok(!memcmp(buf
+ sizeof(contents
) - 4, "ABCD", 4), "file contents mismatch\n");
2680 off
= SetFilePointer(hfile
, 0, NULL
, FILE_CURRENT
);
2681 ok(off
== 0, "expected 0, got %u\n", off
);
2688 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
2689 HMODULE hntdll
= GetModuleHandleA("ntdll.dll");
2692 skip("not running on NT, skipping test\n");
2696 pGetVolumePathNameW
= (void *)GetProcAddress(hkernel32
, "GetVolumePathNameW");
2697 pGetSystemWow64DirectoryW
= (void *)GetProcAddress(hkernel32
, "GetSystemWow64DirectoryW");
2699 pRtlFreeUnicodeString
= (void *)GetProcAddress(hntdll
, "RtlFreeUnicodeString");
2700 pRtlInitUnicodeString
= (void *)GetProcAddress(hntdll
, "RtlInitUnicodeString");
2701 pRtlDosPathNameToNtPathName_U
= (void *)GetProcAddress(hntdll
, "RtlDosPathNameToNtPathName_U");
2702 pRtlWow64EnableFsRedirectionEx
= (void *)GetProcAddress(hntdll
, "RtlWow64EnableFsRedirectionEx");
2703 pNtCreateMailslotFile
= (void *)GetProcAddress(hntdll
, "NtCreateMailslotFile");
2704 pNtCreateFile
= (void *)GetProcAddress(hntdll
, "NtCreateFile");
2705 pNtOpenFile
= (void *)GetProcAddress(hntdll
, "NtOpenFile");
2706 pNtDeleteFile
= (void *)GetProcAddress(hntdll
, "NtDeleteFile");
2707 pNtReadFile
= (void *)GetProcAddress(hntdll
, "NtReadFile");
2708 pNtWriteFile
= (void *)GetProcAddress(hntdll
, "NtWriteFile");
2709 pNtCancelIoFile
= (void *)GetProcAddress(hntdll
, "NtCancelIoFile");
2710 pNtCancelIoFileEx
= (void *)GetProcAddress(hntdll
, "NtCancelIoFileEx");
2711 pNtClose
= (void *)GetProcAddress(hntdll
, "NtClose");
2712 pNtCreateIoCompletion
= (void *)GetProcAddress(hntdll
, "NtCreateIoCompletion");
2713 pNtOpenIoCompletion
= (void *)GetProcAddress(hntdll
, "NtOpenIoCompletion");
2714 pNtQueryIoCompletion
= (void *)GetProcAddress(hntdll
, "NtQueryIoCompletion");
2715 pNtRemoveIoCompletion
= (void *)GetProcAddress(hntdll
, "NtRemoveIoCompletion");
2716 pNtSetIoCompletion
= (void *)GetProcAddress(hntdll
, "NtSetIoCompletion");
2717 pNtSetInformationFile
= (void *)GetProcAddress(hntdll
, "NtSetInformationFile");
2718 pNtQueryInformationFile
= (void *)GetProcAddress(hntdll
, "NtQueryInformationFile");
2719 pNtQueryDirectoryFile
= (void *)GetProcAddress(hntdll
, "NtQueryDirectoryFile");
2720 pNtQueryVolumeInformationFile
= (void *)GetProcAddress(hntdll
, "NtQueryVolumeInformationFile");
2723 test_NtCreateFile();
2730 test_iocompletion();
2731 test_file_basic_information();
2732 test_file_all_information();
2733 test_file_both_information();
2734 test_file_name_information();
2735 test_file_all_name_information();
2736 test_file_disposition_information();
2737 test_query_volume_information_file();
2738 test_query_attribute_information_file();