阅读:2601回复:10
Passthru中查询网卡的IP地址
我使用OID_GEN_NETWORK_LAYER_ADDRESSES来查询网卡的IP地址,可是在PtRequestComplete里面查到的返回状态是(STATUS_NOT_SUPPORTED)0xc00000bb,查以前的贴子,也有朋友遇到相同问题,但是没有具体说如何解决的。
开发环境是Windows XP + WinXPDDK(NDIS5.1)。 请各位朋友多多指教~~ [编辑 - 5/19/04 by dweep] |
|
最新喜欢:![]()
|
沙发#
发布于:2004-05-21 08:56
问题解决了 咋整的?也来个总结吧,呵呵,方便我这样的新手。 :P |
|
|
板凳#
发布于:2004-05-21 07:46
问题解决了
|
|
地板#
发布于:2004-05-19 23:39
我用上述的方法只能在网卡IP改变时拦截的到,我想在驱动中根据需要来查询网卡IP,请指教.
|
|
地下室#
发布于:2004-05-19 15:01
你要再截不到别找我了,上面的代码都是产品级别的了。别让我LB看见-:)
|
|
5楼#
发布于:2004-05-19 14:59
VOID
PtRequestComplete( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_REQUEST NdisRequest, IN NDIS_STATUS Status ) /*++ Routine Description: Completion handler for the previously posted request. All OIDS are completed by and sent to the same miniport that they were requested for. If Oid == OID_PNP_QUERY_POWER then the data structure needs to returned with all entries = NdisDeviceStateUnspecified Arguments: ProtocolBindingContext Pointer to the adapter structure NdisRequest The posted request Status Completion status Return Value: None --*/ { PADAPT pAdapt =(PADAPT)ProtocolBindingContext; NDIS_OID Oid = pAdapt->Request.DATA.SET_INFORMATION.Oid ; PNETWORK_ADDRESS_LIST pAddrList = NULL; PNETWORK_ADDRESS pAddr = NULL; PNETWORK_ADDRESS_IP pIpAddr= NULL; // // Change to the pAdapt for which the request originated // if(MPIsSendOID(Oid)) { pAdapt = pAdapt->pPrimaryAdapt; // // Will point to itself if there is no bundle(see initialization) // } // // Since our request is not outstanding anymore // pAdapt->OutstandingRequests = FALSE; // // Complete the Set or Query, and fill in the buffer for OID_PNP_CAPABILITIES, if need be. // switch(NdisRequest->RequestType) { case NdisRequestQueryInformation: // // This should not have been passsed to the miniport below us // ASSERT(Oid != OID_PNP_QUERY_POWER); // // If oid == OID_PNP_CAPABILITIES and query was successsful // then fill the buffer with the required values // if(Oid == OID_PNP_CAPABILITIES && Status == NDIS_STATUS_SUCCESS) { MPQueryPNPCapbilities(pAdapt,&Status); } *pAdapt->BytesReadOrWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten; *pAdapt->BytesNeeded = NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded; NdisMQueryInformationComplete(pAdapt->MiniportHandle, Status); break; case NdisRequestSetInformation: ASSERT( Oid != OID_PNP_SET_POWER); //================================================= // while(Oid == OID_GEN_NETWORK_LAYER_ADDRESSES) { // DbgPrint(\"=>OID_GEN_NETWORK_LAYER_ADDRESSES\\n\"); pAddrList = (PNETWORK_ADDRESS_LIST)NdisRequest->DATA.SET_INFORMATION.InformationBuffer; if (pAddrList->AddressCount <= 0) break; pAddr = (PNETWORK_ADDRESS)&pAddrList->Address[0]; if (pAddr->AddressType != NDIS_PROTOCOL_ID_TCP_IP) break; pIpAddr = (NETWORK_ADDRESS_IP UNALIGNED *)&pAddr->Address[0]; ipsec_local_ipaddr = pIpAddr->in_addr; // DbgPrint(\"OID_GEN_NETWORK_LAYER_ADDRESSES = %.8X\\n\",ipsec_local_ipaddr); break; }; //================================================= *pAdapt->BytesReadOrWritten = NdisRequest->DATA.SET_INFORMATION.BytesRead; *pAdapt->BytesNeeded = NdisRequest->DATA.SET_INFORMATION.BytesNeeded; NdisMSetInformationComplete(pAdapt->MiniportHandle, Status); break; default: ASSERT(0); break; } } |
|
6楼#
发布于:2004-05-19 14:36
果然是大款,凭你的分,看来我是的帮到底了。 您帮到底吧,我在PtRequestComplete里面没有截获到这个OID... MAC地址可以截获到... :( :( :( |
|
|
7楼#
发布于:2004-05-19 11:53
果然是大款,凭你的分,看来我是的帮到底了。
|
|
8楼#
发布于:2004-05-19 11:34
谢谢。虽然还没有试,但是您的方法应该是可行的。
我已经给您分了,以后还请多多指教。嘿嘿。 [编辑 - 5/19/04 by dweep] |
|
|
9楼#
发布于:2004-05-19 09:35
while(Oid == OID_GEN_NETWORK_LAYER_ADDRESSES)
{ // DbgPrint(\"=>OID_GEN_NETWORK_LAYER_ADDRESSES\\n\"); pAddrList = (PNETWORK_ADDRESS_LIST)NdisRequest->DATA.SET_INFORMATION.InformationBuffer; if (pAddrList->AddressCount <= 0) break; pAddr = (PNETWORK_ADDRESS)&pAddrList->Address[0]; if (pAddr->AddressType != NDIS_PROTOCOL_ID_TCP_IP) break; pIpAddr = (NETWORK_ADDRESS_IP UNALIGNED *)&pAddr->Address[0]; local_ipaddr = pIpAddr->in_addr; // DbgPrint(\"OID_GEN_NETWORK_LAYER_ADDRESSES = %.8X\\n\",local_ipaddr); break; }; [编辑 - 5/19/04 by asmsys] |
|
10楼#
发布于:2004-05-19 09:26
有可能发的太早,网卡好没有初始化完成。直接拦截就可以了,因为网卡向上传递他的MAC地址是必须的,所以你肯定能拦截到。
拦截后保存就可供以后使用。 |
|