2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Kernel mode tests for object information querying
5 * COPYRIGHT: Copyright 2023 George Bișoc <george.bisoc@reactos.org>
10 #define OBJ_WINSTA_DIRECTORY_NAME_INFO_SIZE (sizeof(UNICODE_STRING) + sizeof(L"\\Windows"))
11 #define OBJ_DIRECTORY_TYPE_INFO_SIZE (sizeof(OBJECT_TYPE_INFORMATION) + (wcslen(L"\\Directory") * sizeof(WCHAR)))
15 ObjectBasicInformationTests(VOID
)
18 HANDLE WinStaDirHandle
;
19 OBJECT_BASIC_INFORMATION BasicInfo
;
21 OBJECT_ATTRIBUTES ObjectAttributes
;
22 static UNICODE_STRING WinStaDir
= RTL_CONSTANT_STRING(L
"\\Windows");
24 /* We must be in PASSIVE_LEVEL to do all of this stuff */
25 ok_irql(PASSIVE_LEVEL
);
27 /* Create a path to \Windows directory */
28 InitializeObjectAttributes(&ObjectAttributes
,
30 OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
| OBJ_KERNEL_HANDLE
,
33 Status
= ZwOpenDirectoryObject(&WinStaDirHandle
,
34 DIRECTORY_QUERY
| DIRECTORY_TRAVERSE
,
36 if (!NT_SUCCESS(Status
))
38 ok(FALSE
, "Failed to open \\Windows directory (Status 0x%lx)\n", Status
);
42 /* Give 0 as information length, this must fail */
43 Status
= ZwQueryObject(WinStaDirHandle
,
44 ObjectBasicInformation
,
48 ok_eq_hex(Status
, STATUS_INFO_LENGTH_MISMATCH
);
50 /* Do a proper query now */
51 Status
= ZwQueryObject(WinStaDirHandle
,
52 ObjectBasicInformation
,
56 ok_eq_hex(Status
, STATUS_SUCCESS
);
58 /* \Windows is currently used */
59 ok(BasicInfo
.HandleCount
!= 0, "\\Windows is in use but HandleCount is 0!\n");
60 ok(BasicInfo
.PointerCount
!= 0, "\\Windows is in use but PointerCount is 0!\n");
62 ok_eq_ulong(BasicInfo
.NameInfoSize
, OBJ_WINSTA_DIRECTORY_NAME_INFO_SIZE
);
63 ok_eq_ulong(BasicInfo
.TypeInfoSize
, OBJ_DIRECTORY_TYPE_INFO_SIZE
);
65 ZwClose(WinStaDirHandle
);
70 ObjectBasicInformationTests();