ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
January 2012
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
19 participants
559 discussions
Start a n
N
ew thread
[cgutman] 54877: [NDISUIO] - Fix a query binding bug that caused access to unallocated memory [WLANCONF] - Fix parameter parsing and dumb IOCTL_NDISUIO_QUERY_BINDING usage
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 06:51:44 2012 New Revision: 54877 URL:
http://svn.reactos.org/svn/reactos?rev=54877&view=rev
Log: [NDISUIO] - Fix a query binding bug that caused access to unallocated memory [WLANCONF] - Fix parameter parsing and dumb IOCTL_NDISUIO_QUERY_BINDING usage Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c branches/wlan-bringup/drivers/network/ndisuio/ioctl.c Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] (original) +++ branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] Sun Jan 8 06:51:44 2012 @@ -132,21 +132,16 @@ return INVALID_HANDLE_VALUE; } - /* Query for bindable adapters */ - QueryBinding->BindingIndex = 0; - do { - bSuccess = DeviceIoControl(hDriver, - IOCTL_NDISUIO_QUERY_BINDING, - QueryBinding, - QueryBindingSize, - QueryBinding, - QueryBindingSize, - &dwBytesReturned, - NULL); - if (QueryBinding->BindingIndex == Index) - break; - QueryBinding->BindingIndex++; - } while (bSuccess); + /* Query the adapter binding information */ + QueryBinding->BindingIndex = Index; + bSuccess = DeviceIoControl(hDriver, + IOCTL_NDISUIO_QUERY_BINDING, + QueryBinding, + QueryBindingSize, + QueryBinding, + QueryBindingSize, + &dwBytesReturned, + NULL); if (!bSuccess) { @@ -540,35 +535,46 @@ for (i = 1; i < argc; i++) { - if ((argc > 1) && (argv[i][0] == '-')) - { - TCHAR c; - - while ((c = *++argv[i]) != '\0') + if (argv[i][0] == '-') + { + switch (argv[i][1]) { - switch (c) - { - case 's': - bScan = TRUE; - break; - case 'd': - bDisconnect = TRUE; - break; - case 'c': - bConnect = TRUE; - sSsid = argv[++i]; - break; - case 'w': - sWepKey = argv[++i]; - break; - case 'a': - bAdhoc = TRUE; - break; - default : + case 's': + bScan = TRUE; + break; + case 'd': + bDisconnect = TRUE; + break; + case 'c': + if (i == argc - 1) + { Usage(); return FALSE; - } + } + bConnect = TRUE; + sSsid = argv[++i]; + break; + case 'w': + if (i == argc - 1) + { + Usage(); + return FALSE; + } + sWepKey = argv[++i]; + break; + case 'a': + bAdhoc = TRUE; + break; + default : + Usage(); + return FALSE; } + + } + else + { + Usage(); + return FALSE; } } Modified: branches/wlan-bringup/drivers/network/ndisuio/ioctl.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] Sun Jan 8 06:51:44 2012 @@ -33,7 +33,7 @@ NTSTATUS QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp) { - PNDISUIO_ADAPTER_CONTEXT AdapterContext; + PNDISUIO_ADAPTER_CONTEXT AdapterContext = NULL; PNDISUIO_QUERY_BINDING QueryBinding = Irp->AssociatedIrp.SystemBuffer; ULONG BindingLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength; NTSTATUS Status; @@ -50,14 +50,16 @@ while (CurrentEntry != &GlobalAdapterList) { if (i == QueryBinding->BindingIndex) + { + AdapterContext = CONTAINING_RECORD(CurrentEntry, NDISUIO_ADAPTER_CONTEXT, ListEntry); break; + } i++; CurrentEntry = CurrentEntry->Flink; } KeReleaseSpinLock(&GlobalAdapterListLock, OldIrql); - if (i == QueryBinding->BindingIndex) - { - AdapterContext = CONTAINING_RECORD(CurrentEntry, NDISUIO_ADAPTER_CONTEXT, ListEntry); + if (AdapterContext) + { DPRINT("Query binding for index %d is adapter %wZ\n", i, &AdapterContext->DeviceName); BytesCopied = sizeof(NDISUIO_QUERY_BINDING); if (AdapterContext->DeviceName.Length <= BindingLength - BytesCopied)
12 years, 11 months
1
0
0
0
[cgutman] 54876: [NDISUIO] - Fix incorrect device name offset
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 06:23:53 2012 New Revision: 54876 URL:
http://svn.reactos.org/svn/reactos?rev=54876&view=rev
Log: [NDISUIO] - Fix incorrect device name offset Modified: branches/wlan-bringup/drivers/network/ndisuio/ioctl.c Modified: branches/wlan-bringup/drivers/network/ndisuio/ioctl.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] Sun Jan 8 06:23:53 2012 @@ -62,13 +62,12 @@ BytesCopied = sizeof(NDISUIO_QUERY_BINDING); if (AdapterContext->DeviceName.Length <= BindingLength - BytesCopied) { - BytesCopied += AdapterContext->DeviceName.Length; - QueryBinding->DeviceNameOffset = BytesCopied; QueryBinding->DeviceNameLength = AdapterContext->DeviceName.Length; RtlCopyMemory((PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset, AdapterContext->DeviceName.Buffer, QueryBinding->DeviceNameLength); + BytesCopied += AdapterContext->DeviceName.Length; /* FIXME: Copy description too */ QueryBinding->DeviceDescrOffset = BytesCopied;
12 years, 11 months
1
0
0
0
[cgutman] 54875: [NDISUIO] - Use the correct IOCTL input buffer [WLANCONF] - Fix parameters to IOCTL_NDISUIO_QUERY_BINDING - Wlanconf is ready for testing with a real WLAN adapter (for anyone who w...
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 06:08:47 2012 New Revision: 54875 URL:
http://svn.reactos.org/svn/reactos?rev=54875&view=rev
Log: [NDISUIO] - Use the correct IOCTL input buffer [WLANCONF] - Fix parameters to IOCTL_NDISUIO_QUERY_BINDING - Wlanconf is ready for testing with a real WLAN adapter (for anyone who wants to checkout this branch and try it) - Run "wlanconf -s <SSID>" to connect to an unencrypted wireless network - Run "wlanconf -s <SSID> -w <WEP key>" to connect to a WEP encrypted wireless network (WPA not supported) Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c branches/wlan-bringup/drivers/network/ndisuio/ioctl.c Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] (original) +++ branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] Sun Jan 8 06:08:47 2012 @@ -116,23 +116,31 @@ HANDLE hDriver; BOOL bSuccess; DWORD dwBytesReturned; - char Buffer[1024]; - PNDISUIO_QUERY_BINDING QueryBinding = (PNDISUIO_QUERY_BINDING)Buffer; + DWORD QueryBindingSize = sizeof(NDISUIO_QUERY_BINDING) + (1024 * sizeof(WCHAR)); + PNDISUIO_QUERY_BINDING QueryBinding; /* Open the driver handle */ hDriver = OpenDriverHandle(); if (hDriver == INVALID_HANDLE_VALUE) return INVALID_HANDLE_VALUE; + + /* Allocate the binding struct */ + QueryBinding = HeapAlloc(GetProcessHeap(), 0, QueryBindingSize); + if (!QueryBinding) + { + CloseHandle(hDriver); + return INVALID_HANDLE_VALUE; + } /* Query for bindable adapters */ QueryBinding->BindingIndex = 0; do { bSuccess = DeviceIoControl(hDriver, IOCTL_NDISUIO_QUERY_BINDING, - NULL, - 0, - NULL, - 0, + QueryBinding, + QueryBindingSize, + QueryBinding, + QueryBindingSize, &dwBytesReturned, NULL); if (QueryBinding->BindingIndex == Index) @@ -142,6 +150,7 @@ if (!bSuccess) { + HeapFree(GetProcessHeap(), 0, QueryBinding); CloseHandle(hDriver); return INVALID_HANDLE_VALUE; } @@ -155,6 +164,8 @@ 0, &dwBytesReturned, NULL); + HeapFree(GetProcessHeap(), 0, QueryBinding); + if (!bSuccess) { CloseHandle(hDriver); Modified: branches/wlan-bringup/drivers/network/ndisuio/ioctl.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] Sun Jan 8 06:08:47 2012 @@ -19,6 +19,7 @@ * no official documentation on it. I'm just implementing it as a no-op * right now because I don't see any reason we need it. We handle an open * and bind just fine with IRP_MJ_CREATE and IOCTL_NDISUIO_OPEN_DEVICE */ + DPRINT("Wait for bind complete\n"); Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; @@ -33,14 +34,14 @@ QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp) { PNDISUIO_ADAPTER_CONTEXT AdapterContext; - PNDISUIO_QUERY_BINDING QueryBinding = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; + PNDISUIO_QUERY_BINDING QueryBinding = Irp->AssociatedIrp.SystemBuffer; ULONG BindingLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength; NTSTATUS Status; PLIST_ENTRY CurrentEntry; KIRQL OldIrql; ULONG i; ULONG BytesCopied = 0; - + if (QueryBinding && BindingLength >= sizeof(NDISUIO_QUERY_BINDING)) { KeAcquireSpinLock(&GlobalAdapterListLock, &OldIrql); @@ -58,15 +59,19 @@ { AdapterContext = CONTAINING_RECORD(CurrentEntry, NDISUIO_ADAPTER_CONTEXT, ListEntry); DPRINT("Query binding for index %d is adapter %wZ\n", i, &AdapterContext->DeviceName); - if (AdapterContext->DeviceName.Length <= QueryBinding->DeviceNameLength) + BytesCopied = sizeof(NDISUIO_QUERY_BINDING); + if (AdapterContext->DeviceName.Length <= BindingLength - BytesCopied) { BytesCopied += AdapterContext->DeviceName.Length; + + QueryBinding->DeviceNameOffset = BytesCopied; + QueryBinding->DeviceNameLength = AdapterContext->DeviceName.Length; RtlCopyMemory((PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset, AdapterContext->DeviceName.Buffer, - BytesCopied); - QueryBinding->DeviceNameLength = AdapterContext->DeviceName.Length; + QueryBinding->DeviceNameLength); /* FIXME: Copy description too */ + QueryBinding->DeviceDescrOffset = BytesCopied; QueryBinding->DeviceDescrLength = 0; /* Successful */ @@ -147,7 +152,7 @@ Irp->IoStatus.Information = 0; - SetOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; + SetOidRequest = Irp->AssociatedIrp.SystemBuffer; RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength; if (SetOidRequest && RequestLength >= sizeof(NDIS_OID)) { @@ -203,7 +208,7 @@ Irp->IoStatus.Information = 0; - QueryOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; + QueryOidRequest = Irp->AssociatedIrp.SystemBuffer; RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength; if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID)) { @@ -263,7 +268,7 @@ if (NameLength != 0) { DeviceName.MaximumLength = DeviceName.Length = NameLength; - DeviceName.Buffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; + DeviceName.Buffer = Irp->AssociatedIrp.SystemBuffer; /* Check if this already has a context */ AdapterContext = FindAdapterContextByName(&DeviceName); @@ -357,7 +362,7 @@ if (NameLength != 0) { DeviceName.MaximumLength = DeviceName.Length = NameLength; - DeviceName.Buffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; + DeviceName.Buffer = Irp->AssociatedIrp.SystemBuffer; /* Check if this already has a context */ AdapterContext = FindAdapterContextByName(&DeviceName);
12 years, 11 months
1
0
0
0
[cgutman] 54874: [PSDK] - Add some definitions [WLANCONF] - Add support for adhoc networks and WEP encryption - Fix the BSSID info loop
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 04:45:51 2012 New Revision: 54874 URL:
http://svn.reactos.org/svn/reactos?rev=54874&view=rev
Log: [PSDK] - Add some definitions [WLANCONF] - Add support for adhoc networks and WEP encryption - Fix the BSSID info loop Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c branches/wlan-bringup/include/psdk/ntddndis.h Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] (original) +++ branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] Sun Jan 8 04:45:51 2012 @@ -17,6 +17,8 @@ BOOL bConnect = FALSE; char* sSsid = NULL; +char* sWepKey = NULL; +BOOL bAdhoc = FALSE; BOOL bDisconnect = FALSE; @@ -205,29 +207,204 @@ return bSuccess; } +static +UCHAR +CharToHex(CHAR Char) +{ + Char = toupper(Char); + + switch (Char) + { + case '0': + return 0x0; + case '1': + return 0x1; + case '2': + return 0x2; + case '3': + return 0x3; + case '4': + return 0x4; + case '5': + return 0x5; + case '6': + return 0x6; + case '7': + return 0x7; + case '8': + return 0x8; + case '9': + return 0x9; + case 'A': + return 0xA; + case 'B': + return 0xB; + case 'C': + return 0xC; + case 'D': + return 0xD; + case 'E': + return 0xE; + case 'F': + return 0xF; + default: + return 0; + } +} + BOOL WlanConnect(HANDLE hAdapter) { BOOL bSuccess; - DWORD dwBytesReturned; + DWORD dwBytesReturned, SetOidSize; PNDISUIO_SET_OID SetOid; PNDIS_802_11_SSID Ssid; - - SetOid = HeapAlloc(GetProcessHeap(), 0, sizeof(NDISUIO_SET_OID) + sizeof(NDIS_802_11_SSID)); + DWORD i; + + SetOidSize = sizeof(NDISUIO_SET_OID); + SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize); if (!SetOid) return FALSE; + /* Set the network mode */ + SetOid->Oid = OID_802_11_INFRASTRUCTURE_MODE; + *(PULONG)SetOid->Data = bAdhoc ? Ndis802_11IBSS : Ndis802_11Infrastructure; + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_SET_OID_VALUE, + SetOid, + SetOidSize, + NULL, + 0, + &dwBytesReturned, + NULL); + if (!bSuccess) + { + HeapFree(GetProcessHeap(), 0, SetOid); + return FALSE; + } + + /* Set the authentication mode */ + SetOid->Oid = OID_802_11_AUTHENTICATION_MODE; + *(PULONG)SetOid->Data = sWepKey ? Ndis802_11AuthModeShared : Ndis802_11AuthModeOpen; + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_SET_OID_VALUE, + SetOid, + SetOidSize, + NULL, + 0, + &dwBytesReturned, + NULL); + if (!bSuccess) + { + HeapFree(GetProcessHeap(), 0, SetOid); + return FALSE; + } + + if (sWepKey) + { + PNDIS_802_11_WEP WepData; + + HeapFree(GetProcessHeap(), 0, SetOid); + + SetOidSize = sizeof(NDISUIO_SET_OID) + FIELD_OFFSET(NDIS_802_11_WEP, KeyMaterial) + + (strlen(sWepKey) >> 2); + SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize); + if (!SetOid) + return FALSE; + + /* Add the WEP key */ + SetOid->Oid = OID_802_11_ADD_WEP; + WepData = (PNDIS_802_11_WEP)SetOid->Data; + + WepData->KeyIndex = 0x80000000; + WepData->KeyLength = strlen(sWepKey) >> 2; + WepData->Length = FIELD_OFFSET(NDIS_802_11_WEP, KeyMaterial) + WepData->KeyLength; + + /* Assemble the hex key */ + i = 0; + while (sWepKey[i << 2] != '\0') + { + WepData->KeyMaterial[i] = CharToHex(sWepKey[i << 2]) << 4; + WepData->KeyMaterial[i] |= CharToHex(sWepKey[(i << 2) + 1]); + i++; + } + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_SET_OID_VALUE, + SetOid, + SetOidSize, + NULL, + 0, + &dwBytesReturned, + NULL); + if (!bSuccess) + { + HeapFree(GetProcessHeap(), 0, SetOid); + return FALSE; + } + } + + /* Set the encryption status */ + SetOid->Oid = OID_802_11_WEP_STATUS; + *(PULONG)SetOid->Data = sWepKey ? Ndis802_11WEPEnabled : Ndis802_11WEPDisabled; + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_SET_OID_VALUE, + SetOid, + SetOidSize, + NULL, + 0, + &dwBytesReturned, + NULL); + if (!bSuccess) + { + HeapFree(GetProcessHeap(), 0, SetOid); + return FALSE; + } + + HeapFree(GetProcessHeap(), 0, SetOid); + SetOidSize = sizeof(NDISUIO_SET_OID) + sizeof(NDIS_802_11_MAC_ADDRESS); + SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize); + if (!SetOid) + return FALSE; + + /* Set the BSSID */ + SetOid->Oid = OID_802_11_BSSID; + RtlFillMemory(SetOid->Data, sizeof(NDIS_802_11_MAC_ADDRESS), 0xFF); + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_SET_OID_VALUE, + SetOid, + SetOidSize, + NULL, + 0, + &dwBytesReturned, + NULL); + if (!bSuccess) + { + HeapFree(GetProcessHeap(), 0, SetOid); + return FALSE; + } + + HeapFree(GetProcessHeap(), 0, SetOid); + SetOidSize = sizeof(NDISUIO_SET_OID) + sizeof(NDIS_802_11_SSID); + SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize); + if (!SetOid) + return FALSE; + + /* Finally, set the SSID */ SetOid->Oid = OID_802_11_SSID; Ssid = (PNDIS_802_11_SSID)SetOid->Data; - /* Fill the OID data buffer */ RtlCopyMemory(Ssid->Ssid, sSsid, strlen(sSsid)); Ssid->SsidLength = strlen(sSsid); bSuccess = DeviceIoControl(hAdapter, IOCTL_NDISUIO_SET_OID_VALUE, - &SetOid, - sizeof(SetOid), + SetOid, + SetOidSize, NULL, 0, &dwBytesReturned, @@ -292,9 +469,9 @@ } else { + PNDIS_WLAN_BSSID BssidInfo = BssidList->Bssid; for (i = 0; i < BssidList->NumberOfItems; i++) { - PNDIS_WLAN_BSSID BssidInfo = &BssidList->Bssid[i]; PNDIS_802_11_SSID Ssid = &BssidInfo->Ssid; NDIS_802_11_RSSI Rssi = BssidInfo->Rssi; NDIS_802_11_NETWORK_INFRASTRUCTURE NetworkType = BssidInfo->InfrastructureMode; @@ -307,8 +484,8 @@ _tprintf(_T("\nSSID: %s\n" "Encrypted: %s" "Network Type: %s\n" - "RSSI: %i\n" - "Supported Rates: "), + "RSSI: %i dBm\n" + "Supported Rates (Mbps): "), SsidBuffer, BssidInfo->Privacy == 0 ? "No" : "Yes", NetworkType == Ndis802_11IBSS ? "Adhoc" : "Infrastructure", @@ -323,6 +500,9 @@ } } _tprintf(_T("\n")); + + /* Move to the next entry */ + BssidInfo = (PNDIS_WLAN_BSSID)((PUCHAR)BssidInfo + BssidInfo->Length); } } @@ -334,8 +514,10 @@ VOID Usage() { _tprintf(_T("\nConfigures a WLAN adapter.\n\n" - "WLANCONF [-c SSID] [-d] [-s]\n\n" + "WLANCONF [-c SSID [-w WEP] [-a]] [-d] [-s]\n\n" " -c SSID Connects to a supplied SSID.\n" + " -w WEP Specifies a WEP key to use.\n" + " -a Specifies the target network is ad-hoc\n" " -d Disconnects from the current AP.\n" " -s Scans and displays a list of access points in range.\n")); } @@ -355,15 +537,21 @@ { switch (c) { - case 's' : + case 's': bScan = TRUE; break; - case 'd' : + case 'd': bDisconnect = TRUE; break; - case 'c' : + case 'c': bConnect = TRUE; sSsid = argv[++i]; + break; + case 'w': + sWepKey = argv[++i]; + break; + case 'a': + bAdhoc = TRUE; break; default : Usage(); Modified: branches/wlan-bringup/include/psdk/ntddndis.h URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/include/psdk/ntddn…
============================================================================== --- branches/wlan-bringup/include/psdk/ntddndis.h [iso-8859-1] (original) +++ branches/wlan-bringup/include/psdk/ntddndis.h [iso-8859-1] Sun Jan 8 04:45:51 2012 @@ -41,6 +41,22 @@ NdisDeviceStateD3, NdisDeviceStateMaximum } NDIS_DEVICE_POWER_STATE, *PNDIS_DEVICE_POWER_STATE; + +typedef enum _NDIS_802_11_WEP_STATUS +{ + Ndis802_11WEPEnabled, + Ndis802_11WEPDisabled, + Ndis802_11WEPKeyAbsent, + Ndis802_11WEPNotSupported +} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS; + +typedef enum _NDIS_802_11_AUTHENTICATION_MODE +{ + Ndis802_11AuthModeOpen, + Ndis802_11AuthModeShared, + Ndis802_11AuthModeAutoSwitch, + Ndis802_11AuthModeMax +} NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE; typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE { @@ -116,6 +132,14 @@ ULONG NumberOfItems; NDIS_WLAN_BSSID Bssid[1]; } NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST; + +typedef struct _NDIS_802_11_WEP +{ + ULONG Length; + ULONG KeyIndex; + ULONG KeyLength; + UCHAR KeyMaterial[1]; +} NDIS_802_11_WEP, *PNDIS_802_11_WEP; typedef struct _NDIS_PM_WAKE_UP_CAPABILITIES { NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp;
12 years, 11 months
1
0
0
0
[cgutman] 54873: [BOOTDATA] - Add wlanconf.exe to reactos.cab
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 03:29:56 2012 New Revision: 54873 URL:
http://svn.reactos.org/svn/reactos?rev=54873&view=rev
Log: [BOOTDATA] - Add wlanconf.exe to reactos.cab Modified: branches/wlan-bringup/boot/bootdata/packages/reactos.dff Modified: branches/wlan-bringup/boot/bootdata/packages/reactos.dff URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/boot/bootdata/pack…
============================================================================== --- branches/wlan-bringup/boot/bootdata/packages/reactos.dff [iso-8859-1] (original) +++ branches/wlan-bringup/boot/bootdata/packages/reactos.dff [iso-8859-1] Sun Jan 8 03:29:56 2012 @@ -76,6 +76,7 @@ base\applications\network\telnet\telnet.exe 1 base\applications\network\tracert\tracert.exe 1 base\applications\network\whois\whois.exe 1 +base\applications\network\wlanconf\wlanconf.exe 1 base\applications\notepad\notepad.exe 1 base\applications\rapps\rapps.exe 1 base\applications\regedit\regedit.exe 4
12 years, 11 months
1
0
0
0
[cgutman] 54872: [WLANCONF] - Fix a typo and fix CMake build
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 03:28:03 2012 New Revision: 54872 URL:
http://svn.reactos.org/svn/reactos?rev=54872&view=rev
Log: [WLANCONF] - Fix a typo and fix CMake build Modified: branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c Modified: branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt [iso-8859-1] (original) +++ branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt [iso-8859-1] Sun Jan 8 03:28:03 2012 @@ -4,5 +4,5 @@ ${REACTOS_SOURCE_DIR}/include/reactos/drivers/ndisuio) add_executable(wlanconf wlanconf.c wlanconf.rc) set_module_type(wlanconf win32cui) -add_importlibs(wlanconf kernel32) +add_importlibs(wlanconf msvcrt kernel32) add_cd_file(TARGET wlanconf DESTINATION reactos/system32 FOR all) Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] (original) +++ branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] Sun Jan 8 03:28:03 2012 @@ -55,7 +55,7 @@ DWORD dwBytesReturned; BOOL bSuccess; - /* Open a handle to this NDISUIO driver */ + /* Open a handle to the NDISUIO driver */ hDriver = CreateFileW(NDISUIO_DEVICE_NAME, GENERIC_READ | GENERIC_WRITE, 0,
12 years, 11 months
1
0
0
0
[cgutman] 54871: [WLANCONF] - Build fixes and code improvements
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 03:22:37 2012 New Revision: 54871 URL:
http://svn.reactos.org/svn/reactos?rev=54871&view=rev
Log: [WLANCONF] - Build fixes and code improvements Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c Modified: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] (original) +++ branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] Sun Jan 8 03:22:37 2012 @@ -218,7 +218,7 @@ return FALSE; SetOid->Oid = OID_802_11_SSID; - Ssid = SetOid->Data; + Ssid = (PNDIS_802_11_SSID)SetOid->Data; /* Fill the OID data buffer */ RtlCopyMemory(Ssid->Ssid, sSsid, strlen(sSsid)); @@ -246,7 +246,7 @@ NDISUIO_SET_OID SetOid; PNDISUIO_QUERY_OID QueryOid; DWORD QueryOidSize; - PNDIS_802_11_BSSID_LIST_EX BssidList; + PNDIS_802_11_BSSID_LIST BssidList; DWORD i, j; SetOid.Oid = OID_802_11_BSSID_LIST_SCAN; @@ -264,13 +264,13 @@ return FALSE; /* Allocate space for 15 networks to be returned */ - QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID_EX) * 15); + 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 = QueryOid->Data; + BssidList = (PNDIS_802_11_BSSID_LIST)QueryOid->Data; bSuccess = DeviceIoControl(hAdapter, IOCTL_NDISUIO_QUERY_OID_VALUE, @@ -294,12 +294,11 @@ { for (i = 0; i < BssidList->NumberOfItems; i++) { - PNDIS_WLAN_BSSID_EX BssidInfo = BssidList->Bssid[i]; + PNDIS_WLAN_BSSID BssidInfo = &BssidList->Bssid[i]; PNDIS_802_11_SSID Ssid = &BssidInfo->Ssid; - UCHAR SupportedRates[16] = &BssidInfo->SupportedRates; NDIS_802_11_RSSI Rssi = BssidInfo->Rssi; NDIS_802_11_NETWORK_INFRASTRUCTURE NetworkType = BssidInfo->InfrastructureMode; - CHAR SsidBuffer[33]; + CHAR SsidBuffer[NDIS_802_11_LENGTH_SSID + 1]; /* SSID member is a non-null terminated ASCII string */ RtlCopyMemory(SsidBuffer, Ssid->Ssid, Ssid->SsidLength); @@ -315,12 +314,12 @@ NetworkType == Ndis802_11IBSS ? "Adhoc" : "Infrastructure", (int)Rssi); - for (j = 0; j < 16; j++) + for (j = 0; j < NDIS_802_11_LENGTH_RATES; j++) { - if (SupportedRates[j] != 0) + if (BssidInfo->SupportedRates[j] != 0) { /* SupportedRates are in units of .5 */ - _tprintf(_T("%d "), (SupportedRates[j] << 2)); + _tprintf(_T("%d "), (BssidInfo->SupportedRates[j] << 2)); } } _tprintf(_T("\n"));
12 years, 11 months
1
0
0
0
[cgutman] 54870: [PSDK] - Add 802.11 OIDs
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 03:12:53 2012 New Revision: 54870 URL:
http://svn.reactos.org/svn/reactos?rev=54870&view=rev
Log: [PSDK] - Add 802.11 OIDs Modified: branches/wlan-bringup/include/psdk/ntddndis.h Modified: branches/wlan-bringup/include/psdk/ntddndis.h URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/include/psdk/ntddn…
============================================================================== --- branches/wlan-bringup/include/psdk/ntddndis.h [iso-8859-1] (original) +++ branches/wlan-bringup/include/psdk/ntddndis.h [iso-8859-1] Sun Jan 8 03:12:53 2012 @@ -265,8 +265,34 @@ #define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 #define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 -#define OID_802_11_BSSID_LIST 0x0D010217 -#define OID_802_11_BSSID_LIST_SCAN 0x0D01011A +/* IEEE 802.11 (WLAN) OIDs */ +#define OID_802_11_BSSID 0x0D010101 +#define OID_802_11_SSID 0x0D010102 +#define OID_802_11_NETWORK_TYPES_SUPPORTED 0x0D010203 +#define OID_802_11_NETWORK_TYPE_IN_USE 0x0D010204 +#define OID_802_11_TX_POWER_LEVEL 0x0D010205 +#define OID_802_11_RSSI 0x0D010206 +#define OID_802_11_RSSI_TRIGGER 0x0D010207 +#define OID_802_11_INFRASTRUCTURE_MODE 0x0D010108 +#define OID_802_11_FRAGMENTATION_THRESHOLD 0x0D010209 +#define OID_802_11_RTS_THRESHOLD 0x0D01020A +#define OID_802_11_NUMBER_OF_ANTENNAS 0x0D01020B +#define OID_802_11_RX_ANTENNA_SELECTED 0x0D01020C +#define OID_802_11_TX_ANTENNA_SELECTED 0x0D01020D +#define OID_802_11_SUPPORTED_RATES 0x0D01020E +#define OID_802_11_DESIRED_RATES 0x0D010210 +#define OID_802_11_CONFIGURATION 0x0D010211 +#define OID_802_11_STATISTICS 0x0D020212 +#define OID_802_11_ADD_WEP 0x0D010113 +#define OID_802_11_REMOVE_WEP 0x0D010114 +#define OID_802_11_DISASSOCIATE 0x0D010115 +#define OID_802_11_POWER_MODE 0x0D010216 +#define OID_802_11_BSSID_LIST 0x0D010217 +#define OID_802_11_AUTHENTICATION_MODE 0x0D010118 +#define OID_802_11_PRIVACY_FILTER 0x0D010119 +#define OID_802_11_BSSID_LIST_SCAN 0x0D01011A +#define OID_802_11_WEP_STATUS 0x0D01011B +#define OID_802_11_RELOAD_DEFAULTS 0x0D01011C /* OID_GEN_MINIPORT_INFO constants */ #define NDIS_MINIPORT_BUS_MASTER 0x00000001
12 years, 11 months
1
0
0
0
[cgutman] 54869: [WLANCONF] - Initial drop of a little WLAN configuration tool to use until WZC is implemented and working - Doesn't build yet due to missing OID definitions - Some of this code wil...
by cgutman@svn.reactos.org
Author: cgutman Date: Sun Jan 8 03:02:58 2012 New Revision: 54869 URL:
http://svn.reactos.org/svn/reactos?rev=54869&view=rev
Log: [WLANCONF] - Initial drop of a little WLAN configuration tool to use until WZC is implemented and working - Doesn't build yet due to missing OID definitions - Some of this code will eventually be reused when implementing WZC Added: branches/wlan-bringup/base/applications/network/wlanconf/ branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt (with props) branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c (with props) branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rbuild (with props) branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rc (with props) Modified: branches/wlan-bringup/base/applications/network/CMakeLists.txt branches/wlan-bringup/base/applications/network/network.rbuild Modified: branches/wlan-bringup/base/applications/network/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/CMakeLists.txt [iso-8859-1] (original) +++ branches/wlan-bringup/base/applications/network/CMakeLists.txt [iso-8859-1] Sun Jan 8 03:02:58 2012 @@ -14,3 +14,5 @@ endif() add_subdirectory(tracert) add_subdirectory(whois) +add_subdirectory(wlanconf) + Modified: branches/wlan-bringup/base/applications/network/network.rbuild URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/network.rbuild [iso-8859-1] (original) +++ branches/wlan-bringup/base/applications/network/network.rbuild [iso-8859-1] Sun Jan 8 03:02:58 2012 @@ -40,4 +40,7 @@ <directory name="whois"> <xi:include href="whois/whois.rbuild" /> </directory> + <directory name="wlanconf"> + <xi:include href="wlanconf/wlanconf.rbuild" /> + </directory> </group> Added: branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt (added) +++ branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt [iso-8859-1] Sun Jan 8 03:02:58 2012 @@ -1,0 +1,8 @@ + +include_directories( + BEFORE include + ${REACTOS_SOURCE_DIR}/include/reactos/drivers/ndisuio) +add_executable(wlanconf wlanconf.c wlanconf.rc) +set_module_type(wlanconf win32cui) +add_importlibs(wlanconf kernel32) +add_cd_file(TARGET wlanconf DESTINATION reactos/system32 FOR all) Propchange: branches/wlan-bringup/base/applications/network/wlanconf/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c (added) +++ branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c [iso-8859-1] Sun Jan 8 03:02:58 2012 @@ -1,0 +1,430 @@ +/* + * PROJECT: ReactOS WLAN command-line configuration utility + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/applications/network/wlanconf/wlanconf.c + * PURPOSE: Allows WLAN configuration via the command prompt + * COPYRIGHT: Copyright 2012 Cameron Gutman (cameron.gutman(a)reactos.org) + */ + +#include <windows.h> +#include <tchar.h> +#include <stdio.h> +#include <stdlib.h> +#include <ntddndis.h> +#include <nuiouser.h> + +BOOL bScan = FALSE; + +BOOL bConnect = FALSE; +char* sSsid = NULL; + +BOOL bDisconnect = FALSE; + +DWORD DoFormatMessage(DWORD ErrorCode) +{ + LPVOID lpMsgBuf; + DWORD RetVal; + + if ((RetVal = FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + ErrorCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ + (LPTSTR) &lpMsgBuf, + 0, + NULL ))) + { + _tprintf(_T("%s"), (LPTSTR)lpMsgBuf); + + LocalFree(lpMsgBuf); + + /* return number of TCHAR's stored in output buffer + * excluding '\0' - as FormatMessage does*/ + return RetVal; + } + else + return 0; +} + +HANDLE +OpenDriverHandle(VOID) +{ + HANDLE hDriver; + DWORD dwBytesReturned; + BOOL bSuccess; + + /* Open a handle to this NDISUIO driver */ + hDriver = CreateFileW(NDISUIO_DEVICE_NAME, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hDriver == INVALID_HANDLE_VALUE) + return INVALID_HANDLE_VALUE; + + /* Wait for binds */ + bSuccess = DeviceIoControl(hDriver, + IOCTL_NDISUIO_BIND_WAIT, + NULL, + 0, + NULL, + 0, + &dwBytesReturned, + NULL); + if (!bSuccess) + { + CloseHandle(hDriver); + return INVALID_HANDLE_VALUE; + } + + return hDriver; +} + +BOOL +IsWlanAdapter(HANDLE hAdapter) +{ + BOOL bSuccess; + DWORD dwBytesReturned; + NDISUIO_QUERY_OID QueryOid; + + /* NDIS 5.1 WLAN drivers must support this OID */ + QueryOid.Oid = OID_GEN_PHYSICAL_MEDIUM; + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_QUERY_OID_VALUE, + &QueryOid, + sizeof(QueryOid), + &QueryOid, + sizeof(QueryOid), + &dwBytesReturned, + NULL); + if (!bSuccess || *(PULONG)QueryOid.Data != NdisPhysicalMediumWirelessLan) + return FALSE; + + return TRUE; +} + +HANDLE +OpenAdapterHandle(DWORD Index) +{ + HANDLE hDriver; + BOOL bSuccess; + DWORD dwBytesReturned; + char Buffer[1024]; + PNDISUIO_QUERY_BINDING QueryBinding = (PNDISUIO_QUERY_BINDING)Buffer; + + /* Open the driver handle */ + hDriver = OpenDriverHandle(); + if (hDriver == INVALID_HANDLE_VALUE) + return INVALID_HANDLE_VALUE; + + /* Query for bindable adapters */ + QueryBinding->BindingIndex = 0; + do { + bSuccess = DeviceIoControl(hDriver, + IOCTL_NDISUIO_QUERY_BINDING, + NULL, + 0, + NULL, + 0, + &dwBytesReturned, + NULL); + if (QueryBinding->BindingIndex == Index) + break; + QueryBinding->BindingIndex++; + } while (bSuccess); + + if (!bSuccess) + { + CloseHandle(hDriver); + return INVALID_HANDLE_VALUE; + } + + /* Bind to the adapter */ + bSuccess = DeviceIoControl(hDriver, + IOCTL_NDISUIO_OPEN_DEVICE, + (PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset, + QueryBinding->DeviceNameLength, + NULL, + 0, + &dwBytesReturned, + NULL); + if (!bSuccess) + { + CloseHandle(hDriver); + return INVALID_HANDLE_VALUE; + } + + return hDriver; +} + +/* Only works with the first adapter for now */ +HANDLE +OpenWlanAdapter(VOID) +{ + DWORD dwCurrentIndex; + HANDLE hCurrentAdapter; + + for (dwCurrentIndex = 0; ; dwCurrentIndex++) + { + hCurrentAdapter = OpenAdapterHandle(dwCurrentIndex); + if (hCurrentAdapter == INVALID_HANDLE_VALUE) + break; + + if (IsWlanAdapter(hCurrentAdapter)) + return hCurrentAdapter; + else + CloseHandle(hCurrentAdapter); + } + + return INVALID_HANDLE_VALUE; +} + +BOOL +WlanDisconnect(HANDLE hAdapter) +{ + BOOL bSuccess; + DWORD dwBytesReturned; + NDISUIO_SET_OID SetOid; + + SetOid.Oid = OID_802_11_DISASSOCIATE; + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_SET_OID_VALUE, + &SetOid, + sizeof(SetOid), + NULL, + 0, + &dwBytesReturned, + NULL); + + return bSuccess; +} + +BOOL +WlanConnect(HANDLE hAdapter) +{ + BOOL bSuccess; + DWORD dwBytesReturned; + PNDISUIO_SET_OID SetOid; + PNDIS_802_11_SSID Ssid; + + SetOid = HeapAlloc(GetProcessHeap(), 0, sizeof(NDISUIO_SET_OID) + sizeof(NDIS_802_11_SSID)); + if (!SetOid) + return FALSE; + + SetOid->Oid = OID_802_11_SSID; + Ssid = SetOid->Data; + + /* Fill the OID data buffer */ + RtlCopyMemory(Ssid->Ssid, sSsid, strlen(sSsid)); + Ssid->SsidLength = strlen(sSsid); + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_SET_OID_VALUE, + &SetOid, + sizeof(SetOid), + NULL, + 0, + &dwBytesReturned, + NULL); + + HeapFree(GetProcessHeap(), 0, SetOid); + + return bSuccess; +} + +BOOL +WlanScan(HANDLE hAdapter) +{ + BOOL bSuccess; + DWORD dwBytesReturned; + NDISUIO_SET_OID SetOid; + PNDISUIO_QUERY_OID QueryOid; + DWORD QueryOidSize; + PNDIS_802_11_BSSID_LIST_EX BssidList; + DWORD i, j; + + SetOid.Oid = OID_802_11_BSSID_LIST_SCAN; + + /* Send the scan OID */ + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_SET_OID_VALUE, + &SetOid, + sizeof(SetOid), + NULL, + 0, + &dwBytesReturned, + NULL); + if (!bSuccess) + return FALSE; + + /* Allocate space for 15 networks to be returned */ + QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID_EX) * 15); + QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize); + if (!QueryOid) + return FALSE; + + QueryOid->Oid = OID_802_11_BSSID_LIST; + BssidList = QueryOid->Data; + + bSuccess = DeviceIoControl(hAdapter, + IOCTL_NDISUIO_QUERY_OID_VALUE, + QueryOid, + QueryOidSize, + QueryOid, + QueryOidSize, + &dwBytesReturned, + NULL); + if (!bSuccess) + { + HeapFree(GetProcessHeap(), 0, QueryOid); + return FALSE; + } + + if (BssidList->NumberOfItems == 0) + { + _tprintf(_T("No networks found in range\n")); + } + else + { + for (i = 0; i < BssidList->NumberOfItems; i++) + { + PNDIS_WLAN_BSSID_EX BssidInfo = BssidList->Bssid[i]; + PNDIS_802_11_SSID Ssid = &BssidInfo->Ssid; + UCHAR SupportedRates[16] = &BssidInfo->SupportedRates; + NDIS_802_11_RSSI Rssi = BssidInfo->Rssi; + NDIS_802_11_NETWORK_INFRASTRUCTURE NetworkType = BssidInfo->InfrastructureMode; + CHAR SsidBuffer[33]; + + /* SSID member is a non-null terminated ASCII string */ + RtlCopyMemory(SsidBuffer, Ssid->Ssid, Ssid->SsidLength); + SsidBuffer[Ssid->SsidLength] = 0; + + _tprintf(_T("\nSSID: %s\n" + "Encrypted: %s" + "Network Type: %s\n" + "RSSI: %i\n" + "Supported Rates: "), + SsidBuffer, + BssidInfo->Privacy == 0 ? "No" : "Yes", + NetworkType == Ndis802_11IBSS ? "Adhoc" : "Infrastructure", + (int)Rssi); + + for (j = 0; j < 16; j++) + { + if (SupportedRates[j] != 0) + { + /* SupportedRates are in units of .5 */ + _tprintf(_T("%d "), (SupportedRates[j] << 2)); + } + } + _tprintf(_T("\n")); + } + } + + HeapFree(GetProcessHeap(), 0, QueryOid); + + return bSuccess; +} + +VOID Usage() +{ + _tprintf(_T("\nConfigures a WLAN adapter.\n\n" + "WLANCONF [-c SSID] [-d] [-s]\n\n" + " -c SSID Connects to a supplied SSID.\n" + " -d Disconnects from the current AP.\n" + " -s Scans and displays a list of access points in range.\n")); +} + + +BOOL ParseCmdline(int argc, char* argv[]) +{ + INT i; + + for (i = 1; i < argc; i++) + { + if ((argc > 1) && (argv[i][0] == '-')) + { + TCHAR c; + + while ((c = *++argv[i]) != '\0') + { + switch (c) + { + case 's' : + bScan = TRUE; + break; + case 'd' : + bDisconnect = TRUE; + break; + case 'c' : + bConnect = TRUE; + sSsid = argv[++i]; + break; + default : + Usage(); + return FALSE; + } + } + } + } + + if (!bScan && !bDisconnect && !bConnect) + { + Usage(); + return FALSE; + } + + return TRUE; +} + +int main(int argc, char* argv[]) +{ + HANDLE hAdapter; + + if (!ParseCmdline(argc, argv)) + return -1; + + hAdapter = OpenWlanAdapter(); + if (hAdapter == INVALID_HANDLE_VALUE) + { + DoFormatMessage(GetLastError()); + return -1; + } + + if (bScan) + { + if (!WlanScan(hAdapter)) + { + DoFormatMessage(GetLastError()); + CloseHandle(hAdapter); + return -1; + } + } + else if (bDisconnect) + { + if (!WlanDisconnect(hAdapter)) + { + DoFormatMessage(GetLastError()); + CloseHandle(hAdapter); + return -1; + } + } + else + { + if (!WlanConnect(hAdapter)) + { + DoFormatMessage(GetLastError()); + CloseHandle(hAdapter); + return -1; + } + } + + CloseHandle(hAdapter); + return 0; +} Propchange: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.c ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rbuild URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rbuild (added) +++ branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rbuild [iso-8859-1] Sun Jan 8 03:02:58 2012 @@ -1,0 +1,8 @@ +<?xml version="1.0"?> +<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd"> +<module name="wlanconf" type="win32cui" installbase="system32" installname="wlanconf.exe"> + <include base="wlanconf">.</include> + <include base="ReactOS">include/reactos/drivers/ndisuio</include> + <file>wlanconf.c</file> + <file>wlanconf.rc</file> +</module> Propchange: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rbuild ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rc URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/base/applications/…
============================================================================== --- branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rc (added) +++ branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rc [iso-8859-1] Sun Jan 8 03:02:58 2012 @@ -1,0 +1,7 @@ +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS WLAN Configuration Tool\0" +#define REACTOS_STR_INTERNAL_NAME "wlanconf\0" +#define REACTOS_STR_ORIGINAL_FILENAME "wlanconf.exe\0" +#define REACTOS_STR_ORIGINAL_COPYRIGHT "Cameron Gutman (cameron.gutman(a)reactos.org)\0" +#include <reactos/version.rc> + + Propchange: branches/wlan-bringup/base/applications/network/wlanconf/wlanconf.rc ------------------------------------------------------------------------------ svn:eol-style = native
12 years, 11 months
1
0
0
0
[akhaldi] 54868: [PREFAST] * Write PREfast defect log to the console. Dedicated to Timo.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sat Jan 7 21:50:10 2012 New Revision: 54868 URL:
http://svn.reactos.org/svn/reactos?rev=54868&view=rev
Log: [PREFAST] * Write PREfast defect log to the console. Dedicated to Timo. Modified: trunk/reactos/cmake/msvc.cmake Modified: trunk/reactos/cmake/msvc.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/msvc.cmake?rev=54868…
============================================================================== --- trunk/reactos/cmake/msvc.cmake [iso-8859-1] (original) +++ trunk/reactos/cmake/msvc.cmake [iso-8859-1] Sat Jan 7 21:50:10 2012 @@ -53,9 +53,13 @@ endif() if(_PREFAST_) -message("PREFAST enabled!") -set(CMAKE_C_COMPILER "prefast cl") -set(CMAKE_CXX_COMPILER "prefast cl") + message("PREFAST enabled!") + set(CMAKE_C_COMPILER "prefast cl") + set(CMAKE_CXX_COMPILER "prefast cl") + set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}" + "prefast LIST") + set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> <DEFINES> /TP /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}" + "prefast LIST") endif() set(CMAKE_RC_CREATE_SHARED_LIBRARY ${CMAKE_C_CREATE_SHARED_LIBRARY})
12 years, 11 months
1
0
0
0
← Newer
1
...
46
47
48
49
50
51
52
...
56
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Results per page:
10
25
50
100
200