Author: cgutman
Date: Wed Mar 18 04:49:56 2015
New Revision: 66778
URL:
http://svn.reactos.org/svn/reactos?rev=66778&view=rev
Log:
[WLANCONF]
- Fix network scanning when many base stations are in range
- Fix input buffer size for OID_802_11_DISASSOCIATE and OID_802_11_BSSID_LIST_SCAN
[NDISUIO]
- Return STATUS_BUFFER_TOO_SMALL when the OID buffer length is too small
Modified:
trunk/reactos/base/applications/network/wlanconf/wlanconf.c
trunk/reactos/drivers/network/ndisuio/ioctl.c
Modified: trunk/reactos/base/applications/network/wlanconf/wlanconf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] Wed Mar 18
04:49:56 2015
@@ -271,7 +271,7 @@
bSuccess = DeviceIoControl(hAdapter,
IOCTL_NDISUIO_SET_OID_VALUE,
&SetOid,
- sizeof(SetOid),
+ FIELD_OFFSET(NDISUIO_SET_OID, Data),
NULL,
0,
&dwBytesReturned,
@@ -739,6 +739,7 @@
DWORD QueryOidSize;
PNDIS_802_11_BSSID_LIST BssidList;
DWORD i, j;
+ DWORD dwNetworkCount;
WCHAR szMsgBuf[128];
SetOid.Oid = OID_802_11_BSSID_LIST_SCAN;
@@ -747,7 +748,7 @@
bSuccess = DeviceIoControl(hAdapter,
IOCTL_NDISUIO_SET_OID_VALUE,
&SetOid,
- sizeof(SetOid),
+ FIELD_OFFSET(NDISUIO_SET_OID, Data),
NULL,
0,
&dwBytesReturned,
@@ -755,23 +756,44 @@
if (!bSuccess)
return FALSE;
- /* Allocate space for 15 networks to be returned */
- QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID) * 15);
- QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
- if (!QueryOid)
- return FALSE;
-
- QueryOid->Oid = OID_802_11_BSSID_LIST;
- BssidList = (PNDIS_802_11_BSSID_LIST)QueryOid->Data;
-
- bSuccess = DeviceIoControl(hAdapter,
- IOCTL_NDISUIO_QUERY_OID_VALUE,
- QueryOid,
- QueryOidSize,
- QueryOid,
- QueryOidSize,
- &dwBytesReturned,
- NULL);
+ /* Wait 2 seconds for the scan to return some results */
+ Sleep(2000);
+
+ /* Allocate space for 10 networks to be returned initially */
+ QueryOid = NULL;
+ dwNetworkCount = 10;
+ for (;;)
+ {
+ if (QueryOid)
+ HeapFree(GetProcessHeap(), 0, QueryOid);
+
+ QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID) *
dwNetworkCount);
+ QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
+ if (!QueryOid)
+ return FALSE;
+
+ QueryOid->Oid = OID_802_11_BSSID_LIST;
+ BssidList = (PNDIS_802_11_BSSID_LIST)QueryOid->Data;
+
+ bSuccess = DeviceIoControl(hAdapter,
+ IOCTL_NDISUIO_QUERY_OID_VALUE,
+ QueryOid,
+ QueryOidSize,
+ QueryOid,
+ QueryOidSize,
+ &dwBytesReturned,
+ NULL);
+ if (!bSuccess && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ /* Try allocating space for 10 more networks */
+ dwNetworkCount += 10;
+ }
+ else
+ {
+ break;
+ }
+ }
+
if (!bSuccess)
{
HeapFree(GetProcessHeap(), 0, QueryOid);
Modified: trunk/reactos/drivers/network/ndisuio/ioctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndisuio/io…
==============================================================================
--- trunk/reactos/drivers/network/ndisuio/ioctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndisuio/ioctl.c [iso-8859-1] Wed Mar 18 04:49:56 2015
@@ -190,7 +190,15 @@
}
/* Return the bytes read */
- if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(NDIS_OID) +
Request.DATA.SET_INFORMATION.BytesRead;
+ if (Status == NDIS_STATUS_INVALID_LENGTH ||
+ Status == NDIS_STATUS_BUFFER_TOO_SHORT)
+ {
+ Status = STATUS_BUFFER_TOO_SMALL;
+ }
+ else if (Status == NDIS_STATUS_SUCCESS)
+ {
+ Irp->IoStatus.Information = sizeof(NDIS_OID) +
Request.DATA.SET_INFORMATION.BytesRead;
+ }
DPRINT("Final request status: 0x%x (%d)\n", Status,
Irp->IoStatus.Information);
}
@@ -256,7 +264,15 @@
}
/* Return the bytes written */
- if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(NDIS_OID) +
Request.DATA.QUERY_INFORMATION.BytesWritten;
+ if (Status == NDIS_STATUS_INVALID_LENGTH ||
+ Status == NDIS_STATUS_BUFFER_TOO_SHORT)
+ {
+ Status = STATUS_BUFFER_TOO_SMALL;
+ }
+ else if (Status == NDIS_STATUS_SUCCESS)
+ {
+ Irp->IoStatus.Information = sizeof(NDIS_OID) +
Request.DATA.QUERY_INFORMATION.BytesWritten;
+ }
DPRINT("Final request status: 0x%x (%d)\n", Status,
Irp->IoStatus.Information);
}