ReactOS 0.4.15-dev-8348-gc1b9bb5
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:49
#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:163
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 str1, LPCWSTR str2)
Definition: locale.c:4261
#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