2 * Driver Regression Tests
4 * Copyright 2009 Michael Martin <martinmnet@hotmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; see the file COPYING.LIB.
18 * If not, write to the Free Software Foundation,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /* INCLUDES *******************************************************************/
29 DriverDispatch(IN PDEVICE_OBJECT DeviceObject
,IN PIRP Irp
)
31 DbgPrint(" ControlCode %x\n",IoGetCurrentIrpStackLocation(Irp
)->Parameters
.DeviceIoControl
.IoControlCode
);
32 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
33 Irp
->IoStatus
.Information
=0;
35 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
36 return STATUS_SUCCESS
;
41 DriverCreateClose(IN PDEVICE_OBJECT DeviceObject
,IN PIRP Irp
)
43 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
44 Irp
->IoStatus
.Information
= 0;
46 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
48 return STATUS_SUCCESS
;
53 DriverUnload(IN PDRIVER_OBJECT DriverObject
)
55 UNICODE_STRING DeviceString
;
57 RtlInitUnicodeString(&DeviceString
, L
"\\DosDevices\\kmtestassist");
58 IoDeleteSymbolicLink(&DeviceString
);
60 IoDeleteDevice(DriverObject
->DeviceObject
);
65 DriverEntry(IN PDRIVER_OBJECT DriverObject
,IN PUNICODE_STRING path
)
67 PDEVICE_OBJECT pDeviceObject
;
68 UNICODE_STRING DriverString
;
69 UNICODE_STRING DeviceString
;
71 NTSTATUS Status
= STATUS_DEVICE_CONFIGURATION_ERROR
;
73 RtlInitUnicodeString(&DriverString
, L
"\\Device\\kmtestassist");
75 Status
= IoCreateDevice(DriverObject
,0,&DriverString
,FILE_DEVICE_UNKNOWN
,0,FALSE
,&pDeviceObject
);
76 if (!NT_SUCCESS(Status
))
81 RtlInitUnicodeString(&DeviceString
, L
"\\DosDevices\\kmtestassist");
83 Status
= IoCreateSymbolicLink(&DeviceString
, &DriverString
);
84 if (!NT_SUCCESS(Status
))
86 // Delete device object if not successful
87 IoDeleteDevice(pDeviceObject
);
91 DriverObject
->DriverUnload
= DriverUnload
;
92 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = DriverDispatch
;
93 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = DriverCreateClose
;
94 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = DriverCreateClose
;