ReactOS  0.4.14-dev-98-gb0d4763
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 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MN_QUERY_DIRECTORY
Definition: rdpdr.c:55
#define PAGED_CODE()
Definition: video.h:57
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
static UNICODE_STRING ExpectedExpression
Definition: kernel32_drv.c:20
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
#define ok(value,...)
Definition: atltest.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)

◆ 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 UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static KMT_IRP_HANDLER TestSetInformation
Definition: kernel32_drv.c:18
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
static KMT_IRP_HANDLER TestDirectoryControl
Definition: kernel32_drv.c:16
#define PAGED_CODE()
Definition: video.h:57
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
NTSTATUS KmtRegisterMessageHandler(IN ULONG ControlCode OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_MESSAGE_HANDLER MessageHandler)
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
static KMT_MESSAGE_HANDLER TestMessageHandler
Definition: kernel32_drv.c:15
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
return STATUS_SUCCESS
Definition: btrfs.c:2966
static KMT_IRP_HANDLER TestQueryInformation
Definition: kernel32_drv.c:17

◆ 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));
85  ExpectedExpression.Length = (USHORT)InLength;
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:
113  return STATUS_NOT_SUPPORTED;
114  }
115 
116  return Status;
117 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_EXPECT_EXPRESSION
Definition: kernel32_test.h:11
#define UNICODE_STRING_MAX_BYTES
#define PAGED_CODE()
Definition: video.h:57
void DPRINT(...)
Definition: polytest.cpp:61
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
Definition: bufpool.h:45
#define C_ASSERT(e)
Definition: intsafe.h:79
static BOOLEAN ExpectingQueryAttributes
Definition: kernel32_drv.c:24
static UNICODE_STRING ExpectedExpression
Definition: kernel32_drv.c:20
#define IOCTL_RETURN_QUERY_ATTRIBUTES
Definition: kernel32_test.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOLEAN ExpectingSetAttributes
Definition: kernel32_drv.c:22
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
static WCHAR ExpressionBuffer[MAX_PATH]
Definition: kernel32_drv.c:21
unsigned int * PULONG
Definition: retypes.h:1
static ULONG ReturnQueryAttributes
Definition: kernel32_drv.c:25
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
static ULONG ExpectedSetAttributes
Definition: kernel32_drv.c:23
#define IOCTL_EXPECT_SET_ATTRIBUTES
Definition: kernel32_test.h:13

◆ 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)
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
static BOOLEAN ExpectingQueryAttributes
Definition: kernel32_drv.c:24
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
LARGE_INTEGER ChangeTime
Definition: nt_native.h:942
Status
Definition: gdiplustypes.h:24
#define ok(value,...)
Definition: atltest.h:57
static ULONG ReturnQueryAttributes
Definition: kernel32_drv.c:25
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
return STATUS_SUCCESS
Definition: btrfs.c:2966
LONGLONG QuadPart
Definition: typedefs.h:112

◆ 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;
215  ok_eq_longlong(BasicInfo->CreationTime.QuadPart, 0LL);
217  ok_eq_longlong(BasicInfo->LastWriteTime.QuadPart, 0LL);
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_ulong(value, expected)
#define LL
Definition: tui.h:85
#define ok_eq_longlong(value, expected)
Definition: kmt_test.h:242
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
static BOOLEAN ExpectingSetAttributes
Definition: kernel32_drv.c:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
LARGE_INTEGER ChangeTime
Definition: nt_native.h:942
Status
Definition: gdiplustypes.h:24
#define ok(value,...)
Definition: atltest.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IO_NO_INCREMENT
Definition: iotypes.h:566
return STATUS_SUCCESS
Definition: btrfs.c:2966
static ULONG ExpectedSetAttributes
Definition: kernel32_drv.c:23
LONGLONG QuadPart
Definition: typedefs.h:112

◆ TestUnload()

VOID TestUnload ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 52 of file kernel32_drv.c.

54 {
55  PAGED_CODE();
56 }
#define PAGED_CODE()
Definition: video.h:57

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().