Hi All,
I am developping a FS filter driver based filespy sample,and i define
myself private IOCTL “FILESPY_SetOk”.I have added some code in
IRP_MJ_DEVICE_CONTROL dispatch routine:
NTSTATUS
SpyControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION irpStack;
PVOID ioBuffer;
ULONG InputBufferLength;
ULONG OutputBufferLength;
PDEVICE_EXTENSION deviceExtension;
ULONG ioControlCode;
KIRQL oldIrql;
PWSTR deviceName = NULL;
#if DBG
DebugPrint(“IRP_MJ_DEVICE_CONTROL\n”);
#endif
//
// Get a pointer to the current location in the Irp. This is where
// the function codes and parameters are located.
//
deviceExtension = (PDEVICE_EXTENSION)
DeviceObject->DeviceExtension;
// Can’t accept a new io request if:
// 1) device is removed,
// 2) has never been started,
// 3) is stopped,
// 4) has a remove request pending,
// 5) has a stop device pending
irpStack = IoGetCurrentIrpStackLocation (Irp);
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
// get pointers and lengths of the caller’s (user’s) IO buffer
ioBuffer = Irp->AssociatedIrp.SystemBuffer;
InputBufferLength =
irpStack->Parameters.DeviceIoControl.InputBufferLength;
OutputBufferLength =
irpStack->Parameters.DeviceIoControl.OutputBufferLength;
ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;
switch( ioControlCode)
{
…
//the following is my code
case FILESPY_SetOk:
KeAcquireSpinLock( &gPassOkLock, &oldIrql );
KeSetEvent(gPassOk,IO_NO_INCREMENT, FALSE);
KeReleaseSpinLock( &gPassOkLock, oldIrql );
ntStatus = STATUS_SUCCESS;
break;
}
IoCompleteRequest( Irp, IO_NO_INCREMENT );
return ntStatus;
}
I have Added code in USER MODE App:
bResult = DeviceIoControl(
hDevice,
FILESPY_SetOk,
NULL,
0,
NULL,
0,
&bytesReturned,
NULL);
However,My OS reboot when I running Program.Why?
Thanks a lot!
sailing_an