Hello Maxim,
Tuesday, May 27, 2003, 12:23:22 AM, you wrote:
Still I have a small problem.
After few minutes of normal job system refuses to call My Completion
routine anymore.
Code is simple
// completion routine
NTSTATUS HstdSendComplete(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
{
// mdl buffer
if (Irp->MdlAddress != NULL)
{
MmUnlockPages(Irp->MdlAddress);
IoFreeMdl(Irp->MdlAddress);
Irp->MdlAddress = NULL;
}
// Free buffer
if(Context)
{
CSendCompleteContext* p = (CSendCompleteContext*)Context;
if(p->m_Buf && p->m_fooDeleteProc )
{
p->m_fooDeleteProc(p->m_Buf); // delete preallocated buffer
}
delete p;
}
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
NTSTATUS CTdiInfo::SendBuffer( CClientNote* pClient,
DWORD len,
char* buf,
FOO_DeleteProc DeleteProc )
{
NTSTATUS ret;
IO_STATUS_BLOCK IoStatus;
KEVENT Event;
PMDL pMdl;
// sending
IRP* pIrp = IoAllocateIrp( m_pDeviceObject->StackSize, FALSE );
//DumpTime(“HTSD: 2”);
if ( pIrp == NULL ) // validate pointer
ret = STATUS_INSUFFICIENT_RESOURCES;
else
{
pMdl = IoAllocateMdl (
buf, // buffer pointer - virtual address
len, // length
FALSE, // not secondary
FALSE, // don’t charge quota
NULL ); // don’t use irp
if ( pMdl ) // validate mdl pointer
{
__try
{
MmProbeAndLockPages ( pMdl, KernelMode, IoModifyAccess ); // probe & lock
}
__except ( EXCEPTION_EXECUTE_HANDLER )
{
dump ( “EXCEPTION: MmProbeAndLockPages\n” );
IoFreeMdl( pMdl );
pMdl = NULL;
}
}
if ( pMdl )
{
// internal code
CSendCompleteContext* x = 0;
if( DeleteProc )
{
// data will be destroyed in Completion
// routine
x = new CSendCompleteContext;
x->m_Buf = buf;
x->m_fooDeleteProc = DeleteProc;
}
// building
TdiBuildSend(
pIrp,
m_pDeviceObject,
pClient->m_pEp->m_Object,
HstdSendComplete, // completion routine
x, // completion context
pMdl,
0, // flags
len
);
// marking
IoMarkIrpPending(pIrp);
// calling
ret = IoCallDriver( m_pDeviceObject, pIrp );
// post-processing
if ( ret == STATUS_PENDING ) // make all request synchronous
{
ret = STATUS_SUCCESS;
}
else
{
if(ret != STATUS_SUCCESS)
{
dump(“HSTD: IoCallDriver ret = %X\n”, ret );
return ret;
}
}
if(ret != STATUS_SUCCESS)
{
dump(“Send failed with status %X\n”, ret );
}
}
else
{
IoFreeIrp(pIrp);
ret = STATUS_INSUFFICIENT_RESOURCES;
}
}
return ret;
}
> MSS> Since you return STATUS_MORE_PROCESSING_REQUIRED, you must not
MSS> do
> MSS> this.
>
> Should I call IoFreeIrp in the completion routine? It seems that
MSS> system will
> call it if I return STATUS_MORE_PROCESSING_REQUIRED.
MSS> No, you must call it yourself.
MSS> Max
MSS> —
MSS> You are currently subscribed to ntdev as: kipnis@wp.pl
MSS> To unsubscribe send a blank email to xxxxx@lists.osr.com
–
Best regards,
Sergey mailto:kipnis@wp.pl