2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for GetFileAttributes/SetFileAttributes
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
10 #include "kernel32_test.h"
12 START_TEST(FileAttributes
)
14 PCWSTR FileName
= L
"\\\\.\\Global\\GLOBALROOT\\Device\\Kmtest-kernel32\\Somefile";
18 KmtLoadDriver(L
"kernel32", FALSE
);
21 /* Set read-only attribute */
22 KmtSendUlongToDriver(IOCTL_EXPECT_SET_ATTRIBUTES
, FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_NORMAL
);
23 Ret
= SetFileAttributesW(FileName
, FILE_ATTRIBUTE_READONLY
);
24 ok(Ret
== TRUE
, "SetFileAttributesW returned %d, error %lu\n", Ret
, GetLastError());
26 /* Set normal attribute */
27 KmtSendUlongToDriver(IOCTL_EXPECT_SET_ATTRIBUTES
, FILE_ATTRIBUTE_NORMAL
);
28 Ret
= SetFileAttributesW(FileName
, FILE_ATTRIBUTE_NORMAL
);
29 ok(Ret
== TRUE
, "SetFileAttributesW returned %d, error %lu\n", Ret
, GetLastError());
31 /* Set 0 attribute (driver should receive normal) */
32 KmtSendUlongToDriver(IOCTL_EXPECT_SET_ATTRIBUTES
, FILE_ATTRIBUTE_NORMAL
);
33 Ret
= SetFileAttributesW(FileName
, 0);
34 ok(Ret
== TRUE
, "SetFileAttributesW returned %d, error %lu\n", Ret
, GetLastError());
36 /* Query read-only attribute */
37 KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES
, FILE_ATTRIBUTE_READONLY
);
38 Attributes
= GetFileAttributesW(FileName
);
39 ok_eq_hex(Attributes
, FILE_ATTRIBUTE_READONLY
);
41 /* Query read-only + normal attribute */
42 KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES
, FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_NORMAL
);
43 Attributes
= GetFileAttributesW(FileName
);
44 ok_eq_hex(Attributes
, FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_NORMAL
);
46 /* Query normal attribute */
47 KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES
, FILE_ATTRIBUTE_NORMAL
);
48 Attributes
= GetFileAttributesW(FileName
);
49 ok_eq_hex(Attributes
, FILE_ATTRIBUTE_NORMAL
);
51 /* Query 0 attribute */
52 KmtSendUlongToDriver(IOCTL_RETURN_QUERY_ATTRIBUTES
, 0);
53 Attributes
= GetFileAttributesW(FileName
);
54 ok_eq_hex(Attributes
, 0);