BOOLEAN Write, BOOLEAN LockAddress ) {
UINT i;
/* Copy the buffer array so we don't lose it */
- UINT Lock = (LockAddress && AddressLen) ? 2 : 0;
+ UINT Lock = LockAddress ? 2 : 0;
UINT Size = sizeof(AFD_WSABUF) * (Count + Lock);
PAFD_WSABUF NewBuf = ExAllocatePool( PagedPool, Size * 2 );
- PMDL NewMdl;
BOOLEAN LockFailed = FALSE;
AFD_DbgPrint(MID_TRACE,("Called(%08x)\n", NewBuf));
if( NewBuf ) {
+ RtlZeroMemory(NewBuf, Size * 2);
+
PAFD_MAPBUF MapBuf = (PAFD_MAPBUF)(NewBuf + Count + Lock);
_SEH2_TRY {
RtlCopyMemory( NewBuf, Buf, sizeof(AFD_WSABUF) * Count );
if( LockAddress ) {
- NewBuf[Count].buf = AddressBuf;
- NewBuf[Count].len = *AddressLen;
- Count++;
- NewBuf[Count].buf = (PVOID)AddressLen;
- NewBuf[Count].len = sizeof(*AddressLen);
- Count++;
+ if (AddressBuf && AddressLen) {
+ NewBuf[Count].buf = AddressBuf;
+ NewBuf[Count].len = *AddressLen;
+ NewBuf[Count + 1].buf = (PVOID)AddressLen;
+ NewBuf[Count + 1].len = sizeof(*AddressLen);
+ }
+ Count += 2;
}
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
AFD_DbgPrint(MIN_TRACE,("Access violation copying buffer info "
AFD_DbgPrint(MID_TRACE,("Locking buffer %d (%x:%d)\n",
i, NewBuf[i].buf, NewBuf[i].len));
- if( NewBuf[i].len ) {
- NewMdl = IoAllocateMdl( NewBuf[i].buf,
- NewBuf[i].len,
- FALSE,
- FALSE,
- NULL );
+ if( NewBuf[i].buf && NewBuf[i].len ) {
+ MapBuf[i].Mdl = IoAllocateMdl( NewBuf[i].buf,
+ NewBuf[i].len,
+ FALSE,
+ FALSE,
+ NULL );
} else {
MapBuf[i].Mdl = NULL;
continue;
}
- AFD_DbgPrint(MID_TRACE,("NewMdl @ %x\n", NewMdl));
-
- MapBuf[i].Mdl = NewMdl;
+ AFD_DbgPrint(MID_TRACE,("NewMdl @ %x\n", MapBuf[i].Mdl));
if( MapBuf[i].Mdl ) {
AFD_DbgPrint(MID_TRACE,("Probe and lock pages\n"));
(PVOID*)&FileObjects[i].Handle,
NULL );
}
+
+ if( !NT_SUCCESS(Status) )
+ FileObjects[i].Handle = 0;
}
if( !NT_SUCCESS(Status) ) {
NTSTATUS NTAPI UnlockAndMaybeComplete
( PAFD_FCB FCB, NTSTATUS Status, PIRP Irp,
- UINT Information,
- PIO_COMPLETION_ROUTINE Completion ) {
+ UINT Information ) {
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = Information;
} else {
if ( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
SocketStateUnlock( FCB );
- if( Completion )
- Completion( FCB->DeviceExt->DeviceObject, Irp, FCB );
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
}
return Status;
NTSTATUS LeaveIrpUntilLater( PAFD_FCB FCB, PIRP Irp, UINT Function ) {
InsertTailList( &FCB->PendingIrpList[Function],
&Irp->Tail.Overlay.ListEntry );
- return UnlockAndMaybeComplete( FCB, STATUS_PENDING, Irp, 0, NULL );
-}
-
-VOID SocketCalloutEnter( PAFD_FCB FCB ) {
- ASSERT(FCB->Locked);
- FCB->Critical = TRUE;
- SocketStateUnlock( FCB );
-}
-
-VOID SocketCalloutLeave( PAFD_FCB FCB ) {
- FCB->Critical = FALSE;
- SocketAcquireStateLock( FCB );
+ IoMarkIrpPending(Irp);
+ Irp->IoStatus.Status = STATUS_PENDING;
+ return UnlockAndMaybeComplete( FCB, STATUS_PENDING, Irp, 0 );
}