ReactOS  0.4.15-dev-499-g1f31905
FileAttributes_user.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests
3  * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4  * PURPOSE: Test for GetFileAttributes/SetFileAttributes
5  * COPYRIGHT: Copyright 2017 Thomas Faber <thomas.faber@reactos.org>
6  * Copyright 2017 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7  */
8 
9 #include <kmt_test.h>
10 
11 #include "kernel32_test.h"
12 
14 {
15  PCWSTR FileName = L"\\\\.\\Global\\GLOBALROOT\\Device\\Kmtest-kernel32\\Somefile";
16  BOOL Ret;
18 
19  KmtLoadDriver(L"kernel32", FALSE);
20  KmtOpenDriver();
21 
22  /* Set read-only attribute */
25  ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
26 
27  /* Set normal attribute */
30  ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
31 
32  /* Set 0 attribute (driver should receive normal) */
34  Ret = SetFileAttributesW(FileName, 0);
35  ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
36 
37  /* Set invalid attributes */
40  ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
41 
42  /* Query read-only attribute */
46 
47  /* Query read-only + normal attribute */
51 
52  /* Query normal attribute */
56 
57  /* Query 0 attribute */
61 
62  /* Query invalid attributes */
66 
68  /* Set read-only and directory attribute */
71  ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
72 
73  /* Set normal and directory attribute */
76  ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
77 
78  /* Set directory attribute */
81  ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
82 
83  /* Query read-only and directory attribute */
87 
88  /* Query read-only + normal + directory attribute */
92 
93  /* Query normal and directory attribute */
97 
98  /* Query directory attribute */
102 
103  KmtCloseDriver();
104  KmtUnloadDriver();
105 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
const uint16_t * PCWSTR
Definition: typedefs.h:56
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
START_TEST(FileAttributes)
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1230
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define IOCTL_RETURN_QUERY_ATTRIBUTES
Definition: kernel32_test.h:12
VOID KmtCloseDriver(VOID)
Definition: support.c:207
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
VOID KmtUnloadDriver(VOID)
Definition: support.c:156
#define ok(value,...)
Definition: atltest.h:57
#define ok_eq_hex(value, expected)
VOID KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning)
Definition: support.c:128
VOID KmtOpenDriver(VOID)
Definition: support.c:181
#define FILE_ATTRIBUTE_VALID_SET_FLAGS
Definition: nt_native.h:715
DWORD KmtSendUlongToDriver(IN DWORD ControlCode, IN DWORD Value)
Definition: support.c:305
#define IOCTL_EXPECT_SET_ATTRIBUTES
Definition: kernel32_test.h:13