ReactOS 0.4.15-dev-8191-gbc6c731
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;
19
20 Error = KmtLoadAndOpenDriver(L"kernel32", FALSE);
22 if (Error)
23 return;
24
25 /* Set read-only attribute */
28 ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
29
30 /* Set normal attribute */
33 ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
34
35 /* Set 0 attribute (driver should receive normal) */
38 ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
39
40 /* Set invalid attributes */
43 ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
44
45 /* Query read-only attribute */
49
50 /* Query read-only + normal attribute */
54
55 /* Query normal attribute */
59
60 /* Query 0 attribute */
64
65 /* Query invalid attributes */
69
71 /* Set read-only and directory attribute */
74 ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
75
76 /* Set normal and directory attribute */
79 ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
80
81 /* Set directory attribute */
84 ok(Ret == TRUE, "SetFileAttributesW returned %d, error %lu\n", Ret, GetLastError());
85
86 /* Query read-only and directory attribute */
90
91 /* Query read-only + normal + directory attribute */
95
96 /* Query normal and directory attribute */
100
101 /* Query directory attribute */
105
108}
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_int(value, expected)
Definition: apitest.h:60
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
BOOL Error
Definition: chkdsk.c:66
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_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:1236
#define IOCTL_RETURN_QUERY_ATTRIBUTES
Definition: kernel32_test.h:12
#define IOCTL_EXPECT_SET_ATTRIBUTES
Definition: kernel32_test.h:13
#define FILE_ATTRIBUTE_VALID_SET_FLAGS
Definition: nt_native.h:715
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define L(x)
Definition: ntvdm.h:50
DWORD KmtLoadAndOpenDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning)
Definition: support.c:213
VOID KmtCloseDriver(VOID)
Definition: support.c:236
DWORD KmtSendUlongToDriver(IN DWORD ControlCode, IN DWORD Value)
Definition: support.c:333
VOID KmtUnloadDriver(VOID)
Definition: support.c:167
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
DWORD WINAPI GetLastError(void)
Definition: except.c:1042