ReactOS 0.4.15-dev-7788-g1ad9096
file.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include "ntstatus.h"
#include "wine/test.h"
#include "winternl.h"
#include "winuser.h"
#include "winioctl.h"
#include "ntifs.h"
Include dependency graph for file.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define IO_COMPLETION_ALL_ACCESS   0x001F0003
 
#define TEST_BUF_LEN   3
 
#define CVALUE_FIRST   0xfffabbcc
 
#define CKEY_FIRST   0x1030341
 
#define CKEY_SECOND   0x132E46
 
#define EA_BUFFER_SIZE   4097
 

Functions

static BOOL (WINAPI *pGetVolumePathNameW)(LPCWSTR
 
static UINT (WINAPI *pGetSystemWow64DirectoryW)(LPWSTR
 
static VOID (WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING)
 
static PWSTR CURDIR *static NTSTATUS (WINAPI *pRtlWow64EnableFsRedirectionEx)(ULONG
 
static BOOL is_signaled (HANDLE obj)
 
static HANDLE create_temp_file (ULONG flags)
 
static ULONG get_pending_msgs (HANDLE h)
 
static BOOL get_msg (HANDLE h)
 
static void WINAPI apc (void *arg, IO_STATUS_BLOCK *iosb, ULONG reserved)
 
static void create_file_test (void)
 
static void open_file_test (void)
 
static void delete_file_test (void)
 
static void read_file_test (void)
 
static void append_file_test (void)
 
static void nt_mailslot_test (void)
 
static void test_iocp_setcompletion (HANDLE h)
 
static void test_iocp_fileio (HANDLE h)
 
static void test_file_full_size_information (void)
 
static void test_file_basic_information (void)
 
static void test_file_all_information (void)
 
static void delete_object (WCHAR *path)
 
static void test_file_rename_information (void)
 
static void test_file_link_information (void)
 
static void test_file_both_information (void)
 
static void test_file_disposition_information (void)
 
static void test_iocompletion (void)
 
static void test_file_name_information (void)
 
static void test_file_all_name_information (void)
 
static void test_file_completion_information (void)
 
static void test_file_id_information (void)
 
static void test_file_access_information (void)
 
static void test_query_volume_information_file (void)
 
static void test_query_attribute_information_file (void)
 
static void test_NtCreateFile (void)
 
static void test_readonly (void)
 
static void test_read_write (void)
 
static void test_ioctl (void)
 
static void test_flush_buffers_file (void)
 
static void test_query_ea (void)
 
static INT build_reparse_buffer (WCHAR *filename, REPARSE_DATA_BUFFER **pbuffer)
 
static void test_junction_points (void)
 
 START_TEST (file)
 

Variables

static LPWSTR
 
static DWORD
 
static UINT
 
static LPCWSTR
 
static PUNICODE_STRING
 
static PWSTR CURDIR *static ULONG *static ULONG
 
static PWSTR CURDIR *static ULONG *static POBJECT_ATTRIBUTES
 
static PWSTR CURDIR *static ULONG *static PIO_STATUS_BLOCK
 
static PWSTR CURDIR *static ULONG *static PLARGE_INTEGER
 
static ACCESS_MASK
 
static PVOID
 
static HANDLE hEvent
 
static HANDLE PIO_APC_ROUTINE apc
 
static HANDLE PIO_APC_ROUTINE voidapc_user
 
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
 
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK voidbuffer
 
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK void ULONG length
 
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK void ULONG PLARGE_INTEGER offset
 
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK void ULONG PLARGE_INTEGER PULONG key
 
static PIO_STATUS_BLOCK iosb
 
static HANDLE event
 
static HANDLE PIO_APC_ROUTINE PVOID apc_context
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG code
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID in_buffer
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG in_size
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID out_buffer
 
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
 
static IO_COMPLETION_INFORMATION_CLASS
 
static PULONG
 
static PULONG_PTR
 
static ULONG_PTR
 
static NTSTATUS
 
static SIZE_T
 
static FILE_INFORMATION_CLASS
 
static HANDLE
 
static PIO_APC_ROUTINE
 
static BOOLEAN
 
static FS_INFORMATION_CLASS
 
static ULONG_PTR completionKey
 
static IO_STATUS_BLOCK ioSb
 
static ULONG_PTR completionValue
 

Macro Definition Documentation

◆ CKEY_FIRST

#define CKEY_FIRST   0x1030341

Definition at line 137 of file file.c.

◆ CKEY_SECOND

#define CKEY_SECOND   0x132E46

Definition at line 138 of file file.c.

◆ CVALUE_FIRST

#define CVALUE_FIRST   0xfffabbcc

Definition at line 136 of file file.c.

◆ EA_BUFFER_SIZE

#define EA_BUFFER_SIZE   4097

◆ IO_COMPLETION_ALL_ACCESS

#define IO_COMPLETION_ALL_ACCESS   0x001F0003

Definition at line 72 of file file.c.

◆ TEST_BUF_LEN

#define TEST_BUF_LEN   3

Definition at line 121 of file file.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 34 of file file.c.

Function Documentation

◆ apc()

static void WINAPI apc ( void arg,
IO_STATUS_BLOCK iosb,
ULONG  reserved 
)
static

Definition at line 171 of file file.c.

172{
173 int *count = arg;
174
175 trace( "apc called block %p iosb.status %x iosb.info %lu\n",
176 iosb, U(*iosb).Status, iosb->Information );
177 (*count)++;
178 ok( !reserved, "reserved is not 0: %x\n", reserved );
179}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define U(x)
Definition: wordpad.c:45
r reserved
Definition: btrfs.c:3006
GLuint GLuint GLsizei count
Definition: gl.h:1545
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
void * arg
Definition: msvc.h:10

◆ append_file_test()

static void append_file_test ( void  )
static

Definition at line 781 of file file.c.

782{
783 static const char text[6] = "foobar";
788 char path[MAX_PATH], buffer[MAX_PATH], buf[16];
789 DWORD ret;
790
792 GetTempFileNameA( path, "foo", 0, buffer );
793
795 ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
796
797 U(iosb).Status = -1;
798 iosb.Information = -1;
799 status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text, 2, NULL, NULL);
800 ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
801 ok(U(iosb).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iosb).Status);
802 ok(iosb.Information == 2, "expected 2, got %lu\n", iosb.Information);
803
805
806 /* It is possible to open a file with only FILE_APPEND_DATA access flags.
807 It matches the O_WRONLY|O_APPEND open() posix behavior */
809 ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
810
811 U(iosb).Status = -1;
812 iosb.Information = -1;
813 offset.QuadPart = 1;
814 status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text + 2, 2, &offset, NULL);
815 ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
816 ok(U(iosb).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iosb).Status);
817 ok(iosb.Information == 2, "expected 2, got %lu\n", iosb.Information);
818
820 ok(ret == 4, "expected 4, got %u\n", ret);
821
822 U(iosb).Status = -1;
823 iosb.Information = -1;
824 offset.QuadPart = 3;
825 status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text + 4, 2, &offset, NULL);
826 ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
827 ok(U(iosb).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iosb).Status);
828 ok(iosb.Information == 2, "expected 2, got %lu\n", iosb.Information);
829
831 ok(ret == 6, "expected 6, got %u\n", ret);
832
834
836 ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
837
838 memset(buf, 0, sizeof(buf));
839 U(iosb).Status = -1;
840 iosb.Information = -1;
841 offset.QuadPart = 0;
842 status = pNtReadFile(handle, 0, NULL, NULL, &iosb, buf, sizeof(buf), &offset, NULL);
843 ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
844 ok(U(iosb).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iosb).Status);
845 ok(iosb.Information == 6, "expected 6, got %lu\n", iosb.Information);
846 buf[6] = 0;
847 ok(memcmp(buf, text, 6) == 0, "wrong file contents: %s\n", buf);
848
849 U(iosb).Status = -1;
850 iosb.Information = -1;
851 offset.QuadPart = 0;
852 status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text + 3, 3, &offset, NULL);
853 ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
854 ok(U(iosb).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iosb).Status);
855 ok(iosb.Information == 3, "expected 3, got %lu\n", iosb.Information);
856
857 memset(buf, 0, sizeof(buf));
858 U(iosb).Status = -1;
859 iosb.Information = -1;
860 offset.QuadPart = 0;
861 status = pNtReadFile(handle, 0, NULL, NULL, &iosb, buf, sizeof(buf), &offset, NULL);
862 ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
863 ok(U(iosb).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iosb).Status);
864 ok(iosb.Information == 6, "expected 6, got %lu\n", iosb.Information);
865 buf[6] = 0;
866 ok(memcmp(buf, "barbar", 6) == 0, "wrong file contents: %s\n", buf);
867
870}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define SetFilePointer
Definition: compat.h:743
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
const WCHAR * text
Definition: package.c:1799
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLintptr offset
Definition: glext.h:5920
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ps.c:97
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FILE_CURRENT
Definition: winbase.h:113

Referenced by START_TEST().

◆ BOOL()

static BOOL ( WINAPI pGetVolumePathNameW)
static

◆ build_reparse_buffer()

static INT build_reparse_buffer ( WCHAR filename,
REPARSE_DATA_BUFFER **  pbuffer 
)
static

Definition at line 4542 of file file.c.

4543{
4545 INT buffer_len, string_len;
4546 WCHAR *dest;
4547
4548 string_len = (lstrlenW(filename)+1)*sizeof(WCHAR);
4549 buffer_len = FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer[1]) + string_len;
4551 buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
4552 buffer->ReparseDataLength = sizeof(buffer->MountPointReparseBuffer) + string_len;
4553 buffer->MountPointReparseBuffer.SubstituteNameLength = string_len - sizeof(WCHAR);
4554 buffer->MountPointReparseBuffer.PrintNameOffset = string_len;
4555 dest = &buffer->MountPointReparseBuffer.PathBuffer[0];
4556 memcpy(dest, filename, string_len);
4557 *pbuffer = buffer;
4558 return buffer_len;
4559}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define lstrlenW
Definition: compat.h:750
const char * filename
Definition: ioapi.h:137
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static char * dest
Definition: rtl.c:135
WCHAR PathBuffer[1]
Definition: shellext.h:176
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int32_t INT
Definition: typedefs.h:58
#define IO_REPARSE_TAG_MOUNT_POINT
Definition: iotypes.h:7231
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_junction_points().

◆ create_file_test()

static void create_file_test ( void  )
static

Definition at line 181 of file file.c.

182{
183 static const WCHAR notepadW[] = {'n','o','t','e','p','a','d','.','e','x','e',0};
184 static const WCHAR systemrootW[] = {'\\','S','y','s','t','e','m','R','o','o','t',
185 '\\','f','a','i','l','i','n','g',0};
186 static const WCHAR systemrootExplorerW[] = {'\\','S','y','s','t','e','m','R','o','o','t',
187 '\\','e','x','p','l','o','r','e','r','.','e','x','e',0};
188 static const WCHAR questionmarkInvalidNameW[] = {'a','f','i','l','e','?',0};
189 static const WCHAR pipeInvalidNameW[] = {'a','|','b',0};
190 static const WCHAR pathInvalidNtW[] = {'\\','\\','?','\\',0};
191 static const WCHAR pathInvalidNt2W[] = {'\\','?','?','\\',0};
192 static const WCHAR pathInvalidDosW[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\',0};
193 static const char testdata[] = "Hello World";
194 static const WCHAR sepW[] = {'\\',0};
197 HANDLE dir, file;
203 char buf[32];
204 DWORD ret;
205
207 pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL );
208 attr.Length = sizeof(attr);
209 attr.RootDirectory = 0;
210 attr.ObjectName = &nameW;
211 attr.Attributes = OBJ_CASE_INSENSITIVE;
212 attr.SecurityDescriptor = NULL;
213 attr.SecurityQualityOfService = NULL;
214
215 /* try various open modes and options on directories */
216 status = pNtCreateFile( &dir, GENERIC_READ|GENERIC_WRITE, &attr, &io, NULL, 0,
218 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
219
220 U(io).Status = 0xdeadbeef;
221 offset.QuadPart = 0;
222 status = pNtReadFile( dir, NULL, NULL, NULL, &io, buf, sizeof(buf), &offset, NULL );
223 ok( status == STATUS_INVALID_DEVICE_REQUEST || status == STATUS_PENDING, "NtReadFile error %08x\n", status );
224 if (status == STATUS_PENDING)
225 {
226 ret = WaitForSingleObject( dir, 1000 );
227 ok( ret == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", ret );
229 "expected STATUS_INVALID_DEVICE_REQUEST, got %08x\n", U(io).Status );
230 }
231
232 U(io).Status = 0xdeadbeef;
233 offset.QuadPart = 0;
234 status = pNtWriteFile( dir, NULL, NULL, NULL, &io, testdata, sizeof(testdata), &offset, NULL);
236 ok( status == STATUS_INVALID_DEVICE_REQUEST || status == STATUS_PENDING, "NtWriteFile error %08x\n", status );
237 if (status == STATUS_PENDING)
238 {
239 ret = WaitForSingleObject( dir, 1000 );
240 ok( ret == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", ret );
242 "expected STATUS_INVALID_DEVICE_REQUEST, got %08x\n", U(io).Status );
243 }
244
245 CloseHandle( dir );
246
250 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
251
254 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
255 CloseHandle( dir );
256
259 ok( status == STATUS_INVALID_PARAMETER, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
260
263 ok( status == STATUS_INVALID_PARAMETER, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
264
267 ok( status == STATUS_INVALID_PARAMETER, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
268
270 FILE_OPEN, 0, NULL, 0 );
271 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
272 CloseHandle( dir );
273
275 FILE_CREATE, 0, NULL, 0 );
277 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
278
280 FILE_OPEN_IF, 0, NULL, 0 );
281 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
282 CloseHandle( dir );
283
285 FILE_SUPERSEDE, 0, NULL, 0 );
287 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
288
290 FILE_OVERWRITE, 0, NULL, 0 );
292 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
293
295 FILE_OVERWRITE_IF, 0, NULL, 0 );
297 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
298
299 pRtlFreeUnicodeString( &nameW );
300
301 pRtlInitUnicodeString( &nameW, systemrootW );
302 attr.Length = sizeof(attr);
303 attr.RootDirectory = NULL;
304 attr.ObjectName = &nameW;
305 attr.Attributes = OBJ_CASE_INSENSITIVE;
306 attr.SecurityDescriptor = NULL;
307 attr.SecurityQualityOfService = NULL;
308 dir = NULL;
309 status = pNtCreateFile( &dir, FILE_APPEND_DATA, &attr, &io, NULL, FILE_ATTRIBUTE_NORMAL, 0,
313 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
314
315 /* Invalid chars in file/dirnames */
316 pRtlDosPathNameToNtPathName_U(questionmarkInvalidNameW, &nameW, NULL, NULL);
317 attr.ObjectName = &nameW;
318 status = pNtCreateFile(&dir, GENERIC_READ|SYNCHRONIZE, &attr, &io, NULL, 0,
322 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status);
323
324 status = pNtCreateFile(&file, GENERIC_WRITE|SYNCHRONIZE, &attr, &io, NULL, 0,
325 0, FILE_CREATE,
328 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status);
329 pRtlFreeUnicodeString(&nameW);
330
331 pRtlDosPathNameToNtPathName_U(pipeInvalidNameW, &nameW, NULL, NULL);
332 attr.ObjectName = &nameW;
333 status = pNtCreateFile(&dir, GENERIC_READ|SYNCHRONIZE, &attr, &io, NULL, 0,
337 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status);
338
339 status = pNtCreateFile(&file, GENERIC_WRITE|SYNCHRONIZE, &attr, &io, NULL, 0,
340 0, FILE_CREATE,
343 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status);
344 pRtlFreeUnicodeString(&nameW);
345
346 pRtlInitUnicodeString( &nameW, pathInvalidNtW );
347 status = pNtCreateFile( &dir, GENERIC_READ|SYNCHRONIZE, &attr, &io, NULL, 0,
351 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
352
353 status = pNtQueryFullAttributesFile( &attr, &info );
355 "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
356
357 pRtlInitUnicodeString( &nameW, pathInvalidNt2W );
358 status = pNtCreateFile( &dir, GENERIC_READ|SYNCHRONIZE, &attr, &io, NULL, 0,
362 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
363
364 status = pNtQueryFullAttributesFile( &attr, &info );
366 "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
367
368 pRtlInitUnicodeString( &nameW, pathInvalidDosW );
369 status = pNtCreateFile( &dir, GENERIC_READ|SYNCHRONIZE, &attr, &io, NULL, 0,
373 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
374
375 status = pNtQueryFullAttributesFile( &attr, &info );
377 "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
378
380 path[2] = 0;
382 "QueryDosDeviceW failed with error %u\n", GetLastError() );
383 lstrcatW( temp, sepW );
384 lstrcatW( temp, path+3 );
385 lstrcatW( temp, sepW );
386 lstrcatW( temp, notepadW );
387
388 pRtlInitUnicodeString( &nameW, temp );
389 status = pNtQueryFullAttributesFile( &attr, &info );
391 "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
392
393 pRtlInitUnicodeString( &nameW, systemrootExplorerW );
394 status = pNtQueryFullAttributesFile( &attr, &info );
396 "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
397}
unsigned int dir
Definition: maze.c:112
static const WCHAR nameW[]
Definition: main.c:46
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI QueryDosDeviceW(LPCWSTR lpDeviceName, LPWSTR lpTargetPath, DWORD ucchMax)
Definition: dosdev.c:542
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
static const WCHAR systemrootW[]
Definition: path.c:4163
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_CREATE
Definition: from_kernel.h:55
#define FILE_OVERWRITE_IF
Definition: from_kernel.h:58
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_OVERWRITE
Definition: from_kernel.h:57
#define FILE_OPEN_IF
Definition: from_kernel.h:56
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define wine_dbgstr_w
Definition: kernel32.h:34
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define todo_wine
Definition: custom.c:79
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define GENERIC_WRITE
Definition: nt_native.h:90
#define STATUS_PENDING
Definition: ntstatus.h:82
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: cookie.c:202
Definition: fci.c:127
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define WAIT_OBJECT_0
Definition: winbase.h:406

Referenced by START_TEST().

◆ create_temp_file()

◆ delete_file_test()

static void delete_file_test ( void  )
static

Definition at line 603 of file file.c.

604{
608 WCHAR pathW[MAX_PATH];
609 WCHAR pathsubW[MAX_PATH];
610 static const WCHAR testdirW[] = {'n','t','d','e','l','e','t','e','f','i','l','e',0};
611 static const WCHAR subdirW[] = {'\\','s','u','b',0};
612
613 ret = GetTempPathW(MAX_PATH, pathW);
614 if (!ret)
615 {
616 ok(0, "couldn't get temp dir\n");
617 return;
618 }
619 if (ret + sizeof(testdirW)/sizeof(WCHAR)-1 + sizeof(subdirW)/sizeof(WCHAR)-1 >= MAX_PATH)
620 {
621 ok(0, "MAX_PATH exceeded in constructing paths\n");
622 return;
623 }
624
625 lstrcatW(pathW, testdirW);
626 lstrcpyW(pathsubW, pathW);
627 lstrcatW(pathsubW, subdirW);
628
629 ret = CreateDirectoryW(pathW, NULL);
630 ok(ret == TRUE, "couldn't create directory ntdeletefile\n");
631 if (!pRtlDosPathNameToNtPathName_U(pathW, &nameW, NULL, NULL))
632 {
633 ok(0,"RtlDosPathNametoNtPathName_U failed\n");
634 return;
635 }
636
637 attr.Length = sizeof(attr);
638 attr.RootDirectory = 0;
639 attr.Attributes = OBJ_CASE_INSENSITIVE;
640 attr.ObjectName = &nameW;
641 attr.SecurityDescriptor = NULL;
642 attr.SecurityQualityOfService = NULL;
643
644 /* test NtDeleteFile on an empty directory */
645 ret = pNtDeleteFile(&attr);
646 ok(ret == STATUS_SUCCESS, "NtDeleteFile should succeed in removing an empty directory\n");
647 ret = RemoveDirectoryW(pathW);
648 ok(ret == FALSE, "expected to fail removing directory, NtDeleteFile should have removed it\n");
649
650 /* test NtDeleteFile on a non-empty directory */
651 ret = CreateDirectoryW(pathW, NULL);
652 ok(ret == TRUE, "couldn't create directory ntdeletefile ?!\n");
653 ret = CreateDirectoryW(pathsubW, NULL);
654 ok(ret == TRUE, "couldn't create directory subdir\n");
655 ret = pNtDeleteFile(&attr);
656 ok(ret == STATUS_SUCCESS, "expected NtDeleteFile to ret STATUS_SUCCESS\n");
657 ret = RemoveDirectoryW(pathsubW);
658 ok(ret == TRUE, "expected to remove directory ntdeletefile\\sub\n");
659 ret = RemoveDirectoryW(pathW);
660 ok(ret == TRUE, "expected to remove directory ntdeletefile, NtDeleteFile failed.\n");
661
662 pRtlFreeUnicodeString( &nameW );
663}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define lstrcpyW
Definition: compat.h:749
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080

Referenced by START_TEST().

◆ delete_object()

static void delete_object ( WCHAR path)
static

Definition at line 1342 of file file.c.

1343{
1344 BOOL ret = DeleteFileW( path );
1346 "DeleteFileW failed with %u\n", GetLastError() );
1348 {
1350 ok( ret, "RemoveDirectoryW failed with %u\n", GetLastError() );
1351 }
1352}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79

Referenced by test_file_link_information(), and test_file_rename_information().

◆ get_msg()

static BOOL get_msg ( HANDLE  h)
static

Definition at line 156 of file file.c.

157{
158 LARGE_INTEGER timeout = {{-10000000*3}};
159 DWORD res = pNtRemoveIoCompletion( h, &completionKey, &completionValue, &ioSb, &timeout);
160 ok( res == STATUS_SUCCESS, "NtRemoveIoCompletion failed: %x\n", res );
161 if (res != STATUS_SUCCESS)
162 {
164 memset(&ioSb, 0, sizeof(ioSb));
165 return FALSE;
166 }
167 return TRUE;
168}
GLuint res
Definition: glext.h:9613
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static ULONG_PTR completionKey
Definition: file.c:140
static IO_STATUS_BLOCK ioSb
Definition: file.c:141
static ULONG_PTR completionValue
Definition: file.c:142
Definition: dhcpd.h:245

Referenced by test_iocp_fileio(), and test_iocp_setcompletion().

◆ get_pending_msgs()

static ULONG get_pending_msgs ( HANDLE  h)
static

Definition at line 144 of file file.c.

145{
147 ULONG a, req;
148
149 res = pNtQueryIoCompletion( h, IoCompletionBasicInformation, &a, sizeof(a), &req );
150 ok( res == STATUS_SUCCESS, "NtQueryIoCompletion failed: %x\n", res );
151 if (res != STATUS_SUCCESS) return -1;
152 ok( req == sizeof(a), "Unexpected response size: %x\n", req );
153 return a;
154}
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
@ IoCompletionBasicInformation
Definition: iotypes.h:233
uint32_t ULONG
Definition: typedefs.h:59

Referenced by test_iocp_fileio(), and test_iocp_setcompletion().

◆ is_signaled()

static BOOL is_signaled ( HANDLE  obj)
inlinestatic

Definition at line 116 of file file.c.

117{
118 return WaitForSingleObject( obj, 0 ) == WAIT_OBJECT_0;
119}

Referenced by read_file_test(), test_ioctl(), and test_read_write().

◆ nt_mailslot_test()

static void nt_mailslot_test ( void  )
static

Definition at line 872 of file file.c.

873{
874 HANDLE hslot;
877
879 ULONG MailslotQuota;
880 ULONG MaxMessageSize;
881 LARGE_INTEGER TimeOut;
883 NTSTATUS rc;
885 WCHAR buffer1[] = { '\\','?','?','\\','M','A','I','L','S','L','O','T','\\',
886 'R',':','\\','F','R','E','D','\0' };
887
888 TimeOut.QuadPart = -1;
889
890 pRtlInitUnicodeString(&str, buffer1);
892 CreateOptions = MailslotQuota = MaxMessageSize = 0;
894
895 /*
896 * Check for NULL pointer handling
897 */
898 rc = pNtCreateMailslotFile(NULL, DesiredAccess,
899 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
900 &TimeOut);
902 rc == STATUS_INVALID_PARAMETER, /* win2k3 */
903 "rc = %x not STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER\n", rc);
904
905 /*
906 * Test to see if the Timeout can be NULL
907 */
908 hslot = (HANDLE)0xdeadbeef;
909 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
910 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
911 NULL);
912 ok( rc == STATUS_SUCCESS ||
913 rc == STATUS_INVALID_PARAMETER, /* win2k3 */
914 "rc = %x not STATUS_SUCCESS or STATUS_INVALID_PARAMETER\n", rc);
915 ok( hslot != 0, "Handle is invalid\n");
916
917 if ( rc == STATUS_SUCCESS ) pNtClose(hslot);
918
919 /*
920 * Test a valid call
921 */
923 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
924 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
925 &TimeOut);
926 ok( rc == STATUS_SUCCESS, "Create MailslotFile failed rc = %x\n", rc);
927 ok( hslot != 0, "Handle is invalid\n");
928
929 rc = pNtClose(hslot);
930 ok( rc == STATUS_SUCCESS, "NtClose failed\n");
931}
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
const WCHAR * str
PVOID HANDLE
Definition: typedefs.h:73
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG CreateOptions
Definition: wdfregistry.h:118

Referenced by START_TEST().

◆ NTSTATUS()

static PWSTR CURDIR *static NTSTATUS ( WINAPI pRtlWow64EnableFsRedirectionEx)
static

◆ open_file_test()

static void open_file_test ( void  )
static

Definition at line 399 of file file.c.

400{
401 static const char testdata[] = "Hello World";
402 static WCHAR fooW[] = {'f','o','o',0};
406 BYTE data[1024];
410 UINT i, len;
411 BOOL ret, restart = TRUE;
412 DWORD numbytes;
413
415 pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL );
416 attr.Length = sizeof(attr);
417 attr.RootDirectory = 0;
418 attr.ObjectName = &nameW;
419 attr.Attributes = OBJ_CASE_INSENSITIVE;
420 attr.SecurityDescriptor = NULL;
421 attr.SecurityQualityOfService = NULL;
422 status = pNtOpenFile( &dir, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &io,
424 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
425 pRtlFreeUnicodeString( &nameW );
426
427 path[3] = 0; /* root of the drive */
428 pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL );
429 status = pNtOpenFile( &root, GENERIC_READ, &attr, &io,
431 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
432 pRtlFreeUnicodeString( &nameW );
433
434 /* test opening system dir with RootDirectory set to windows dir */
436 while (path[len] == '\\') len++;
437 nameW.Buffer = path + len;
438 nameW.Length = lstrlenW(path + len) * sizeof(WCHAR);
439 attr.RootDirectory = dir;
440 status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
442 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
444
445 /* try uppercase name */
446 for (i = len; path[i]; i++) if (path[i] >= 'a' && path[i] <= 'z') path[i] -= 'a' - 'A';
447 status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
449 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
451
452 /* try with leading backslash */
453 nameW.Buffer--;
454 nameW.Length += sizeof(WCHAR);
455 status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
460 "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
461 if (!status) CloseHandle( handle );
462
463 /* try with empty name */
464 nameW.Length = 0;
465 status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
467 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
469
470 /* try open by file id */
471
472 while (!pNtQueryDirectoryFile( dir, NULL, NULL, NULL, &io, data, sizeof(data),
474 {
476
477 restart = FALSE;
478
479 if (!info->FileId.QuadPart) continue;
480
481 nameW.Buffer = (WCHAR *)&info->FileId;
482 nameW.Length = sizeof(info->FileId);
483 info->FileName[info->FileNameLength/sizeof(WCHAR)] = 0;
484 attr.RootDirectory = dir;
485 /* We skip 'open' files by not specifying FILE_SHARE_WRITE */
486 status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
489 ((info->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FILE_DIRECTORY_FILE : 0) );
491 "open %s failed %x\n", wine_dbgstr_w(info->FileName), status );
493 {
494 win_skip( "FILE_OPEN_BY_FILE_ID not supported\n" );
495 break;
496 }
498 trace( "%s is currently open\n", wine_dbgstr_w(info->FileName) );
499 if (!status)
500 {
501 BYTE buf[sizeof(FILE_ALL_INFORMATION) + MAX_PATH * sizeof(WCHAR)];
502
503 if (!pNtQueryInformationFile( handle, &io, buf, sizeof(buf), FileAllInformation ))
504 {
506
507 /* check that it's the same file/directory */
508
509 /* don't check the size for directories */
510 if (!(info->FileAttributes & FILE_ATTRIBUTE_DIRECTORY))
511 ok( info->EndOfFile.QuadPart == fai->StandardInformation.EndOfFile.QuadPart,
512 "mismatched file size for %s\n", wine_dbgstr_w(info->FileName));
513
514 ok( info->CreationTime.QuadPart == fai->BasicInformation.CreationTime.QuadPart,
515 "mismatched creation time for %s\n", wine_dbgstr_w(info->FileName));
516 }
518
519 /* try same thing from drive root */
520 attr.RootDirectory = root;
521 status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
524 ((info->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FILE_DIRECTORY_FILE : 0) );
526 "open %s failed %x\n", wine_dbgstr_w(info->FileName), status );
527 if (!status) CloseHandle( handle );
528 }
529 }
530
531 CloseHandle( dir );
532 CloseHandle( root );
533
536 pRtlDosPathNameToNtPathName_U( tmpfile, &nameW, NULL, NULL );
537
539 ok( file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError() );
540 numbytes = 0xdeadbeef;
541 ret = WriteFile( file, testdata, sizeof(testdata) - 1, &numbytes, NULL );
542 ok( ret, "WriteFile failed with error %u\n", GetLastError() );
543 ok( numbytes == sizeof(testdata) - 1, "failed to write all data\n" );
544 CloseHandle( file );
545
546 attr.Length = sizeof(attr);
547 attr.RootDirectory = 0;
548 attr.ObjectName = &nameW;
549 attr.Attributes = OBJ_CASE_INSENSITIVE;
550 attr.SecurityDescriptor = NULL;
551 attr.SecurityQualityOfService = NULL;
552 status = pNtOpenFile( &file, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &io,
554 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
555 pRtlFreeUnicodeString( &nameW );
556
557 numbytes = 0xdeadbeef;
558 memset( data, 0, sizeof(data) );
559 ret = ReadFile( file, data, sizeof(data), &numbytes, NULL );
560 ok( ret, "ReadFile failed with error %u\n", GetLastError() );
561 ok( numbytes == sizeof(testdata) - 1, "failed to read all data\n" );
562 ok( !memcmp( data, testdata, sizeof(testdata) - 1 ), "testdata doesn't match\n" );
563
564 nameW.Length = sizeof(fooW) - sizeof(WCHAR);
565 nameW.Buffer = fooW;
566 attr.RootDirectory = file;
567 attr.ObjectName = &nameW;
568 status = pNtOpenFile( &root, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &io,
571 "expected STATUS_OBJECT_PATH_NOT_FOUND, got %08x\n", status );
572
573 nameW.Length = 0;
574 nameW.Buffer = NULL;
575 attr.RootDirectory = file;
576 attr.ObjectName = &nameW;
577 status = pNtOpenFile( &root, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &io,
579 ok( !status, "open %s failed %x\n", wine_dbgstr_w(tmpfile), status );
580
581 numbytes = SetFilePointer( file, 0, 0, FILE_CURRENT );
582 ok( numbytes == sizeof(testdata) - 1, "SetFilePointer returned %u\n", numbytes );
583 numbytes = SetFilePointer( root, 0, 0, FILE_CURRENT );
584 ok( numbytes == 0, "SetFilePointer returned %u\n", numbytes );
585
586 numbytes = 0xdeadbeef;
587 memset( data, 0, sizeof(data) );
588 ret = ReadFile( root, data, sizeof(data), &numbytes, NULL );
589 ok( ret, "ReadFile failed with error %u\n", GetLastError() );
590 ok( numbytes == sizeof(testdata) - 1, "failed to read all data\n" );
591 ok( !memcmp( data, testdata, sizeof(testdata) - 1 ), "testdata doesn't match\n" );
592
593 numbytes = SetFilePointer( file, 0, 0, FILE_CURRENT );
594 ok( numbytes == sizeof(testdata) - 1, "SetFilePointer returned %u\n", numbytes );
595 numbytes = SetFilePointer( root, 0, 0, FILE_CURRENT );
596 ok( numbytes == sizeof(testdata) - 1, "SetFilePointer returned %u\n", numbytes );
597
598 CloseHandle( file );
599 CloseHandle( root );
601}
void restart(int argc, const char *argv[])
Definition: cmds.c:2115
struct _root root
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define CreateFileW
Definition: compat.h:741
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
#define FILE_OPEN_BY_FILE_ID
Definition: from_kernel.h:41
@ FileAllInformation
Definition: from_kernel.h:79
@ FileIdBothDirectoryInformation
Definition: from_kernel.h:98
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ _CRTIMP FILE *__cdecl tmpfile(void)
Definition: file.c:3914
struct _FILE_ALL_INFORMATION FILE_ALL_INFORMATION
static const WCHAR fooW[]
Definition: locale.c:44
unsigned int UINT
Definition: ndis.h:50
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:295
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define win_skip
Definition: test.h:160
FILE_STANDARD_INFORMATION StandardInformation
Definition: winternl.h:797
FILE_BASIC_INFORMATION BasicInformation
Definition: winternl.h:796
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
#define STATUS_SHARING_VIOLATION
Definition: udferr_usr.h:154
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ read_file_test()

static void read_file_test ( void  )
static

Definition at line 665 of file file.c.

666{
667 const char text[] = "foobar";
671 int apc_count = 0;
672 char buffer[128];
674 HANDLE event = CreateEventA( NULL, TRUE, FALSE, NULL );
675
676 if (!(handle = create_temp_file( FILE_FLAG_OVERLAPPED ))) return;
677 apc_count = 0;
678 U(iosb).Status = 0xdeadbabe;
679 iosb.Information = 0xdeadbeef;
680 offset.QuadPart = 0;
681 ResetEvent( event );
682 status = pNtWriteFile( handle, event, apc, &apc_count, &iosb, text, strlen(text), &offset, NULL );
683 ok( status == STATUS_SUCCESS || status == STATUS_PENDING, "wrong status %x\n", status );
685 ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
686 ok( iosb.Information == strlen(text), "wrong info %lu\n", iosb.Information );
687 ok( is_signaled( event ), "event is not signaled\n" );
688 ok( !apc_count, "apc was called\n" );
689 SleepEx( 1, TRUE ); /* alertable sleep */
690 ok( apc_count == 1, "apc was not called\n" );
691
692 apc_count = 0;
693 U(iosb).Status = 0xdeadbabe;
694 iosb.Information = 0xdeadbeef;
695 offset.QuadPart = 0;
696 ResetEvent( event );
697 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, strlen(text) + 10, &offset, NULL );
699 status == STATUS_PENDING, /* vista */
700 "wrong status %x\n", status );
702 ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
703 ok( iosb.Information == strlen(text), "wrong info %lu\n", iosb.Information );
704 ok( is_signaled( event ), "event is not signaled\n" );
705 ok( !apc_count, "apc was called\n" );
706 SleepEx( 1, TRUE ); /* alertable sleep */
707 ok( apc_count == 1, "apc was not called\n" );
708
709 /* read beyond eof */
710 apc_count = 0;
711 U(iosb).Status = 0xdeadbabe;
712 iosb.Information = 0xdeadbeef;
713 offset.QuadPart = strlen(text) + 2;
714 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, &offset, NULL );
715 ok(status == STATUS_PENDING || status == STATUS_END_OF_FILE /* before Vista */, "expected STATUS_PENDING or STATUS_END_OF_FILE, got %#x\n", status);
716 if (status == STATUS_PENDING) /* vista */
717 {
718 WaitForSingleObject( event, 1000 );
719 ok( U(iosb).Status == STATUS_END_OF_FILE, "wrong status %x\n", U(iosb).Status );
720 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
721 ok( is_signaled( event ), "event is not signaled\n" );
722 ok( !apc_count, "apc was called\n" );
723 SleepEx( 1, TRUE ); /* alertable sleep */
724 ok( apc_count == 1, "apc was not called\n" );
725 }
727
728 /* now a non-overlapped file */
729 if (!(handle = create_temp_file(0))) return;
730 apc_count = 0;
731 U(iosb).Status = 0xdeadbabe;
732 iosb.Information = 0xdeadbeef;
733 offset.QuadPart = 0;
734 status = pNtWriteFile( handle, event, apc, &apc_count, &iosb, text, strlen(text), &offset, NULL );
737 status == STATUS_PENDING, /* vista */
738 "wrong status %x\n", status );
740 ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
741 ok( iosb.Information == strlen(text), "wrong info %lu\n", iosb.Information );
742 ok( is_signaled( event ), "event is not signaled\n" );
743 ok( !apc_count, "apc was called\n" );
744 SleepEx( 1, TRUE ); /* alertable sleep */
745 ok( apc_count == 1, "apc was not called\n" );
746
747 apc_count = 0;
748 U(iosb).Status = 0xdeadbabe;
749 iosb.Information = 0xdeadbeef;
750 offset.QuadPart = 0;
751 ResetEvent( event );
752 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, strlen(text) + 10, &offset, NULL );
753 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
754 ok( U(iosb).Status == STATUS_SUCCESS, "wrong status %x\n", U(iosb).Status );
755 ok( iosb.Information == strlen(text), "wrong info %lu\n", iosb.Information );
756 ok( is_signaled( event ), "event is not signaled\n" );
757 ok( !apc_count, "apc was called\n" );
758 SleepEx( 1, TRUE ); /* alertable sleep */
759 todo_wine ok( !apc_count, "apc was called\n" );
760
761 /* read beyond eof */
762 apc_count = 0;
763 U(iosb).Status = 0xdeadbabe;
764 iosb.Information = 0xdeadbeef;
765 offset.QuadPart = strlen(text) + 2;
766 ResetEvent( event );
767 status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, &offset, NULL );
768 ok( status == STATUS_END_OF_FILE, "wrong status %x\n", status );
769 ok( U(iosb).Status == STATUS_END_OF_FILE, "wrong status %x\n", U(iosb).Status );
770 ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
771 ok( is_signaled( event ), "event is not signaled\n" );
772 ok( !apc_count, "apc was called\n" );
773 SleepEx( 1, TRUE ); /* alertable sleep */
774 ok( !apc_count, "apc was called\n" );
775
777
779}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct _cl_event * event
Definition: glext.h:7739
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
static HANDLE PIO_APC_ROUTINE apc
Definition: file.c:89
static HANDLE create_temp_file(ULONG flags)
Definition: file.c:123
static BOOL is_signaled(HANDLE obj)
Definition: file.c:116
#define STATUS_END_OF_FILE
Definition: shellext.h:67
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( file  )

Definition at line 4713 of file file.c.

4714{
4715 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
4716 HMODULE hntdll = GetModuleHandleA("ntdll.dll");
4717 if (!hntdll)
4718 {
4719 skip("not running on NT, skipping test\n");
4720 return;
4721 }
4722
4723 pGetVolumePathNameW = (void *)GetProcAddress(hkernel32, "GetVolumePathNameW");
4724 pGetSystemWow64DirectoryW = (void *)GetProcAddress(hkernel32, "GetSystemWow64DirectoryW");
4725
4726 pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
4727 pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
4728 pRtlDosPathNameToNtPathName_U = (void *)GetProcAddress(hntdll, "RtlDosPathNameToNtPathName_U");
4729 pRtlWow64EnableFsRedirectionEx = (void *)GetProcAddress(hntdll, "RtlWow64EnableFsRedirectionEx");
4730 pNtCreateMailslotFile = (void *)GetProcAddress(hntdll, "NtCreateMailslotFile");
4731 pNtCreateFile = (void *)GetProcAddress(hntdll, "NtCreateFile");
4732 pNtOpenFile = (void *)GetProcAddress(hntdll, "NtOpenFile");
4733 pNtDeleteFile = (void *)GetProcAddress(hntdll, "NtDeleteFile");
4734 pNtReadFile = (void *)GetProcAddress(hntdll, "NtReadFile");
4735 pNtWriteFile = (void *)GetProcAddress(hntdll, "NtWriteFile");
4736 pNtCancelIoFile = (void *)GetProcAddress(hntdll, "NtCancelIoFile");
4737 pNtCancelIoFileEx = (void *)GetProcAddress(hntdll, "NtCancelIoFileEx");
4738 pNtClose = (void *)GetProcAddress(hntdll, "NtClose");
4739 pNtFsControlFile = (void *)GetProcAddress(hntdll, "NtFsControlFile");
4740 pNtCreateIoCompletion = (void *)GetProcAddress(hntdll, "NtCreateIoCompletion");
4741 pNtOpenIoCompletion = (void *)GetProcAddress(hntdll, "NtOpenIoCompletion");
4742 pNtQueryIoCompletion = (void *)GetProcAddress(hntdll, "NtQueryIoCompletion");
4743 pNtRemoveIoCompletion = (void *)GetProcAddress(hntdll, "NtRemoveIoCompletion");
4744 pNtSetIoCompletion = (void *)GetProcAddress(hntdll, "NtSetIoCompletion");
4745 pNtSetInformationFile = (void *)GetProcAddress(hntdll, "NtSetInformationFile");
4746 pNtQueryInformationFile = (void *)GetProcAddress(hntdll, "NtQueryInformationFile");
4747 pNtQueryDirectoryFile = (void *)GetProcAddress(hntdll, "NtQueryDirectoryFile");
4748 pNtQueryVolumeInformationFile = (void *)GetProcAddress(hntdll, "NtQueryVolumeInformationFile");
4749 pNtQueryFullAttributesFile = (void *)GetProcAddress(hntdll, "NtQueryFullAttributesFile");
4750 pNtFlushBuffersFile = (void *)GetProcAddress(hntdll, "NtFlushBuffersFile");
4751 pNtQueryEaFile = (void *)GetProcAddress(hntdll, "NtQueryEaFile");
4752
4755 test_readonly();
4777 test_ioctl();
4779 test_query_ea();
4781}
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_read_write(void)
Definition: file.c:3130
static HINSTANCE hkernel32
Definition: process.c:66
static HINSTANCE hntdll
Definition: process.c:66
static void append_file_test(void)
Definition: file.c:781
static void test_file_both_information(void)
Definition: file.c:2615
static void test_file_all_name_information(void)
Definition: file.c:3021
static void test_file_link_information(void)
Definition: file.c:1986
static void test_query_ea(void)
Definition: file.c:4462
static void test_file_basic_information(void)
Definition: file.c:1212
static void test_readonly(void)
Definition: file.c:3549
static void test_file_access_information(void)
Definition: file.c:3340
static void test_NtCreateFile(void)
Definition: file.c:3462
static void open_file_test(void)
Definition: file.c:399
static void test_junction_points(void)
Definition: file.c:4561
static void test_iocompletion(void)
Definition: file.c:2874
static void test_query_volume_information_file(void)
Definition: file.c:3363
static void test_query_attribute_information_file(void)
Definition: file.c:3416
static void create_file_test(void)
Definition: file.c:181
static void test_file_name_information(void)
Definition: file.c:2892
static void test_file_disposition_information(void)
Definition: file.c:2631
static void test_file_rename_information(void)
Definition: file.c:1354
static void test_file_completion_information(void)
Definition: file.c:3156
static void test_file_full_size_information(void)
Definition: file.c:1156
static void test_flush_buffers_file(void)
Definition: file.c:4415
static void test_file_id_information(void)
Definition: file.c:3301
static void test_ioctl(void)
Definition: file.c:4384
static void delete_file_test(void)
Definition: file.c:603
static void test_file_all_information(void)
Definition: file.c:1272
static void read_file_test(void)
Definition: file.c:665
static void nt_mailslot_test(void)
Definition: file.c:872

◆ test_file_access_information()

static void test_file_access_information ( void  )
static

Definition at line 3340 of file file.c.

3341{
3345 HANDLE h;
3346
3347 if (!(h = create_temp_file(0))) return;
3348
3349 status = pNtQueryInformationFile( h, &io, &info, sizeof(info) - 1, FileAccessInformation );
3350 ok( status == STATUS_INFO_LENGTH_MISMATCH, "expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status );
3351
3352 status = pNtQueryInformationFile( (HANDLE)0xdeadbeef, &io, &info, sizeof(info), FileAccessInformation );
3353 ok( status == STATUS_INVALID_HANDLE, "expected STATUS_INVALID_HANDLE, got %08x\n", status );
3354
3355 memset(&info, 0x11, sizeof(info));
3356 status = pNtQueryInformationFile( h, &io, &info, sizeof(info), FileAccessInformation );
3357 ok( status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status );
3358 ok( info.AccessFlags == 0x13019f, "got %08x\n", info.AccessFlags );
3359
3360 CloseHandle( h );
3361}
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define FileAccessInformation
Definition: propsheet.cpp:51
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133

Referenced by START_TEST().

◆ test_file_all_information()

static void test_file_all_information ( void  )
static

Definition at line 1272 of file file.c.

1273{
1275 /* FileAllInformation, like FileNameInformation, has a variable-length pathname
1276 * buffer at the end. Vista objects with STATUS_BUFFER_OVERFLOW if you
1277 * don't leave enough room there.
1278 */
1279 struct {
1281 WCHAR buf[256];
1282 } fai_buf;
1283 HANDLE h;
1284 int res;
1286
1287 if (!(h = create_temp_file(0))) return;
1288
1289 /* Check default first */
1290 res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
1291 ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);
1292 ok ( (fai_buf.fai.BasicInformation.FileAttributes & FILE_ATTRIBUTE_ARCHIVE) == FILE_ATTRIBUTE_ARCHIVE,
1293 "attribute %x not expected\n", fai_buf.fai.BasicInformation.FileAttributes );
1294
1295 /* Then SYSTEM */
1296 /* Clear fbi to avoid setting times */
1297 memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
1298 fai_buf.fai.BasicInformation.FileAttributes = FILE_ATTRIBUTE_SYSTEM;
1299 U(io).Status = 0xdeadbeef;
1300 res = pNtSetInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
1301 ok ( res == STATUS_INVALID_INFO_CLASS || broken(res == STATUS_NOT_IMPLEMENTED), "shouldn't be able to set FileAllInformation, res %x\n", res);
1302 todo_wine ok ( U(io).Status == 0xdeadbeef, "shouldn't be able to set FileAllInformation, io.Status is %x\n", U(io).Status);
1303 U(io).Status = 0xdeadbeef;
1304 res = pNtSetInformationFile(h, &io, &fai_buf.fai.BasicInformation, sizeof fai_buf.fai.BasicInformation, FileBasicInformation);
1305 ok ( res == STATUS_SUCCESS, "can't set system attribute, res: %x\n", res );
1306 ok ( U(io).Status == STATUS_SUCCESS, "can't set system attribute, io.Status: %x\n", U(io).Status );
1307
1308 memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
1309 res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
1310 ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);
1311 ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM (ok in old linux without xattr)\n", fai_buf.fai.BasicInformation.FileAttributes );
1312
1313 /* Then HIDDEN */
1314 memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
1315 fai_buf.fai.BasicInformation.FileAttributes = FILE_ATTRIBUTE_HIDDEN;
1316 U(io).Status = 0xdeadbeef;
1317 res = pNtSetInformationFile(h, &io, &fai_buf.fai.BasicInformation, sizeof fai_buf.fai.BasicInformation, FileBasicInformation);
1318 ok ( res == STATUS_SUCCESS, "can't set system attribute, res: %x\n", res );
1319 ok ( U(io).Status == STATUS_SUCCESS, "can't set system attribute, io.Status: %x\n", U(io).Status );
1320
1321 memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
1322 res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
1323 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
1324 ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN (ok in old linux without xattr)\n", fai_buf.fai.BasicInformation.FileAttributes );
1325
1326 /* Check NORMAL last of all (to make sure we can clear attributes) */
1327 memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
1328 fai_buf.fai.BasicInformation.FileAttributes = FILE_ATTRIBUTE_NORMAL;
1329 U(io).Status = 0xdeadbeef;
1330 res = pNtSetInformationFile(h, &io, &fai_buf.fai.BasicInformation, sizeof fai_buf.fai.BasicInformation, FileBasicInformation);
1331 ok ( res == STATUS_SUCCESS, "can't set system attribute, res: %x\n", res );
1332 ok ( U(io).Status == STATUS_SUCCESS, "can't set system attribute, io.Status: %x\n", U(io).Status );
1333
1334 memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
1335 res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
1336 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
1337 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
1339 CloseHandle( h );
1340}
#define broken(x)
Definition: _sntprintf.h:21
@ FileBasicInformation
Definition: from_kernel.h:65
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240

Referenced by START_TEST().

◆ test_file_all_name_information()

static void test_file_all_name_information ( void  )
static

Definition at line 3021 of file file.c.

3022{
3023 WCHAR *file_name, *volume_prefix, *expected;
3025 ULONG old_redir = 1, tmp;
3026 UINT file_name_size;
3028 UINT info_size;
3029 HRESULT hr;
3030 HANDLE h;
3031 UINT len;
3032
3033 /* GetVolumePathName is not present before w2k */
3034 if (!pGetVolumePathNameW) {
3035 win_skip("GetVolumePathNameW not found\n");
3036 return;
3037 }
3038
3039 file_name_size = GetSystemDirectoryW( NULL, 0 );
3040 file_name = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*file_name) );
3041 volume_prefix = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) );
3042 expected = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) );
3043
3044 len = GetSystemDirectoryW( file_name, file_name_size );
3045 ok(len == file_name_size - 1,
3046 "GetSystemDirectoryW returned %u, expected %u.\n",
3047 len, file_name_size - 1);
3048
3049 len = pGetVolumePathNameW( file_name, volume_prefix, file_name_size );
3050 ok(len, "GetVolumePathNameW failed.\n");
3051
3052 len = lstrlenW( volume_prefix );
3053 if (len && volume_prefix[len - 1] == '\\') --len;
3054 memcpy( expected, file_name + len, (file_name_size - len - 1) * sizeof(WCHAR) );
3055 expected[file_name_size - len - 1] = '\0';
3056
3057 /* A bit more than we actually need, but it keeps the calculation simple. */
3058 info_size = sizeof(*info) + (file_name_size * sizeof(WCHAR));
3059 info = HeapAlloc( GetProcessHeap(), 0, info_size );
3060
3061 if (pRtlWow64EnableFsRedirectionEx) pRtlWow64EnableFsRedirectionEx( TRUE, &old_redir );
3065 if (pRtlWow64EnableFsRedirectionEx) pRtlWow64EnableFsRedirectionEx( old_redir, &tmp );
3066 ok(h != INVALID_HANDLE_VALUE, "Failed to open file.\n");
3067
3068 hr = pNtQueryInformationFile( h, &io, info, sizeof(*info) - 1, FileAllInformation );
3069 ok(hr == STATUS_INFO_LENGTH_MISMATCH, "NtQueryInformationFile returned %#x, expected %#x.\n",
3071
3072 memset( info, 0xcc, info_size );
3073 hr = pNtQueryInformationFile( h, &io, info, sizeof(*info), FileAllInformation );
3074 ok(hr == STATUS_BUFFER_OVERFLOW, "NtQueryInformationFile returned %#x, expected %#x.\n",
3076 ok(U(io).Status == STATUS_BUFFER_OVERFLOW, "io.Status is %#x, expected %#x.\n",
3078 ok(info->NameInformation.FileNameLength == lstrlenW( expected ) * sizeof(WCHAR),
3079 "info->NameInformation.FileNameLength is %u\n", info->NameInformation.FileNameLength );
3080 ok(info->NameInformation.FileName[2] == 0xcccc,
3081 "info->NameInformation.FileName[2] is %#x, expected 0xcccc.\n", info->NameInformation.FileName[2]);
3082 ok(CharLowerW((LPWSTR)(UINT_PTR)info->NameInformation.FileName[1]) == CharLowerW((LPWSTR)(UINT_PTR)expected[1]),
3083 "info->NameInformation.FileName[1] is %p, expected %p.\n",
3084 CharLowerW((LPWSTR)(UINT_PTR)info->NameInformation.FileName[1]), CharLowerW((LPWSTR)(UINT_PTR)expected[1]));
3085 ok(io.Information == sizeof(*info), "io.Information is %lu\n", io.Information);
3086
3087 memset( info, 0xcc, info_size );
3088 hr = pNtQueryInformationFile( h, &io, info, info_size, FileAllInformation );
3089 ok(hr == STATUS_SUCCESS, "NtQueryInformationFile returned %#x, expected %#x.\n", hr, STATUS_SUCCESS);
3090 ok(U(io).Status == STATUS_SUCCESS, "io.Status is %#x, expected %#x.\n", U(io).Status, STATUS_SUCCESS);
3091 ok(info->NameInformation.FileNameLength == lstrlenW( expected ) * sizeof(WCHAR),
3092 "info->NameInformation.FileNameLength is %u\n", info->NameInformation.FileNameLength );
3093 ok(info->NameInformation.FileName[info->NameInformation.FileNameLength / sizeof(WCHAR)] == 0xcccc,
3094 "info->NameInformation.FileName[len] is %#x, expected 0xcccc.\n",
3095 info->NameInformation.FileName[info->NameInformation.FileNameLength / sizeof(WCHAR)]);
3096 info->NameInformation.FileName[info->NameInformation.FileNameLength / sizeof(WCHAR)] = '\0';
3097 ok(!lstrcmpiW( info->NameInformation.FileName, expected ),
3098 "info->NameInformation.FileName is %s, expected %s.\n",
3099 wine_dbgstr_w( info->NameInformation.FileName ), wine_dbgstr_w( expected ));
3100 ok(io.Information == FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName)
3101 + info->NameInformation.FileNameLength,
3102 "io.Information is %lu\n", io.Information );
3103
3104 CloseHandle( h );
3105 HeapFree( GetProcessHeap(), 0, info );
3107 HeapFree( GetProcessHeap(), 0, volume_prefix );
3108
3109 if (old_redir || !pGetSystemWow64DirectoryW || !(file_name_size = pGetSystemWow64DirectoryW( NULL, 0 )))
3110 {
3111 skip("Not running on WoW64, skipping test.\n");
3113 return;
3114 }
3115
3119 ok(h != INVALID_HANDLE_VALUE, "Failed to open file.\n");
3121
3122 file_name = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*file_name) );
3123 volume_prefix = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) );
3124 expected = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*expected) );
3125
3126 len = pGetSystemWow64DirectoryW( file_name, file_name_size );
3127 ok(len == file_name_size - 1,
3128 "GetSystemWow64DirectoryW returned %u, expected %u.\n",
3129 len, file_name_size - 1);
3130
3131 len = pGetVolumePathNameW( file_name, volume_prefix, file_name_size );
3132 ok(len, "GetVolumePathNameW failed.\n");
3133
3134 len = lstrlenW( volume_prefix );
3135 if (len && volume_prefix[len - 1] == '\\') --len;
3136 memcpy( expected, file_name + len, (file_name_size - len - 1) * sizeof(WCHAR) );
3137 expected[file_name_size - len - 1] = '\0';
3138
3139 info_size = sizeof(*info) + (file_name_size * sizeof(WCHAR));
3140 info = HeapAlloc( GetProcessHeap(), 0, info_size );
3141
3142 memset( info, 0xcc, info_size );
3143 hr = pNtQueryInformationFile( h, &io, info, info_size, FileAllInformation );
3144 ok(hr == STATUS_SUCCESS, "NtQueryInformationFile returned %#x, expected %#x.\n", hr, STATUS_SUCCESS);
3145 info->NameInformation.FileName[info->NameInformation.FileNameLength / sizeof(WCHAR)] = '\0';
3146 ok(!lstrcmpiW( info->NameInformation.FileName, expected ), "info->NameInformation.FileName is %s, expected %s.\n",
3147 wine_dbgstr_w( info->NameInformation.FileName ), wine_dbgstr_w( expected ));
3148
3149 CloseHandle( h );
3150 HeapFree( GetProcessHeap(), 0, info );
3152 HeapFree( GetProcessHeap(), 0, volume_prefix );
3154}
#define HeapFree(x, y, z)
Definition: compat.h:735
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
BOOL expected
Definition: file.c:2511
static LPCWSTR file_name
Definition: protocol.c:147
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
HRESULT hr
Definition: shlfolder.c:183
LPWSTR WINAPI CharLowerW(_Inout_ LPWSTR)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by START_TEST().

◆ test_file_basic_information()

static void test_file_basic_information ( void  )
static

Definition at line 1212 of file file.c.

1213{
1216 HANDLE h;
1217 int res;
1219
1220 if (!(h = create_temp_file(0))) return;
1221
1222 /* Check default first */
1223 memset(&fbi, 0, sizeof(fbi));
1224 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
1225 ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);
1227 "attribute %x not expected\n", fbi.FileAttributes );
1228
1229 /* Then SYSTEM */
1230 /* Clear fbi to avoid setting times */
1231 memset(&fbi, 0, sizeof(fbi));
1233 U(io).Status = 0xdeadbeef;
1234 res = pNtSetInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
1235 ok ( res == STATUS_SUCCESS, "can't set system attribute, NtSetInformationFile returned %x\n", res );
1236 ok ( U(io).Status == STATUS_SUCCESS, "can't set system attribute, io.Status is %x\n", U(io).Status );
1237
1238 memset(&fbi, 0, sizeof(fbi));
1239 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
1240 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
1241 ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM (ok in old linux without xattr)\n", fbi.FileAttributes );
1242
1243 /* Then HIDDEN */
1244 memset(&fbi, 0, sizeof(fbi));
1246 U(io).Status = 0xdeadbeef;
1247 res = pNtSetInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
1248 ok ( res == STATUS_SUCCESS, "can't set system attribute, NtSetInformationFile returned %x\n", res );
1249 ok ( U(io).Status == STATUS_SUCCESS, "can't set system attribute, io.Status is %x\n", U(io).Status );
1250
1251 memset(&fbi, 0, sizeof(fbi));
1252 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
1253 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
1254 ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN (ok in old linux without xattr)\n", fbi.FileAttributes );
1255
1256 /* Check NORMAL last of all (to make sure we can clear attributes) */
1257 memset(&fbi, 0, sizeof(fbi));
1259 U(io).Status = 0xdeadbeef;
1260 res = pNtSetInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
1261 ok ( res == STATUS_SUCCESS, "can't set normal attribute, NtSetInformationFile returned %x\n", res );
1262 ok ( U(io).Status == STATUS_SUCCESS, "can't set normal attribute, io.Status is %x\n", U(io).Status );
1263
1264 memset(&fbi, 0, sizeof(fbi));
1265 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
1266 ok ( res == STATUS_SUCCESS, "can't get attributes\n");
1267 todo_wine ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_NORMAL, "attribute %x not 0\n", fbi.FileAttributes );
1268
1269 CloseHandle( h );
1270}

Referenced by START_TEST().

◆ test_file_both_information()

static void test_file_both_information ( void  )
static

Definition at line 2615 of file file.c.

2616{
2619 HANDLE h;
2620 int res;
2621
2622 if (!(h = create_temp_file(0))) return;
2623
2624 memset(&fbi, 0, sizeof(fbi));
2625 res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBothDirectoryInformation);
2626 ok ( res == STATUS_INVALID_INFO_CLASS || res == STATUS_NOT_IMPLEMENTED, "shouldn't be able to query FileBothDirectoryInformation, res %x\n", res);
2627
2628 CloseHandle( h );
2629}
@ FileBothDirectoryInformation
Definition: from_kernel.h:64

Referenced by START_TEST().

◆ test_file_completion_information()

static void test_file_completion_information ( void  )
static

Definition at line 3156 of file file.c.

3157{
3158 static const char buf[] = "testdata";
3160 OVERLAPPED ov, *pov;
3163 DWORD num_bytes;
3164 HANDLE port, h;
3165 ULONG_PTR key;
3166 BOOL ret;
3167 int i;
3168
3169 if (!(h = create_temp_file(0))) return;
3170
3171 status = pNtSetInformationFile(h, &io, &info, sizeof(info) - 1, FileIoCompletionNotificationInformation);
3173 "expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
3175 {
3176 win_skip("FileIoCompletionNotificationInformation class not supported\n");
3177 CloseHandle(h);
3178 return;
3179 }
3180
3182 status = pNtSetInformationFile(h, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
3183 ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %08x\n", status);
3184
3185 CloseHandle(h);
3186 if (!(h = create_temp_file(FILE_FLAG_OVERLAPPED))) return;
3187
3189 status = pNtSetInformationFile(h, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
3190 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
3191
3193 status = pNtSetInformationFile(h, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
3194 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
3195
3196 CloseHandle(h);
3197 if (!(h = create_temp_file(FILE_FLAG_OVERLAPPED))) return;
3198
3199 info.Flags = ~0U;
3200 status = pNtQueryInformationFile(h, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
3201 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
3202 ok(!(info.Flags & FILE_SKIP_COMPLETION_PORT_ON_SUCCESS), "got %08x\n", info.Flags);
3203
3204 memset(&ov, 0, sizeof(ov));
3206 port = CreateIoCompletionPort(h, NULL, 0xdeadbeef, 0);
3207 ok(port != NULL, "CreateIoCompletionPort failed, error %u\n", GetLastError());
3208
3209 for (i = 0; i < 10; i++)
3210 {
3211 SetLastError(0xdeadbeef);
3212 ret = WriteFile(h, buf, sizeof(buf), &num_bytes, &ov);
3213 if (ret || GetLastError() != ERROR_IO_PENDING) break;
3214 ret = GetOverlappedResult(h, &ov, &num_bytes, TRUE);
3215 ok(ret, "GetOverlappedResult failed, error %u\n", GetLastError());
3216 ret = GetQueuedCompletionStatus(port, &num_bytes, &key, &pov, 1000);
3217 ok(ret, "GetQueuedCompletionStatus failed, error %u\n", GetLastError());
3218 ret = FALSE;
3219 }
3220 if (ret)
3221 {
3222 ok(num_bytes == sizeof(buf), "expected sizeof(buf), got %u\n", num_bytes);
3223
3224 key = 0;
3225 pov = NULL;
3226 ret = GetQueuedCompletionStatus(port, &num_bytes, &key, &pov, 1000);
3227 ok(ret, "GetQueuedCompletionStatus failed, error %u\n", GetLastError());
3228 ok(key == 0xdeadbeef, "expected 0xdeadbeef, got %lx\n", key);
3229 ok(pov == &ov, "expected %p, got %p\n", &ov, pov);
3230 }
3231 else
3232 win_skip("WriteFile never returned TRUE\n");
3233
3235 status = pNtSetInformationFile(h, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
3236 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
3237
3238 info.Flags = 0;
3239 status = pNtQueryInformationFile(h, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
3240 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
3241 ok((info.Flags & FILE_SKIP_COMPLETION_PORT_ON_SUCCESS) != 0, "got %08x\n", info.Flags);
3242
3243 for (i = 0; i < 10; i++)
3244 {
3245 SetLastError(0xdeadbeef);
3246 ret = WriteFile(h, buf, sizeof(buf), &num_bytes, &ov);
3247 if (ret || GetLastError() != ERROR_IO_PENDING) break;
3248 ret = GetOverlappedResult(h, &ov, &num_bytes, TRUE);
3249 ok(ret, "GetOverlappedResult failed, error %u\n", GetLastError());
3250 ret = FALSE;
3251 }
3252 if (ret)
3253 {
3254 ok(num_bytes == sizeof(buf), "expected sizeof(buf), got %u\n", num_bytes);
3255
3256 pov = (void *)0xdeadbeef;
3257 ret = GetQueuedCompletionStatus(port, &num_bytes, &key, &pov, 500);
3258 ok(!ret, "GetQueuedCompletionStatus succeeded\n");
3259 ok(pov == NULL, "expected NULL, got %p\n", pov);
3260 }
3261 else
3262 win_skip("WriteFile never returned TRUE\n");
3263
3264 info.Flags = 0;
3265 status = pNtSetInformationFile(h, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
3266 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
3267
3268 info.Flags = 0;
3269 status = pNtQueryInformationFile(h, &io, &info, sizeof(info), FileIoCompletionNotificationInformation);
3270 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
3271 ok((info.Flags & FILE_SKIP_COMPLETION_PORT_ON_SUCCESS) != 0, "got %08x\n", info.Flags);
3272
3273 for (i = 0; i < 10; i++)
3274 {
3275 SetLastError(0xdeadbeef);
3276 ret = WriteFile(h, buf, sizeof(buf), &num_bytes, &ov);
3277 if (ret || GetLastError() != ERROR_IO_PENDING) break;
3278 ret = GetOverlappedResult(h, &ov, &num_bytes, TRUE);
3279 ok(ret, "GetOverlappedResult failed, error %u\n", GetLastError());
3280 ret = GetQueuedCompletionStatus(port, &num_bytes, &key, &pov, 1000);
3281 ok(ret, "GetQueuedCompletionStatus failed, error %u\n", GetLastError());
3282 ret = FALSE;
3283 }
3284 if (ret)
3285 {
3286 ok(num_bytes == sizeof(buf), "expected sizeof(buf), got %u\n", num_bytes);
3287
3288 pov = (void *)0xdeadbeef;
3289 ret = GetQueuedCompletionStatus(port, &num_bytes, &key, &pov, 1000);
3290 ok(!ret, "GetQueuedCompletionStatus succeeded\n");
3291 ok(pov == NULL, "expected NULL, got %p\n", pov);
3292 }
3293 else
3294 win_skip("WriteFile never returned TRUE\n");
3295
3296 CloseHandle(ov.hEvent);
3298 CloseHandle(h);
3299}
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define SetLastError(x)
Definition: compat.h:752
USHORT port
Definition: uri.c:228
@ FileIoCompletionNotificationInformation
Definition: from_kernel.h:102
#define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO
Definition: winternl.h:813
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:65
#define FILE_SKIP_SET_EVENT_ON_HANDLE
Definition: iocompl.c:23
#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS
Definition: iocompl.c:22
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:131
HANDLE hEvent
Definition: winbase.h:820
Definition: copy.c:22
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by START_TEST().

◆ test_file_disposition_information()

static void test_file_disposition_information ( void  )
static

Definition at line 2631 of file file.c.

2632{
2633 char tmp_path[MAX_PATH], buffer[MAX_PATH + 16];
2634 DWORD dirpos;
2635 HANDLE handle, handle2, mapping;
2636 NTSTATUS res;
2639 BOOL fileDeleted;
2640 DWORD fdi2;
2641 void *ptr;
2642
2643 GetTempPathA( MAX_PATH, tmp_path );
2644
2645 /* tests for info struct size */
2646 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2648 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2649 res = pNtSetInformationFile( handle, &io, &fdi, 0, FileDispositionInformation );
2650 todo_wine
2651 ok( res == STATUS_INFO_LENGTH_MISMATCH, "expected STATUS_INFO_LENGTH_MISMATCH, got %x\n", res );
2652 fdi2 = 0x100;
2653 res = pNtSetInformationFile( handle, &io, &fdi2, sizeof(fdi2), FileDispositionInformation );
2654 ok( res == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %x\n", res );
2657 ok( !fileDeleted, "File shouldn't have been deleted\n" );
2659
2660 /* cannot set disposition on file not opened with delete access */
2661 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2663 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2664 res = pNtQueryInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2665 ok( res == STATUS_INVALID_INFO_CLASS || res == STATUS_NOT_IMPLEMENTED, "Unexpected NtQueryInformationFile result (expected STATUS_INVALID_INFO_CLASS, got %x)\n", res );
2666 fdi.DoDeleteFile = TRUE;
2667 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2668 ok( res == STATUS_ACCESS_DENIED, "unexpected FileDispositionInformation result (expected STATUS_ACCESS_DENIED, got %x)\n", res );
2671 ok( !fileDeleted, "File shouldn't have been deleted\n" );
2673
2674 /* can set disposition on file opened with proper access */
2675 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2677 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2678 fdi.DoDeleteFile = TRUE;
2679 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2680 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2683 ok( fileDeleted, "File should have been deleted\n" );
2685
2686 /* cannot set disposition on readonly file */
2687 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2690 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2691 fdi.DoDeleteFile = TRUE;
2692 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2693 ok( res == STATUS_CANNOT_DELETE, "unexpected FileDispositionInformation result (expected STATUS_CANNOT_DELETE, got %x)\n", res );
2696 ok( !fileDeleted, "File shouldn't have been deleted\n" );
2699
2700 /* cannot set disposition on readonly file */
2701 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2703 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2704 fdi.DoDeleteFile = TRUE;
2705 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2706 todo_wine
2707 ok( res == STATUS_CANNOT_DELETE, "unexpected FileDispositionInformation result (expected STATUS_CANNOT_DELETE, got %x)\n", res );
2710 todo_wine
2711 ok( !fileDeleted, "File shouldn't have been deleted\n" );
2714
2715 /* can set disposition on file and then reset it */
2716 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2718 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2719 fdi.DoDeleteFile = TRUE;
2720 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2721 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2722 fdi.DoDeleteFile = FALSE;
2723 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2724 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2727 ok( !fileDeleted, "File shouldn't have been deleted\n" );
2729
2730 /* Delete-on-close flag doesn't change file disposition until a handle is closed */
2731 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2733 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2734 fdi.DoDeleteFile = FALSE;
2735 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2736 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2739 ok( fileDeleted, "File should have been deleted\n" );
2741
2742 /* Delete-on-close flag sets disposition when a handle is closed and then it could be changed back */
2743 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2745 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2746 ok( DuplicateHandle( GetCurrentProcess(), handle, GetCurrentProcess(), &handle2, 0, FALSE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
2748 fdi.DoDeleteFile = FALSE;
2749 res = pNtSetInformationFile( handle2, &io, &fdi, sizeof fdi, FileDispositionInformation );
2750 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2751 CloseHandle( handle2 );
2753 ok( fileDeleted, "File should have been deleted\n" );
2755
2756 /* can set disposition on a directory opened with proper access */
2757 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2759 ok( CreateDirectoryA( buffer, NULL ), "CreateDirectory failed\n" );
2761 ok( handle != INVALID_HANDLE_VALUE, "failed to open a directory\n" );
2762 fdi.DoDeleteFile = TRUE;
2763 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2764 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2767 ok( fileDeleted, "Directory should have been deleted\n" );
2769
2770 /* RemoveDirectory sets directory disposition and it can be undone */
2771 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2773 ok( CreateDirectoryA( buffer, NULL ), "CreateDirectory failed\n" );
2775 ok( handle != INVALID_HANDLE_VALUE, "failed to open a directory\n" );
2777 fdi.DoDeleteFile = FALSE;
2778 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2779 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2782 ok( !fileDeleted, "Directory shouldn't have been deleted\n" );
2784
2785 /* cannot set disposition on a non-empty directory */
2786 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2788 ok( CreateDirectoryA( buffer, NULL ), "CreateDirectory failed\n" );
2790 ok( handle != INVALID_HANDLE_VALUE, "failed to open a directory\n" );
2791 dirpos = lstrlenA( buffer );
2792 lstrcpyA( buffer + dirpos, "\\tst" );
2793 handle2 = CreateFileA(buffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
2794 CloseHandle( handle2 );
2795 fdi.DoDeleteFile = TRUE;
2796 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2797 todo_wine
2798 ok( res == STATUS_DIRECTORY_NOT_EMPTY, "unexpected FileDispositionInformation result (expected STATUS_DIRECTORY_NOT_EMPTY, got %x)\n", res );
2800 buffer[dirpos] = '\0';
2803 todo_wine
2804 ok( !fileDeleted, "Directory shouldn't have been deleted\n" );
2806
2807 /* cannot set disposition on file with file mapping opened */
2808 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2810 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2811 mapping = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 64 * 1024, "DelFileTest" );
2812 ok( mapping != NULL, "failed to create file mapping\n");
2813 fdi.DoDeleteFile = TRUE;
2814 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2815 ok( res == STATUS_CANNOT_DELETE, "unexpected FileDispositionInformation result (expected STATUS_CANNOT_DELETE, got %x)\n", res );
2818 ok( !fileDeleted, "File shouldn't have been deleted\n" );
2821
2822 /* can set disposition on file with file mapping closed */
2823 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2825 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2826 mapping = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 64 * 1024, "DelFileTest" );
2827 ok( mapping != NULL, "failed to create file mapping\n");
2829 fdi.DoDeleteFile = TRUE;
2830 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2831 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2834 ok( fileDeleted, "File should have been deleted\n" );
2836
2837 /* cannot set disposition on file which is mapped to memory */
2838 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2840 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2841 mapping = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 64 * 1024, "DelFileTest" );
2842 ok( mapping != NULL, "failed to create file mapping\n");
2843 ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
2844 ok( ptr != NULL, "MapViewOfFile failed\n");
2846 fdi.DoDeleteFile = TRUE;
2847 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2848 ok( res == STATUS_CANNOT_DELETE, "unexpected FileDispositionInformation result (expected STATUS_CANNOT_DELETE, got %x)\n", res );
2851 ok( !fileDeleted, "File shouldn't have been deleted\n" );
2854
2855 /* can set disposition on file which is mapped to memory and unmapped again */
2856 GetTempFileNameA( tmp_path, "dis", 0, buffer );
2858 ok( handle != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
2859 mapping = CreateFileMappingA( handle, NULL, PAGE_READWRITE, 0, 64 * 1024, "DelFileTest" );
2860 ok( mapping != NULL, "failed to create file mapping\n");
2861 ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
2862 ok( ptr != NULL, "MapViewOfFile failed\n");
2865 fdi.DoDeleteFile = TRUE;
2866 res = pNtSetInformationFile( handle, &io, &fdi, sizeof fdi, FileDispositionInformation );
2867 ok( res == STATUS_SUCCESS, "unexpected FileDispositionInformation result (expected STATUS_SUCCESS, got %x)\n", res );
2870 ok( fileDeleted, "File should have been deleted\n" );
2872}
#define UnmapViewOfFile
Definition: compat.h:746
#define GetCurrentProcess()
Definition: compat.h:759
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:776
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23
@ FileDispositionInformation
Definition: from_kernel.h:74
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static PVOID ptr
Definition: dispmode.c:27
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define DELETE
Definition: nt_native.h:57
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
#define STATUS_DIRECTORY_NOT_EMPTY
Definition: udferr_usr.h:167
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define DUPLICATE_SAME_ACCESS

Referenced by START_TEST().

◆ test_file_full_size_information()

static void test_file_full_size_information ( void  )
static

Definition at line 1156 of file file.c.

1157{
1161 HANDLE h;
1162 NTSTATUS res;
1163
1164 if(!(h = create_temp_file(0))) return ;
1165
1166 memset(&ffsi,0,sizeof(ffsi));
1167 memset(&fsi,0,sizeof(fsi));
1168
1169 /* Assume No Quota Settings configured on Wine Testbot */
1170 res = pNtQueryVolumeInformationFile(h, &io, &ffsi, sizeof ffsi, FileFsFullSizeInformation);
1171 ok(res == STATUS_SUCCESS, "cannot get attributes, res %x\n", res);
1172 res = pNtQueryVolumeInformationFile(h, &io, &fsi, sizeof fsi, FileFsSizeInformation);
1173 ok(res == STATUS_SUCCESS, "cannot get attributes, res %x\n", res);
1174
1175 /* Test for FileFsSizeInformation */
1177 "[fsi] TotalAllocationUnits expected positive, got 0x%s\n",
1180 "[fsi] AvailableAllocationUnits expected positive, got 0x%s\n",
1182
1183 /* Assume file system is NTFS */
1184 ok(fsi.BytesPerSector == 512, "[fsi] BytesPerSector expected 512, got %d\n",fsi.BytesPerSector);
1185 ok(fsi.SectorsPerAllocationUnit == 8, "[fsi] SectorsPerAllocationUnit expected 8, got %d\n",fsi.SectorsPerAllocationUnit);
1186
1188 "[ffsi] TotalAllocationUnits expected positive, got negative value 0x%s\n",
1191 "[ffsi] CallerAvailableAllocationUnits expected positive, got negative value 0x%s\n",
1194 "[ffsi] ActualAvailableAllocationUnits expected positive, got negative value 0x%s\n",
1197 "[ffsi] TotalAllocationUnits error fsi:0x%s, ffsi:0x%s\n",
1201 "[ffsi] CallerAvailableAllocationUnits error fsi:0x%s, ffsi: 0x%s\n",
1204
1205 /* Assume file system is NTFS */
1206 ok(ffsi.BytesPerSector == 512, "[ffsi] BytesPerSector expected 512, got %d\n",ffsi.BytesPerSector);
1207 ok(ffsi.SectorsPerAllocationUnit == 8, "[ffsi] SectorsPerAllocationUnit expected 8, got %d\n",ffsi.SectorsPerAllocationUnit);
1208
1209 CloseHandle( h );
1210}
return
Definition: dirsup.c:529
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
@ FileFsSizeInformation
Definition: from_kernel.h:221
#define FileFsFullSizeInformation
Definition: ntifs_ex.h:389
LARGE_INTEGER ActualAvailableAllocationUnits
Definition: from_kernel.h:272
LARGE_INTEGER CallerAvailableAllocationUnits
Definition: from_kernel.h:271
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:270
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:263
LARGE_INTEGER AvailableAllocationUnits
Definition: from_kernel.h:264

Referenced by START_TEST().

◆ test_file_id_information()

static void test_file_id_information ( void  )
static

Definition at line 3301 of file file.c.

3302{
3307 DWORD *dwords;
3308 HANDLE h;
3309 BOOL ret;
3310
3311 if (!(h = create_temp_file(0))) return;
3312
3313 memset( &fid, 0x11, sizeof(fid) );
3314 status = pNtQueryInformationFile( h, &io, &fid, sizeof(fid), FileIdInformation );
3316 {
3317 win_skip( "FileIdInformation not supported\n" );
3318 CloseHandle( h );
3319 return;
3320 }
3321
3322 memset( &info, 0x22, sizeof(info) );
3324 ok( ret, "GetFileInformationByHandle failed\n" );
3325
3326 dwords = (DWORD *)&fid.VolumeSerialNumber;
3327 ok( dwords[0] == info.dwVolumeSerialNumber, "expected %08x, got %08x\n",
3328 info.dwVolumeSerialNumber, dwords[0] );
3329 ok( dwords[1] != 0x11111111, "expected != 0x11111111\n" );
3330
3331 dwords = (DWORD *)&fid.FileId;
3332 ok( dwords[0] == info.nFileIndexLow, "expected %08x, got %08x\n", info.nFileIndexLow, dwords[0] );
3333 ok( dwords[1] == info.nFileIndexHigh, "expected %08x, got %08x\n", info.nFileIndexHigh, dwords[1] );
3334 ok( dwords[2] == 0, "expected 0, got %08x\n", dwords[2] );
3335 ok( dwords[3] == 0, "expected 0, got %08x\n", dwords[3] );
3336
3337 CloseHandle( h );
3338}
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:458
#define FileIdInformation
Definition: fileinfo.c:24
FILE_ID_128 FileId
Definition: fileinfo.c:36
ULONGLONG VolumeSerialNumber
Definition: fileinfo.c:35

Referenced by START_TEST().

◆ test_file_link_information()

static void test_file_link_information ( void  )
static

Definition at line 1986 of file file.c.

1987{
1988 static const WCHAR foo_txtW[] = {'\\','f','o','o','.','t','x','t',0};
1989 static const WCHAR fooW[] = {'f','o','o',0};
1990 WCHAR tmp_path[MAX_PATH], oldpath[MAX_PATH + 16], newpath[MAX_PATH + 16], *filename, *p;
1993 BOOL success, fileDeleted;
1994 UNICODE_STRING name_str;
1995 HANDLE handle, handle2;
1997 NTSTATUS res;
1998
1999 GetTempPathW( MAX_PATH, tmp_path );
2000
2001 /* oldpath is a file, newpath doesn't exist */
2002 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2003 ok( res != 0, "failed to create temp file\n" );
2004 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2005 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2006
2007 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2008 ok( res != 0, "failed to create temp file\n" );
2009 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2010 DeleteFileW( newpath );
2011 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2012 fli->ReplaceIfExists = FALSE;
2013 fli->RootDirectory = NULL;
2014 fli->FileNameLength = name_str.Length;
2015 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2016 pRtlFreeUnicodeString( &name_str );
2017
2018 U(io).Status = 0xdeadbeef;
2019 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2020 ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
2021 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
2023 ok( !fileDeleted, "file should exist\n" );
2025 ok( !fileDeleted, "file should exist\n" );
2026
2027 fni = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR) );
2028 res = pNtQueryInformationFile( handle, &io, fni, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), FileNameInformation );
2029 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
2030 fni->FileName[ fni->FileNameLength / sizeof(WCHAR) ] = 0;
2031 ok( !lstrcmpiW(fni->FileName, oldpath + 2), "FileName expected %s, got %s\n",
2032 wine_dbgstr_w(oldpath + 2), wine_dbgstr_w(fni->FileName) );
2033 HeapFree( GetProcessHeap(), 0, fni );
2034
2036 HeapFree( GetProcessHeap(), 0, fli );
2037 delete_object( oldpath );
2038 delete_object( newpath );
2039
2040 /* oldpath is a file, newpath is a file, ReplaceIfExists = FALSE */
2041 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2042 ok( res != 0, "failed to create temp file\n" );
2043 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2044 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2045
2046 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2047 ok( res != 0, "failed to create temp file\n" );
2048 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2049 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2050 fli->ReplaceIfExists = FALSE;
2051 fli->RootDirectory = NULL;
2052 fli->FileNameLength = name_str.Length;
2053 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2054 pRtlFreeUnicodeString( &name_str );
2055
2056 U(io).Status = 0xdeadbeef;
2057 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2058 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2059 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
2061 ok( !fileDeleted, "file should exist\n" );
2063 ok( !fileDeleted, "file should exist\n" );
2064
2066 HeapFree( GetProcessHeap(), 0, fli );
2067 delete_object( oldpath );
2068 delete_object( newpath );
2069
2070 /* oldpath is a file, newpath is a file, ReplaceIfExists = TRUE */
2071 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2072 ok( res != 0, "failed to create temp file\n" );
2073 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2074 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2075
2076 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2077 ok( res != 0, "failed to create temp file\n" );
2078 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2079 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2080 fli->ReplaceIfExists = TRUE;
2081 fli->RootDirectory = NULL;
2082 fli->FileNameLength = name_str.Length;
2083 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2084 pRtlFreeUnicodeString( &name_str );
2085
2086 U(io).Status = 0xdeadbeef;
2087 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2088 ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
2089 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
2091 ok( !fileDeleted, "file should exist\n" );
2093 ok( !fileDeleted, "file should exist\n" );
2094
2096 HeapFree( GetProcessHeap(), 0, fli );
2097 delete_object( oldpath );
2098 delete_object( newpath );
2099
2100 /* oldpath is a file, newpath is a file, ReplaceIfExists = FALSE, target file opened */
2101 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2102 ok( res != 0, "failed to create temp file\n" );
2103 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2104 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2105
2106 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2107 ok( res != 0, "failed to create temp file\n" );
2108 handle2 = CreateFileW( newpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2109 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2110
2111 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2112 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2113 fli->ReplaceIfExists = FALSE;
2114 fli->RootDirectory = NULL;
2115 fli->FileNameLength = name_str.Length;
2116 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2117 pRtlFreeUnicodeString( &name_str );
2118
2119 U(io).Status = 0xdeadbeef;
2120 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2121 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2122 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
2124 ok( !fileDeleted, "file should exist\n" );
2126 ok( !fileDeleted, "file should exist\n" );
2127
2129 CloseHandle( handle2 );
2130 HeapFree( GetProcessHeap(), 0, fli );
2131 delete_object( oldpath );
2132 delete_object( newpath );
2133
2134 /* oldpath is a file, newpath is a file, ReplaceIfExists = TRUE, target file opened */
2135 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2136 ok( res != 0, "failed to create temp file\n" );
2137 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2138 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2139
2140 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2141 ok( res != 0, "failed to create temp file\n" );
2142 handle2 = CreateFileW( newpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2143 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2144
2145 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2146 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2147 fli->ReplaceIfExists = TRUE;
2148 fli->RootDirectory = NULL;
2149 fli->FileNameLength = name_str.Length;
2150 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2151 pRtlFreeUnicodeString( &name_str );
2152
2153 U(io).Status = 0xdeadbeef;
2154 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2155 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2156 ok( res == STATUS_ACCESS_DENIED, "res expected STATUS_ACCESS_DENIED, got %x\n", res );
2158 ok( !fileDeleted, "file should exist\n" );
2160 ok( !fileDeleted, "file should exist\n" );
2161
2163 CloseHandle( handle2 );
2164 HeapFree( GetProcessHeap(), 0, fli );
2165 delete_object( oldpath );
2166 delete_object( newpath );
2167
2168 /* oldpath is a directory, newpath doesn't exist, ReplaceIfExists = FALSE */
2169 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2170 ok( res != 0, "failed to create temp file\n" );
2171 DeleteFileW( oldpath );
2172 success = CreateDirectoryW( oldpath, NULL );
2173 ok( success != 0, "failed to create temp directory\n" );
2175 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2176
2177 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2178 ok( res != 0, "failed to create temp file\n" );
2179 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2180 DeleteFileW( newpath );
2181 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2182 fli->ReplaceIfExists = FALSE;
2183 fli->RootDirectory = NULL;
2184 fli->FileNameLength = name_str.Length;
2185 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2186 pRtlFreeUnicodeString( &name_str );
2187
2188 U(io).Status = 0xdeadbeef;
2189 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2190 todo_wine ok( U(io).Status == 0xdeadbeef , "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2191 ok( res == STATUS_FILE_IS_A_DIRECTORY, "res expected STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2193 ok( !fileDeleted, "file should exist\n" );
2195 ok( fileDeleted, "file should not exist\n" );
2196
2197 fni = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR) );
2198 res = pNtQueryInformationFile( handle, &io, fni, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), FileNameInformation );
2199 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
2200 fni->FileName[ fni->FileNameLength / sizeof(WCHAR) ] = 0;
2201 ok( !lstrcmpiW(fni->FileName, oldpath + 2), "FileName expected %s, got %s\n",
2202 wine_dbgstr_w(oldpath + 2), wine_dbgstr_w(fni->FileName) );
2203 HeapFree( GetProcessHeap(), 0, fni );
2204
2206 HeapFree( GetProcessHeap(), 0, fli );
2207 delete_object( oldpath );
2208 delete_object( newpath );
2209
2210 /* oldpath is a directory (but child object opened), newpath doesn't exist, ReplaceIfExists = FALSE */
2211 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2212 ok( res != 0, "failed to create temp file\n" );
2213 DeleteFileW( oldpath );
2214 success = CreateDirectoryW( oldpath, NULL );
2215 ok( success != 0, "failed to create temp directory\n" );
2217 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2218
2219 lstrcpyW( newpath, oldpath );
2220 lstrcatW( newpath, foo_txtW );
2222 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2223
2224 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2225 ok( res != 0, "failed to create temp file\n" );
2226 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2227 DeleteFileW( newpath );
2228 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2229 fli->ReplaceIfExists = FALSE;
2230 fli->RootDirectory = NULL;
2231 fli->FileNameLength = name_str.Length;
2232 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2233 pRtlFreeUnicodeString( &name_str );
2234
2235 U(io).Status = 0xdeadbeef;
2236 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2237 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2238 ok( res == STATUS_FILE_IS_A_DIRECTORY, "res expected STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2240 ok( !fileDeleted, "file should exist\n" );
2242 ok( fileDeleted, "file should not exist\n" );
2243
2245 CloseHandle( handle2 );
2246 HeapFree( GetProcessHeap(), 0, fli );
2247 delete_object( oldpath );
2248 delete_object( newpath );
2249
2250 /* oldpath is a directory, newpath is a file, ReplaceIfExists = FALSE */
2251 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2252 ok( res != 0, "failed to create temp file\n" );
2253 DeleteFileW( oldpath );
2254 success = CreateDirectoryW( oldpath, NULL );
2255 ok( success != 0, "failed to create temp directory\n" );
2257 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2258
2259 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2260 ok( res != 0, "failed to create temp file\n" );
2261 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2262 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2263 fli->ReplaceIfExists = FALSE;
2264 fli->RootDirectory = NULL;
2265 fli->FileNameLength = name_str.Length;
2266 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2267 pRtlFreeUnicodeString( &name_str );
2268
2269 U(io).Status = 0xdeadbeef;
2270 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2271 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2273 "res expected STATUS_OBJECT_NAME_COLLISION or STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2275 ok( !fileDeleted, "file should exist\n" );
2277 ok( !fileDeleted, "file should exist\n" );
2278
2280 HeapFree( GetProcessHeap(), 0, fli );
2281 delete_object( oldpath );
2282 delete_object( newpath );
2283
2284 /* oldpath is a directory, newpath is a file, ReplaceIfExists = FALSE, target file opened */
2285 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2286 ok( res != 0, "failed to create temp file\n" );
2287 DeleteFileW( oldpath );
2288 success = CreateDirectoryW( oldpath, NULL );
2289 ok( success != 0, "failed to create temp directory\n" );
2291 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2292
2293 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2294 ok( res != 0, "failed to create temp file\n" );
2295 handle2 = CreateFileW( newpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2296 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2297
2298 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2299 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2300 fli->ReplaceIfExists = FALSE;
2301 fli->RootDirectory = NULL;
2302 fli->FileNameLength = name_str.Length;
2303 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2304 pRtlFreeUnicodeString( &name_str );
2305
2306 U(io).Status = 0xdeadbeef;
2307 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2308 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2310 "res expected STATUS_OBJECT_NAME_COLLISION or STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2312 ok( !fileDeleted, "file should exist\n" );
2314 ok( !fileDeleted, "file should exist\n" );
2315
2317 CloseHandle( handle2 );
2318 HeapFree( GetProcessHeap(), 0, fli );
2319 delete_object( oldpath );
2320 delete_object( newpath );
2321
2322 /* oldpath is a directory, newpath is a file, ReplaceIfExists = TRUE */
2323 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2324 ok( res != 0, "failed to create temp file\n" );
2325 DeleteFileW( oldpath );
2326 success = CreateDirectoryW( oldpath, NULL );
2327 ok( success != 0, "failed to create temp directory\n" );
2329 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2330
2331 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2332 ok( res != 0, "failed to create temp file\n" );
2333 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2334 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2335 fli->ReplaceIfExists = TRUE;
2336 fli->RootDirectory = NULL;
2337 fli->FileNameLength = name_str.Length;
2338 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2339 pRtlFreeUnicodeString( &name_str );
2340
2341 U(io).Status = 0xdeadbeef;
2342 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2343 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2344 ok( res == STATUS_FILE_IS_A_DIRECTORY, "res expected STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2346 ok( !fileDeleted, "file should exist\n" );
2348 ok( !fileDeleted, "file should exist\n" );
2349
2351 HeapFree( GetProcessHeap(), 0, fli );
2352 delete_object( oldpath );
2353 delete_object( newpath );
2354
2355 /* oldpath is a directory, newpath is a file, ReplaceIfExists = TRUE, target file opened */
2356 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2357 ok( res != 0, "failed to create temp file\n" );
2358 DeleteFileW( oldpath );
2359 success = CreateDirectoryW( oldpath, NULL );
2360 ok( success != 0, "failed to create temp directory\n" );
2362 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2363
2364 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2365 ok( res != 0, "failed to create temp file\n" );
2366 handle2 = CreateFileW( newpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2367 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2368
2369 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2370 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2371 fli->ReplaceIfExists = TRUE;
2372 fli->RootDirectory = NULL;
2373 fli->FileNameLength = name_str.Length;
2374 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2375 pRtlFreeUnicodeString( &name_str );
2376
2377 U(io).Status = 0xdeadbeef;
2378 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2379 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2380 ok( res == STATUS_FILE_IS_A_DIRECTORY, "res expected STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2382 ok( !fileDeleted, "file should exist\n" );
2384 ok( !fileDeleted, "file should exist\n" );
2385
2387 CloseHandle( handle2 );
2388 HeapFree( GetProcessHeap(), 0, fli );
2389 delete_object( oldpath );
2390 delete_object( newpath );
2391
2392 /* oldpath is a directory, newpath is a directory, ReplaceIfExists = FALSE */
2393 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2394 ok( res != 0, "failed to create temp file\n" );
2395 DeleteFileW( oldpath );
2396 success = CreateDirectoryW( oldpath, NULL );
2397 ok( success != 0, "failed to create temp directory\n" );
2399 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2400
2401 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2402 ok( res != 0, "failed to create temp file\n" );
2403 DeleteFileW( newpath );
2404 success = CreateDirectoryW( newpath, NULL );
2405 ok( success != 0, "failed to create temp directory\n" );
2406 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2407 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2408 fli->ReplaceIfExists = FALSE;
2409 fli->RootDirectory = NULL;
2410 fli->FileNameLength = name_str.Length;
2411 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2412 pRtlFreeUnicodeString( &name_str );
2413
2414 U(io).Status = 0xdeadbeef;
2415 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2416 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2418 "res expected STATUS_OBJECT_NAME_COLLISION or STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2420 ok( !fileDeleted, "file should exist\n" );
2422 ok( !fileDeleted, "file should exist\n" );
2423
2425 HeapFree( GetProcessHeap(), 0, fli );
2426 delete_object( oldpath );
2427 delete_object( newpath );
2428
2429 /* oldpath is a directory, newpath is a directory, ReplaceIfExists = TRUE */
2430 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2431 ok( res != 0, "failed to create temp file\n" );
2432 DeleteFileW( oldpath );
2433 success = CreateDirectoryW( oldpath, NULL );
2434 ok( success != 0, "failed to create temp directory\n" );
2436 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2437
2438 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2439 ok( res != 0, "failed to create temp file\n" );
2440 DeleteFileW( newpath );
2441 success = CreateDirectoryW( newpath, NULL );
2442 ok( success != 0, "failed to create temp directory\n" );
2443 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2444 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2445 fli->ReplaceIfExists = TRUE;
2446 fli->RootDirectory = NULL;
2447 fli->FileNameLength = name_str.Length;
2448 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2449 pRtlFreeUnicodeString( &name_str );
2450
2451 U(io).Status = 0xdeadbeef;
2452 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2453 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2454 ok( res == STATUS_FILE_IS_A_DIRECTORY, "res expected STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2456 ok( !fileDeleted, "file should exist\n" );
2458 ok( !fileDeleted, "file should exist\n" );
2459
2461 HeapFree( GetProcessHeap(), 0, fli );
2462 delete_object( oldpath );
2463 delete_object( newpath );
2464
2465 /* oldpath is a directory, newpath is a directory, ReplaceIfExists = TRUE, target file opened */
2466 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2467 ok( res != 0, "failed to create temp file\n" );
2468 DeleteFileW( oldpath );
2469 success = CreateDirectoryW( oldpath, NULL );
2470 ok( success != 0, "failed to create temp directory\n" );
2472 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2473
2474 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2475 ok( res != 0, "failed to create temp file\n" );
2476 DeleteFileW( newpath );
2477 success = CreateDirectoryW( newpath, NULL );
2478 ok( success != 0, "failed to create temp directory\n" );
2480 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2481
2482 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2483 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2484 fli->ReplaceIfExists = TRUE;
2485 fli->RootDirectory = NULL;
2486 fli->FileNameLength = name_str.Length;
2487 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2488 pRtlFreeUnicodeString( &name_str );
2489
2490 U(io).Status = 0xdeadbeef;
2491 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2492 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2493 ok( res == STATUS_FILE_IS_A_DIRECTORY, "res expected STATUS_FILE_IS_A_DIRECTORY, got %x\n", res );
2495 ok( !fileDeleted, "file should exist\n" );
2497 ok( !fileDeleted, "file should exist\n" );
2498
2500 CloseHandle( handle2 );
2501 HeapFree( GetProcessHeap(), 0, fli );
2502 delete_object( oldpath );
2503 delete_object( newpath );
2504
2505 /* oldpath is a file, newpath is a directory, ReplaceIfExists = FALSE */
2506 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2507 ok( res != 0, "failed to create temp file\n" );
2508 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2509 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2510
2511 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2512 ok( res != 0, "failed to create temp file\n" );
2513 DeleteFileW( newpath );
2514 success = CreateDirectoryW( newpath, NULL );
2515 ok( success != 0, "failed to create temp directory\n" );
2516 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2517 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2518 fli->ReplaceIfExists = FALSE;
2519 fli->RootDirectory = NULL;
2520 fli->FileNameLength = name_str.Length;
2521 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2522 pRtlFreeUnicodeString( &name_str );
2523
2524 U(io).Status = 0xdeadbeef;
2525 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2526 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2527 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
2529 ok( !fileDeleted, "file should exist\n" );
2531 ok( !fileDeleted, "file should exist\n" );
2532
2534 HeapFree( GetProcessHeap(), 0, fli );
2535 delete_object( oldpath );
2536 delete_object( newpath );
2537
2538 /* oldpath is a file, newpath is a directory, ReplaceIfExists = TRUE */
2539 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2540 ok( res != 0, "failed to create temp file\n" );
2541 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2542 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2543
2544 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2545 ok( res != 0, "failed to create temp file\n" );
2546 DeleteFileW( newpath );
2547 success = CreateDirectoryW( newpath, NULL );
2548 ok( success != 0, "failed to create temp directory\n" );
2549 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
2550 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + name_str.Length );
2551 fli->ReplaceIfExists = TRUE;
2552 fli->RootDirectory = NULL;
2553 fli->FileNameLength = name_str.Length;
2554 memcpy( fli->FileName, name_str.Buffer, name_str.Length );
2555 pRtlFreeUnicodeString( &name_str );
2556
2557 U(io).Status = 0xdeadbeef;
2558 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2559 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
2560 ok( res == STATUS_ACCESS_DENIED, "res expected STATUS_ACCESS_DENIED, got %x\n", res );
2562 ok( !fileDeleted, "file should exist\n" );
2564 ok( !fileDeleted, "file should exist\n" );
2565
2567 HeapFree( GetProcessHeap(), 0, fli );
2568 delete_object( oldpath );
2569 delete_object( newpath );
2570
2571 /* oldpath is a file, newpath doesn't exist, test with RootDirectory != NULL */
2572 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
2573 ok( res != 0, "failed to create temp file\n" );
2574 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
2575 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2576
2577 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
2578 ok( res != 0, "failed to create temp file\n" );
2579 DeleteFileW( newpath );
2580 for (filename = newpath, p = newpath; *p; p++)
2581 if (*p == '\\') filename = p + 1;
2582 handle2 = CreateFileW( tmp_path, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 );
2583 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
2584
2585 fli = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_LINK_INFORMATION) + lstrlenW(filename) * sizeof(WCHAR) );
2586 fli->ReplaceIfExists = FALSE;
2587 fli->RootDirectory = handle2;
2588 fli->FileNameLength = lstrlenW(filename) * sizeof(WCHAR);
2589 memcpy( fli->FileName, filename, fli->FileNameLength );
2590
2591 U(io).Status = 0xdeadbeef;
2592 res = pNtSetInformationFile( handle, &io, fli, sizeof(FILE_LINK_INFORMATION) + fli->FileNameLength, FileLinkInformation );
2593 ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
2594 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
2596 ok( !fileDeleted, "file should exist\n" );
2598 ok( !fileDeleted, "file should exist\n" );
2599
2600 fni = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR) );
2601 res = pNtQueryInformationFile( handle, &io, fni, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), FileNameInformation );
2602 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
2603 fni->FileName[ fni->FileNameLength / sizeof(WCHAR) ] = 0;
2604 ok( !lstrcmpiW(fni->FileName, oldpath + 2), "FileName expected %s, got %s\n",
2605 wine_dbgstr_w(oldpath + 2), wine_dbgstr_w(fni->FileName) );
2606 HeapFree( GetProcessHeap(), 0, fni );
2607
2609 CloseHandle( handle2 );
2610 HeapFree( GetProcessHeap(), 0, fli );
2611 delete_object( oldpath );
2612 delete_object( newpath );
2613}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
@ FileLinkInformation
Definition: from_kernel.h:72
@ FileNameInformation
Definition: from_kernel.h:70
GLfloat GLfloat p
Definition: glext.h:8902
static char filename[MAX_PATH]
Definition: file.c:51
static void delete_object(WCHAR *path)
Definition: file.c:1342
#define STATUS_FILE_IS_A_DIRECTORY
Definition: udferr_usr.h:164
#define success(from, fromstr, to, tostr)

Referenced by START_TEST().

◆ test_file_name_information()

static void test_file_name_information ( void  )
static

Definition at line 2892 of file file.c.

2893{
2894 WCHAR *file_name, *volume_prefix, *expected;
2896 ULONG old_redir = 1, tmp;
2897 UINT file_name_size;
2899 UINT info_size;
2900 HRESULT hr;
2901 HANDLE h;
2902 UINT len;
2903
2904 /* GetVolumePathName is not present before w2k */
2905 if (!pGetVolumePathNameW) {
2906 win_skip("GetVolumePathNameW not found\n");
2907 return;
2908 }
2909
2910 file_name_size = GetSystemDirectoryW( NULL, 0 );
2911 file_name = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*file_name) );
2912 volume_prefix = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) );
2913 expected = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) );
2914
2915 len = GetSystemDirectoryW( file_name, file_name_size );
2916 ok(len == file_name_size - 1,
2917 "GetSystemDirectoryW returned %u, expected %u.\n",
2918 len, file_name_size - 1);
2919
2920 len = pGetVolumePathNameW( file_name, volume_prefix, file_name_size );
2921 ok(len, "GetVolumePathNameW failed.\n");
2922
2923 len = lstrlenW( volume_prefix );
2924 if (len && volume_prefix[len - 1] == '\\') --len;
2925 memcpy( expected, file_name + len, (file_name_size - len - 1) * sizeof(WCHAR) );
2926 expected[file_name_size - len - 1] = '\0';
2927
2928 /* A bit more than we actually need, but it keeps the calculation simple. */
2929 info_size = sizeof(*info) + (file_name_size * sizeof(WCHAR));
2930 info = HeapAlloc( GetProcessHeap(), 0, info_size );
2931
2932 if (pRtlWow64EnableFsRedirectionEx) pRtlWow64EnableFsRedirectionEx( TRUE, &old_redir );
2936 if (pRtlWow64EnableFsRedirectionEx) pRtlWow64EnableFsRedirectionEx( old_redir, &tmp );
2937 ok(h != INVALID_HANDLE_VALUE, "Failed to open file.\n");
2938
2939 hr = pNtQueryInformationFile( h, &io, info, sizeof(*info) - 1, FileNameInformation );
2940 ok(hr == STATUS_INFO_LENGTH_MISMATCH, "NtQueryInformationFile returned %#x.\n", hr);
2941
2942 memset( info, 0xcc, info_size );
2943 hr = pNtQueryInformationFile( h, &io, info, sizeof(*info), FileNameInformation );
2944 ok(hr == STATUS_BUFFER_OVERFLOW, "NtQueryInformationFile returned %#x, expected %#x.\n",
2946 ok(U(io).Status == STATUS_BUFFER_OVERFLOW, "io.Status is %#x, expected %#x.\n",
2948 ok(info->FileNameLength == lstrlenW( expected ) * sizeof(WCHAR), "info->FileNameLength is %u\n", info->FileNameLength);
2949 ok(info->FileName[2] == 0xcccc, "info->FileName[2] is %#x, expected 0xcccc.\n", info->FileName[2]);
2951 "info->FileName[1] is %p, expected %p.\n",
2953 ok(io.Information == sizeof(*info), "io.Information is %lu\n", io.Information);
2954
2955 memset( info, 0xcc, info_size );
2956 hr = pNtQueryInformationFile( h, &io, info, info_size, FileNameInformation );
2957 ok(hr == STATUS_SUCCESS, "NtQueryInformationFile returned %#x, expected %#x.\n", hr, STATUS_SUCCESS);
2958 ok(U(io).Status == STATUS_SUCCESS, "io.Status is %#x, expected %#x.\n", U(io).Status, STATUS_SUCCESS);
2959 ok(info->FileNameLength == lstrlenW( expected ) * sizeof(WCHAR), "info->FileNameLength is %u\n", info->FileNameLength);
2960 ok(info->FileName[info->FileNameLength / sizeof(WCHAR)] == 0xcccc, "info->FileName[len] is %#x, expected 0xcccc.\n",
2961 info->FileName[info->FileNameLength / sizeof(WCHAR)]);
2962 info->FileName[info->FileNameLength / sizeof(WCHAR)] = '\0';
2963 ok(!lstrcmpiW( info->FileName, expected ), "info->FileName is %s, expected %s.\n",
2964 wine_dbgstr_w( info->FileName ), wine_dbgstr_w( expected ));
2965 ok(io.Information == FIELD_OFFSET(FILE_NAME_INFORMATION, FileName) + info->FileNameLength,
2966 "io.Information is %lu, expected %u.\n",
2967 io.Information, FIELD_OFFSET(FILE_NAME_INFORMATION, FileName) + info->FileNameLength);
2968
2969 CloseHandle( h );
2970 HeapFree( GetProcessHeap(), 0, info );
2972 HeapFree( GetProcessHeap(), 0, volume_prefix );
2973
2974 if (old_redir || !pGetSystemWow64DirectoryW || !(file_name_size = pGetSystemWow64DirectoryW( NULL, 0 )))
2975 {
2976 skip("Not running on WoW64, skipping test.\n");
2978 return;
2979 }
2980
2984 ok(h != INVALID_HANDLE_VALUE, "Failed to open file.\n");
2986
2987 file_name = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*file_name) );
2988 volume_prefix = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) );
2989 expected = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*expected) );
2990
2991 len = pGetSystemWow64DirectoryW( file_name, file_name_size );
2992 ok(len == file_name_size - 1,
2993 "GetSystemWow64DirectoryW returned %u, expected %u.\n",
2994 len, file_name_size - 1);
2995
2996 len = pGetVolumePathNameW( file_name, volume_prefix, file_name_size );
2997 ok(len, "GetVolumePathNameW failed.\n");
2998
2999 len = lstrlenW( volume_prefix );
3000 if (len && volume_prefix[len - 1] == '\\') --len;
3001 memcpy( expected, file_name + len, (file_name_size - len - 1) * sizeof(WCHAR) );
3002 expected[file_name_size - len - 1] = '\0';
3003
3004 info_size = sizeof(*info) + (file_name_size * sizeof(WCHAR));
3005 info = HeapAlloc( GetProcessHeap(), 0, info_size );
3006
3007 memset( info, 0xcc, info_size );
3008 hr = pNtQueryInformationFile( h, &io, info, info_size, FileNameInformation );
3009 ok(hr == STATUS_SUCCESS, "NtQueryInformationFile returned %#x, expected %#x.\n", hr, STATUS_SUCCESS);
3010 info->FileName[info->FileNameLength / sizeof(WCHAR)] = '\0';
3011 ok(!lstrcmpiW( info->FileName, expected ), "info->FileName is %s, expected %s.\n",
3012 wine_dbgstr_w( info->FileName ), wine_dbgstr_w( expected ));
3013
3014 CloseHandle( h );
3015 HeapFree( GetProcessHeap(), 0, info );
3017 HeapFree( GetProcessHeap(), 0, volume_prefix );
3019}

Referenced by START_TEST().

◆ test_file_rename_information()

static void test_file_rename_information ( void  )
static

Definition at line 1354 of file file.c.

1355{
1356 static const WCHAR foo_txtW[] = {'\\','f','o','o','.','t','x','t',0};
1357 static const WCHAR fooW[] = {'f','o','o',0};
1358 WCHAR tmp_path[MAX_PATH], oldpath[MAX_PATH + 16], newpath[MAX_PATH + 16], *filename, *p;
1361 BOOL success, fileDeleted;
1362 UNICODE_STRING name_str;
1363 HANDLE handle, handle2;
1365 NTSTATUS res;
1366
1367 GetTempPathW( MAX_PATH, tmp_path );
1368
1369 /* oldpath is a file, newpath doesn't exist */
1370 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1371 ok( res != 0, "failed to create temp file\n" );
1372 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1373 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1374
1375 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1376 ok( res != 0, "failed to create temp file\n" );
1377 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1378 DeleteFileW( newpath );
1379 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1380 fri->Replace = FALSE;
1381 fri->RootDir = NULL;
1382 fri->FileNameLength = name_str.Length;
1383 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1384 pRtlFreeUnicodeString( &name_str );
1385
1386 U(io).Status = 0xdeadbeef;
1387 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1388 ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
1389 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
1391 ok( fileDeleted, "file should not exist\n" );
1393 ok( !fileDeleted, "file should exist\n" );
1394
1395 fni = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR) );
1396 res = pNtQueryInformationFile( handle, &io, fni, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), FileNameInformation );
1397 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
1398 fni->FileName[ fni->FileNameLength / sizeof(WCHAR) ] = 0;
1399 ok( !lstrcmpiW(fni->FileName, newpath + 2), "FileName expected %s, got %s\n",
1400 wine_dbgstr_w(newpath + 2), wine_dbgstr_w(fni->FileName) );
1401 HeapFree( GetProcessHeap(), 0, fni );
1402
1404 HeapFree( GetProcessHeap(), 0, fri );
1405 delete_object( oldpath );
1406 delete_object( newpath );
1407
1408 /* oldpath is a file, newpath is a file, Replace = FALSE */
1409 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1410 ok( res != 0, "failed to create temp file\n" );
1411 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1412 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1413
1414 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1415 ok( res != 0, "failed to create temp file\n" );
1416 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1417 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1418 fri->Replace = FALSE;
1419 fri->RootDir = NULL;
1420 fri->FileNameLength = name_str.Length;
1421 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1422 pRtlFreeUnicodeString( &name_str );
1423
1424 U(io).Status = 0xdeadbeef;
1425 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1426 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1427 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
1429 ok( !fileDeleted, "file should exist\n" );
1431 ok( !fileDeleted, "file should exist\n" );
1432
1434 HeapFree( GetProcessHeap(), 0, fri );
1435 delete_object( oldpath );
1436 delete_object( newpath );
1437
1438 /* oldpath is a file, newpath is a file, Replace = TRUE */
1439 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1440 ok( res != 0, "failed to create temp file\n" );
1441 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1442 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1443
1444 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1445 ok( res != 0, "failed to create temp file\n" );
1446 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1447 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1448 fri->Replace = TRUE;
1449 fri->RootDir = NULL;
1450 fri->FileNameLength = name_str.Length;
1451 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1452 pRtlFreeUnicodeString( &name_str );
1453
1454 U(io).Status = 0xdeadbeef;
1455 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1456 ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
1457 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
1459 ok( fileDeleted, "file should not exist\n" );
1461 ok( !fileDeleted, "file should exist\n" );
1462
1464 HeapFree( GetProcessHeap(), 0, fri );
1465 delete_object( oldpath );
1466 delete_object( newpath );
1467
1468 /* oldpath is a file, newpath is a file, Replace = FALSE, target file opened */
1469 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1470 ok( res != 0, "failed to create temp file\n" );
1471 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1472 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1473
1474 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1475 ok( res != 0, "failed to create temp file\n" );
1476 handle2 = CreateFileW( newpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1477 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1478
1479 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1480 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1481 fri->Replace = FALSE;
1482 fri->RootDir = NULL;
1483 fri->FileNameLength = name_str.Length;
1484 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1485 pRtlFreeUnicodeString( &name_str );
1486
1487 U(io).Status = 0xdeadbeef;
1488 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1489 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1490 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
1492 ok( !fileDeleted, "file should exist\n" );
1494 ok( !fileDeleted, "file should exist\n" );
1495
1497 CloseHandle( handle2 );
1498 HeapFree( GetProcessHeap(), 0, fri );
1499 delete_object( oldpath );
1500 delete_object( newpath );
1501
1502 /* oldpath is a file, newpath is a file, Replace = TRUE, target file opened */
1503 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1504 ok( res != 0, "failed to create temp file\n" );
1505 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1506 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1507
1508 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1509 ok( res != 0, "failed to create temp file\n" );
1510 handle2 = CreateFileW( newpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1511 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1512
1513 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1514 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1515 fri->Replace = TRUE;
1516 fri->RootDir = NULL;
1517 fri->FileNameLength = name_str.Length;
1518 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1519 pRtlFreeUnicodeString( &name_str );
1520
1521 U(io).Status = 0xdeadbeef;
1522 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1523 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1524 ok( res == STATUS_ACCESS_DENIED, "res expected STATUS_ACCESS_DENIED, got %x\n", res );
1526 ok( !fileDeleted, "file should exist\n" );
1528 ok( !fileDeleted, "file should exist\n" );
1529
1531 CloseHandle( handle2 );
1532 HeapFree( GetProcessHeap(), 0, fri );
1533 delete_object( oldpath );
1534 delete_object( newpath );
1535
1536 /* oldpath is a directory, newpath doesn't exist, Replace = FALSE */
1537 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1538 ok( res != 0, "failed to create temp file\n" );
1539 DeleteFileW( oldpath );
1540 success = CreateDirectoryW( oldpath, NULL );
1541 ok( success != 0, "failed to create temp directory\n" );
1543 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1544
1545 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1546 ok( res != 0, "failed to create temp file\n" );
1547 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1548 DeleteFileW( newpath );
1549 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1550 fri->Replace = FALSE;
1551 fri->RootDir = NULL;
1552 fri->FileNameLength = name_str.Length;
1553 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1554 pRtlFreeUnicodeString( &name_str );
1555
1556 U(io).Status = 0xdeadbeef;
1557 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1558 ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
1559 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
1561 ok( fileDeleted, "file should not exist\n" );
1563 ok( !fileDeleted, "file should exist\n" );
1564
1565 fni = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR) );
1566 res = pNtQueryInformationFile( handle, &io, fni, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), FileNameInformation );
1567 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
1568 fni->FileName[ fni->FileNameLength / sizeof(WCHAR) ] = 0;
1569 ok( !lstrcmpiW(fni->FileName, newpath + 2), "FileName expected %s, got %s\n",
1570 wine_dbgstr_w(newpath + 2), wine_dbgstr_w(fni->FileName) );
1571 HeapFree( GetProcessHeap(), 0, fni );
1572
1574 HeapFree( GetProcessHeap(), 0, fri );
1575 delete_object( oldpath );
1576 delete_object( newpath );
1577
1578 /* oldpath is a directory (but child object opened), newpath doesn't exist, Replace = FALSE */
1579 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1580 ok( res != 0, "failed to create temp file\n" );
1581 DeleteFileW( oldpath );
1582 success = CreateDirectoryW( oldpath, NULL );
1583 ok( success != 0, "failed to create temp directory\n" );
1585 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1586
1587 lstrcpyW( newpath, oldpath );
1588 lstrcatW( newpath, foo_txtW );
1590 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1591
1592 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1593 ok( res != 0, "failed to create temp file\n" );
1594 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1595 DeleteFileW( newpath );
1596 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1597 fri->Replace = FALSE;
1598 fri->RootDir = NULL;
1599 fri->FileNameLength = name_str.Length;
1600 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1601 pRtlFreeUnicodeString( &name_str );
1602
1603 U(io).Status = 0xdeadbeef;
1604 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1605 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1606 todo_wine ok( res == STATUS_ACCESS_DENIED, "res expected STATUS_ACCESS_DENIED, got %x\n", res );
1608 todo_wine ok( !fileDeleted, "file should exist\n" );
1610 todo_wine ok( fileDeleted, "file should not exist\n" );
1611
1613 CloseHandle( handle2 );
1614 HeapFree( GetProcessHeap(), 0, fri );
1615 delete_object( oldpath );
1616 if (res == STATUS_SUCCESS) /* remove when Wine is fixed */
1617 {
1618 lstrcpyW( oldpath, newpath );
1619 lstrcatW( oldpath, foo_txtW );
1620 delete_object( oldpath );
1621 }
1622 delete_object( newpath );
1623
1624 /* oldpath is a directory, newpath is a file, Replace = FALSE */
1625 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1626 ok( res != 0, "failed to create temp file\n" );
1627 DeleteFileW( oldpath );
1628 success = CreateDirectoryW( oldpath, NULL );
1629 ok( success != 0, "failed to create temp directory\n" );
1631 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1632
1633 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1634 ok( res != 0, "failed to create temp file\n" );
1635 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1636 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1637 fri->Replace = FALSE;
1638 fri->RootDir = NULL;
1639 fri->FileNameLength = name_str.Length;
1640 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1641 pRtlFreeUnicodeString( &name_str );
1642
1643 U(io).Status = 0xdeadbeef;
1644 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1645 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1646 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
1648 ok( !fileDeleted, "file should exist\n" );
1650 ok( !fileDeleted, "file should exist\n" );
1651
1653 HeapFree( GetProcessHeap(), 0, fri );
1654 delete_object( oldpath );
1655 delete_object( newpath );
1656
1657 /* oldpath is a directory, newpath is a file, Replace = FALSE, target file opened */
1658 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1659 ok( res != 0, "failed to create temp file\n" );
1660 DeleteFileW( oldpath );
1661 success = CreateDirectoryW( oldpath, NULL );
1662 ok( success != 0, "failed to create temp directory\n" );
1664 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1665
1666 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1667 ok( res != 0, "failed to create temp file\n" );
1668 handle2 = CreateFileW( newpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1669 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1670
1671 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1672 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1673 fri->Replace = FALSE;
1674 fri->RootDir = NULL;
1675 fri->FileNameLength = name_str.Length;
1676 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1677 pRtlFreeUnicodeString( &name_str );
1678
1679 U(io).Status = 0xdeadbeef;
1680 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1681 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1682 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
1684 ok( !fileDeleted, "file should exist\n" );
1686 ok( !fileDeleted, "file should exist\n" );
1687
1689 CloseHandle( handle2 );
1690 HeapFree( GetProcessHeap(), 0, fri );
1691 delete_object( oldpath );
1692 delete_object( newpath );
1693
1694 /* oldpath is a directory, newpath is a file, Replace = TRUE */
1695 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1696 ok( res != 0, "failed to create temp file\n" );
1697 DeleteFileW( oldpath );
1698 success = CreateDirectoryW( oldpath, NULL );
1699 ok( success != 0, "failed to create temp directory\n" );
1701 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1702
1703 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1704 ok( res != 0, "failed to create temp file\n" );
1705 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1706 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1707 fri->Replace = TRUE;
1708 fri->RootDir = NULL;
1709 fri->FileNameLength = name_str.Length;
1710 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1711 pRtlFreeUnicodeString( &name_str );
1712
1713 U(io).Status = 0xdeadbeef;
1714 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1715 ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
1716 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
1718 ok( fileDeleted, "file should not exist\n" );
1720 ok( !fileDeleted, "file should exist\n" );
1721
1723 HeapFree( GetProcessHeap(), 0, fri );
1724 delete_object( oldpath );
1725 delete_object( newpath );
1726
1727 /* oldpath is a directory, newpath is a file, Replace = TRUE, target file opened */
1728 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1729 ok( res != 0, "failed to create temp file\n" );
1730 DeleteFileW( oldpath );
1731 success = CreateDirectoryW( oldpath, NULL );
1732 ok( success != 0, "failed to create temp directory\n" );
1734 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1735
1736 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1737 ok( res != 0, "failed to create temp file\n" );
1738 handle2 = CreateFileW( newpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1739 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1740
1741 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1742 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1743 fri->Replace = TRUE;
1744 fri->RootDir = NULL;
1745 fri->FileNameLength = name_str.Length;
1746 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1747 pRtlFreeUnicodeString( &name_str );
1748
1749 U(io).Status = 0xdeadbeef;
1750 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1751 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1752 ok( res == STATUS_ACCESS_DENIED, "res expected STATUS_ACCESS_DENIED, got %x\n", res );
1754 ok( !fileDeleted, "file should exist\n" );
1756 ok( !fileDeleted, "file should exist\n" );
1757
1759 CloseHandle( handle2 );
1760 HeapFree( GetProcessHeap(), 0, fri );
1761 delete_object( oldpath );
1762 delete_object( newpath );
1763
1764 /* oldpath is a directory, newpath is a directory, Replace = FALSE */
1765 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1766 ok( res != 0, "failed to create temp file\n" );
1767 DeleteFileW( oldpath );
1768 success = CreateDirectoryW( oldpath, NULL );
1769 ok( success != 0, "failed to create temp directory\n" );
1771 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1772
1773 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1774 ok( res != 0, "failed to create temp file\n" );
1775 DeleteFileW( newpath );
1776 success = CreateDirectoryW( newpath, NULL );
1777 ok( success != 0, "failed to create temp directory\n" );
1778 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1779 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1780 fri->Replace = FALSE;
1781 fri->RootDir = NULL;
1782 fri->FileNameLength = name_str.Length;
1783 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1784 pRtlFreeUnicodeString( &name_str );
1785
1786 U(io).Status = 0xdeadbeef;
1787 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1788 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1789 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
1791 ok( !fileDeleted, "file should exist\n" );
1793 ok( !fileDeleted, "file should exist\n" );
1794
1796 HeapFree( GetProcessHeap(), 0, fri );
1797 delete_object( oldpath );
1798 delete_object( newpath );
1799
1800 /* oldpath is a directory, newpath is a directory, Replace = TRUE */
1801 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1802 ok( res != 0, "failed to create temp file\n" );
1803 DeleteFileW( oldpath );
1804 success = CreateDirectoryW( oldpath, NULL );
1805 ok( success != 0, "failed to create temp directory\n" );
1807 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1808
1809 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1810 ok( res != 0, "failed to create temp file\n" );
1811 DeleteFileW( newpath );
1812 success = CreateDirectoryW( newpath, NULL );
1813 ok( success != 0, "failed to create temp directory\n" );
1814 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1815 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1816 fri->Replace = TRUE;
1817 fri->RootDir = NULL;
1818 fri->FileNameLength = name_str.Length;
1819 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1820 pRtlFreeUnicodeString( &name_str );
1821
1822 U(io).Status = 0xdeadbeef;
1823 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1824 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1825 ok( res == STATUS_ACCESS_DENIED, "res expected STATUS_ACCESS_DENIED, got %x\n", res );
1827 ok( !fileDeleted, "file should exist\n" );
1829 ok( !fileDeleted, "file should exist\n" );
1830
1832 HeapFree( GetProcessHeap(), 0, fri );
1833 delete_object( oldpath );
1834 delete_object( newpath );
1835
1836 /* oldpath is a directory, newpath is a directory, Replace = TRUE, target file opened */
1837 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1838 ok( res != 0, "failed to create temp file\n" );
1839 DeleteFileW( oldpath );
1840 success = CreateDirectoryW( oldpath, NULL );
1841 ok( success != 0, "failed to create temp directory\n" );
1843 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1844
1845 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1846 ok( res != 0, "failed to create temp file\n" );
1847 DeleteFileW( newpath );
1848 success = CreateDirectoryW( newpath, NULL );
1849 ok( success != 0, "failed to create temp directory\n" );
1851 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1852
1853 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1854 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1855 fri->Replace = TRUE;
1856 fri->RootDir = NULL;
1857 fri->FileNameLength = name_str.Length;
1858 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1859 pRtlFreeUnicodeString( &name_str );
1860
1861 U(io).Status = 0xdeadbeef;
1862 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1863 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1864 ok( res == STATUS_ACCESS_DENIED, "res expected STATUS_ACCESS_DENIED, got %x\n", res );
1866 ok( !fileDeleted, "file should exist\n" );
1868 ok( !fileDeleted, "file should exist\n" );
1869
1871 CloseHandle( handle2 );
1872 HeapFree( GetProcessHeap(), 0, fri );
1873 delete_object( oldpath );
1874 delete_object( newpath );
1875
1876 /* oldpath is a file, newpath is a directory, Replace = FALSE */
1877 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1878 ok( res != 0, "failed to create temp file\n" );
1879 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1880 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1881
1882 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1883 ok( res != 0, "failed to create temp file\n" );
1884 DeleteFileW( newpath );
1885 success = CreateDirectoryW( newpath, NULL );
1886 ok( success != 0, "failed to create temp directory\n" );
1887 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1888 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1889 fri->Replace = FALSE;
1890 fri->RootDir = NULL;
1891 fri->FileNameLength = name_str.Length;
1892 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1893 pRtlFreeUnicodeString( &name_str );
1894
1895 U(io).Status = 0xdeadbeef;
1896 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1897 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1898 ok( res == STATUS_OBJECT_NAME_COLLISION, "res expected STATUS_OBJECT_NAME_COLLISION, got %x\n", res );
1900 ok( !fileDeleted, "file should exist\n" );
1902 ok( !fileDeleted, "file should exist\n" );
1903
1905 HeapFree( GetProcessHeap(), 0, fri );
1906 delete_object( oldpath );
1907 delete_object( newpath );
1908
1909 /* oldpath is a file, newpath is a directory, Replace = TRUE */
1910 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1911 ok( res != 0, "failed to create temp file\n" );
1912 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1913 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1914
1915 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1916 ok( res != 0, "failed to create temp file\n" );
1917 DeleteFileW( newpath );
1918 success = CreateDirectoryW( newpath, NULL );
1919 ok( success != 0, "failed to create temp directory\n" );
1920 pRtlDosPathNameToNtPathName_U( newpath, &name_str, NULL, NULL );
1921 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + name_str.Length );
1922 fri->Replace = TRUE;
1923 fri->RootDir = NULL;
1924 fri->FileNameLength = name_str.Length;
1925 memcpy( fri->FileName, name_str.Buffer, name_str.Length );
1926 pRtlFreeUnicodeString( &name_str );
1927
1928 U(io).Status = 0xdeadbeef;
1929 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1930 todo_wine ok( U(io).Status == 0xdeadbeef, "io.Status expected 0xdeadbeef, got %x\n", U(io).Status );
1931 ok( res == STATUS_ACCESS_DENIED, "res expected STATUS_ACCESS_DENIED, got %x\n", res );
1933 ok( !fileDeleted, "file should exist\n" );
1935 ok( !fileDeleted, "file should exist\n" );
1936
1938 HeapFree( GetProcessHeap(), 0, fri );
1939 delete_object( oldpath );
1940 delete_object( newpath );
1941
1942 /* oldpath is a file, newpath doesn't exist, test with RootDir != NULL */
1943 res = GetTempFileNameW( tmp_path, fooW, 0, oldpath );
1944 ok( res != 0, "failed to create temp file\n" );
1945 handle = CreateFileW( oldpath, GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0 );
1946 ok( handle != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1947
1948 res = GetTempFileNameW( tmp_path, fooW, 0, newpath );
1949 ok( res != 0, "failed to create temp file\n" );
1950 DeleteFileW( newpath );
1951 for (filename = newpath, p = newpath; *p; p++)
1952 if (*p == '\\') filename = p + 1;
1953 handle2 = CreateFileW( tmp_path, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 );
1954 ok( handle2 != INVALID_HANDLE_VALUE, "CreateFileW failed\n" );
1955
1956 fri = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_RENAME_INFORMATION) + lstrlenW(filename) * sizeof(WCHAR) );
1957 fri->Replace = FALSE;
1958 fri->RootDir = handle2;
1959 fri->FileNameLength = lstrlenW(filename) * sizeof(WCHAR);
1960 memcpy( fri->FileName, filename, fri->FileNameLength );
1961
1962 U(io).Status = 0xdeadbeef;
1963 res = pNtSetInformationFile( handle, &io, fri, sizeof(FILE_RENAME_INFORMATION) + fri->FileNameLength, FileRenameInformation );
1964 ok( U(io).Status == STATUS_SUCCESS, "io.Status expected STATUS_SUCCESS, got %x\n", U(io).Status );
1965 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
1967 ok( fileDeleted, "file should not exist\n" );
1969 ok( !fileDeleted, "file should exist\n" );
1970
1971 fni = HeapAlloc( GetProcessHeap(), 0, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR) );
1972 res = pNtQueryInformationFile( handle, &io, fni, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), FileNameInformation );
1973 ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
1974 fni->FileName[ fni->FileNameLength / sizeof(WCHAR) ] = 0;
1975 ok( !lstrcmpiW(fni->FileName, newpath + 2), "FileName expected %s, got %s\n",
1976 wine_dbgstr_w(newpath + 2), wine_dbgstr_w(fni->FileName) );
1977 HeapFree( GetProcessHeap(), 0, fni );
1978
1980 CloseHandle( handle2 );
1981 HeapFree( GetProcessHeap(), 0, fri );
1982 delete_object( oldpath );
1983 delete_object( newpath );
1984}
@ FileRenameInformation
Definition: from_kernel.h:71

Referenced by START_TEST().

◆ test_flush_buffers_file()

static void test_flush_buffers_file ( void  )
static

Definition at line 4415 of file file.c.

4416{
4417 char path[MAX_PATH], buffer[MAX_PATH];
4418 HANDLE hfile, hfileread;
4420 IO_STATUS_BLOCK io_status_block;
4421
4423 GetTempFileNameA(path, "foo", 0, buffer);
4426 ok(hfile != INVALID_HANDLE_VALUE, "failed to create temp file.\n" );
4427
4429 OPEN_EXISTING, 0, NULL);
4430 ok(hfileread != INVALID_HANDLE_VALUE, "could not open temp file, error %d.\n", GetLastError());
4431
4432 status = pNtFlushBuffersFile(hfile, NULL);
4433 todo_wine
4434 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %#x.\n", status);
4435
4436 status = pNtFlushBuffersFile(hfile, (IO_STATUS_BLOCK *)0xdeadbeaf);
4437 todo_wine
4438 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %#x.\n", status);
4439
4440 status = pNtFlushBuffersFile(hfile, &io_status_block);
4441 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x.\n", status);
4442
4443 status = pNtFlushBuffersFile(hfileread, &io_status_block);
4444 ok(status == STATUS_ACCESS_DENIED, "expected STATUS_ACCESS_DENIED, got %#x.\n", status);
4445
4446 status = pNtFlushBuffersFile(NULL, &io_status_block);
4447 ok(status == STATUS_INVALID_HANDLE, "expected STATUS_INVALID_HANDLE, got %#x.\n", status);
4448
4449 CloseHandle(hfileread);
4450 CloseHandle(hfile);
4452 OPEN_EXISTING, 0, NULL);
4453 ok(hfile != INVALID_HANDLE_VALUE, "could not open temp file, error %d.\n", GetLastError());
4454
4455 status = pNtFlushBuffersFile(hfile, &io_status_block);
4456 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x.\n", status);
4457
4458 CloseHandle(hfile);
4460}

Referenced by START_TEST().

◆ test_iocompletion()

static void test_iocompletion ( void  )
static

Definition at line 2874 of file file.c.

2875{
2877 NTSTATUS res;
2878
2879 res = pNtCreateIoCompletion( &h, IO_COMPLETION_ALL_ACCESS, NULL, 0);
2880
2881 ok( res == 0, "NtCreateIoCompletion anonymous failed: %x\n", res );
2882 ok( h && h != INVALID_HANDLE_VALUE, "Invalid handle returned\n" );
2883
2884 if ( h && h != INVALID_HANDLE_VALUE)
2885 {
2888 pNtClose(h);
2889 }
2890}
#define IO_COMPLETION_ALL_ACCESS
Definition: file.c:72
static void test_iocp_setcompletion(HANDLE h)
Definition: file.c:933
static void test_iocp_fileio(HANDLE h)
Definition: file.c:959

Referenced by START_TEST().

◆ test_iocp_fileio()

static void test_iocp_fileio ( HANDLE  h)
static

Definition at line 959 of file file.c.

960{
961 static const char pipe_name[] = "\\\\.\\pipe\\iocompletiontestnamedpipe";
962
965 HANDLE hPipeSrv, hPipeClt;
967
968 hPipeSrv = CreateNamedPipeA( pipe_name, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 4, 1024, 1024, 1000, NULL );
969 ok( hPipeSrv != INVALID_HANDLE_VALUE, "Cannot create named pipe\n" );
970 if (hPipeSrv != INVALID_HANDLE_VALUE )
971 {
973 ok( hPipeClt != INVALID_HANDLE_VALUE, "Cannot connect to pipe\n" );
974 if (hPipeClt != INVALID_HANDLE_VALUE)
975 {
976 U(iosb).Status = 0xdeadbeef;
977 res = pNtSetInformationFile( hPipeSrv, &iosb, &fci, sizeof(fci), FileCompletionInformation );
978 ok( res == STATUS_INVALID_PARAMETER, "Unexpected NtSetInformationFile on non-overlapped handle: %x\n", res );
979 ok( U(iosb).Status == STATUS_INVALID_PARAMETER /* 98 */ || U(iosb).Status == 0xdeadbeef /* NT4+ */,
980 "Unexpected iosb.Status on non-overlapped handle: %x\n", U(iosb).Status );
981 CloseHandle(hPipeClt);
982 }
983 CloseHandle( hPipeSrv );
984 }
985
987 ok( hPipeSrv != INVALID_HANDLE_VALUE, "Cannot create named pipe\n" );
988 if (hPipeSrv == INVALID_HANDLE_VALUE )
989 return;
990
992 ok( hPipeClt != INVALID_HANDLE_VALUE, "Cannot connect to pipe\n" );
993 if (hPipeClt != INVALID_HANDLE_VALUE)
994 {
995 OVERLAPPED o = {0,};
997 DWORD read;
998 long count;
999
1000 U(iosb).Status = 0xdeadbeef;
1001 res = pNtSetInformationFile( hPipeSrv, &iosb, &fci, sizeof(fci), FileCompletionInformation );
1002 ok( res == STATUS_SUCCESS, "NtSetInformationFile failed: %x\n", res );
1003 ok( U(iosb).Status == STATUS_SUCCESS, "iosb.Status invalid: %x\n", U(iosb).Status );
1004
1006 memset( recv_buf, 0xde, TEST_BUF_LEN );
1008 ok( !count, "Unexpected msg count: %ld\n", count );
1009 ReadFile( hPipeSrv, recv_buf, TEST_BUF_LEN, &read, &o);
1011 ok( !count, "Unexpected msg count: %ld\n", count );
1012 WriteFile( hPipeClt, send_buf, TEST_BUF_LEN, &read, NULL );
1013
1014 if (get_msg(h))
1015 {
1016 ok( completionKey == CKEY_SECOND, "Invalid completion key: %lx\n", completionKey );
1017 ok( ioSb.Information == 3, "Invalid ioSb.Information: %ld\n", ioSb.Information );
1018 ok( U(ioSb).Status == STATUS_SUCCESS, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
1019 ok( completionValue == (ULONG_PTR)&o, "Invalid completion value: %lx\n", completionValue );
1020 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] );
1021 }
1023 ok( !count, "Unexpected msg count: %ld\n", count );
1024
1026 memset( recv_buf, 0xde, TEST_BUF_LEN );
1027 WriteFile( hPipeClt, send_buf, 2, &read, NULL );
1029 ok( !count, "Unexpected msg count: %ld\n", count );
1030 ReadFile( hPipeSrv, recv_buf, 2, &read, &o);
1032 ok( count == 1, "Unexpected msg count: %ld\n", count );
1033 if (get_msg(h))
1034 {
1035 ok( completionKey == CKEY_SECOND, "Invalid completion key: %lx\n", completionKey );
1036 ok( ioSb.Information == 2, "Invalid ioSb.Information: %ld\n", ioSb.Information );
1037 ok( U(ioSb).Status == STATUS_SUCCESS, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
1038 ok( completionValue == (ULONG_PTR)&o, "Invalid completion value: %lx\n", completionValue );
1039 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] );
1040 }
1041
1042 ReadFile( hPipeSrv, recv_buf, TEST_BUF_LEN, &read, &o);
1043 CloseHandle( hPipeSrv );
1045 ok( count == 1, "Unexpected msg count: %ld\n", count );
1046 if (get_msg(h))
1047 {
1048 ok( completionKey == CKEY_SECOND, "Invalid completion key: %lx\n", completionKey );
1049 ok( ioSb.Information == 0, "Invalid ioSb.Information: %ld\n", ioSb.Information );
1050 /* wine sends wrong status here */
1051 ok( U(ioSb).Status == STATUS_PIPE_BROKEN, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
1052 ok( completionValue == (ULONG_PTR)&o, "Invalid completion value: %lx\n", completionValue );
1053 }
1054 }
1055
1056 CloseHandle( hPipeClt );
1057
1058 /* test associating a completion port with a handle after an async is queued */
1060 ok( hPipeSrv != INVALID_HANDLE_VALUE, "Cannot create named pipe\n" );
1061 if (hPipeSrv == INVALID_HANDLE_VALUE )
1062 return;
1064 ok( hPipeClt != INVALID_HANDLE_VALUE, "Cannot connect to pipe\n" );
1065 if (hPipeClt != INVALID_HANDLE_VALUE)
1066 {
1067 OVERLAPPED o = {0,};
1069 int apc_count = 0;
1070 DWORD read;
1071 long count;
1072
1074 memset( recv_buf, 0xde, TEST_BUF_LEN );
1076 ok( !count, "Unexpected msg count: %ld\n", count );
1077 ReadFile( hPipeSrv, recv_buf, TEST_BUF_LEN, &read, &o);
1078
1079 U(iosb).Status = 0xdeadbeef;
1080 res = pNtSetInformationFile( hPipeSrv, &iosb, &fci, sizeof(fci), FileCompletionInformation );
1081 ok( res == STATUS_SUCCESS, "NtSetInformationFile failed: %x\n", res );
1082 ok( U(iosb).Status == STATUS_SUCCESS, "iosb.Status invalid: %x\n", U(iosb).Status );
1084 ok( !count, "Unexpected msg count: %ld\n", count );
1085
1086 WriteFile( hPipeClt, send_buf, TEST_BUF_LEN, &read, NULL );
1087
1088 if (get_msg(h))
1089 {
1090 ok( completionKey == CKEY_SECOND, "Invalid completion key: %lx\n", completionKey );
1091 ok( ioSb.Information == 3, "Invalid ioSb.Information: %ld\n", ioSb.Information );
1092 ok( U(ioSb).Status == STATUS_SUCCESS, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
1093 ok( completionValue == (ULONG_PTR)&o, "Invalid completion value: %lx\n", completionValue );
1094 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] );
1095 }
1097 ok( !count, "Unexpected msg count: %ld\n", count );
1098
1099 /* using APCs on handle with associated completion port is not allowed */
1100 res = NtReadFile( hPipeSrv, NULL, apc, &apc_count, &iosb, recv_buf, sizeof(recv_buf), NULL, NULL );
1101 ok(res == STATUS_INVALID_PARAMETER, "NtReadFile returned %x\n", res);
1102 }
1103
1104 CloseHandle( hPipeSrv );
1105 CloseHandle( hPipeClt );
1106
1107 /* test associating a completion port with a handle after an async using APC is queued */
1109 ok( hPipeSrv != INVALID_HANDLE_VALUE, "Cannot create named pipe\n" );
1110 if (hPipeSrv == INVALID_HANDLE_VALUE )
1111 return;
1113 ok( hPipeClt != INVALID_HANDLE_VALUE, "Cannot connect to pipe\n" );
1114 if (hPipeClt != INVALID_HANDLE_VALUE)
1115 {
1117 int apc_count = 0;
1118 DWORD read;
1119 long count;
1120
1122 memset( recv_buf, 0xde, TEST_BUF_LEN );
1124 ok( !count, "Unexpected msg count: %ld\n", count );
1125
1126 res = NtReadFile( hPipeSrv, NULL, apc, &apc_count, &iosb, recv_buf, sizeof(recv_buf), NULL, NULL );
1127 ok(res == STATUS_PENDING, "NtReadFile returned %x\n", res);
1128
1129 U(iosb).Status = 0xdeadbeef;
1130 res = pNtSetInformationFile( hPipeSrv, &iosb, &fci, sizeof(fci), FileCompletionInformation );
1131 ok( res == STATUS_SUCCESS, "NtSetInformationFile failed: %x\n", res );
1132 ok( U(iosb).Status == STATUS_SUCCESS, "iosb.Status invalid: %x\n", U(iosb).Status );
1134 ok( !count, "Unexpected msg count: %ld\n", count );
1135
1136 WriteFile( hPipeClt, send_buf, TEST_BUF_LEN, &read, NULL );
1137
1138 ok(!apc_count, "apc_count = %u\n", apc_count);
1140 ok( !count, "Unexpected msg count: %ld\n", count );
1141
1142 SleepEx(1, TRUE); /* alertable sleep */
1143 ok(apc_count == 1, "apc was not called\n");
1145 ok( !count, "Unexpected msg count: %ld\n", count );
1146
1147 /* using APCs on handle with associated completion port is not allowed */
1148 res = NtReadFile( hPipeSrv, NULL, apc, &apc_count, &iosb, recv_buf, sizeof(recv_buf), NULL, NULL );
1149 ok(res == STATUS_INVALID_PARAMETER, "NtReadFile returned %x\n", res);
1150 }
1151
1152 CloseHandle( hPipeSrv );
1153 CloseHandle( hPipeClt );
1154}
#define read
Definition: acwin.h:96
@ FileCompletionInformation
Definition: from_kernel.h:91
#define FILE_FLAG_NO_BUFFERING
Definition: disk.h:45
#define TEST_BUF_LEN
Definition: file.c:121
#define CKEY_SECOND
Definition: file.c:138
static ULONG get_pending_msgs(HANDLE h)
Definition: file.c:144
static BOOL get_msg(HANDLE h)
Definition: file.c:156
static int send_buf(SOCKET s, const char *buf, size_t length)
Definition: send.c:74
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
#define STATUS_PIPE_BROKEN
Definition: ntstatus.h:567
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
#define PIPE_ACCESS_INBOUND
Definition: winbase.h:165
#define PIPE_WAIT
Definition: winbase.h:171
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:168

Referenced by test_iocompletion().

◆ test_iocp_setcompletion()

static void test_iocp_setcompletion ( HANDLE  h)
static

Definition at line 933 of file file.c.

934{
936 ULONG count;
937 SIZE_T size = 3;
938
939 if (sizeof(size) > 4) size |= (ULONGLONG)0x12345678 << 32;
940
942 ok( res == STATUS_SUCCESS, "NtSetIoCompletion failed: %x\n", res );
943
945 ok( count == 1, "Unexpected msg count: %d\n", count );
946
947 if (get_msg(h))
948 {
949 ok( completionKey == CKEY_FIRST, "Invalid completion key: %lx\n", completionKey );
950 ok( ioSb.Information == size, "Invalid ioSb.Information: %lu\n", ioSb.Information );
951 ok( U(ioSb).Status == STATUS_INVALID_DEVICE_REQUEST, "Invalid ioSb.Status: %x\n", U(ioSb).Status);
952 ok( completionValue == CVALUE_FIRST, "Invalid completion value: %lx\n", completionValue );
953 }
954
956 ok( !count, "Unexpected msg count: %d\n", count );
957}
GLsizeiptr size
Definition: glext.h:5919
#define CKEY_FIRST
Definition: file.c:137
#define CVALUE_FIRST
Definition: file.c:136
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by test_iocompletion().

◆ test_ioctl()

static void test_ioctl ( void  )
static

Definition at line 4384 of file file.c.

4385{
4386 HANDLE event = CreateEventA(NULL, TRUE, FALSE, NULL);
4387 FILE_PIPE_PEEK_BUFFER peek_buf;
4389 HANDLE file;
4391
4393 ok(file != INVALID_HANDLE_VALUE, "could not create temp file\n");
4394
4395 SetEvent(event);
4396 status = pNtFsControlFile(file, event, NULL, NULL, &iosb, 0xdeadbeef, 0, 0, 0, 0);
4397 todo_wine
4398 ok(status == STATUS_INVALID_DEVICE_REQUEST, "NtFsControlFile returned %x\n", status);
4399 ok(!is_signaled(event), "event is signaled\n");
4400
4401 status = pNtFsControlFile(file, (HANDLE)0xdeadbeef, NULL, NULL, &iosb, 0xdeadbeef, 0, 0, 0, 0);
4402 ok(status == STATUS_INVALID_HANDLE, "NtFsControlFile returned %x\n", status);
4403
4404 memset(&iosb, 0x55, sizeof(iosb));
4406 &peek_buf, sizeof(peek_buf));
4407 todo_wine
4408 ok(status == STATUS_INVALID_DEVICE_REQUEST, "NtFsControlFile failed: %x\n", status);
4409 ok(iosb.Status == 0x55555555, "iosb.Status = %x\n", iosb.Status);
4410
4413}
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FSCTL_PIPE_PEEK
Definition: winioctl.h:196
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733

Referenced by START_TEST().

◆ test_junction_points()

static void test_junction_points ( void  )
static

Definition at line 4561 of file file.c.

4562{
4563 static const WCHAR junctionW[] = {'\\','j','u','n','c','t','i','o','n',0};
4564 WCHAR path[MAX_PATH], junction_path[MAX_PATH], target_path[MAX_PATH];
4565 static const WCHAR targetW[] = {'\\','t','a','r','g','e','t',0};
4566 FILE_BASIC_INFORMATION old_attrib, new_attrib;
4567 static const WCHAR fooW[] = {'f','o','o',0};
4568 static WCHAR volW[] = {'c',':','\\',0};
4569 REPARSE_GUID_DATA_BUFFER guid_buffer;
4570 static const WCHAR dotW[] = {'.',0};
4572 DWORD dwret, dwLen, dwFlags, err;
4573 INT buffer_len, string_len;
4576 HANDLE hJunction;
4577 WCHAR *dest;
4578 BOOL bret;
4579
4580 /* Create a temporary folder for the junction point tests */
4583 if (!CreateDirectoryW(path, NULL))
4584 {
4585 win_skip("Unable to create a temporary junction point directory.\n");
4586 return;
4587 }
4588
4589 /* Check that the volume this folder is located on supports junction points */
4590 pRtlDosPathNameToNtPathName_U(path, &nameW, NULL, NULL);
4591 volW[0] = nameW.Buffer[4];
4592 pRtlFreeUnicodeString( &nameW );
4593 GetVolumeInformationW(volW, 0, 0, 0, &dwLen, &dwFlags, 0, 0);
4595 {
4596 skip("File system does not support junction points.\n");
4598 return;
4599 }
4600
4601 /* Create the folder to be replaced by a junction point */
4602 lstrcpyW(junction_path, path);
4603 lstrcatW(junction_path, junctionW);
4604 bret = CreateDirectoryW(junction_path, NULL);
4605 ok(bret, "Failed to create junction point directory.\n");
4606
4607 /* Create a destination folder for the junction point to target */
4608 lstrcpyW(target_path, path);
4609 lstrcatW(target_path, targetW);
4610 bret = CreateDirectoryW(target_path, NULL);
4611 ok(bret, "Failed to create junction point target directory.\n");
4612 pRtlDosPathNameToNtPathName_U(target_path, &nameW, NULL, NULL);
4613
4614 /* Create the junction point */
4615 hJunction = CreateFileW(junction_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
4617 if (hJunction == INVALID_HANDLE_VALUE)
4618 {
4619 win_skip("Failed to open junction point directory handle (0x%x).\n", GetLastError());
4620 goto cleanup;
4621 }
4622 dwret = NtQueryInformationFile(hJunction, &iosb, &old_attrib, sizeof(old_attrib), FileBasicInformation);
4623 ok(dwret == STATUS_SUCCESS, "Failed to get junction point folder's attributes (0x%x).\n", dwret);
4624 buffer_len = build_reparse_buffer(nameW.Buffer, &buffer);
4625 bret = DeviceIoControl(hJunction, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0);
4626 ok(bret, "Failed to create junction point! (0x%x)\n", GetLastError());
4627
4628 /* Check the file attributes of the junction point */
4629 dwret = GetFileAttributesW(junction_path);
4630 ok(dwret != (DWORD)~0, "Junction point doesn't exist (attributes: 0x%x)!\n", dwret);
4631 ok(dwret & FILE_ATTRIBUTE_REPARSE_POINT, "File is not a junction point! (attributes: %d)\n", dwret);
4632
4633 /* Read back the junction point */
4635 buffer_len = sizeof(*buffer) + MAX_PATH*sizeof(WCHAR);
4637 bret = DeviceIoControl(hJunction, FSCTL_GET_REPARSE_POINT, NULL, 0, (LPVOID)buffer, buffer_len, &dwret, 0);
4638 string_len = buffer->MountPointReparseBuffer.SubstituteNameLength;
4639 dest = &buffer->MountPointReparseBuffer.PathBuffer[buffer->MountPointReparseBuffer.SubstituteNameOffset/sizeof(WCHAR)];
4640 ok(bret, "Failed to read junction point!\n");
4641 ok((memcmp(dest, nameW.Buffer, string_len) == 0), "Junction point destination does not match ('%s' != '%s')!\n",
4643
4644 /* Delete the junction point */
4645 memset(&old_attrib, 0x00, sizeof(old_attrib));
4646 old_attrib.LastAccessTime.QuadPart = 0x200deadcafebeef;
4647 dwret = NtSetInformationFile(hJunction, &iosb, &old_attrib, sizeof(old_attrib), FileBasicInformation);
4648 ok(dwret == STATUS_SUCCESS, "Failed to set junction point folder's attributes (0x%x).\n", dwret);
4649 memset(&guid_buffer, 0x00, sizeof(guid_buffer));
4651 bret = DeviceIoControl(hJunction, FSCTL_DELETE_REPARSE_POINT, (LPVOID)&guid_buffer,
4653 ok(bret, "Failed to delete junction point! (0x%x)\n", GetLastError());
4654 memset(&new_attrib, 0x00, sizeof(new_attrib));
4655 dwret = NtQueryInformationFile(hJunction, &iosb, &new_attrib, sizeof(new_attrib), FileBasicInformation);
4656 ok(dwret == STATUS_SUCCESS, "Failed to get junction point folder's attributes (0x%x).\n", dwret);
4657 ok(old_attrib.LastAccessTime.QuadPart == new_attrib.LastAccessTime.QuadPart,
4658 "Junction point folder's access time does not match.\n");
4659 CloseHandle(hJunction);
4660
4661 /* Check deleting a junction point as if it were a directory */
4663 hJunction = CreateFileW(junction_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
4665 buffer_len = build_reparse_buffer(nameW.Buffer, &buffer);
4666 bret = DeviceIoControl(hJunction, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0);
4667 ok(bret, "Failed to create junction point! (0x%x)\n", GetLastError());
4668 CloseHandle(hJunction);
4669 bret = RemoveDirectoryW(junction_path);
4670 ok(bret, "Failed to delete junction point as directory!\n");
4671 dwret = GetFileAttributesW(junction_path);
4672 ok(dwret == (DWORD)~0, "Junction point still exists (attributes: 0x%x)!\n", dwret);
4673
4674 /* Check deleting a junction point as if it were a file */
4676 bret = CreateDirectoryW(junction_path, NULL);
4677 ok(bret, "Failed to create junction point target directory.\n");
4678 hJunction = CreateFileW(junction_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
4680 buffer_len = build_reparse_buffer(nameW.Buffer, &buffer);
4681 bret = DeviceIoControl(hJunction, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0);
4682 ok(bret, "Failed to create junction point! (0x%x)\n", GetLastError());
4683 CloseHandle(hJunction);
4684 bret = DeleteFileW(junction_path);
4685 ok(!bret, "Succeeded in deleting junction point as file!\n");
4686 err = GetLastError();
4687 ok(err == ERROR_ACCESS_DENIED, "Expected last error 0x%x for DeleteFile on junction point (actually 0x%x)!\n",
4689 dwret = GetFileAttributesW(junction_path);
4690 ok(dwret != (DWORD)~0, "Junction point doesn't exist (attributes: 0x%x)!\n", dwret);
4691 ok(dwret & FILE_ATTRIBUTE_REPARSE_POINT, "File is not a junction point! (attributes: 0x%x)\n", dwret);
4692
4693 /* Test deleting a junction point's target */
4694 dwret = GetFileAttributesW(junction_path);
4695 ok(dwret == 0x410 || broken(dwret == 0x430) /* win2k */,
4696 "Unexpected junction point attributes (0x%x != 0x410)!\n", dwret);
4697 bret = RemoveDirectoryW(target_path);
4698 ok(bret, "Failed to delete junction point target!\n");
4699 bret = CreateDirectoryW(target_path, NULL);
4700 ok(bret, "Failed to create junction point target directory.\n");
4701
4702cleanup:
4703 /* Cleanup */
4704 pRtlFreeUnicodeString( &nameW );
4706 bret = RemoveDirectoryW(junction_path);
4707 ok(bret, "Failed to remove temporary junction point directory!\n");
4708 bret = RemoveDirectoryW(target_path);
4709 ok(bret, "Failed to remove temporary target directory!\n");
4711}
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
static void cleanup(void)
Definition: main.c:1335
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
#define FILE_SUPPORTS_REPARSE_POINTS
Definition: from_kernel.h:240
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
static const WCHAR dotW[]
Definition: directory.c:80
static INT build_reparse_buffer(WCHAR *filename, REPARSE_DATA_BUFFER **pbuffer)
Definition: file.c:4542
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:3096
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
#define FSCTL_GET_REPARSE_POINT
Definition: winioctl.h:97
#define FSCTL_SET_REPARSE_POINT
Definition: winioctl.h:98
#define FSCTL_DELETE_REPARSE_POINT
Definition: winioctl.h:99
#define err(...)
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define REPARSE_GUID_DATA_BUFFER_HEADER_SIZE
Definition: iotypes.h:7211

Referenced by START_TEST().

◆ test_NtCreateFile()

static void test_NtCreateFile ( void  )
static

Definition at line 3462 of file file.c.

3463{
3464 static const struct test_data
3465 {
3466 DWORD disposition, attrib_in, status, result, attrib_out, needs_cleanup;
3467 } td[] =
3468 {
3470 /* 1*/{ FILE_CREATE, 0, STATUS_OBJECT_NAME_COLLISION, 0, 0, TRUE },
3478 /* 9*/{ FILE_OVERWRITE, 0, STATUS_ACCESS_DENIED, 0, 0, TRUE },
3482 /*13*/{ FILE_OVERWRITE_IF, 0, STATUS_ACCESS_DENIED, 0, 0, TRUE },
3488 };
3489 static const WCHAR fooW[] = {'f','o','o',0};
3491 HANDLE handle;
3496 DWORD ret, i;
3497
3501 pRtlDosPathNameToNtPathName_U(path, &nameW, NULL, NULL);
3502
3503 attr.Length = sizeof(attr);
3504 attr.RootDirectory = NULL;
3505 attr.ObjectName = &nameW;
3506 attr.Attributes = OBJ_CASE_INSENSITIVE;
3507 attr.SecurityDescriptor = NULL;
3508 attr.SecurityQualityOfService = NULL;
3509
3510 for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
3511 {
3512 status = pNtCreateFile(&handle, GENERIC_READ, &attr, &io, NULL,
3513 td[i].attrib_in, FILE_SHARE_READ|FILE_SHARE_WRITE,
3514 td[i].disposition, 0, NULL, 0);
3515
3516 ok(status == td[i].status, "%d: expected %#x got %#x\n", i, td[i].status, status);
3517
3518 if (!status)
3519 {
3520 ok(io.Information == td[i].result,"%d: expected %#x got %#lx\n", i, td[i].result, io.Information);
3521
3523 ret &= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
3524 /* FIXME: leave only 'else' case below once Wine is fixed */
3525 if (ret != td[i].attrib_out)
3526 {
3527 todo_wine
3528 ok(ret == td[i].attrib_out, "%d: expected %#x got %#x\n", i, td[i].attrib_out, ret);
3529 SetFileAttributesW(path, td[i].attrib_out);
3530 }
3531 else
3532 ok(ret == td[i].attrib_out, "%d: expected %#x got %#x\n", i, td[i].attrib_out, ret);
3533
3535 }
3536
3537 if (td[i].needs_cleanup)
3538 {
3541 }
3542 }
3543
3544 pRtlFreeUnicodeString( &nameW );
3546 DeleteFileW( path );
3547}
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
GLuint64EXT * result
Definition: glext.h:11304
#define FILE_CREATED
Definition: nt_native.h:770
#define FILE_OVERWRITTEN
Definition: nt_native.h:771
#define FILE_SUPERSEDED
Definition: nt_native.h:768
#define FILE_OPENED
Definition: nt_native.h:769
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by START_TEST().

◆ test_query_attribute_information_file()

static void test_query_attribute_information_file ( void  )
static

Definition at line 3416 of file file.c.

3417{
3419 HANDLE dir;
3426
3428 pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL );
3429 attr.Length = sizeof(attr);
3430 attr.RootDirectory = 0;
3431 attr.ObjectName = &nameW;
3432 attr.Attributes = OBJ_CASE_INSENSITIVE;
3433 attr.SecurityDescriptor = NULL;
3434 attr.SecurityQualityOfService = NULL;
3435
3436 status = pNtOpenFile( &dir, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &io,
3438 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
3439 pRtlFreeUnicodeString( &nameW );
3440
3441 ZeroMemory( buf, sizeof(buf) );
3442 U(io).Status = 0xdadadada;
3443 io.Information = 0xcacacaca;
3444
3445 status = pNtQueryVolumeInformationFile( dir, &io, buf, sizeof(buf), FileFsAttributeInformation );
3446
3448
3449 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %d\n", status);
3450 ok(U(io).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %d\n", U(io).Status);
3451 ok(ffai->FileSystemAttribute != 0, "Missing FileSystemAttribute\n");
3452 ok(ffai->MaximumComponentNameLength != 0, "Missing MaximumComponentNameLength\n");
3453 ok(ffai->FileSystemNameLength != 0, "Missing FileSystemNameLength\n");
3454
3455 trace("FileSystemAttribute: %x MaximumComponentNameLength: %x FileSystemName: %s\n",
3458
3459 CloseHandle( dir );
3460}
const char * wine_dbgstr_wn(const WCHAR *str, int n)
Definition: compat.c:367
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
@ FileFsAttributeInformation
Definition: from_kernel.h:223
#define ZeroMemory
Definition: winbase.h:1712

Referenced by START_TEST().

◆ test_query_ea()

static void test_query_ea ( void  )
static

Definition at line 4462 of file file.c.

4463{
4464 #define EA_BUFFER_SIZE 4097
4465 unsigned char data[EA_BUFFER_SIZE + 8];
4466 unsigned char *buffer = (void *)(((DWORD_PTR)data + 7) & ~7);
4467 DWORD buffer_len, i;
4470 HANDLE handle;
4471
4472 if (!(handle = create_temp_file(0))) return;
4473
4474 /* test with INVALID_HANDLE_VALUE */
4475 U(io).Status = 0xdeadbeef;
4476 io.Information = 0xdeadbeef;
4478 buffer_len = EA_BUFFER_SIZE - 1;
4479 status = pNtQueryEaFile(INVALID_HANDLE_VALUE, &io, buffer, buffer_len, TRUE, NULL, 0, NULL, FALSE);
4480 ok(status == STATUS_OBJECT_TYPE_MISMATCH, "expected STATUS_OBJECT_TYPE_MISMATCH, got %x\n", status);
4481 ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
4482 ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
4483 ok(buffer[0] == 0xcc, "data at position 0 overwritten\n");
4484
4485 /* test with 0xdeadbeef */
4486 U(io).Status = 0xdeadbeef;
4487 io.Information = 0xdeadbeef;
4489 buffer_len = EA_BUFFER_SIZE - 1;
4490 status = pNtQueryEaFile((void *)0xdeadbeef, &io, buffer, buffer_len, TRUE, NULL, 0, NULL, FALSE);
4491 ok(status == STATUS_INVALID_HANDLE, "expected STATUS_INVALID_HANDLE, got %x\n", status);
4492 ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
4493 ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
4494 ok(buffer[0] == 0xcc, "data at position 0 overwritten\n");
4495
4496 /* test without buffer */
4497 U(io).Status = 0xdeadbeef;
4498 io.Information = 0xdeadbeef;
4499 status = pNtQueryEaFile(handle, &io, NULL, 0, TRUE, NULL, 0, NULL, FALSE);
4500 ok(status == STATUS_NO_EAS_ON_FILE, "expected STATUS_NO_EAS_ON_FILE, got %x\n", status);
4501 ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
4502 ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
4503
4504 /* test with zero buffer */
4505 U(io).Status = 0xdeadbeef;
4506 io.Information = 0xdeadbeef;
4507 status = pNtQueryEaFile(handle, &io, buffer, 0, TRUE, NULL, 0, NULL, FALSE);
4508 ok(status == STATUS_NO_EAS_ON_FILE, "expected STATUS_NO_EAS_ON_FILE, got %x\n", status);
4509 ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
4510 ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
4511
4512 /* test with very small buffer */
4513 U(io).Status = 0xdeadbeef;
4514 io.Information = 0xdeadbeef;
4516 buffer_len = 4;
4517 status = pNtQueryEaFile(handle, &io, buffer, buffer_len, TRUE, NULL, 0, NULL, FALSE);
4518 ok(status == STATUS_NO_EAS_ON_FILE, "expected STATUS_NO_EAS_ON_FILE, got %x\n", status);
4519 ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
4520 ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
4521 for (i = 0; i < buffer_len && !buffer[i]; i++);
4522 ok(i == buffer_len, "expected %u bytes filled with 0x00, got %u bytes\n", buffer_len, i);
4523 ok(buffer[i] == 0xcc, "data at position %u overwritten\n", buffer[i]);
4524
4525 /* test with very big buffer */
4526 U(io).Status = 0xdeadbeef;
4527 io.Information = 0xdeadbeef;
4529 buffer_len = EA_BUFFER_SIZE - 1;
4530 status = pNtQueryEaFile(handle, &io, buffer, buffer_len, TRUE, NULL, 0, NULL, FALSE);
4531 ok(status == STATUS_NO_EAS_ON_FILE, "expected STATUS_NO_EAS_ON_FILE, got %x\n", status);
4532 ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
4533 ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
4534 for (i = 0; i < buffer_len && !buffer[i]; i++);
4535 ok(i == buffer_len, "expected %u bytes filled with 0x00, got %u bytes\n", buffer_len, i);
4536 ok(buffer[i] == 0xcc, "data at position %u overwritten\n", buffer[i]);
4537
4539 #undef EA_BUFFER_SIZE
4540}
#define EA_BUFFER_SIZE
#define STATUS_NO_EAS_ON_FILE
Definition: ntstatus.h:318
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:273
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by START_TEST().

◆ test_query_volume_information_file()

static void test_query_volume_information_file ( void  )
static

Definition at line 3363 of file file.c.

3364{
3366 HANDLE dir;
3372 BYTE buf[sizeof(FILE_FS_VOLUME_INFORMATION) + MAX_PATH * sizeof(WCHAR)];
3373
3375 pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL );
3376 attr.Length = sizeof(attr);
3377 attr.RootDirectory = 0;
3378 attr.ObjectName = &nameW;
3379 attr.Attributes = OBJ_CASE_INSENSITIVE;
3380 attr.SecurityDescriptor = NULL;
3381 attr.SecurityQualityOfService = NULL;
3382
3383 status = pNtOpenFile( &dir, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &io,
3385 ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
3386 pRtlFreeUnicodeString( &nameW );
3387
3388 ZeroMemory( buf, sizeof(buf) );
3389 U(io).Status = 0xdadadada;
3390 io.Information = 0xcacacaca;
3391
3392 status = pNtQueryVolumeInformationFile( dir, &io, buf, sizeof(buf), FileFsVolumeInformation );
3393
3395
3396 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %d\n", status);
3397 ok(U(io).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %d\n", U(io).Status);
3398
3400{
3401 ok(io.Information == (FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel) + ffvi->VolumeLabelLength),
3402 "expected %d, got %lu\n", (FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel) + ffvi->VolumeLabelLength),
3403 io.Information);
3404
3405 ok(ffvi->VolumeCreationTime.QuadPart != 0, "Missing VolumeCreationTime\n");
3406 ok(ffvi->VolumeSerialNumber != 0, "Missing VolumeSerialNumber\n");
3407 ok(ffvi->SupportsObjects == 1,"expected 1, got %d\n", ffvi->SupportsObjects);
3408}
3409 ok(ffvi->VolumeLabelLength == lstrlenW(ffvi->VolumeLabel) * sizeof(WCHAR), "got %d\n", ffvi->VolumeLabelLength);
3410
3411 trace("VolumeSerialNumber: %x VolumeLabelName: %s\n", ffvi->VolumeSerialNumber, wine_dbgstr_w(ffvi->VolumeLabel));
3412
3413 CloseHandle( dir );
3414}
@ FileFsVolumeInformation
Definition: from_kernel.h:219
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION
LARGE_INTEGER VolumeCreationTime
Definition: winioctl.h:408

Referenced by START_TEST().

◆ test_read_write()

static void test_read_write ( void  )
static

Definition at line 3626 of file file.c.

3627{
3628 static const char contents[14] = "1234567890abcd";
3629 char buf[256];
3630 HANDLE hfile, event;
3631 OVERLAPPED ovl;
3632 IO_STATUS_BLOCK iob;
3633 DWORD ret, bytes, status, off;
3635 LONG i;
3636
3637 event = CreateEventA( NULL, TRUE, FALSE, NULL );
3638
3639 U(iob).Status = -1;
3640 iob.Information = -1;
3641 offset.QuadPart = 0;
3642 status = pNtReadFile(INVALID_HANDLE_VALUE, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
3643 ok(status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, "expected STATUS_OBJECT_TYPE_MISMATCH, got %#x\n", status);
3644 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3645 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3646
3647 U(iob).Status = -1;
3648 iob.Information = -1;
3649 offset.QuadPart = 0;
3650 status = pNtReadFile(INVALID_HANDLE_VALUE, 0, NULL, NULL, &iob, NULL, sizeof(buf), &offset, NULL);
3651 ok(status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, "expected STATUS_OBJECT_TYPE_MISMATCH, got %#x\n", status);
3652 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3653 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3654
3655 U(iob).Status = -1;
3656 iob.Information = -1;
3657 offset.QuadPart = 0;
3658 status = pNtWriteFile(INVALID_HANDLE_VALUE, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
3659 ok(status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, "expected STATUS_OBJECT_TYPE_MISMATCH, got %#x\n", status);
3660 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3661 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3662
3663 U(iob).Status = -1;
3664 iob.Information = -1;
3665 offset.QuadPart = 0;
3666 status = pNtWriteFile(INVALID_HANDLE_VALUE, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
3667 ok(status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_INVALID_HANDLE, "expected STATUS_OBJECT_TYPE_MISMATCH, got %#x\n", status);
3668 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3669 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3670
3671 hfile = create_temp_file(0);
3672 if (!hfile) return;
3673
3674 U(iob).Status = -1;
3675 iob.Information = -1;
3676 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, NULL, sizeof(contents), NULL, NULL);
3677 ok(status == STATUS_INVALID_USER_BUFFER, "expected STATUS_INVALID_USER_BUFFER, got %#x\n", status);
3678 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3679 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3680
3681 U(iob).Status = -1;
3682 iob.Information = -1;
3683 SetEvent(event);
3684 status = pNtWriteFile(hfile, event, NULL, NULL, &iob, NULL, sizeof(contents), NULL, NULL);
3685 ok(status == STATUS_INVALID_USER_BUFFER, "expected STATUS_INVALID_USER_BUFFER, got %#x\n", status);
3686 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3687 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3688 ok(!is_signaled(event), "event is not signaled\n");
3689
3690 U(iob).Status = -1;
3691 iob.Information = -1;
3692 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, NULL, sizeof(contents), NULL, NULL);
3693 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %#x\n", status);
3694 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3695 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3696
3697 U(iob).Status = -1;
3698 iob.Information = -1;
3699 SetEvent(event);
3700 status = pNtReadFile(hfile, event, NULL, NULL, &iob, NULL, sizeof(contents), NULL, NULL);
3701 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %#x\n", status);
3702 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3703 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3704 ok(is_signaled(event), "event is not signaled\n");
3705
3706 U(iob).Status = -1;
3707 iob.Information = -1;
3708 SetEvent(event);
3709 status = pNtReadFile(hfile, event, NULL, NULL, &iob, (void*)0xdeadbeef, sizeof(contents), NULL, NULL);
3710 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %#x\n", status);
3711 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3712 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
3713 ok(is_signaled(event), "event is not signaled\n");
3714
3715 U(iob).Status = -1;
3716 iob.Information = -1;
3717 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents, 7, NULL, NULL);
3718 ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
3719 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3720 ok(iob.Information == 7, "expected 7, got %lu\n", iob.Information);
3721
3722 SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
3723
3724 U(iob).Status = -1;
3725 iob.Information = -1;
3726 offset.QuadPart = (LONGLONG)-1 /* FILE_WRITE_TO_END_OF_FILE */;
3727 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents + 7, sizeof(contents) - 7, &offset, NULL);
3728 ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
3729 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3730 ok(iob.Information == sizeof(contents) - 7, "expected sizeof(contents)-7, got %lu\n", iob.Information);
3731
3732 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3733 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3734
3735 bytes = 0xdeadbeef;
3736 SetLastError(0xdeadbeef);
3738 ok(!ret, "ReadFile should fail\n");
3739 ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
3740 ok(bytes == 0, "bytes %u\n", bytes);
3741
3742 bytes = 0xdeadbeef;
3743 SetLastError(0xdeadbeef);
3744 ret = ReadFile(hfile, buf, 0, &bytes, NULL);
3745 ok(ret, "ReadFile error %d\n", GetLastError());
3746 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
3747 ok(bytes == 0, "bytes %u\n", bytes);
3748
3749 bytes = 0xdeadbeef;
3750 SetLastError(0xdeadbeef);
3751 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL);
3752 ok(ret, "ReadFile error %d\n", GetLastError());
3753 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
3754 ok(bytes == 0, "bytes %u\n", bytes);
3755
3756 SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
3757
3758 bytes = 0;
3759 SetLastError(0xdeadbeef);
3760 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL);
3761 ok(ret, "ReadFile error %d\n", GetLastError());
3762 ok(bytes == sizeof(contents), "bytes %u\n", bytes);
3763 ok(!memcmp(contents, buf, sizeof(contents)), "file contents mismatch\n");
3764
3765 for (i = -20; i < -1; i++)
3766 {
3767 if (i == -2) continue;
3768
3769 U(iob).Status = -1;
3770 iob.Information = -1;
3771 offset.QuadPart = (LONGLONG)i;
3772 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents, sizeof(contents), &offset, NULL);
3773 ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
3774 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3775 ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
3776 }
3777
3778 SetFilePointer(hfile, sizeof(contents) - 4, NULL, FILE_BEGIN);
3779
3780 U(iob).Status = -1;
3781 iob.Information = -1;
3782 offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */;
3783 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, "DCBA", 4, &offset, NULL);
3784 ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
3785 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3786 ok(iob.Information == 4, "expected 4, got %lu\n", iob.Information);
3787
3788 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3789 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3790
3791 U(iob).Status = -1;
3792 iob.Information = -1;
3793 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL);
3794 ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
3795 ok(U(iob).Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", U(iob).Status);
3796 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
3797
3798 SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
3799
3800 bytes = 0;
3801 SetLastError(0xdeadbeef);
3802 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL);
3803 ok(ret, "ReadFile error %d\n", GetLastError());
3804 ok(bytes == sizeof(contents), "bytes %u\n", bytes);
3805 ok(!memcmp(contents, buf, sizeof(contents) - 4), "file contents mismatch\n");
3806 ok(!memcmp(buf + sizeof(contents) - 4, "DCBA", 4), "file contents mismatch\n");
3807
3808 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3809 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3810
3811 SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
3812
3813 bytes = 0;
3814 SetLastError(0xdeadbeef);
3815 ret = WriteFile(hfile, contents, sizeof(contents), &bytes, NULL);
3816 ok(ret, "WriteFile error %d\n", GetLastError());
3817 ok(bytes == sizeof(contents), "bytes %u\n", bytes);
3818
3819 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3820 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3821
3822 /* test reading beyond EOF */
3823 bytes = -1;
3824 SetLastError(0xdeadbeef);
3825 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL);
3826 ok(ret, "ReadFile error %d\n", GetLastError());
3827 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
3828 ok(bytes == 0, "bytes %u\n", bytes);
3829
3830 bytes = -1;
3831 SetLastError(0xdeadbeef);
3832 ret = ReadFile(hfile, buf, 0, &bytes, NULL);
3833 ok(ret, "ReadFile error %d\n", GetLastError());
3834 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
3835 ok(bytes == 0, "bytes %u\n", bytes);
3836
3837 bytes = -1;
3838 SetLastError(0xdeadbeef);
3839 ret = ReadFile(hfile, NULL, 0, &bytes, NULL);
3840 ok(ret, "ReadFile error %d\n", GetLastError());
3841 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
3842 ok(bytes == 0, "bytes %u\n", bytes);
3843
3844 S(U(ovl)).Offset = sizeof(contents);
3845 S(U(ovl)).OffsetHigh = 0;
3846 ovl.Internal = -1;
3847 ovl.InternalHigh = -1;
3848 ovl.hEvent = 0;
3849 bytes = -1;
3850 SetLastError(0xdeadbeef);
3851 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl);
3852 ok(!ret, "ReadFile should fail\n");
3853 ok(GetLastError() == ERROR_HANDLE_EOF, "expected ERROR_HANDLE_EOF, got %d\n", GetLastError());
3854 ok(bytes == 0, "bytes %u\n", bytes);
3855 ok((NTSTATUS)ovl.Internal == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#lx\n", ovl.Internal);
3856 ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
3857
3858 S(U(ovl)).Offset = sizeof(contents);
3859 S(U(ovl)).OffsetHigh = 0;
3860 ovl.Internal = -1;
3861 ovl.InternalHigh = -1;
3862 ovl.hEvent = 0;
3863 bytes = -1;
3864 SetLastError(0xdeadbeef);
3865 ret = ReadFile(hfile, buf, 0, &bytes, &ovl);
3866 ok(ret, "ReadFile error %d\n", GetLastError());
3867 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
3868 ok(bytes == 0, "bytes %u\n", bytes);
3869 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
3870 ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
3871
3872 U(iob).Status = -1;
3873 iob.Information = -1;
3874 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL);
3875 ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
3876 ok(U(iob).Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", U(iob).Status);
3877 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
3878
3879 U(iob).Status = -1;
3880 iob.Information = -1;
3881 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, NULL, NULL);
3882 ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
3883 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3884 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
3885
3886 U(iob).Status = -1;
3887 iob.Information = -1;
3888 offset.QuadPart = sizeof(contents);
3889 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
3890 ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
3891 ok(U(iob).Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", U(iob).Status);
3892 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
3893
3894 U(iob).Status = -1;
3895 iob.Information = -1;
3896 offset.QuadPart = sizeof(contents);
3897 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
3898 ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
3899 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3900 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
3901
3902 U(iob).Status = -1;
3903 iob.Information = -1;
3904 offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */;
3905 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
3906 ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
3907 ok(U(iob).Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", U(iob).Status);
3908 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
3909
3910 U(iob).Status = -1;
3911 iob.Information = -1;
3912 offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */;
3913 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
3914 ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
3915 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3916 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
3917
3918 for (i = -20; i < 0; i++)
3919 {
3920 if (i == -2) continue;
3921
3922 U(iob).Status = -1;
3923 iob.Information = -1;
3924 offset.QuadPart = (LONGLONG)i;
3925 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
3926 ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
3927 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
3928 ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
3929 }
3930
3931 SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
3932
3933 bytes = 0;
3934 SetLastError(0xdeadbeef);
3935 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL);
3936 ok(ret, "ReadFile error %d\n", GetLastError());
3937 ok(bytes == sizeof(contents), "bytes %u\n", bytes);
3938 ok(!memcmp(contents, buf, sizeof(contents)), "file contents mismatch\n");
3939
3940 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3941 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3942
3943 U(iob).Status = -1;
3944 iob.Information = -1;
3945 offset.QuadPart = 0;
3946 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
3947 ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
3948 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3949 ok(iob.Information == sizeof(contents), "expected sizeof(contents), got %lu\n", iob.Information);
3950 ok(!memcmp(contents, buf, sizeof(contents)), "file contents mismatch\n");
3951
3952 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3953 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3954
3955 U(iob).Status = -1;
3956 iob.Information = -1;
3957 offset.QuadPart = sizeof(contents) - 4;
3958 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, "DCBA", 4, &offset, NULL);
3959 ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
3960 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3961 ok(iob.Information == 4, "expected 4, got %lu\n", iob.Information);
3962
3963 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3964 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3965
3966 U(iob).Status = -1;
3967 iob.Information = -1;
3968 offset.QuadPart = 0;
3969 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
3970 ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
3971 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
3972 ok(iob.Information == sizeof(contents), "expected sizeof(contents), got %lu\n", iob.Information);
3973 ok(!memcmp(contents, buf, sizeof(contents) - 4), "file contents mismatch\n");
3974 ok(!memcmp(buf + sizeof(contents) - 4, "DCBA", 4), "file contents mismatch\n");
3975
3976 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3977 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3978
3979 S(U(ovl)).Offset = sizeof(contents) - 4;
3980 S(U(ovl)).OffsetHigh = 0;
3981 ovl.hEvent = 0;
3982 bytes = 0;
3983 SetLastError(0xdeadbeef);
3984 ret = WriteFile(hfile, "ABCD", 4, &bytes, &ovl);
3985 ok(ret, "WriteFile error %d\n", GetLastError());
3986 ok(bytes == 4, "bytes %u\n", bytes);
3987
3988 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
3989 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
3990
3991 S(U(ovl)).Offset = 0;
3992 S(U(ovl)).OffsetHigh = 0;
3993 ovl.Internal = -1;
3994 ovl.InternalHigh = -1;
3995 ovl.hEvent = 0;
3996 bytes = 0;
3997 SetLastError(0xdeadbeef);
3998 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl);
3999 ok(ret, "ReadFile error %d\n", GetLastError());
4000 ok(bytes == sizeof(contents), "bytes %u\n", bytes);
4001 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4002 ok(ovl.InternalHigh == sizeof(contents), "expected sizeof(contents), got %lu\n", ovl.InternalHigh);
4003 ok(!memcmp(contents, buf, sizeof(contents) - 4), "file contents mismatch\n");
4004 ok(!memcmp(buf + sizeof(contents) - 4, "ABCD", 4), "file contents mismatch\n");
4005
4006 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4007 ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
4008
4009 CloseHandle(hfile);
4010
4012 if (!hfile) return;
4013
4014 bytes = 0xdeadbeef;
4015 SetLastError(0xdeadbeef);
4017 ok(!ret, "ReadFile should fail\n");
4018 ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
4019 ok(bytes == 0, "bytes %u\n", bytes);
4020
4021 S(U(ovl)).Offset = 0;
4022 S(U(ovl)).OffsetHigh = 0;
4023 ovl.Internal = -1;
4024 ovl.InternalHigh = -1;
4025 ovl.hEvent = 0;
4026 bytes = 0xdeadbeef;
4027 SetLastError(0xdeadbeef);
4028 /* ReadFile return value depends on Windows version and testing it is not practical */
4029 ReadFile(hfile, buf, 0, &bytes, &ovl);
4030 ok(bytes == 0, "bytes %u\n", bytes);
4031 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4032 ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
4033
4034 bytes = 0xdeadbeef;
4035 SetLastError(0xdeadbeef);
4036 ret = WriteFile(hfile, contents, sizeof(contents), &bytes, NULL);
4037 ok(!ret, "WriteFile should fail\n");
4038 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
4039 ok(bytes == 0, "bytes %u\n", bytes);
4040
4041 U(iob).Status = -1;
4042 iob.Information = -1;
4043 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents, sizeof(contents), NULL, NULL);
4044 ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
4045 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
4046 ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
4047
4048 for (i = -20; i < -1; i++)
4049 {
4050 U(iob).Status = -1;
4051 iob.Information = -1;
4052 offset.QuadPart = (LONGLONG)i;
4053 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents, sizeof(contents), &offset, NULL);
4054 ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
4055 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
4056 ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
4057 }
4058
4059 U(iob).Status = -1;
4060 iob.Information = -1;
4061 offset.QuadPart = 0;
4062 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents, sizeof(contents), &offset, NULL);
4063 ok(status == STATUS_PENDING || status == STATUS_SUCCESS /* before Vista */, "expected STATUS_PENDING or STATUS_SUCCESS, got %#x\n", status);
4064 if (status == STATUS_PENDING)
4065 {
4066 ret = WaitForSingleObject(hfile, 3000);
4067 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret);
4068 }
4069 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
4070 ok(iob.Information == sizeof(contents), "expected sizeof(contents), got %lu\n", iob.Information);
4071
4072 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4073 ok(off == 0, "expected 0, got %u\n", off);
4074
4075 bytes = 0xdeadbeef;
4076 SetLastError(0xdeadbeef);
4077 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL);
4078 ok(!ret, "ReadFile should fail\n");
4079 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
4080 ok(bytes == 0, "bytes %u\n", bytes);
4081
4082 U(iob).Status = -1;
4083 iob.Information = -1;
4084 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL);
4085 ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
4086 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
4087 ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
4088
4089 for (i = -20; i < 0; i++)
4090 {
4091 U(iob).Status = -1;
4092 iob.Information = -1;
4093 offset.QuadPart = (LONGLONG)i;
4094 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
4095 ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
4096 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
4097 ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
4098 }
4099
4100 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4101 ok(off == 0, "expected 0, got %u\n", off);
4102
4103 /* test reading beyond EOF */
4104 offset.QuadPart = sizeof(contents);
4105 S(U(ovl)).Offset = offset.u.LowPart;
4106 S(U(ovl)).OffsetHigh = offset.u.HighPart;
4107 ovl.Internal = -1;
4108 ovl.InternalHigh = -1;
4109 ovl.hEvent = 0;
4110 bytes = 0xdeadbeef;
4111 SetLastError(0xdeadbeef);
4112 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl);
4113 ok(!ret, "ReadFile should fail\n");
4114 ret = GetLastError();
4115 ok(ret == ERROR_IO_PENDING || ret == ERROR_HANDLE_EOF /* before Vista */, "expected ERROR_IO_PENDING or ERROR_HANDLE_EOF, got %d\n", ret);
4116 ok(bytes == 0, "bytes %u\n", bytes);
4117
4118 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4119 ok(off == 0, "expected 0, got %u\n", off);
4120
4121 if (ret == ERROR_IO_PENDING)
4122 {
4123 bytes = 0xdeadbeef;
4124 SetLastError(0xdeadbeef);
4125 ret = GetOverlappedResult(hfile, &ovl, &bytes, TRUE);
4126 ok(!ret, "GetOverlappedResult should report FALSE\n");
4127 ok(GetLastError() == ERROR_HANDLE_EOF, "expected ERROR_HANDLE_EOF, got %d\n", GetLastError());
4128 ok(bytes == 0, "expected 0, read %u\n", bytes);
4129 ok((NTSTATUS)ovl.Internal == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#lx\n", ovl.Internal);
4130 ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
4131 }
4132
4133 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4134 ok(off == 0, "expected 0, got %u\n", off);
4135
4136 offset.QuadPart = sizeof(contents);
4137 S(U(ovl)).Offset = offset.u.LowPart;
4138 S(U(ovl)).OffsetHigh = offset.u.HighPart;
4139 ovl.Internal = -1;
4140 ovl.InternalHigh = -1;
4141 ovl.hEvent = 0;
4142 bytes = 0xdeadbeef;
4143 SetLastError(0xdeadbeef);
4144 ret = ReadFile(hfile, buf, 0, &bytes, &ovl);
4145 /* ReadFile return value depends on Windows version and testing it is not practical */
4146 if (!ret)
4147 ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
4148 ret = GetLastError();
4149 ok(bytes == 0, "bytes %u\n", bytes);
4150
4151 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4152 ok(off == 0, "expected 0, got %u\n", off);
4153
4154 if (ret == ERROR_IO_PENDING)
4155 {
4156 bytes = 0xdeadbeef;
4157 SetLastError(0xdeadbeef);
4158 ret = GetOverlappedResult(hfile, &ovl, &bytes, TRUE);
4159 ok(ret, "GetOverlappedResult should report TRUE\n");
4160 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
4161 ok(bytes == 0, "expected 0, read %u\n", bytes);
4162 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4163 ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
4164 }
4165
4166 offset.QuadPart = sizeof(contents);
4167 S(U(ovl)).Offset = offset.u.LowPart;
4168 S(U(ovl)).OffsetHigh = offset.u.HighPart;
4169 ovl.Internal = -1;
4170 ovl.InternalHigh = -1;
4171 ovl.hEvent = 0;
4172 bytes = 0xdeadbeef;
4173 SetLastError(0xdeadbeef);
4174 ret = ReadFile(hfile, NULL, 0, &bytes, &ovl);
4175 /* ReadFile return value depends on Windows version and testing it is not practical */
4176 if (!ret)
4177 ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
4178 ret = GetLastError();
4179 ok(bytes == 0, "bytes %u\n", bytes);
4180
4181 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4182 ok(off == 0, "expected 0, got %u\n", off);
4183
4184 if (ret == ERROR_IO_PENDING)
4185 {
4186 bytes = 0xdeadbeef;
4187 SetLastError(0xdeadbeef);
4188 ret = GetOverlappedResult(hfile, &ovl, &bytes, TRUE);
4189 ok(ret, "GetOverlappedResult should report TRUE\n");
4190 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
4191 ok(bytes == 0, "expected 0, read %u\n", bytes);
4192 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4193 ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
4194 }
4195
4196 U(iob).Status = -1;
4197 iob.Information = -1;
4198 offset.QuadPart = sizeof(contents);
4199 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
4200 if (status == STATUS_PENDING)
4201 {
4202 ret = WaitForSingleObject(hfile, 3000);
4203 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret);
4204 ok(U(iob).Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", U(iob).Status);
4205 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
4206 }
4207 else
4208 {
4209 ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status);
4210 ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
4211 ok(iob.Information == -1, "expected -1, got %lu\n", iob.Information);
4212 }
4213
4214 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4215 ok(off == 0, "expected 0, got %u\n", off);
4216
4217 U(iob).Status = -1;
4218 iob.Information = -1;
4219 offset.QuadPart = sizeof(contents);
4220 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
4221 if (status == STATUS_PENDING)
4222 {
4223 ret = WaitForSingleObject(hfile, 3000);
4224 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret);
4225 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
4226 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
4227 }
4228 else
4229 {
4230 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", status);
4231 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
4232 ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
4233 }
4234
4235 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4236 ok(off == 0, "expected 0, got %u\n", off);
4237
4238 S(U(ovl)).Offset = 0;
4239 S(U(ovl)).OffsetHigh = 0;
4240 ovl.Internal = -1;
4241 ovl.InternalHigh = -1;
4242 ovl.hEvent = 0;
4243 bytes = 0;
4244 SetLastError(0xdeadbeef);
4245 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl);
4246 /* ReadFile return value depends on Windows version and testing it is not practical */
4247 if (!ret)
4248 {
4249 ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
4250 ok(bytes == 0, "bytes %u\n", bytes);
4251 }
4252 else ok(bytes == 14, "bytes %u\n", bytes);
4253 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4254 ok(ovl.InternalHigh == sizeof(contents), "expected sizeof(contents), got %lu\n", ovl.InternalHigh);
4255
4256 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4257 ok(off == 0, "expected 0, got %u\n", off);
4258
4259 bytes = 0xdeadbeef;
4260 ret = GetOverlappedResult(hfile, &ovl, &bytes, TRUE);
4261 ok(ret, "GetOverlappedResult error %d\n", GetLastError());
4262 ok(bytes == sizeof(contents), "bytes %u\n", bytes);
4263 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4264 ok(ovl.InternalHigh == sizeof(contents), "expected sizeof(contents), got %lu\n", ovl.InternalHigh);
4265 ok(!memcmp(contents, buf, sizeof(contents)), "file contents mismatch\n");
4266
4267 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4268 ok(off == 0, "expected 0, got %u\n", off);
4269
4270 SetFilePointer(hfile, sizeof(contents) - 4, NULL, FILE_BEGIN);
4271 SetEndOfFile(hfile);
4272 SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
4273
4274 U(iob).Status = -1;
4275 iob.Information = -1;
4276 offset.QuadPart = (LONGLONG)-1 /* FILE_WRITE_TO_END_OF_FILE */;
4277 status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, "DCBA", 4, &offset, NULL);
4278 ok(status == STATUS_PENDING || status == STATUS_SUCCESS /* before Vista */, "expected STATUS_PENDING or STATUS_SUCCESS, got %#x\n", status);
4279 if (status == STATUS_PENDING)
4280 {
4281 ret = WaitForSingleObject(hfile, 3000);
4282 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret);
4283 }
4284 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
4285 ok(iob.Information == 4, "expected 4, got %lu\n", iob.Information);
4286
4287 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4288 ok(off == 0, "expected 0, got %u\n", off);
4289
4290 U(iob).Status = -1;
4291 iob.Information = -1;
4292 offset.QuadPart = 0;
4293 status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
4294 ok(status == STATUS_PENDING || status == STATUS_SUCCESS, "expected STATUS_PENDING or STATUS_SUCCESS, got %#x\n", status);
4295 if (status == STATUS_PENDING)
4296 {
4297 ret = WaitForSingleObject(hfile, 3000);
4298 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret);
4299 }
4300 ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
4301 ok(iob.Information == sizeof(contents), "expected sizeof(contents), got %lu\n", iob.Information);
4302
4303 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4304 ok(off == 0, "expected 0, got %u\n", off);
4305
4306 ok(!memcmp(contents, buf, sizeof(contents) - 4), "file contents mismatch\n");
4307 ok(!memcmp(buf + sizeof(contents) - 4, "DCBA", 4), "file contents mismatch\n");
4308
4309 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4310 ok(off == 0, "expected 0, got %u\n", off);
4311
4312 S(U(ovl)).Offset = sizeof(contents) - 4;
4313 S(U(ovl)).OffsetHigh = 0;
4314 ovl.Internal = -1;
4315 ovl.InternalHigh = -1;
4316 ovl.hEvent = 0;
4317 bytes = 0;
4318 SetLastError(0xdeadbeef);
4319 ret = WriteFile(hfile, "ABCD", 4, &bytes, &ovl);
4320 /* WriteFile return value depends on Windows version and testing it is not practical */
4321 if (!ret)
4322 {
4323 ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
4324 ok(bytes == 0, "bytes %u\n", bytes);
4325 ret = WaitForSingleObject(hfile, 3000);
4326 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret);
4327 }
4328 else ok(bytes == 4, "bytes %u\n", bytes);
4329 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4330 ok(ovl.InternalHigh == 4, "expected 4, got %lu\n", ovl.InternalHigh);
4331
4332 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4333 ok(off == 0, "expected 0, got %u\n", off);
4334
4335 bytes = 0xdeadbeef;
4336 ret = GetOverlappedResult(hfile, &ovl, &bytes, TRUE);
4337 ok(ret, "GetOverlappedResult error %d\n", GetLastError());
4338 ok(bytes == 4, "bytes %u\n", bytes);
4339 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4340 ok(ovl.InternalHigh == 4, "expected 4, got %lu\n", ovl.InternalHigh);
4341
4342 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4343 ok(off == 0, "expected 0, got %u\n", off);
4344
4345 S(U(ovl)).Offset = 0;
4346 S(U(ovl)).OffsetHigh = 0;
4347 ovl.Internal = -1;
4348 ovl.InternalHigh = -1;
4349 ovl.hEvent = 0;
4350 bytes = 0;
4351 SetLastError(0xdeadbeef);
4352 ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl);
4353 /* ReadFile return value depends on Windows version and testing it is not practical */
4354 if (!ret)
4355 {
4356 ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
4357 ok(bytes == 0, "bytes %u\n", bytes);
4358 ret = WaitForSingleObject(hfile, 3000);
4359 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret);
4360 }
4361 else ok(bytes == 14, "bytes %u\n", bytes);
4362 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4363 ok(ovl.InternalHigh == sizeof(contents), "expected sizeof(contents), got %lu\n", ovl.InternalHigh);
4364
4365 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4366 ok(off == 0, "expected 0, got %u\n", off);
4367
4368 bytes = 0xdeadbeef;
4369 ret = GetOverlappedResult(hfile, &ovl, &bytes, TRUE);
4370 ok(ret, "GetOverlappedResult error %d\n", GetLastError());
4371 ok(bytes == sizeof(contents), "bytes %u\n", bytes);
4372 ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
4373 ok(ovl.InternalHigh == sizeof(contents), "expected sizeof(contents), got %lu\n", ovl.InternalHigh);
4374 ok(!memcmp(contents, buf, sizeof(contents) - 4), "file contents mismatch\n");
4375 ok(!memcmp(buf + sizeof(contents) - 4, "ABCD", 4), "file contents mismatch\n");
4376
4377 off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
4378 ok(off == 0, "expected 0, got %u\n", off);
4379
4381 CloseHandle(hfile);
4382}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FILE_BEGIN
Definition: compat.h:761
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
static HANDLE event
Definition: file.c:100
static const char * contents
Definition: parser.c:511
long LONG
Definition: pedump.c:60
#define S(x)
Definition: test.h:217
ULONG_PTR Internal
Definition: winbase.h:811
ULONG_PTR InternalHigh
Definition: winbase.h:812
int64_t LONGLONG
Definition: typedefs.h:68
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
#define ERROR_HANDLE_EOF
Definition: winerror.h:140

◆ test_readonly()

static void test_readonly ( void  )
static

Definition at line 3549 of file file.c.

3550{
3551 static const WCHAR fooW[] = {'f','o','o',0};
3553 HANDLE handle;
3558
3562 pRtlDosPathNameToNtPathName_U(path, &nameW, NULL, NULL);
3563
3564 attr.Length = sizeof(attr);
3565 attr.RootDirectory = NULL;
3566 attr.ObjectName = &nameW;
3567 attr.Attributes = OBJ_CASE_INSENSITIVE;
3568 attr.SecurityDescriptor = NULL;
3569 attr.SecurityQualityOfService = NULL;
3570
3573 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3575
3576 status = pNtOpenFile(&handle, GENERIC_WRITE, &attr, &io,
3578 ok(status == STATUS_ACCESS_DENIED, "got %#x\n", status);
3580
3581 status = pNtOpenFile(&handle, GENERIC_READ, &attr, &io,
3583 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3585
3586 status = pNtOpenFile(&handle, FILE_READ_ATTRIBUTES, &attr, &io,
3588 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3590
3591 status = pNtOpenFile(&handle, FILE_WRITE_ATTRIBUTES, &attr, &io,
3593 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3595
3596 status = pNtOpenFile(&handle, DELETE, &attr, &io,
3598 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3600
3601 status = pNtOpenFile(&handle, READ_CONTROL, &attr, &io,
3603 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3605
3606 status = pNtOpenFile(&handle, WRITE_DAC, &attr, &io,
3608 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3610
3611 status = pNtOpenFile(&handle, WRITE_OWNER, &attr, &io,
3613 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3615
3616 status = pNtOpenFile(&handle, SYNCHRONIZE, &attr, &io,
3618 ok(status == STATUS_SUCCESS, "got %#x\n", status);
3620
3621 pRtlFreeUnicodeString(&nameW);
3624}
#define FILE_OPEN_FOR_BACKUP_INTENT
Definition: from_kernel.h:42
#define WRITE_DAC
Definition: nt_native.h:59
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
#define READ_CONTROL
Definition: nt_native.h:58
#define WRITE_OWNER
Definition: nt_native.h:60

Referenced by START_TEST().

◆ UINT()

static UINT ( WINAPI pGetSystemWow64DirectoryW)
static

◆ VOID()

static VOID ( WINAPI pRtlFreeUnicodeString)
static

Variable Documentation

◆ ACCESS_MASK

Definition at line 85 of file file.c.

◆ apc

Definition at line 89 of file file.c.

Referenced by read_file_test(), and test_iocp_fileio().

◆ apc_context

Definition at line 100 of file file.c.

◆ apc_user

Definition at line 89 of file file.c.

◆ BOOLEAN

Definition at line 110 of file file.c.

◆ buffer

◆ code

◆ completionKey

ULONG_PTR completionKey
static

Definition at line 140 of file file.c.

Referenced by get_msg(), test_iocp_fileio(), and test_iocp_setcompletion().

◆ completionValue

ULONG_PTR completionValue
static

Definition at line 142 of file file.c.

Referenced by get_msg(), test_iocp_fileio(), and test_iocp_setcompletion().

◆ DWORD

Definition at line 75 of file file.c.

◆ event

Definition at line 100 of file file.c.

Referenced by test_read_write().

◆ FILE_INFORMATION_CLASS

Definition at line 107 of file file.c.

◆ FS_INFORMATION_CLASS

Definition at line 111 of file file.c.

◆ HANDLE

Definition at line 109 of file file.c.

◆ hEvent

HANDLE hEvent

Definition at line 88 of file file.c.

◆ in_buffer

Definition at line 100 of file file.c.

◆ in_size

◆ io

◆ IO_COMPLETION_INFORMATION_CLASS

Definition at line 104 of file file.c.

◆ io_status

Definition at line 90 of file file.c.

◆ iosb

static IO_STATUS_BLOCK * iosb

Definition at line 98 of file file.c.

Referenced by __attribute__(), _Dispatch_type_(), _Function_class_(), BtrfsSend::AddClone(), BtrfsDeviceAdd::AddDevice(), apc(), append_file_test(), BtrfsPropSheet::apply_changes_file(), BtrfsSend::BrowseParent(), BtrfsPropSheet::check_file(), clear_first_megabyte(), BtrfsRecv::cmd_chmod(), BtrfsRecv::cmd_chown(), BtrfsRecv::cmd_clone(), BtrfsRecv::cmd_mkfile(), BtrfsRecv::cmd_removexattr(), BtrfsRecv::cmd_setxattr(), BtrfsRecv::cmd_snapshot(), BtrfsRecv::cmd_subvol(), BtrfsRecv::cmd_utimes(), BtrfsRecv::cmd_write(), mountmgr::create_point(), create_snapshot(), create_snapshot2(), create_subvol(), mountmgr::delete_points(), dev_ioctl(), BtrfsDeviceResize::DeviceResizeDlgProc(), disk_arrival(), do_full_trim(), BtrfsRecv::do_recv(), BtrfsDeviceResize::do_resize(), BtrfsPropSheet::do_search(), Ext2RefreshSuper(), find_devices(), flush_fcb_caches(), flush_subvol_fcbs(), FormatEx2(), get_device_change_count(), get_mountdev_name(), BtrfsContextMenu::Initialize(), BtrfsVolPropSheet::Initialize(), BtrfsContextMenu::InvokeCommand(), is_mounted_multi_device(), is_ssd(), is_volume_mounted(), BtrfsIconOverlay::IsMemberOf(), mountmgr::mountmgr(), PauseBalanceW(), BtrfsScrub::PauseScrub(), BtrfsDeviceAdd::populate_device_tree(), mountmgr::query_points(), read_file_test(), read_registry(), BtrfsContextMenu::reflink_copy(), reflink_copy2(), BtrfsBalance::RefreshBalanceDlg(), BtrfsVolPropSheet::RefreshDevList(), BtrfsScrub::RefreshScrubDlg(), BtrfsVolPropSheet::RefreshUsage(), RemoveDeviceW(), BtrfsVolPropSheet::ResetStats(), ResetStatsW(), send_subvol(), BtrfsSend::SendDlgProc(), BtrfsPropSheet::set_cmdline(), set_rename_information(), set_zero_data(), BtrfsBalance::ShowBalance(), StartBalanceW(), BtrfsScrub::StartScrub(), StartScrubW(), StopBalanceW(), BtrfsScrub::StopScrub(), StopScrubW(), test_iocp_fileio(), test_ioctl(), test_junction_points(), test_name_limits(), test_namespace_pipe(), test_notify(), test_ntncdf(), test_ntncdf_async(), test_null_device(), test_symboliclink(), test_vol(), BtrfsSend::Thread(), BtrfsScrub::UpdateTextBox(), BtrfsVolPropSheet::UsageDlgProc(), verify_device(), verify_vcb(), watch_registry(), write_data(), and write_superblocks().

◆ ioSb

IO_STATUS_BLOCK ioSb
static

Definition at line 141 of file file.c.

Referenced by get_msg(), test_iocp_fileio(), and test_iocp_setcompletion().

◆ key

◆ length

◆ LPCWSTR

Definition at line 79 of file file.c.

◆ LPWSTR

Definition at line 75 of file file.c.

◆ NTSTATUS

Definition at line 106 of file file.c.

◆ offset

◆ out_buffer

◆ out_size

◆ PIO_APC_ROUTINE

PIO_APC_ROUTINE

Definition at line 109 of file file.c.

◆ PIO_STATUS_BLOCK

Definition at line 83 of file file.c.

◆ PLARGE_INTEGER

Definition at line 84 of file file.c.

◆ POBJECT_ATTRIBUTES

Definition at line 83 of file file.c.

◆ PULONG

Definition at line 104 of file file.c.

◆ PULONG_PTR

Definition at line 105 of file file.c.

◆ PUNICODE_STRING

Definition at line 80 of file file.c.

◆ PVOID

Definition at line 85 of file file.c.

◆ SIZE_T

Definition at line 106 of file file.c.

◆ UINT

Definition at line 76 of file file.c.

◆ ULONG

Definition at line 83 of file file.c.

◆ ULONG_PTR

Definition at line 106 of file file.c.