Re: about READ_PORT_ULONG by Doron
Doron
Fri Dec 30 10:14:30 CST 2005
i suggest you do alot more reading of the samples, documenation, and
hopefully a book or two. you are missing some fundamental concepts here.
KEVENT startDeviceEvent;
NTSTATUS ntStatus;
//
// We cannot touch the device (send it any non pnp irps) until a
// start device has been passed down to the lower drivers.
// first pass the Irp down
//
KeInitializeEvent(&startDeviceEvent, NotificationEvent, FALSE);
IoCopyCurrentIrpStackLocationToNext(Irp);
IoSetCompletionRoutine(Irp,
(PIO_COMPLETION_ROUTINE)IrpCompletionRoutine,
(PVOID)&startDeviceEvent,
TRUE,
TRUE,
TRUE);
ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);
if(ntStatus == STATUS_PENDING) {
KeWaitForSingleObject(&startDeviceEvent,
Executive,
KernelMode,
FALSE,
NULL);
ntStatus = Irp->IoStatus.Status;
}
NTSTATUS
IrpCompletionRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
PKEVENT event = Context;
KeSetEvent(event, 0, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"kerby" <kerby@driftmark.com> wrote in message
news:uHKbtEUDGHA.3984@TK2MSFTNGP14.phx.gbl...
> Doron Holan [MS] wrote:
>> you need to synchronously send the start irp down the stack, you have
>>
>>
>>>NTSTATUS status = IoCallDriver(pdx->LowerDeviceObject, Irp);
>>>
>>>// then pass down this Minor Function for the next driver stack:
>>>IoSkipCurrentIrpStackLocation(Irp);
>>
>>
>> you are touching an irp after it left your driver in the call to
>> IoSkipCurrentStackLocation after calling IoCallDriver. instead, send the
>> irp and synchronously wait for it to come back. there are many examples
>> in the DDK which show this.
>>
>> d
>
> one question, is there somehing in my code before that should be removed?
>
> anyway, is what you're saying
> something like this:
> NTSTATUS PassDownPnP( IN PDEVICE_OBJECT pDO,
> IN PIRP pIrp ) {
> IoSkipCurrentIrpStackLocation( pIrp );
> PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)
> pDO->DeviceExtension;
> return IoCallDriver(pDevExt->pLowerDevice, pIrp);
> }
>
> ?
> -krby_xtrm-