ReactOS 0.4.16-dev-2610-ge2c92c0
wlanconf.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS WLAN command-line configuration utility
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Allows WLAN configuration via the command prompt
5 * COPYRIGHT: Copyright 2012 Cameron Gutman <cameron.gutman@reactos.org>
6 */
7
8#include <stdio.h>
9#include <stdarg.h>
10
11#include <windef.h>
12#include <winbase.h>
13#include <devioctl.h>
14#include <ntddndis.h>
15#include <nuiouser.h>
16#include <iphlpapi.h>
17
18#include <conutils.h>
19
20#include "resource.h"
21
28
30{
32 return;
33
36}
37
40{
42 DWORD dwBytesReturned;
43 BOOL bSuccess;
44
45 /* Open a handle to the NDISUIO driver */
48 0,
49 NULL,
52 NULL);
55
56 /* Wait for binds */
57 bSuccess = DeviceIoControl(hDriver,
59 NULL,
60 0,
61 NULL,
62 0,
63 &dwBytesReturned,
64 NULL);
65 if (!bSuccess)
66 {
69 }
70
71 return hDriver;
72}
73
74BOOL
76{
77 BOOL bSuccess;
78 DWORD dwBytesReturned;
79 NDISUIO_QUERY_OID QueryOid;
80
81 /* WLAN drivers must support this OID */
83
84 bSuccess = DeviceIoControl(hAdapter,
86 &QueryOid,
87 sizeof(QueryOid),
88 &QueryOid,
89 sizeof(QueryOid),
90 &dwBytesReturned,
91 NULL);
92 if (!bSuccess || *(PULONG)QueryOid.Data != NdisPhysicalMediumWirelessLan)
93 return FALSE;
94
95 return TRUE;
96}
97
98BOOL
100{
102 BOOL bSuccess;
103 DWORD dwBytesReturned;
104 DWORD QueryBindingSize = sizeof(NDISUIO_QUERY_BINDING) + (1024 * sizeof(WCHAR));
107 LONG i;
108 PIP_INTERFACE_INFO InterfaceInfo = NULL;
109
110 /* Open the driver handle */
113 return FALSE;
114
115 /* Allocate the binding struct */
116 QueryBinding = HeapAlloc(GetProcessHeap(), 0, QueryBindingSize);
117 if (!QueryBinding)
118 {
120 return FALSE;
121 }
122
123 /* Query the adapter binding information */
124 QueryBinding->BindingIndex = Index;
125 bSuccess = DeviceIoControl(hDriver,
128 QueryBindingSize,
130 QueryBindingSize,
131 &dwBytesReturned,
132 NULL);
133
134 if (!bSuccess)
135 {
138 return FALSE;
139 }
140
141 /* Bind to the adapter */
142 bSuccess = DeviceIoControl(hDriver,
144 (PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset,
145 QueryBinding->DeviceNameLength,
146 NULL,
147 0,
148 &dwBytesReturned,
149 NULL);
150
151 if (!bSuccess)
152 {
155 return FALSE;
156 }
157
158 /* Get interface info from the IP helper */
159 dwSize = sizeof(IP_INTERFACE_INFO);
160 do {
161 if (InterfaceInfo) HeapFree(GetProcessHeap(), 0, InterfaceInfo);
162 InterfaceInfo = HeapAlloc(GetProcessHeap(), 0, dwSize);
163 if (!InterfaceInfo)
164 {
167 return FALSE;
168 }
169 dwStatus = GetInterfaceInfo(InterfaceInfo, &dwSize);
171
172 if (dwStatus != NO_ERROR)
173 {
175 HeapFree(GetProcessHeap(), 0, InterfaceInfo);
177 return FALSE;
178 }
179
180 for (i = 0; i < InterfaceInfo->NumAdapters; i++)
181 {
182 PWCHAR InterfaceGuid = wcschr(InterfaceInfo->Adapter[i].Name, L'{');
183
184 if (InterfaceGuid == NULL)
185 continue;
186
187 if (wcsstr((PWCHAR)((PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset),
189 {
190 *IpInfo = InterfaceInfo->Adapter[i];
191 *hAdapter = hDriver;
192
194 HeapFree(GetProcessHeap(), 0, InterfaceInfo);
195
196 return TRUE;
197 }
198 }
199
201 HeapFree(GetProcessHeap(), 0, InterfaceInfo);
203
204 return FALSE;
205}
206
207/* Only works with the first adapter for now */
208BOOL
210{
212
213 for (dwCurrentIndex = 0; ; dwCurrentIndex++)
214 {
215 if (!OpenAdapterHandle(dwCurrentIndex, hAdapter, IpInfo))
216 break;
217
218 if (IsWlanAdapter(*hAdapter))
219 return TRUE;
220 else
221 CloseHandle(*hAdapter);
222 }
223
224 return FALSE;
225}
226
227BOOL
229{
230 BOOL bSuccess;
231 DWORD dwBytesReturned;
232 NDISUIO_SET_OID SetOid;
233
234 /* Release this IP address */
235 IpReleaseAddress(IpInfo);
236
237 /* Disassociate from the AP */
239 bSuccess = DeviceIoControl(hAdapter,
241 &SetOid,
243 NULL,
244 0,
245 &dwBytesReturned,
246 NULL);
247 if (!bSuccess)
248 return FALSE;
249
251 return TRUE;
252}
253
254static
255UCHAR
257{
258 if ((Char >= L'0') && (Char <= L'9'))
259 return Char - L'0';
260
261 if ((Char >= L'a') && (Char <= L'f'))
262 return Char - L'a' + 10;
263
264 if ((Char >= L'A') && (Char <= L'F'))
265 return Char - L'A' + 10;
266
267 return 0;
268}
269
270BOOL
272{
273 PNDISUIO_QUERY_OID QueryOid;
274 DWORD QueryOidSize;
275 BOOL bSuccess;
276 DWORD dwBytesReturned;
277 PNDIS_802_11_SSID SsidInfo;
278 CHAR SsidBuffer[NDIS_802_11_LENGTH_SSID + 1];
279 DWORD i;
280 WCHAR szMsgBuf[128];
281
282 QueryOidSize = FIELD_OFFSET(NDISUIO_QUERY_OID, Data) + sizeof(NDIS_802_11_SSID);
283 QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
284 if (!QueryOid)
285 return FALSE;
286
287 QueryOid->Oid = OID_802_11_SSID;
288 SsidInfo = (PNDIS_802_11_SSID)QueryOid->Data;
289
290 bSuccess = DeviceIoControl(hAdapter,
292 QueryOid,
293 QueryOidSize,
294 QueryOid,
295 QueryOidSize,
296 &dwBytesReturned,
297 NULL);
298 if (!bSuccess)
299 {
300 HeapFree(GetProcessHeap(), 0, QueryOid);
301 return FALSE;
302 }
303
304 /* Copy the SSID to our internal buffer and terminate it */
305 RtlCopyMemory(SsidBuffer, SsidInfo->Ssid, SsidInfo->SsidLength);
306 SsidBuffer[SsidInfo->SsidLength] = 0;
307
308 HeapFree(GetProcessHeap(), 0, QueryOid);
310 QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
311 if (!QueryOid)
312 return FALSE;
313
314 QueryOid->Oid = OID_802_11_BSSID;
315
316 bSuccess = DeviceIoControl(hAdapter,
318 QueryOid,
319 QueryOidSize,
320 QueryOid,
321 QueryOidSize,
322 &dwBytesReturned,
323 NULL);
324 if (SsidInfo->SsidLength == 0 || !bSuccess)
325 {
327 HeapFree(GetProcessHeap(), 0, QueryOid);
328 return TRUE;
329 }
330 else
331 {
333 }
334
335 ConPrintf(StdOut, L"SSID: %S\n", SsidBuffer);
336
337 ConPuts(StdOut, L"BSSID: ");
338 for (i = 0; i < sizeof(NDIS_802_11_MAC_ADDRESS); i++)
339 {
340 UINT BssidData = QueryOid->Data[i];
341
342 ConPrintf(StdOut, L"%.2x", BssidData);
343
344 if (i != sizeof(NDIS_802_11_MAC_ADDRESS) - 1)
345 ConPuts(StdOut, L":");
346 }
347 ConPuts(StdOut, L"\n");
348
349 HeapFree(GetProcessHeap(), 0, QueryOid);
350 QueryOidSize = sizeof(NDISUIO_QUERY_OID);
351 QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
352 if (!QueryOid)
353 return FALSE;
354
356
357 bSuccess = DeviceIoControl(hAdapter,
359 QueryOid,
360 QueryOidSize,
361 QueryOid,
362 QueryOidSize,
363 &dwBytesReturned,
364 NULL);
365 if (!bSuccess)
366 {
367 HeapFree(GetProcessHeap(), 0, QueryOid);
368 return FALSE;
369 }
370
373 szMsgBuf,
374 ARRAYSIZE(szMsgBuf));
376
377 QueryOid->Oid = OID_802_11_WEP_STATUS;
378
379 bSuccess = DeviceIoControl(hAdapter,
381 QueryOid,
382 QueryOidSize,
383 QueryOid,
384 QueryOidSize,
385 &dwBytesReturned,
386 NULL);
387 if (!bSuccess)
388 {
389 HeapFree(GetProcessHeap(), 0, QueryOid);
390 return FALSE;
391 }
392
394 *(PUINT)QueryOid->Data == Ndis802_11WEPEnabled ? IDS_YES : IDS_NO,
395 szMsgBuf,
396 ARRAYSIZE(szMsgBuf));
398
399 ConPuts(StdOut, L"\n");
400 QueryOid->Oid = OID_802_11_RSSI;
401
402 bSuccess = DeviceIoControl(hAdapter,
404 QueryOid,
405 QueryOidSize,
406 QueryOid,
407 QueryOidSize,
408 &dwBytesReturned,
409 NULL);
410 if (bSuccess)
411 {
412 /* This OID is optional */
413 ConPrintf(StdOut, L"RSSI: %i dBm\n", *(PINT)QueryOid->Data);
414 }
415
416 QueryOid->Oid = OID_802_11_TX_POWER_LEVEL;
417
418 bSuccess = DeviceIoControl(hAdapter,
420 QueryOid,
421 QueryOidSize,
422 QueryOid,
423 QueryOidSize,
424 &dwBytesReturned,
425 NULL);
426 if (bSuccess)
427 {
428 /* This OID is optional */
430 }
431
432 ConPuts(StdOut, L"\n");
433
435
436 bSuccess = DeviceIoControl(hAdapter,
438 QueryOid,
439 QueryOidSize,
440 QueryOid,
441 QueryOidSize,
442 &dwBytesReturned,
443 NULL);
444 if (bSuccess)
445 {
446 /* This OID is optional */
448 }
449
451
452 bSuccess = DeviceIoControl(hAdapter,
454 QueryOid,
455 QueryOidSize,
456 QueryOid,
457 QueryOidSize,
458 &dwBytesReturned,
459 NULL);
460 if (bSuccess)
461 {
462 UINT TransmitAntenna = *(PUINT)QueryOid->Data;
463
464 if (TransmitAntenna != 0xFFFFFFFF)
466 else
468 }
469
471
472 bSuccess = DeviceIoControl(hAdapter,
474 QueryOid,
475 QueryOidSize,
476 QueryOid,
477 QueryOidSize,
478 &dwBytesReturned,
479 NULL);
480 if (bSuccess)
481 {
482 UINT ReceiveAntenna = *(PUINT)QueryOid->Data;
483
484 if (ReceiveAntenna != 0xFFFFFFFF)
486 else
488 }
489
490 ConPuts(StdOut, L"\n");
491
493
494 bSuccess = DeviceIoControl(hAdapter,
496 QueryOid,
497 QueryOidSize,
498 QueryOid,
499 QueryOidSize,
500 &dwBytesReturned,
501 NULL);
502 if (bSuccess)
503 {
504 /* This OID is optional */
506 }
507
508 QueryOid->Oid = OID_802_11_RTS_THRESHOLD;
509
510 bSuccess = DeviceIoControl(hAdapter,
512 QueryOid,
513 QueryOidSize,
514 QueryOid,
515 QueryOidSize,
516 &dwBytesReturned,
517 NULL);
518 if (bSuccess)
519 {
520 /* This OID is optional */
522 }
523
524 HeapFree(GetProcessHeap(), 0, QueryOid);
525
526 ConPuts(StdOut, L"\n");
527 return TRUE;
528}
529
530BOOL
532{
533 BOOL bSuccess;
534 DWORD dwBytesReturned, SetOidSize;
535 PNDISUIO_SET_OID SetOid;
537 DWORD StrLength, i;
538 CHAR SsidBuffer[NDIS_802_11_LENGTH_SSID + 1];
539
540 SetOidSize = sizeof(NDISUIO_SET_OID);
541 SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize);
542 if (!SetOid)
543 return FALSE;
544
545 /* Set the network mode */
548
549 bSuccess = DeviceIoControl(hAdapter,
551 SetOid,
552 SetOidSize,
553 NULL,
554 0,
555 &dwBytesReturned,
556 NULL);
557 if (!bSuccess)
558 {
559 HeapFree(GetProcessHeap(), 0, SetOid);
560 return FALSE;
561 }
562
563 /* Set the authentication mode */
566
567 bSuccess = DeviceIoControl(hAdapter,
569 SetOid,
570 SetOidSize,
571 NULL,
572 0,
573 &dwBytesReturned,
574 NULL);
575 if (!bSuccess)
576 {
577 HeapFree(GetProcessHeap(), 0, SetOid);
578 return FALSE;
579 }
580
581 if (sWepKey)
582 {
583 PNDIS_802_11_WEP WepData;
584
585 HeapFree(GetProcessHeap(), 0, SetOid);
586
587 StrLength = (DWORD)wcslen(sWepKey) >> 1; // 2 string characters represent 1 hex byte.
588 SetOidSize = FIELD_OFFSET(NDISUIO_SET_OID, Data) +
589 FIELD_OFFSET(NDIS_802_11_WEP, KeyMaterial) +
590 StrLength;
591 SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize);
592 if (!SetOid)
593 return FALSE;
594
595 /* Add the WEP key */
596 SetOid->Oid = OID_802_11_ADD_WEP;
597 WepData = (PNDIS_802_11_WEP)SetOid->Data;
598
599 WepData->KeyIndex = 0x80000000;
600 WepData->KeyLength = StrLength;
601 WepData->Length = FIELD_OFFSET(NDIS_802_11_WEP, KeyMaterial) + StrLength;
602
603 /* Assemble the hex key */
604 i = 0;
605 while (sWepKey[i << 1] != '\0')
606 {
607 WepData->KeyMaterial[i] = CharToHex(sWepKey[i << 1]) << 4;
608 WepData->KeyMaterial[i] |= CharToHex(sWepKey[(i << 1) + 1]);
609 i++;
610 }
611
612 bSuccess = DeviceIoControl(hAdapter,
614 SetOid,
615 SetOidSize,
616 NULL,
617 0,
618 &dwBytesReturned,
619 NULL);
620 if (!bSuccess)
621 {
622 HeapFree(GetProcessHeap(), 0, SetOid);
623 return FALSE;
624 }
625 }
626
627 /* Set the encryption status */
628 SetOid->Oid = OID_802_11_WEP_STATUS;
630
631 bSuccess = DeviceIoControl(hAdapter,
633 SetOid,
634 SetOidSize,
635 NULL,
636 0,
637 &dwBytesReturned,
638 NULL);
639 if (!bSuccess)
640 {
641 HeapFree(GetProcessHeap(), 0, SetOid);
642 return FALSE;
643 }
644
645 HeapFree(GetProcessHeap(), 0, SetOid);
647 SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize);
648 if (!SetOid)
649 return FALSE;
650
651 /* Set the BSSID */
652 SetOid->Oid = OID_802_11_BSSID;
653 RtlFillMemory(SetOid->Data, sizeof(NDIS_802_11_MAC_ADDRESS), 0xFF);
654
655 bSuccess = DeviceIoControl(hAdapter,
657 SetOid,
658 SetOidSize,
659 NULL,
660 0,
661 &dwBytesReturned,
662 NULL);
663 if (!bSuccess)
664 {
665 HeapFree(GetProcessHeap(), 0, SetOid);
666 return FALSE;
667 }
668
669 HeapFree(GetProcessHeap(), 0, SetOid);
670 SetOidSize = FIELD_OFFSET(NDISUIO_SET_OID, Data) + sizeof(NDIS_802_11_SSID);
671 SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize);
672 if (!SetOid)
673 return FALSE;
674
675 /* Finally, set the SSID */
676 SetOid->Oid = OID_802_11_SSID;
677 Ssid = (PNDIS_802_11_SSID)SetOid->Data;
678
679 snprintf(SsidBuffer, sizeof(SsidBuffer), "%S", sSsid);
680 Ssid->SsidLength = StrLength = (DWORD)strlen(SsidBuffer);
681 RtlCopyMemory(Ssid->Ssid, SsidBuffer, StrLength);
682
683 bSuccess = DeviceIoControl(hAdapter,
685 SetOid,
686 SetOidSize,
687 NULL,
688 0,
689 &dwBytesReturned,
690 NULL);
691
692 HeapFree(GetProcessHeap(), 0, SetOid);
693
694 if (!bSuccess)
695 return FALSE;
696
698 return TRUE;
699}
700
701BOOL
703{
704 BOOL bSuccess;
705 DWORD dwBytesReturned;
706 NDISUIO_SET_OID SetOid;
707 PNDISUIO_QUERY_OID QueryOid;
708 DWORD QueryOidSize;
709 PNDIS_802_11_BSSID_LIST BssidList;
710 DWORD i, j;
711 DWORD dwNetworkCount;
712 WCHAR szMsgBuf[128];
713
715
716 /* Send the scan OID */
717 bSuccess = DeviceIoControl(hAdapter,
719 &SetOid,
721 NULL,
722 0,
723 &dwBytesReturned,
724 NULL);
725 if (!bSuccess)
726 return FALSE;
727
728 /* Wait 2 seconds for the scan to return some results */
729 Sleep(2000);
730
731 /* Allocate space for 10 networks to be returned initially */
732 QueryOid = NULL;
733 dwNetworkCount = 10;
734 for (;;)
735 {
736 if (QueryOid)
737 HeapFree(GetProcessHeap(), 0, QueryOid);
738
739 QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID) * dwNetworkCount);
740 QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
741 if (!QueryOid)
742 return FALSE;
743
744 QueryOid->Oid = OID_802_11_BSSID_LIST;
745 BssidList = (PNDIS_802_11_BSSID_LIST)QueryOid->Data;
746
747 bSuccess = DeviceIoControl(hAdapter,
749 QueryOid,
750 QueryOidSize,
751 QueryOid,
752 QueryOidSize,
753 &dwBytesReturned,
754 NULL);
755 if (!bSuccess && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
756 {
757 /* Try allocating space for 10 more networks */
758 dwNetworkCount += 10;
759 }
760 else
761 {
762 break;
763 }
764 }
765
766 if (!bSuccess)
767 {
768 HeapFree(GetProcessHeap(), 0, QueryOid);
769 return FALSE;
770 }
771
772 if (BssidList->NumberOfItems == 0)
773 {
775 }
776 else
777 {
778 PNDIS_WLAN_BSSID BssidInfo = BssidList->Bssid;
779 for (i = 0; i < BssidList->NumberOfItems; i++)
780 {
781 PNDIS_802_11_SSID Ssid = &BssidInfo->Ssid;
782 NDIS_802_11_RSSI Rssi = BssidInfo->Rssi;
784 UINT Rate;
785
786 /* The SSID member is a non-NUL terminated ASCII string */
787 ConPrintf(StdOut, L"\nSSID: %.*S\n", Ssid->SsidLength, Ssid->Ssid);
788
789 ConPuts(StdOut, L"BSSID: ");
790 for (j = 0; j < sizeof(NDIS_802_11_MAC_ADDRESS); j++)
791 {
792 UINT BssidData = BssidInfo->MacAddress[j];
793
794 ConPrintf(StdOut, L"%.2x", BssidData);
795
796 if (j != sizeof(NDIS_802_11_MAC_ADDRESS) - 1)
797 ConPuts(StdOut, L":");
798 }
799 ConPuts(StdOut, L"\n");
800
802 BssidInfo->Privacy == 0 ? IDS_NO : IDS_YES,
803 szMsgBuf,
804 ARRAYSIZE(szMsgBuf));
808 szMsgBuf,
809 ARRAYSIZE(szMsgBuf));
811 ConResPrintf(StdOut, IDS_MSG_RSSI, (int)Rssi);
813
814 for (j = 0; j < NDIS_802_11_LENGTH_RATES; j++)
815 {
816 Rate = BssidInfo->SupportedRates[j];
817 if (Rate != 0)
818 {
819 /* Bit 7 is the basic rates bit */
820 Rate = Rate & 0x7F;
821
822 /* SupportedRates are in units of .5 */
823 if (Rate & 0x01)
824 {
825 /* Bit 0 is set so we need to add 0.5 */
826 ConPrintf(StdOut, L"%u.5 ", (Rate >> 1));
827 }
828 else
829 {
830 /* Bit 0 is clear so just print the conversion */
831 ConPrintf(StdOut, L"%u ", (Rate >> 1));
832 }
833 }
834 }
835 ConPuts(StdOut, L"\n");
836
837 /* Move to the next entry */
838 BssidInfo = (PNDIS_WLAN_BSSID)((PUCHAR)BssidInfo + BssidInfo->Length);
839 }
840 }
841
842 HeapFree(GetProcessHeap(), 0, QueryOid);
843
844 return bSuccess;
845}
846
848{
849 INT i;
850
851 for (i = 1; i < argc; i++)
852 {
853 if (argv[i][0] == L'-')
854 {
855 switch (argv[i][1])
856 {
857 case L's':
858 bScan = TRUE;
859 break;
860 case L'd':
862 break;
863 case L'c':
864 if (i == argc - 1)
865 {
867 return FALSE;
868 }
869 bConnect = TRUE;
870 sSsid = argv[++i];
871 break;
872 case L'w':
873 if (i == argc - 1)
874 {
876 return FALSE;
877 }
878 sWepKey = argv[++i];
879 break;
880 case L'a':
881 bAdhoc = TRUE;
882 break;
883 default :
885 return FALSE;
886 }
887
888 }
889 else
890 {
892 return FALSE;
893 }
894 }
895
896 return TRUE;
897}
898
899int wmain(int argc, WCHAR *argv[])
900{
901 HANDLE hAdapter;
903
904 /* Initialize the Console Standard Streams */
906
907 if (!ParseCmdline(argc, argv))
908 return -1;
909
910 if (!OpenWlanAdapter(&hAdapter, &IpInfo))
911 {
913 return -1;
914 }
915
916 if (bScan)
917 {
918 if (!WlanScan(hAdapter))
919 {
921 CloseHandle(hAdapter);
922 return -1;
923 }
924 }
925 else if (bDisconnect)
926 {
927 if (!WlanDisconnect(hAdapter, &IpInfo))
928 {
930 CloseHandle(hAdapter);
931 return -1;
932 }
933 }
934 else if (bConnect)
935 {
936 if (!WlanConnect(hAdapter))
937 {
939 CloseHandle(hAdapter);
940 return -1;
941 }
942 }
943 else
944 {
945 if (!WlanPrintCurrentStatus(hAdapter))
946 {
948 CloseHandle(hAdapter);
949 return -1;
950 }
951 }
952
953 CloseHandle(hAdapter);
954 return 0;
955}
#define IDS_USAGE
Definition: resource.h:3
#define IDS_YES
Definition: resource.h:16
#define IDS_NO
Definition: resource.h:17
#define IDS_SUCCESS
Definition: resource.h:11
#define IDS_MSG_TRANSMIT_ANTENNA
Definition: resource.h:17
#define IDS_MSG_FRAGMENT_THRESHOLD
Definition: resource.h:21
#define IDS_MSG_TRANSMISSION_POWER
Definition: resource.h:15
#define IDS_MSG_ENCRYPTED
Definition: resource.h:11
#define IDS_ADHOC
Definition: resource.h:25
#define IDS_MSG_ANTENNA_COUNT
Definition: resource.h:16
#define IDS_NO_NETWORK
Definition: resource.h:4
#define IDS_MSG_NETWORK_MODE
Definition: resource.h:9
#define IDS_MSG_RECEIVE_ANTENNA
Definition: resource.h:19
#define IDS_MSG_SUPPORT_RATE
Definition: resource.h:14
#define IDS_NO_WLAN_ADAPTER
Definition: resource.h:5
#define IDS_INFRASTRUCTURE
Definition: resource.h:26
#define IDS_MSG_WEP_ENABLED
Definition: resource.h:8
#define IDS_MSG_TRANSMIT_ANTENNA_ANY
Definition: resource.h:18
#define IDS_MSG_RSSI
Definition: resource.h:13
#define IDS_WLAN_DISCONNECT
Definition: resource.h:7
#define IDS_MSG_CURRENT_WIRELESS
Definition: resource.h:10
#define IDS_MSG_RTS_THRESHOLD
Definition: resource.h:22
#define IDS_MSG_NETWORK_TYPE
Definition: resource.h:12
#define IDS_MSG_RECEIVE_ANTENNA_ANY
Definition: resource.h:20
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: conutils_noros.h:8
#define ConInitStdStreams()
Definition: conutils_noros.h:5
void ConPrintf(FILE *fp, LPCWSTR psz,...)
#define StdOut
Definition: conutils_noros.h:6
void ConResPrintf(FILE *fp, UINT nID,...)
#define StdErr
Definition: conutils_noros.h:7
void ConResPuts(FILE *fp, UINT nID)
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define GENERIC_READ
Definition: compat.h:135
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
MonoAssembly int argc
Definition: metahost.c:107
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
Definition: wcs.c:2993
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
#define L(x)
Definition: resources.c:13
static NTSTATUS QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: ioctl.c:34
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
struct _IP_INTERFACE_INFO IP_INTERFACE_INFO
DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
if(dx< 0)
Definition: linetemp.h:194
int * PINT
Definition: minwindef.h:150
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define argv
Definition: mplay32.c:18
unsigned int * PUINT
Definition: ndis.h:50
unsigned int UINT
Definition: ndis.h:50
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
_In_ LPWSTR _In_ DWORD dwCurrentIndex
Definition: netsh.h:139
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
#define OID_802_11_BSSID_LIST
Definition: ntddndis.h:359
struct _NDIS_802_11_BSSID_LIST * PNDIS_802_11_BSSID_LIST
@ NdisPhysicalMediumWirelessLan
Definition: ntddndis.h:223
struct _NDIS_WLAN_BSSID * PNDIS_WLAN_BSSID
#define OID_802_11_NUMBER_OF_ANTENNAS
Definition: ntddndis.h:348
#define OID_802_11_SSID
Definition: ntddndis.h:339
@ Ndis802_11IBSS
Definition: ntddndis.h:77
@ Ndis802_11Infrastructure
Definition: ntddndis.h:78
#define OID_GEN_PHYSICAL_MEDIUM
Definition: ntddndis.h:283
#define OID_802_11_ADD_WEP
Definition: ntddndis.h:355
#define OID_802_11_WEP_STATUS
Definition: ntddndis.h:363
struct _NDIS_802_11_WEP * PNDIS_802_11_WEP
enum _NDIS_802_11_NETWORK_INFRASTRUCTURE NDIS_802_11_NETWORK_INFRASTRUCTURE
#define OID_802_11_BSSID_LIST_SCAN
Definition: ntddndis.h:362
@ Ndis802_11AuthModeShared
Definition: ntddndis.h:65
@ Ndis802_11AuthModeOpen
Definition: ntddndis.h:64
#define NDIS_802_11_LENGTH_SSID
Definition: ntddndis.h:100
#define OID_802_11_RX_ANTENNA_SELECTED
Definition: ntddndis.h:349
struct _NDIS_802_11_SSID * PNDIS_802_11_SSID
UCHAR NDIS_802_11_MAC_ADDRESS[6]
Definition: ntddndis.h:103
#define NDIS_802_11_LENGTH_RATES
Definition: ntddndis.h:101
#define OID_802_11_RTS_THRESHOLD
Definition: ntddndis.h:347
@ Ndis802_11WEPDisabled
Definition: ntddndis.h:49
@ Ndis802_11WEPEnabled
Definition: ntddndis.h:47
struct _NDIS_802_11_SSID NDIS_802_11_SSID
#define OID_802_11_RSSI
Definition: ntddndis.h:343
#define OID_802_11_BSSID
Definition: ntddndis.h:338
#define OID_802_11_FRAGMENTATION_THRESHOLD
Definition: ntddndis.h:346
#define OID_802_11_INFRASTRUCTURE_MODE
Definition: ntddndis.h:345
#define OID_802_11_TX_ANTENNA_SELECTED
Definition: ntddndis.h:350
LONG NDIS_802_11_RSSI
Definition: ntddndis.h:104
#define OID_802_11_TX_POWER_LEVEL
Definition: ntddndis.h:342
#define OID_802_11_DISASSOCIATE
Definition: ntddndis.h:357
#define OID_802_11_AUTHENTICATION_MODE
Definition: ntddndis.h:360
struct _NDISUIO_QUERY_OID NDISUIO_QUERY_OID
#define IOCTL_NDISUIO_QUERY_OID_VALUE
Definition: nuiouser.h:16
#define IOCTL_NDISUIO_BIND_WAIT
Definition: nuiouser.h:27
struct _NDISUIO_QUERY_BINDING NDISUIO_QUERY_BINDING
#define NDISUIO_DEVICE_NAME
Definition: nuiouser.h:9
struct _NDISUIO_SET_OID NDISUIO_SET_OID
#define IOCTL_NDISUIO_OPEN_DEVICE
Definition: nuiouser.h:12
#define IOCTL_NDISUIO_QUERY_BINDING
Definition: nuiouser.h:23
#define IOCTL_NDISUIO_SET_OID_VALUE
Definition: nuiouser.h:31
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:835
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
char CHAR
Definition: pedump.c:57
DWORD dwStatus
Definition: mediaobj.idl:95
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603
int wmain()
#define LoadStringW
Definition: utils.h:64
WCHAR Name[MAX_ADAPTER_NAME]
Definition: ipexport.h:147
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:152
UCHAR Data[sizeof(ULONG)]
Definition: nuiouser.h:38
NDIS_OID Oid
Definition: nuiouser.h:37
NDIS_OID Oid
Definition: nuiouser.h:44
UCHAR Data[sizeof(ULONG)]
Definition: nuiouser.h:45
NDIS_WLAN_BSSID Bssid[1]
Definition: ntddndis.h:147
UCHAR Ssid[NDIS_802_11_LENGTH_SSID]
Definition: ntddndis.h:110
UCHAR KeyMaterial[1]
Definition: ntddndis.h:155
NDIS_802_11_RSSI Rssi
Definition: ntddndis.h:137
NDIS_802_11_RATES SupportedRates
Definition: ntddndis.h:141
NDIS_802_11_MAC_ADDRESS MacAddress
Definition: ntddndis.h:133
NDIS_802_11_SSID Ssid
Definition: ntddndis.h:135
NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode
Definition: ntddndis.h:140
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
NetworkType
Definition: tnetwork.h:8
uint32_t * PULONG
Definition: typedefs.h:59
const uint16_t * PCWSTR
Definition: typedefs.h:57
unsigned char UCHAR
Definition: typedefs.h:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ WDFCOLLECTION _In_ ULONG Index
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3557
#define snprintf
Definition: wintirpc.h:48
static const GUID InterfaceGuid
Definition: wlanapi.c:25
BOOL bScan
Definition: wlanconf.c:22
BOOL bDisconnect
Definition: wlanconf.c:23
BOOL ParseCmdline(int argc, WCHAR *argv[])
Definition: wlanconf.c:847
BOOL OpenWlanAdapter(HANDLE *hAdapter, IP_ADAPTER_INDEX_MAP *IpInfo)
Definition: wlanconf.c:209
VOID DoFormatMessage(DWORD ErrorCode)
Definition: wlanconf.c:29
PCWSTR sWepKey
Definition: wlanconf.c:27
PCWSTR sSsid
Definition: wlanconf.c:26
BOOL WlanDisconnect(HANDLE hAdapter, PIP_ADAPTER_INDEX_MAP IpInfo)
Definition: wlanconf.c:228
BOOL OpenAdapterHandle(DWORD Index, HANDLE *hAdapter, IP_ADAPTER_INDEX_MAP *IpInfo)
Definition: wlanconf.c:99
BOOL WlanScan(HANDLE hAdapter)
Definition: wlanconf.c:702
BOOL WlanConnect(HANDLE hAdapter)
Definition: wlanconf.c:531
BOOL bAdhoc
Definition: wlanconf.c:25
BOOL bConnect
Definition: wlanconf.c:24
HANDLE OpenDriverHandle(VOID)
Definition: wlanconf.c:39
BOOL WlanPrintCurrentStatus(HANDLE hAdapter)
Definition: wlanconf.c:271
static UCHAR CharToHex(WCHAR Char)
Definition: wlanconf.c:256
BOOL IsWlanAdapter(HANDLE hAdapter)
Definition: wlanconf.c:75