刚才测试了Win7自带的无线网卡驱动使用的NDIS版本号。虽然之前不能肯定,但是一直觉得是6.20,因为他能支持virutal wifi 中的hosted network.这个应该是6.20才可能支持的,但是不完全肯定,主要理由是因为我使用OID_DOT11_CREATE_MAC 这个OID时,虽然返回成功,但是没有返回DOT11_MAC_INFO 因为返回的的缓冲区可读数据为0.所以疑惑就在这里:
现在既然是6.20的版本,而且OID_DOT11_CREATE_MAC返回Success的状态。可是就是没有返回创建New MAC的信息,包括端口号和MAC地址。
Oid = OID_GEN_DRIVER_VERSION; Status = filterDoInternalRequest(pFilter, NdisRequestQueryInformation, Oid, &InformationBuffer, sizeof(InformationBuffer), sizeof(InformationBuffer), MethodId, &BytesProcessed); if(Status == NDIS_STATUS_SUCCESS){ DEBUGP(DL_TEST,("Delete a new mac successfully!\n")); VersionHighByte = (InformationBuffer & 0xFF00) >> 8; VersionLowByte = (InformationBuffer & 0x00FF); DEBUGP(DL_TEST,("Ndis version:High %x, and Low: %x\n",VersionHighByte,VersionLowByte)); }
返回的值高位=0x6,低位=0x14(20)
所以现在的唯一的方法就是返回OID_GEN_SUPPORTED_LIST。 看看返回链表中是否有OID_DOT11_CREATE_MAC。
一般在驱动中都会定义该驱动支持的OID链表:
UINT supportedOIDs[] = { // // General required OIDs. // OID_GEN_SUPPORTED_LIST, OID_GEN_HARDWARE_STATUS, OID_GEN_MEDIA_SUPPORTED, OID_GEN_MEDIA_IN_USE, OID_GEN_MAXIMUM_LOOKAHEAD, OID_GEN_MAXIMUM_FRAME_SIZE, OID_GEN_LINK_SPEED, };
当有需要返回整个链表的时候:
case OID_GEN_SUPPORTED_LIST: infoSizeNeeded = sizeof(supportedOIDs); NdisMoveMemory( InformationBuffer, (PVOID)supportedOIDs, sizeof(supportedOIDs) ); break;
所以返回的list的size和关于数组的指针。虽然知道每个OID的是uint类型的,可是现在怎么把他们打印出来,成了问题。如果直接*(information+4*i),参考 General Operational Characteristics ,估计是数字,而不是字符。这是MSDN的描述:
最后一句没有明白。
--------------------------------------------2009-12-13------UPDATE-----------------------------------------
之前,由于锁的问题,而我却以为是内存分配的问题。所以对于DOT11_MAC_INFO,使用ULONG informationBuffer来保存,显然空间不够,unsigned long 应该是8个Bytes,而sizeof(DOT11_MAC_INFO) =16.
所以今天测试的时候返回了如下的状态:
所以需要申请额外的空间:
Oid = OID_DOT11_CREATE_MAC;//OID used to create a new MAC pFilter = CONTAINING_RECORD(Link, MS_FILTER, FilterModuleLink); pMacInfo = (PDOT11_MAC_INFO)NdisAllocateMemoryWithTagPriority(pFilter->FilterHandle, sizeof(DOT11_MAC_INFO), FILTER_ALLOC_TAG, LowPoolPriority); NdisZeroMemory(pMacInfo,sizeof(DOT11_MAC_INFO)); DEBUGP(DL_TEST,("sizeof DOT11_MAC_INFO is%u!\n",sizeof(DOT11_MAC_INFO))); Status = filterDoInternalRequest(pFilter, NdisRequestMethod, Oid, pMacInfo, sizeof(DOT11_MAC_INFO), sizeof(DOT11_MAC_INFO), MethodId, &BytesProcessed); if(Status == NDIS_STATUS_SUCCESS){ DEBUGP(DL_TEST,("Creae a new mac successfully!\n")); if(BytesProcessed > 0){ DEBUGP(DL_TEST,("Prot Number is %u\n",pMacInfo->uNdisPortNumber)); DEBUGP(DL_TEST,("Mac Address is %x-%x-%x-%x-%x-%x\n",pMacInfo->MacAddr[0],pMacInfo->MacAddr[1],pMacInfo->MacAddr[2],pMacInfo->MacAddr[3],pMacInfo->MacAddr[4],pMacInfo->MacAddr[5])); } }else if(Status == NDIS_STATUS_OPEN_LIST_FULL) { DEBUGP(DL_TEST,("Status is NDIS_STATUS_OPEN_LIST_FULL !\n")); } else { DEBUGP(DL_TEST,("Creae a new mac Fail!\n")); }
这下子,好了,可以返回:
00000026 50.94353104 NDISLWF:
00000027 50.94354630 ==>Filter IO Control dispatch
00000028 50.94360352 NDISLWF:
00000029 50.94364929 The input length is 44, and inputdata isRequest from user mode to crate a new MAC.
00000030 50.94365311
00000031 50.94380951 NDISLWF:
00000032 50.94382858 ==>filterDoInternalRequest
00000033 51.13080597 NDISLWF:
00000034 51.13083649 BytesProcessed = 16
00000035 51.13090897 NDISLWF:
00000036 51.13092422 Creae a new mac successfully!
00000037 51.13094711 NDISLWF:
00000038 51.13096237 Prot Number is 1
00000039 51.13098145 NDISLWF:
00000040 51.13098526 Filter IO Control dispatch<====
这个测试没有打印出MAC 地址。
可是奇怪的是,创建成功之后,估计是没有删除,但是没有到达可以创建MAC的上限,当我第二次测试的时候,想把MAC打印出来的时候,发现返回的BytesProcessed=0.可是仍然是创建成功的,当然这个时候没有portnumber了。跟之前的状况有点相似了
-------------------继续更新---------------------
其实不小心犯了一个错误,忘记了将返回的内容写进InformationBuffer:
00000019 23.88084602 Filter IO Control dispatch<====
00000020 24.11517906 NDISLWF:
00000021 24.11519814 ==>Filter IO Control dispatch
00000022 24.11523628 NDISLWF:
00000023 24.11548042 The input length is 44, and inputdata isRequest from user mode to crate a new MAC.
00000024 24.11548805
00000025 24.11552620 NDISLWF:
00000026 24.11553955 sizeof DOT11_MAC_INFO is16!
00000027 24.11557198 NDISLWF:
00000028 24.11559105 ==>filterDoInternalRequest
00000029 24.27196312 NDISLWF:
00000030 24.27199936 Creae a new mac successfully!
00000031 24.27202034 NDISLWF:
00000032 24.27203941 Prot Number is 1
00000033 24.27205467 NDISLWF:
00000034 24.27209473 Mac Address is 0-14-78-7a-2-a2
00000035 24.27212715 NDISLWF:
00000036 24.27213287 Filter IO Control dispatch<====
估计是该驱动不支持?这个不是很可能,因为它已经支持了OID_DOT11_CREATE_MAC,必定支持OID_DOT11_DELETE_MAC.另外查询没有问题:6.20.