ReactOS 0.4.15-dev-7918-g2a2556c
kernel32_drv.c File Reference
#include <kmt_test.h>
#include <debug.h>
#include "kernel32_test.h"
Include dependency graph for kernel32_drv.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS TestEntry (IN PDRIVER_OBJECT DriverObject, IN PCUNICODE_STRING RegistryPath, OUT PCWSTR *DeviceName, IN OUT INT *Flags)
 
VOID TestUnload (IN PDRIVER_OBJECT DriverObject)
 
static NTSTATUS TestMessageHandler (IN PDEVICE_OBJECT DeviceObject, IN ULONG ControlCode, IN PVOID Buffer OPTIONAL, IN SIZE_T InLength, IN OUT PSIZE_T OutLength)
 
static NTSTATUS TestDirectoryControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
 
static NTSTATUS TestQueryInformation (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
 
static NTSTATUS TestSetInformation (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation)
 

Variables

static KMT_MESSAGE_HANDLER TestMessageHandler
 
static KMT_IRP_HANDLER TestDirectoryControl
 
static KMT_IRP_HANDLER TestQueryInformation
 
static KMT_IRP_HANDLER TestSetInformation
 
static UNICODE_STRING ExpectedExpression = RTL_CONSTANT_STRING(L"<not set>")
 
static WCHAR ExpressionBuffer [MAX_PATH]
 
static BOOLEAN ExpectingSetAttributes = FALSE
 
static ULONG ExpectedSetAttributes = -1
 
static BOOLEAN ExpectingQueryAttributes = FALSE
 
static ULONG ReturnQueryAttributes = -1
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file kernel32_drv.c.

Function Documentation

◆ TestDirectoryControl()

static NTSTATUS TestDirectoryControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation 
)
static

Definition at line 121 of file kernel32_drv.c.

125{
127
128 PAGED_CODE();
129
130 DPRINT("IRP %x/%x\n", IoStackLocation->MajorFunction, IoStackLocation->MinorFunction);
131 ASSERT(IoStackLocation->MajorFunction == IRP_MJ_DIRECTORY_CONTROL);
132
133 ok(IoStackLocation->MinorFunction == IRP_MN_QUERY_DIRECTORY, "Minor function: %u\n", IoStackLocation->MinorFunction);
134 if (IoStackLocation->MinorFunction == IRP_MN_QUERY_DIRECTORY)
135 {
136 ok(IoStackLocation->Parameters.QueryDirectory.FileInformationClass == FileBothDirectoryInformation,
137 "FileInformationClass: %d\n", IoStackLocation->Parameters.QueryDirectory.FileInformationClass);
138 if (IoStackLocation->Parameters.QueryDirectory.FileInformationClass == FileBothDirectoryInformation)
139 {
140 ok(RtlEqualUnicodeString(IoStackLocation->Parameters.QueryDirectory.FileName, &ExpectedExpression, FALSE),
141 "Expression is '%wZ', expected '%wZ'\n", IoStackLocation->Parameters.QueryDirectory.FileName, &ExpectedExpression);
142 RtlZeroMemory(Irp->UserBuffer, IoStackLocation->Parameters.QueryDirectory.Length);
144 }
145 }
146
147 Irp->IoStatus.Status = Status;
148 Irp->IoStatus.Information = 0;
149
151
152 return Status;
153}
#define PAGED_CODE()
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
@ FileBothDirectoryInformation
Definition: from_kernel.h:64
Status
Definition: gdiplustypes.h:25
static UNICODE_STRING ExpectedExpression
Definition: kernel32_drv.c:20
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MN_QUERY_DIRECTORY
Definition: rdpdr.c:55
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ TestEntry()

NTSTATUS TestEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PCUNICODE_STRING  RegistryPath,
OUT PCWSTR DeviceName,
IN OUT INT Flags 
)

Definition at line 28 of file kernel32_drv.c.

33{
35
36 PAGED_CODE();
37
39
40 *DeviceName = L"kernel32";
41 *Flags = TESTENTRY_NO_EXCLUSIVE_DEVICE;
42
47
48 return Status;
49}
#define NULL
Definition: types.h:112
static KMT_IRP_HANDLER TestDirectoryControl
Definition: kernel32_drv.c:16
static KMT_IRP_HANDLER TestSetInformation
Definition: kernel32_drv.c:18
static KMT_MESSAGE_HANDLER TestMessageHandler
Definition: kernel32_drv.c:15
static KMT_IRP_HANDLER TestQueryInformation
Definition: kernel32_drv.c:17
NTSTATUS KmtRegisterMessageHandler(IN ULONG ControlCode OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_MESSAGE_HANDLER MessageHandler)
NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

◆ TestMessageHandler()

static NTSTATUS TestMessageHandler ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  ControlCode,
IN PVOID Buffer  OPTIONAL,
IN SIZE_T  InLength,
IN OUT PSIZE_T  OutLength 
)
static

Definition at line 60 of file kernel32_drv.c.

66{
68
69 PAGED_CODE();
70
71 switch (ControlCode)
72 {
74 {
76 DPRINT("IOCTL_EXPECT_EXPRESSION, InLength = %lu\n", InLength);
77 if (InLength > sizeof(ExpressionBuffer))
79
80 if (InLength % sizeof(WCHAR) != 0)
82
83 RtlInitEmptyUnicodeString(&ExpectedExpression, ExpressionBuffer, sizeof(ExpressionBuffer));
86 DPRINT("IOCTL_EXPECT_EXPRESSION: %wZ\n", &ExpectedExpression);
87
88 break;
89 }
91 {
92 DPRINT("IOCTL_RETURN_QUERY_ATTRIBUTES, InLength = %lu\n", InLength);
93 if (InLength != sizeof(ULONG))
95
98 DPRINT("IOCTL_RETURN_QUERY_ATTRIBUTES: %lu\n", ReturnQueryAttributes);
99 break;
100 }
102 {
103 DPRINT("IOCTL_EXPECT_SET_ATTRIBUTES, InLength = %lu\n", InLength);
104 if (InLength != sizeof(ULONG))
106
109 DPRINT("IOCTL_EXPECT_SET_ATTRIBUTES: %lu\n", ExpectedSetAttributes);
110 break;
111 }
112 default:
114 }
115
116 return Status;
117}
Definition: bufpool.h:45
#define TRUE
Definition: types.h:120
#define C_ASSERT(e)
Definition: intsafe.h:73
static BOOLEAN ExpectingSetAttributes
Definition: kernel32_drv.c:22
static ULONG ReturnQueryAttributes
Definition: kernel32_drv.c:25
static BOOLEAN ExpectingQueryAttributes
Definition: kernel32_drv.c:24
static WCHAR ExpressionBuffer[MAX_PATH]
Definition: kernel32_drv.c:21
static ULONG ExpectedSetAttributes
Definition: kernel32_drv.c:23
#define IOCTL_RETURN_QUERY_ATTRIBUTES
Definition: kernel32_test.h:12
#define IOCTL_EXPECT_EXPRESSION
Definition: kernel32_test.h:11
#define IOCTL_EXPECT_SET_ATTRIBUTES
Definition: kernel32_test.h:13
#define UNICODE_STRING_MAX_BYTES
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ TestQueryInformation()

static NTSTATUS TestQueryInformation ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation 
)
static

Definition at line 157 of file kernel32_drv.c.

161{
163 PFILE_BASIC_INFORMATION BasicInfo;
164
165 PAGED_CODE();
166
167 DPRINT("IRP %x/%x\n", IoStackLocation->MajorFunction, IoStackLocation->MinorFunction);
168 ASSERT(IoStackLocation->MajorFunction == IRP_MJ_QUERY_INFORMATION);
169
170 Irp->IoStatus.Information = 0;
171
172 ok_eq_ulong(IoStackLocation->Parameters.QueryFile.FileInformationClass, FileBasicInformation);
173 if (IoStackLocation->Parameters.QueryFile.FileInformationClass == FileBasicInformation)
174 {
175 ok(ExpectingQueryAttributes, "Unexpected QUERY_INFORMATION call\n");
176 BasicInfo = Irp->AssociatedIrp.SystemBuffer;
177 BasicInfo->CreationTime.QuadPart = 126011664000000000;
178 BasicInfo->LastAccessTime.QuadPart = 130899112800000000;
179 BasicInfo->LastWriteTime.QuadPart = 130899112800000000;
180 BasicInfo->ChangeTime.QuadPart = 130899112800000000;
185 Irp->IoStatus.Information = sizeof(*BasicInfo);
186 }
187
188 Irp->IoStatus.Status = Status;
189
191
192 return Status;
193}
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
@ FileBasicInformation
Definition: from_kernel.h:65
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
LARGE_INTEGER ChangeTime
Definition: nt_native.h:942
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
LONGLONG QuadPart
Definition: typedefs.h:114

◆ TestSetInformation()

static NTSTATUS TestSetInformation ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation 
)
static

Definition at line 197 of file kernel32_drv.c.

201{
203 PFILE_BASIC_INFORMATION BasicInfo;
204
205 PAGED_CODE();
206
207 DPRINT("IRP %x/%x\n", IoStackLocation->MajorFunction, IoStackLocation->MinorFunction);
208 ASSERT(IoStackLocation->MajorFunction == IRP_MJ_SET_INFORMATION);
209
210 ok_eq_ulong(IoStackLocation->Parameters.SetFile.FileInformationClass, FileBasicInformation);
211 if (IoStackLocation->Parameters.SetFile.FileInformationClass == FileBasicInformation)
212 {
213 ok(ExpectingSetAttributes, "Unexpected SET_INFORMATION call\n");
214 BasicInfo = Irp->AssociatedIrp.SystemBuffer;
218 ok_eq_longlong(BasicInfo->ChangeTime.QuadPart, 0LL);
223 }
224
225 Irp->IoStatus.Status = Status;
226 Irp->IoStatus.Information = 0;
227
229
230 return Status;
231}
#define ok_eq_longlong(value, expected)
Definition: apitest.h:64
#define LL
Definition: tui.h:167

◆ TestUnload()

VOID TestUnload ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 52 of file kernel32_drv.c.

54{
55 PAGED_CODE();
56}

Variable Documentation

◆ ExpectedExpression

UNICODE_STRING ExpectedExpression = RTL_CONSTANT_STRING(L"<not set>")
static

Definition at line 20 of file kernel32_drv.c.

Referenced by START_TEST(), TestDirectoryControl(), and TestMessageHandler().

◆ ExpectedSetAttributes

ULONG ExpectedSetAttributes = -1
static

Definition at line 23 of file kernel32_drv.c.

Referenced by TestMessageHandler(), and TestSetInformation().

◆ ExpectingQueryAttributes

BOOLEAN ExpectingQueryAttributes = FALSE
static

Definition at line 24 of file kernel32_drv.c.

Referenced by TestMessageHandler(), and TestQueryInformation().

◆ ExpectingSetAttributes

BOOLEAN ExpectingSetAttributes = FALSE
static

Definition at line 22 of file kernel32_drv.c.

Referenced by TestMessageHandler(), and TestSetInformation().

◆ ExpressionBuffer

WCHAR ExpressionBuffer[MAX_PATH]
static

Definition at line 21 of file kernel32_drv.c.

Referenced by START_TEST(), and TestMessageHandler().

◆ ReturnQueryAttributes

ULONG ReturnQueryAttributes = -1
static

Definition at line 25 of file kernel32_drv.c.

Referenced by TestMessageHandler(), and TestQueryInformation().

◆ TestDirectoryControl

KMT_IRP_HANDLER TestDirectoryControl
static

Definition at line 16 of file kernel32_drv.c.

Referenced by TestEntry().

◆ TestMessageHandler

KMT_MESSAGE_HANDLER TestMessageHandler
static

Definition at line 15 of file kernel32_drv.c.

Referenced by TestEntry().

◆ TestQueryInformation

KMT_IRP_HANDLER TestQueryInformation
static

Definition at line 17 of file kernel32_drv.c.

Referenced by TestEntry().

◆ TestSetInformation

KMT_IRP_HANDLER TestSetInformation
static

Definition at line 18 of file kernel32_drv.c.

Referenced by TestEntry().