|
|
|
|
|
|
|
Windows内核
帖子发起人: joe2007max83 发起时间: 2011-07-01 16:19 下午 回复: 3
|
帖子排序:
|
|
|
|
2011-07-01, 16:19 下午
|
joe2007max83
注册: 2011-07-01
发 贴: 5
|
大家帮看看为什么DeviceIoControl访问OID_802_11_BSSID_LIST老是失败
|
|
|
|
如题,下面一段程序中,DeviceIoControl访问OID_802_11_BSSID_LIST老是失败(见下面红色),也就是说bResult一直等于0;为什么?请教牛人!!!
可能的问题出现在哪?为什么第二个DeviceIoControl失败?
#include "stdafx.h"
#include
#include
#include
#include
#include
#include
#include
#define NUMBEROF_BSSIDS 10
int main()
{
HANDLE hDev;
bool bResult;
DWORD junk;
unsigned char macadress[32];
NDIS_802_11_BSSID_LIST* m_pBSSIDList;
m_pBSSIDList = ( NDIS_802_11_BSSID_LIST *) VirtualAlloc( NULL,
sizeof( NDIS_802_11_BSSID_LIST)* NUMBEROF_BSSIDS,
MEM_RESERVE | MEM_COMMIT,
PAGE_READWRITE) ;
hDev=CreateFile(L"//./{FC1F5ED6-543B-404D-9051-FF85FC7D8161}",
GENERIC_READ|GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if (hDev == INVALID_HANDLE_VALUE)
{
return (FALSE);
}
else
{
memset( m_pBSSIDList, 0, sizeof( NDIS_802_11_BSSID_LIST)* NUMBEROF_BSSIDS);
ULONG oidcode = OID_802_11_BSSID_LIST_SCAN ; //0x0D01011A=218169626
DeviceIoControl(hDev,
IOCTL_NDIS_QUERY_GLOBAL_STATS,
(LPVOID)&oidcode,
sizeof(oidcode),
(ULONG *)NULL,
0,
&junk,
0);
Sleep(2000);
memset( m_pBSSIDList, 0, sizeof( NDIS_802_11_BSSID_LIST)* NUMBEROF_BSSIDS);
oidcode = OID_802_11_BSSID_LIST; //0x0D010217=218169879
bResult= DeviceIoControl(hDev, 。。。。。。。。。。。。。就是这个DeviceIoControl失败!
IOCTL_NDIS_QUERY_GLOBAL_STATS,
&oidcode,
sizeof( oidcode),
( ULONG *) m_pBSSIDList,
sizeof( NDIS_802_11_BSSID_LIST)* NUMBEROF_BSSIDS,
&junk,
NULL);
if (bResult)
{
for (int i=0;iNumberOfItems;i++)
{
int temp=i;
PNDIS_WLAN_BSSID cpSsid=m_pBSSIDList->Bssid;
while(temp!=0)
{
cpSsid=(PNDIS_WLAN_BSSID)((char *)cpSsid +cpSsid->Length);
temp--;
}
printf("%f",cpSsid->Ssid.Ssid);
printf("%d",cpSsid->Rssi);
printf((char*)macadress,"%02X-%02X-%02X-%02X-%02X-%02X",
(int*)m_pBSSIDList->Bssid.MacAddress[0],
(int*)m_pBSSIDList->Bssid.MacAddress[1],
(int*)m_pBSSIDList->Bssid.MacAddress[2],
(int*)m_pBSSIDList->Bssid.MacAddress[3],
(int*)m_pBSSIDList->Bssid.MacAddress[4],
(int*)m_pBSSIDList->Bssid.MacAddress[5]);
}
}
printf("failed");
CloseHandle(hDev);
getchar();
}
}
|
|
|
IP 地址: 已记录
|
报告
|
|
|
|
2011-07-02, 04:30 上午
|
joe2007max83
注册: 2011-07-01
发 贴: 5
|
Re: 大家帮看看为什么DeviceIoControl访问OID_802_11_BSSID_LIST老是失败
|
|
|
|
GetLastError返回值为31,
〖31〗-连到系统上的设备没有发挥作用。
是什么意思?如何解决?
我的网卡应该是好的。我还用它上网呢
|
|
|
IP 地址: 已记录
|
报告
|
|
|
|
2011-07-02, 11:52 上午
|
johnl
注册: 2008-09-29
发 贴: 9
|
Re: 大家帮看看为什么DeviceIoControl访问OID_802_11_BSSID_LIST老是失败
|
|
|
|
|
|
IP 地址: 已记录
|
报告
|
|
|
|
2011-07-03, 19:55 下午
|
joe2007max83
注册: 2011-07-01
发 贴: 5
|
Re: 大家帮看看为什么DeviceIoControl访问OID_802_11_BSSID_LIST老是失败
|
|
|
|
|
|
IP 地址: 已记录
|
报告
|
|
|
|
高端调试 » 内核探秘 » Windows内核 » Re: 大家帮看看为什么DeviceIoControl访问OID_802_11_BSSID_LIST老是失败
|
|
|
|
|
|