Hi,
I have coded a very basic driver for a device which stores the most recent
string written to the device and on a read returns that string.
I am doing my debugging on VmWare using SoftIce.
The loading part i.e. DriverEntry goes smooth , but when I do a write on the
device,
the DriverObject gets destroyed automatically in the Dispatch Routine for
Write.
The code is as follows( not the complete routine,but till the point where
deviceobject
automatically becomes 0 ):
***********************************************************
NTSTATUS MyWrite( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp )
{
PVOID argBuffer = NULL;
UINT32 argBufLength = 0;
PIO_STACK_LOCATION pIoStack;
PLOCAL_DEVICE_INFO deviceInfo = NULL;
DbgPrint(“\nMyWrite()::Write called on LoopBack device…”);
deviceInfo = (PLOCAL_DEVICE_INFO) DeviceObject->DeviceExtension;
//get the argument string buffer which contains the string to be
written
argBuffer = Irp->AssociatedIrp.SystemBuffer;
DbgPrint(“\nMyWrite()::Getting the arguments…”);
pIoStack = IoGetCurrentIrpStackLocation(Irp);
//get the length of the argument string passed to this routine
argBufLength = pIoStack->Parameters.Write.Length;
DbgPrint(“\nMyWrite()::length : %d”,argBufLength);
//here the DeviceObject gets destroyed.
**********************************************************
Can somebody point any bugs in code or some tips to make it work.
Bye.
–Mayur.