The platform I use is WinXP and the WinXP DDK.
I have a TDI Kernel Mode Client which queries the underlying transport
driver. (\\device\udp)
When I call IoCallDevice to query it returns STATUS_INVALID_DEVICE_REQUEST.
Please HELP!!!!
My code is as follows.........
I have the right deviceobject and Transport Object
NTSTATUS Status;
PIRP Irp;
KEVENT Event;
IO_STATUS_BLOCK IoStatus;
MDL *pMdl;
if( !pTdiTransportObject )
{
return( STATUS_FILE_CLOSED );
}
*pBuffer = (PTDI_ADDRESS_INFO) ExAllocatePool (NonPagedPool, sizeof
(TDI_ADDRESS_INFO));
// Create MDL for buffer
pMdl = IoAllocateMdl (pBuffer, sizeof(TDI_ADDRESS_INFO),FALSE, TRUE, NULL);
if ( pMdl ) // validate mdl
pointer
MmProbeAndLockPages ( pMdl, KernelMode, IoModifyAccess ); // probe
& lock
else
return( STATUS_INSUFFICIENT_RESOURCES );
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = TdiBuildInternalDeviceControlIrp(
TDI_QUERY_INFORMATION, // IrpSubFunction
pDeviceObject, // DeviceObject
pTdiTransportObject, // TransportObject
&Event, // Event
&IoStatus // IoStatusBlock
);
if( !Irp )
{
IoFreeMdl(pMdl);
return( STATUS_INSUFFICIENT_RESOURCES );
}
TdiBuildQueryInformation(
Irp, // IRP
pDeviceObject, // Pointer To TDI Device Object
pTdiTransportObject, // File Object
NULL, // CompletionRoutine
NULL, // Event Context
TDI_QUERY_ADDRESS_INFO, // QType
pMdl // Buffer
);
Status = IoCallDriver(pDeviceObject, Irp);
The Status is STATUS_INVALID_DEVICE_REQUEST
WHY??????????
Good luck,
--
Thomas F. Divine
PCAUSA - Tools & Resources For Network Software Developers
NDIS Protocol/Intermediate/Hooking - TDI Client/Filter
<http://www.pcausa.com> - <http://www.rawether.net>
"Mony Shetty" <beans...@yahoo.com> wrote in message
news:#NxDrNuuBHA.2280@tkmsftngp05...
I have created a control channel( documentation says using this to Query
underlying Transport)
RtlInitUnicodeString (&DeviceName, L"\\Device\\tcp");
//create control channel
Status = IoGetDeviceObjectPointer (&DeviceName, FILE_READ_DATA, &pFile,
&pDeviceObject);
And tried querying all parameters( again from ddk doc) like
TDI_QUERY_MAX_DATAGRAM_INFO etc.
I have no idea why all of them gives me STATUS_NOT_IMPLEMENTED .
Thanks in advance for any help.
M.
"Thomas F. Divine" <pca...@hotmail.com> wrote in message
news:u7agc0p...@corp.supernews.com...
Is there anyone out there who can help me with my problem. IoCallDriver
fails when I try to send an Irp built using TDIBuildQueryInformation.
TdiBuildQueryInformation(
Irp, // IRP
pDeviceObject, // Pointer To TDI Device Object
pTdiTransportObject, // File Object
NULL, // CompletionRoutine
NULL, // Event Context
TDI_QUERY_ADDRESS_INFO, // QType
pMdl // Buffer
);
Status = IoCallDriver(pDeviceObject, Irp); /*********** FAILS AT THIS
POINT */
I have been struggling with is for over 2 weeks now and have made no
progess. The code I have wriiten is according to the DDK documentaion.
If anyone has a working copy please send me the code snippet or redirect
me to a another resouce where I can get help.
SOMEBODY PLEASE HELP!!!
Thanks in advance,
M.
"Mony Shetty" <beans...@yahoo.com> wrote in message
news:eG1jYD6uBHA.2716@tkmsftngp05...
It works for me on NT/2000.
USHORT GetPortFromAddressInfo(PDEVICE_OBJECT pDeviceObject, PFILE_OBJECT
pAddressObject)
{
NTSTATUS status ;
PIRP pIrp = NULL ;
PMDL pMDL = NULL ;
TDI_ADDRESS_INFO *pAddrInfo = NULL ;
TDI_ADDRESS_IP TDI_IP ;
USHORT usPort ;
IO_STATUS_BLOCK IoStatusBlock ;
pIrp = TdiBuildInternalDeviceControlIrp (TDI_QUERY_INFORMATION,
pDeviceObject,
pAddressObject,
NULL,
&IoStatusBlock
);
if(!pIrp)
{
DebugPrint("pIrp not allocated") ;
return 0 ;
}
if(!pAddrInfo) //not yet allocated
pAddrInfo = (TDI_ADDRESS_INFO*)ExAllocatePool(NonPagedPool , 2048) ;
if(!pAddrInfo) //not allocated
{
return 0 ;
}
{
pMDL = IoAllocateMdl(
pAddrInfo,
2048,
FALSE,
TRUE,
pIrp
);
}
if(!pMDL)
{
DebugPrint("MDL not allocated") ;
goto CLEANUP ;
}
//__try
{
MmProbeAndLockPages(pMDL, KernelMode, IoWriteAccess) ;
}
//__except(EXCEPTION_EXECUTE_HANDLER){
//DebugPrint("MDL not locked") ;
//bSuccess = 0 ;
//}
TdiBuildQueryInformation (
pIrp,
pDeviceObject,
pAddressObject,
NULL, //QUERY_COMPLETION_ROUTINE,
NULL,
TDI_QUERY_ADDRESS_INFO,
pMDL );
status = IoCallDriver(pDeviceObject, pIrp);
if( status == STATUS_SUCCESS )
{ in_addr *p_inetAddr ;
//DebugPrint("Connection State [%u]", pAddrInfo->ActivityCount) ;
TRANSPORT_ADDRESS *pTAddress = &pAddrInfo->Address ;
TA_ADDRESS *pTA = &pTAddress->Address[0] ;
RtlCopyMemory(&TDI_IP, (TDI_ADDRESS_IP*)pTA->Address,
TDI_ADDRESS_LENGTH_IP) ;
p_inetAddr = (in_addr*)&TDI_IP.in_addr ;
}
else
{
DebugPrint("Connection State - CallDriver failed") ;
}
usPort = TDI_IP.sin_port ;
CLEANUP:
if(pAddrInfo)
ExFreePool(pAddrInfo) ;
return usPort ;
}
"Mony Shetty" <beans...@yahoo.com> schrieb im Newsbeitrag
news:#GqIDaevBHA.1608@tkmsftngp04...
Thanks...Your help very much appreciated.
Cheers,
M
"Jeff Runaway" <je...@runaway.co> wrote in message
news:uTSzxc6wBHA.2556@tkmsftngp07...