ReactOS 0.4.15-dev-8413-gc1c91f2
ObQuery.c
Go to the documentation of this file.
1/*
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>
6 */
7
8#include <kmt_test.h>
9
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) + sizeof(L"Directory"))
12
13static
14VOID
16{
18 HANDLE WinStaDirHandle;
22 static UNICODE_STRING WinStaDir = RTL_CONSTANT_STRING(L"\\Windows");
23
24 /* We must be in PASSIVE_LEVEL to do all of this stuff */
25 ok_irql(PASSIVE_LEVEL);
26
27 /* Create a path to \Windows directory */
29 &WinStaDir,
31 NULL,
32 NULL);
33 Status = ZwOpenDirectoryObject(&WinStaDirHandle,
36 if (!NT_SUCCESS(Status))
37 {
38 ok(FALSE, "Failed to open \\Windows directory (Status 0x%lx)\n", Status);
39 return;
40 }
41
42 /* Give 0 as information length, this must fail */
43 Status = ZwQueryObject(WinStaDirHandle,
45 &BasicInfo,
46 0,
49
50 /* Do a proper query now */
51 Status = ZwQueryObject(WinStaDirHandle,
53 &BasicInfo,
54 sizeof(BasicInfo),
57
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");
61
64
65 ZwClose(WinStaDirHandle);
66}
67
68START_TEST(ObQuery)
69{
71}
@ ObjectBasicInformation
Definition: DriverTester.h:54
#define OBJ_WINSTA_DIRECTORY_NAME_INFO_SIZE
Definition: ObQuery.c:10
static VOID ObjectBasicInformationTests(VOID)
Definition: ObQuery.c:15
#define OBJ_DIRECTORY_TYPE_INFO_SIZE
Definition: ObQuery.c:11
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwOpenDirectoryObject(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define DIRECTORY_QUERY
Definition: nt_native.h:1254
#define DIRECTORY_TRAVERSE
Definition: nt_native.h:1255
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133