Fixes for bugs previously posted in bugzilla.

svn path=/trunk/; revision=7469
This commit is contained in:
Art Yerkes 2004-01-06 03:44:38 +00:00
parent e2bc674743
commit 5662831f38
2 changed files with 60 additions and 12 deletions

View file

@ -368,21 +368,46 @@ NTSTATUS AfdDispSendTo(
#if 0
#ifdef _MSC_VER
try {
try {
#endif
MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess);
MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess);
#ifdef _MSC_VER
} except(EXCEPTION_EXECUTE_HANDLER) {
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
IoFreeMdl(Mdl);
if (BufferSize != 0) {
ExFreePool(SystemVirtualAddress);
}
return STATUS_UNSUCCESSFUL;
}
} except(EXCEPTION_EXECUTE_HANDLER) {
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
IoFreeMdl(Mdl);
if (BufferSize != 0) {
ExFreePool(SystemVirtualAddress);
}
return STATUS_UNSUCCESSFUL;
}
#endif
#endif
if (!FCB->TdiAddressObject) {
struct sockaddr_in BindName;
RtlZeroMemory(&BindName,sizeof(BindName));
BindName.sin_family = AF_INET;
Status = TdiOpenAddressFile
(&FCB->TdiDeviceName,
(SOCKADDR *)&BindName,
&FCB->TdiAddressObjectHandle,
&FCB->TdiAddressObject);
if (NT_SUCCESS(Status)) {
AfdRegisterEventHandlers(FCB);
FCB->State = SOCKET_STATE_BOUND;
Reply->Status = NO_ERROR;
} else {
//FIXME: WSAEADDRNOTAVAIL
Reply->Status = WSAEINVAL;
MmUnlockPages(Mdl);
IoFreeMdl(Mdl);
return Status;
}
}
Status = TdiSendDatagram(FCB->TdiAddressObject,
&Request->To,
Mdl,

View file

@ -256,8 +256,10 @@ NTSTATUS TdiCall(
NTSTATUS Status;
AFD_DbgPrint(MAX_TRACE, ("Called\n"));
Status = IoCallDriver(DeviceObject, Irp);
AFD_DbgPrint(MAX_TRACE, ("IoCallDriver: %08x\n", Status));
if ((Status == STATUS_PENDING) && (Event != NULL)) {
AFD_DbgPrint(MAX_TRACE, ("Waiting on transport.\n"));
KeWaitForSingleObject(
@ -1108,12 +1110,17 @@ NTSTATUS TdiSendDatagram(
KEVENT Event;
PIRP Irp;
AFD_DbgPrint(MAX_TRACE, ("Called.\n"));
DeviceObject = IoGetRelatedDeviceObject(TransportObject);
if (!DeviceObject) {
AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
return STATUS_INVALID_PARAMETER;
}
AFD_DbgPrint(MAX_TRACE,
("TdiSendDatagram: TansportObject = %08x\n", TransportObject));
TdiAddressSize = TdiAddressSizeFromName(Address);
ConnectInfo = (PTDI_CONNECTION_INFORMATION)
@ -1123,18 +1130,28 @@ NTSTATUS TdiSendDatagram(
if (!ConnectInfo)
return STATUS_INSUFFICIENT_RESOURCES;
AFD_DbgPrint(MAX_TRACE,
("TdiAddressSize = %d, sizeof(TDI_CONNECTION_INFORMATION) = %d\n",
TdiAddressSize, sizeof(TDI_CONNECTION_INFORMATION)));
RtlZeroMemory(ConnectInfo,
sizeof(TDI_CONNECTION_INFORMATION) +
TdiAddressSize);
ConnectInfo->RemoteAddressLength = TdiAddressSize;
ConnectInfo->RemoteAddress = (PVOID)
(ConnectInfo + sizeof(TDI_CONNECTION_INFORMATION));
(((PCHAR)ConnectInfo) + sizeof(TDI_CONNECTION_INFORMATION));
AFD_DbgPrint(MAX_TRACE, ("Point A\n"));
TdiBuildAddress(ConnectInfo->RemoteAddress, Address);
AFD_DbgPrint(MAX_TRACE, ("Point B\n"));
KeInitializeEvent(&Event, NotificationEvent, FALSE);
AFD_DbgPrint(MAX_TRACE, ("Point 0\n"));
Irp = TdiBuildInternalDeviceControlIrp(TDI_SEND_DATAGRAM, /* Sub function */
DeviceObject, /* Device object */
TransportObject, /* File object */
@ -1146,6 +1163,8 @@ NTSTATUS TdiSendDatagram(
return STATUS_INSUFFICIENT_RESOURCES;
}
AFD_DbgPrint(MAX_TRACE, ("Point 1\n"));
#if 0
Mdl = IoAllocateMdl(Buffer, /* Virtual address of buffer */
BufferSize, /* Length of buffer */
@ -1172,6 +1191,7 @@ NTSTATUS TdiSendDatagram(
#endif
#endif
AFD_DbgPrint(MAX_TRACE, ("TdiBuildSendDatagram()\n"));
TdiBuildSendDatagram(Irp, /* I/O Request Packet */
DeviceObject, /* Device object */
TransportObject, /* File object */
@ -1180,8 +1200,10 @@ NTSTATUS TdiSendDatagram(
Mdl, /* Descriptor for data buffer */
BufferSize, /* Size of data to send */
ConnectInfo); /* Connection information */
AFD_DbgPrint(MAX_TRACE, ("Returned from TdiBuildSendDatagram\n"));
Status = TdiCall(Irp, DeviceObject, &Event, &Iosb);
AFD_DbgPrint(MAX_TRACE, ("Returned from TdiCall\n"));
#if 0
MmUnlockPages(Mdl);
@ -1190,6 +1212,7 @@ NTSTATUS TdiSendDatagram(
#endif
ExFreePool(ConnectInfo);
AFD_DbgPrint(MAX_TRACE, ("Leaving %08x.\n", Status));
return Status;
}