ReactOS 0.4.15-dev-7842-g558ab78
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#include <tchar.h>
11
12#include <windef.h>
13#include <winbase.h>
14#include <devioctl.h>
15#include <ntddndis.h>
16#include <nuiouser.h>
17#include <iphlpapi.h>
18
19#include <conutils.h>
20
21#include "resource.h"
22
24
29
31
33{
35 return;
36
39}
40
43{
45 DWORD dwBytesReturned;
47
48 /* Open a handle to the NDISUIO driver */
51 0,
52 NULL,
55 NULL);
58
59 /* Wait for binds */
62 NULL,
63 0,
64 NULL,
65 0,
66 &dwBytesReturned,
67 NULL);
68 if (!bSuccess)
69 {
72 }
73
74 return hDriver;
75}
76
77BOOL
79{
81 DWORD dwBytesReturned;
82 NDISUIO_QUERY_OID QueryOid;
83
84 /* WLAN drivers must support this OID */
86
87 bSuccess = DeviceIoControl(hAdapter,
89 &QueryOid,
90 sizeof(QueryOid),
91 &QueryOid,
92 sizeof(QueryOid),
93 &dwBytesReturned,
94 NULL);
96 return FALSE;
97
98 return TRUE;
99}
100
101BOOL
103{
106 DWORD dwBytesReturned;
107 DWORD QueryBindingSize = sizeof(NDISUIO_QUERY_BINDING) + (1024 * sizeof(WCHAR));
110 LONG i;
111 PIP_INTERFACE_INFO InterfaceInfo = NULL;
112
113 /* Open the driver handle */
116 return FALSE;
117
118 /* Allocate the binding struct */
119 QueryBinding = HeapAlloc(GetProcessHeap(), 0, QueryBindingSize);
120 if (!QueryBinding)
121 {
123 return FALSE;
124 }
125
126 /* Query the adapter binding information */
127 QueryBinding->BindingIndex = Index;
131 QueryBindingSize,
133 QueryBindingSize,
134 &dwBytesReturned,
135 NULL);
136
137 if (!bSuccess)
138 {
141 return FALSE;
142 }
143
144 /* Bind to the adapter */
147 (PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset,
148 QueryBinding->DeviceNameLength,
149 NULL,
150 0,
151 &dwBytesReturned,
152 NULL);
153
154 if (!bSuccess)
155 {
158 return FALSE;
159 }
160
161 /* Get interface info from the IP helper */
162 dwSize = sizeof(IP_INTERFACE_INFO);
163 do {
164 if (InterfaceInfo) HeapFree(GetProcessHeap(), 0, InterfaceInfo);
165 InterfaceInfo = HeapAlloc(GetProcessHeap(), 0, dwSize);
166 if (!InterfaceInfo)
167 {
170 return FALSE;
171 }
172 dwStatus = GetInterfaceInfo(InterfaceInfo, &dwSize);
174
175 if (dwStatus != NO_ERROR)
176 {
178 HeapFree(GetProcessHeap(), 0, InterfaceInfo);
180 return FALSE;
181 }
182
183 for (i = 0; i < InterfaceInfo->NumAdapters; i++)
184 {
185 PWCHAR InterfaceGuid = wcschr(InterfaceInfo->Adapter[i].Name, L'{');
186
187 if (InterfaceGuid == NULL)
188 continue;
189
190 if (wcsstr((PWCHAR)((PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset),
192 {
193 *IpInfo = InterfaceInfo->Adapter[i];
194 *hAdapter = hDriver;
195
197 HeapFree(GetProcessHeap(), 0, InterfaceInfo);
198
199 return TRUE;
200 }
201 }
202
204 HeapFree(GetProcessHeap(), 0, InterfaceInfo);
206
207 return FALSE;
208}
209
210/* Only works with the first adapter for now */
211BOOL
213{
214 DWORD dwCurrentIndex;
215
216 for (dwCurrentIndex = 0; ; dwCurrentIndex++)
217 {
218 if (!OpenAdapterHandle(dwCurrentIndex, hAdapter, IpInfo))
219 break;
220
221 if (IsWlanAdapter(*hAdapter))
222 return TRUE;
223 else
224 CloseHandle(*hAdapter);
225 }
226
227 return FALSE;
228}
229
230BOOL
232{
234 DWORD dwBytesReturned;
235 NDISUIO_SET_OID SetOid;
236
237 /* Release this IP address */
238 IpReleaseAddress(IpInfo);
239
240 /* Disassociate from the AP */
242 bSuccess = DeviceIoControl(hAdapter,
244 &SetOid,
246 NULL,
247 0,
248 &dwBytesReturned,
249 NULL);
250 if (!bSuccess)
251 return FALSE;
252
254 return TRUE;
255}
256
257static
258UCHAR
260{
261 if ((Char >= L'0') && (Char <= L'9'))
262 return Char - L'0';
263
264 if ((Char >= L'a') && (Char <= L'f'))
265 return Char - L'a' + 10;
266
267 if ((Char >= L'A') && (Char <= L'F'))
268 return Char - L'A' + 10;
269
270 return 0;
271}
272
273BOOL
275{
276 PNDISUIO_QUERY_OID QueryOid;
277 DWORD QueryOidSize;
279 DWORD dwBytesReturned;
280 PNDIS_802_11_SSID SsidInfo;
281 CHAR SsidBuffer[NDIS_802_11_LENGTH_SSID + 1];
282 DWORD i;
283 WCHAR szMsgBuf[128];
284
285 QueryOidSize = FIELD_OFFSET(NDISUIO_QUERY_OID, Data) + sizeof(NDIS_802_11_SSID);
286 QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
287 if (!QueryOid)
288 return FALSE;
289
290 QueryOid->Oid = OID_802_11_SSID;
291 SsidInfo = (PNDIS_802_11_SSID)QueryOid->Data;
292
293 bSuccess = DeviceIoControl(hAdapter,
295 QueryOid,
296 QueryOidSize,
297 QueryOid,
298 QueryOidSize,
299 &dwBytesReturned,
300 NULL);
301 if (!bSuccess)
302 {
303 HeapFree(GetProcessHeap(), 0, QueryOid);
304 return FALSE;
305 }
306
307 /* Copy the SSID to our internal buffer and terminate it */
308 RtlCopyMemory(SsidBuffer, SsidInfo->Ssid, SsidInfo->SsidLength);
309 SsidBuffer[SsidInfo->SsidLength] = 0;
310
311 HeapFree(GetProcessHeap(), 0, QueryOid);
313 QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
314 if (!QueryOid)
315 return FALSE;
316
317 QueryOid->Oid = OID_802_11_BSSID;
318
319 bSuccess = DeviceIoControl(hAdapter,
321 QueryOid,
322 QueryOidSize,
323 QueryOid,
324 QueryOidSize,
325 &dwBytesReturned,
326 NULL);
327 if (SsidInfo->SsidLength == 0 || !bSuccess)
328 {
330 HeapFree(GetProcessHeap(), 0, QueryOid);
331 return TRUE;
332 }
333 else
334 {
336 }
337
338 printf("SSID: %s\n", SsidBuffer);
339
340 printf("BSSID: ");
341 for (i = 0; i < sizeof(NDIS_802_11_MAC_ADDRESS); i++)
342 {
343 UINT BssidData = QueryOid->Data[i];
344
345 printf("%.2x", BssidData);
346
347 if (i != sizeof(NDIS_802_11_MAC_ADDRESS) - 1)
348 printf(":");
349 }
350 printf("\n");
351
352 HeapFree(GetProcessHeap(), 0, QueryOid);
353 QueryOidSize = sizeof(NDISUIO_QUERY_OID);
354 QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
355 if (!QueryOid)
356 return FALSE;
357
359
360 bSuccess = DeviceIoControl(hAdapter,
362 QueryOid,
363 QueryOidSize,
364 QueryOid,
365 QueryOidSize,
366 &dwBytesReturned,
367 NULL);
368 if (!bSuccess)
369 {
370 HeapFree(GetProcessHeap(), 0, QueryOid);
371 return FALSE;
372 }
373
376 szMsgBuf,
377 ARRAYSIZE(szMsgBuf));
379
380 QueryOid->Oid = OID_802_11_WEP_STATUS;
381
382 bSuccess = DeviceIoControl(hAdapter,
384 QueryOid,
385 QueryOidSize,
386 QueryOid,
387 QueryOidSize,
388 &dwBytesReturned,
389 NULL);
390 if (!bSuccess)
391 {
392 HeapFree(GetProcessHeap(), 0, QueryOid);
393 return FALSE;
394 }
395
397 *(PUINT)QueryOid->Data == Ndis802_11WEPEnabled ? IDS_YES : IDS_NO,
398 szMsgBuf,
399 ARRAYSIZE(szMsgBuf));
401
402 printf("\n");
403 QueryOid->Oid = OID_802_11_RSSI;
404
405 bSuccess = DeviceIoControl(hAdapter,
407 QueryOid,
408 QueryOidSize,
409 QueryOid,
410 QueryOidSize,
411 &dwBytesReturned,
412 NULL);
413 if (bSuccess)
414 {
415 /* This OID is optional */
416 printf("RSSI: %i dBm\n", *(PINT)QueryOid->Data);
417 }
418
419 QueryOid->Oid = OID_802_11_TX_POWER_LEVEL;
420
421 bSuccess = DeviceIoControl(hAdapter,
423 QueryOid,
424 QueryOidSize,
425 QueryOid,
426 QueryOidSize,
427 &dwBytesReturned,
428 NULL);
429 if (bSuccess)
430 {
431 /* This OID is optional */
433 }
434
435 printf("\n");
436
438
439 bSuccess = DeviceIoControl(hAdapter,
441 QueryOid,
442 QueryOidSize,
443 QueryOid,
444 QueryOidSize,
445 &dwBytesReturned,
446 NULL);
447 if (bSuccess)
448 {
449 /* This OID is optional */
451 }
452
454
455 bSuccess = DeviceIoControl(hAdapter,
457 QueryOid,
458 QueryOidSize,
459 QueryOid,
460 QueryOidSize,
461 &dwBytesReturned,
462 NULL);
463 if (bSuccess)
464 {
465 UINT TransmitAntenna = *(PUINT)QueryOid->Data;
466
467 if (TransmitAntenna != 0xFFFFFFFF)
469 else
471 }
472
474
475 bSuccess = DeviceIoControl(hAdapter,
477 QueryOid,
478 QueryOidSize,
479 QueryOid,
480 QueryOidSize,
481 &dwBytesReturned,
482 NULL);
483 if (bSuccess)
484 {
485 UINT ReceiveAntenna = *(PUINT)QueryOid->Data;
486
487 if (ReceiveAntenna != 0xFFFFFFFF)
489 else
491 }
492
493 printf("\n");
494
496
497 bSuccess = DeviceIoControl(hAdapter,
499 QueryOid,
500 QueryOidSize,
501 QueryOid,
502 QueryOidSize,
503 &dwBytesReturned,
504 NULL);
505 if (bSuccess)
506 {
507 /* This OID is optional */
509 }
510
511 QueryOid->Oid = OID_802_11_RTS_THRESHOLD;
512
513 bSuccess = DeviceIoControl(hAdapter,
515 QueryOid,
516 QueryOidSize,
517 QueryOid,
518 QueryOidSize,
519 &dwBytesReturned,
520 NULL);
521 if (bSuccess)
522 {
523 /* This OID is optional */
525 }
526
527 HeapFree(GetProcessHeap(), 0, QueryOid);
528
529 printf("\n");
530 return TRUE;
531}
532
533BOOL
535{
536 CHAR SsidBuffer[NDIS_802_11_LENGTH_SSID + 1];
538 DWORD dwBytesReturned, SetOidSize;
539 PNDISUIO_SET_OID SetOid;
541 DWORD i;
542
543 SetOidSize = sizeof(NDISUIO_SET_OID);
544 SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize);
545 if (!SetOid)
546 return FALSE;
547
548 /* Set the network mode */
551
552 bSuccess = DeviceIoControl(hAdapter,
554 SetOid,
555 SetOidSize,
556 NULL,
557 0,
558 &dwBytesReturned,
559 NULL);
560 if (!bSuccess)
561 {
562 HeapFree(GetProcessHeap(), 0, SetOid);
563 return FALSE;
564 }
565
566 /* Set the authentication mode */
569
570 bSuccess = DeviceIoControl(hAdapter,
572 SetOid,
573 SetOidSize,
574 NULL,
575 0,
576 &dwBytesReturned,
577 NULL);
578 if (!bSuccess)
579 {
580 HeapFree(GetProcessHeap(), 0, SetOid);
581 return FALSE;
582 }
583
584 if (sWepKey)
585 {
586 PNDIS_802_11_WEP WepData;
587
588 HeapFree(GetProcessHeap(), 0, SetOid);
589
590 SetOidSize = FIELD_OFFSET(NDISUIO_SET_OID, Data) +
591 FIELD_OFFSET(NDIS_802_11_WEP, KeyMaterial) +
592 (wcslen(sWepKey) >> 1);
593 SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize);
594 if (!SetOid)
595 return FALSE;
596
597 /* Add the WEP key */
598 SetOid->Oid = OID_802_11_ADD_WEP;
599 WepData = (PNDIS_802_11_WEP)SetOid->Data;
600
601 WepData->KeyIndex = 0x80000000;
602 WepData->KeyLength = wcslen(sWepKey) >> 1;
603 WepData->Length = FIELD_OFFSET(NDIS_802_11_WEP, KeyMaterial) + WepData->KeyLength;
604
605 /* Assemble the hex key */
606 i = 0;
607 while (sWepKey[i << 1] != '\0')
608 {
609 WepData->KeyMaterial[i] = CharToHex(sWepKey[i << 1]) << 4;
610 WepData->KeyMaterial[i] |= CharToHex(sWepKey[(i << 1) + 1]);
611 i++;
612 }
613
614 bSuccess = DeviceIoControl(hAdapter,
616 SetOid,
617 SetOidSize,
618 NULL,
619 0,
620 &dwBytesReturned,
621 NULL);
622 if (!bSuccess)
623 {
624 HeapFree(GetProcessHeap(), 0, SetOid);
625 return FALSE;
626 }
627 }
628
629 /* Set the encryption status */
630 SetOid->Oid = OID_802_11_WEP_STATUS;
632
633 bSuccess = DeviceIoControl(hAdapter,
635 SetOid,
636 SetOidSize,
637 NULL,
638 0,
639 &dwBytesReturned,
640 NULL);
641 if (!bSuccess)
642 {
643 HeapFree(GetProcessHeap(), 0, SetOid);
644 return FALSE;
645 }
646
647 HeapFree(GetProcessHeap(), 0, SetOid);
649 SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize);
650 if (!SetOid)
651 return FALSE;
652
653 /* Set the BSSID */
654 SetOid->Oid = OID_802_11_BSSID;
655 RtlFillMemory(SetOid->Data, sizeof(NDIS_802_11_MAC_ADDRESS), 0xFF);
656
657 bSuccess = DeviceIoControl(hAdapter,
659 SetOid,
660 SetOidSize,
661 NULL,
662 0,
663 &dwBytesReturned,
664 NULL);
665 if (!bSuccess)
666 {
667 HeapFree(GetProcessHeap(), 0, SetOid);
668 return FALSE;
669 }
670
671 HeapFree(GetProcessHeap(), 0, SetOid);
672 SetOidSize = FIELD_OFFSET(NDISUIO_SET_OID, Data) + sizeof(NDIS_802_11_SSID);
673 SetOid = HeapAlloc(GetProcessHeap(), 0, SetOidSize);
674 if (!SetOid)
675 return FALSE;
676
677 /* Finally, set the SSID */
678 SetOid->Oid = OID_802_11_SSID;
679 Ssid = (PNDIS_802_11_SSID)SetOid->Data;
680
681 snprintf(SsidBuffer, sizeof(SsidBuffer), "%S", sSsid);
682 RtlCopyMemory(Ssid->Ssid, SsidBuffer, strlen(SsidBuffer));
683 Ssid->SsidLength = strlen(SsidBuffer);
684
685 bSuccess = DeviceIoControl(hAdapter,
687 SetOid,
688 SetOidSize,
689 NULL,
690 0,
691 &dwBytesReturned,
692 NULL);
693
694 HeapFree(GetProcessHeap(), 0, SetOid);
695
696 if (!bSuccess)
697 return FALSE;
698
700 return TRUE;
701}
702
703BOOL
705{
707 DWORD dwBytesReturned;
708 NDISUIO_SET_OID SetOid;
709 PNDISUIO_QUERY_OID QueryOid;
710 DWORD QueryOidSize;
711 PNDIS_802_11_BSSID_LIST BssidList;
712 DWORD i, j;
713 DWORD dwNetworkCount;
714 WCHAR szMsgBuf[128];
715
717
718 /* Send the scan OID */
719 bSuccess = DeviceIoControl(hAdapter,
721 &SetOid,
723 NULL,
724 0,
725 &dwBytesReturned,
726 NULL);
727 if (!bSuccess)
728 return FALSE;
729
730 /* Wait 2 seconds for the scan to return some results */
731 Sleep(2000);
732
733 /* Allocate space for 10 networks to be returned initially */
734 QueryOid = NULL;
735 dwNetworkCount = 10;
736 for (;;)
737 {
738 if (QueryOid)
739 HeapFree(GetProcessHeap(), 0, QueryOid);
740
741 QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID) * dwNetworkCount);
742 QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
743 if (!QueryOid)
744 return FALSE;
745
746 QueryOid->Oid = OID_802_11_BSSID_LIST;
747 BssidList = (PNDIS_802_11_BSSID_LIST)QueryOid->Data;
748
749 bSuccess = DeviceIoControl(hAdapter,
751 QueryOid,
752 QueryOidSize,
753 QueryOid,
754 QueryOidSize,
755 &dwBytesReturned,
756 NULL);
758 {
759 /* Try allocating space for 10 more networks */
760 dwNetworkCount += 10;
761 }
762 else
763 {
764 break;
765 }
766 }
767
768 if (!bSuccess)
769 {
770 HeapFree(GetProcessHeap(), 0, QueryOid);
771 return FALSE;
772 }
773
774 if (BssidList->NumberOfItems == 0)
775 {
777 }
778 else
779 {
780 PNDIS_WLAN_BSSID BssidInfo = BssidList->Bssid;
781 for (i = 0; i < BssidList->NumberOfItems; i++)
782 {
783 PNDIS_802_11_SSID Ssid = &BssidInfo->Ssid;
784 NDIS_802_11_RSSI Rssi = BssidInfo->Rssi;
786 CHAR SsidBuffer[NDIS_802_11_LENGTH_SSID + 1];
787 UINT Rate;
788
789 /* SSID member is a non-null terminated ASCII string */
790 RtlCopyMemory(SsidBuffer, Ssid->Ssid, Ssid->SsidLength);
791 SsidBuffer[Ssid->SsidLength] = 0;
792
793 printf("\nSSID: %s\n", SsidBuffer);
794
795 printf("BSSID: ");
796 for (j = 0; j < sizeof(NDIS_802_11_MAC_ADDRESS); j++)
797 {
798 UINT BssidData = BssidInfo->MacAddress[j];
799
800 printf("%.2x", BssidData);
801
802 if (j != sizeof(NDIS_802_11_MAC_ADDRESS) - 1)
803 printf(":");
804 }
805 printf("\n");
806
808 BssidInfo->Privacy == 0 ? IDS_NO : IDS_YES,
809 szMsgBuf,
810 ARRAYSIZE(szMsgBuf));
814 szMsgBuf,
815 ARRAYSIZE(szMsgBuf));
817 ConResPrintf(StdOut, IDS_MSG_RSSI, (int)Rssi);
819
820 for (j = 0; j < NDIS_802_11_LENGTH_RATES; j++)
821 {
822 Rate = BssidInfo->SupportedRates[j];
823 if (Rate != 0)
824 {
825 /* Bit 7 is the basic rates bit */
826 Rate = Rate & 0x7F;
827
828 /* SupportedRates are in units of .5 */
829 if (Rate & 0x01)
830 {
831 /* Bit 0 is set so we need to add 0.5 */
832 printf("%u.5 ", (Rate >> 1));
833 }
834 else
835 {
836 /* Bit 0 is clear so just print the conversion */
837 printf("%u ", (Rate >> 1));
838 }
839 }
840 }
841 printf("\n");
842
843 /* Move to the next entry */
844 BssidInfo = (PNDIS_WLAN_BSSID)((PUCHAR)BssidInfo + BssidInfo->Length);
845 }
846 }
847
848 HeapFree(GetProcessHeap(), 0, QueryOid);
849
850 return bSuccess;
851}
852
854{
855 INT i;
856
857 for (i = 1; i < argc; i++)
858 {
859 if (argv[i][0] == L'-')
860 {
861 switch (argv[i][1])
862 {
863 case L's':
864 bScan = TRUE;
865 break;
866 case L'd':
868 break;
869 case L'c':
870 if (i == argc - 1)
871 {
873 return FALSE;
874 }
875 bConnect = TRUE;
876 sSsid = argv[++i];
877 break;
878 case L'w':
879 if (i == argc - 1)
880 {
882 return FALSE;
883 }
884 sWepKey = argv[++i];
885 break;
886 case L'a':
887 bAdhoc = TRUE;
888 break;
889 default :
891 return FALSE;
892 }
893
894 }
895 else
896 {
898 return FALSE;
899 }
900 }
901
902 return TRUE;
903}
904
905int wmain(int argc, WCHAR *argv[])
906{
907 HANDLE hAdapter;
909
910 /* Initialize the Console Standard Streams */
912
913 if (!ParseCmdline(argc, argv))
914 return -1;
915
916 if (!OpenWlanAdapter(&hAdapter, &IpInfo))
917 {
919 return -1;
920 }
921
922 if (bScan)
923 {
924 if (!WlanScan(hAdapter))
925 {
927 CloseHandle(hAdapter);
928 return -1;
929 }
930 }
931 else if (bDisconnect)
932 {
933 if (!WlanDisconnect(hAdapter, &IpInfo))
934 {
936 CloseHandle(hAdapter);
937 return -1;
938 }
939 }
940 else if (bConnect)
941 {
942 if (!WlanConnect(hAdapter))
943 {
945 CloseHandle(hAdapter);
946 return -1;
947 }
948 }
949 else
950 {
951 if (!WlanPrintCurrentStatus(hAdapter))
952 {
954 CloseHandle(hAdapter);
955 return -1;
956 }
957 }
958
959 CloseHandle(hAdapter);
960 return 0;
961}
static int argc
Definition: ServiceArgs.c:12
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define IDS_USAGE
Definition: resource.h:3
#define IDS_YES
Definition: resource.h:16
#define IDS_NO
Definition: resource.h:17
#define ConInitStdStreams()
Definition: fc.c:13
#define StdOut
Definition: fc.c:14
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define StdErr
Definition: fc.c:15
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#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
#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
static BOOLEAN bSuccess
Definition: drive.cpp:433
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
#define printf
Definition: freeldr.h:93
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
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
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
#define GENERIC_WRITE
Definition: nt_native.h:90
#define OID_802_11_BSSID_LIST
Definition: ntddndis.h:340
struct _NDIS_802_11_BSSID_LIST * PNDIS_802_11_BSSID_LIST
@ NdisPhysicalMediumWirelessLan
Definition: ntddndis.h:208
struct _NDIS_WLAN_BSSID * PNDIS_WLAN_BSSID
#define OID_802_11_NUMBER_OF_ANTENNAS
Definition: ntddndis.h:329
#define OID_802_11_SSID
Definition: ntddndis.h:320
@ Ndis802_11IBSS
Definition: ntddndis.h:77
@ Ndis802_11Infrastructure
Definition: ntddndis.h:78
#define OID_GEN_PHYSICAL_MEDIUM
Definition: ntddndis.h:264
#define OID_802_11_ADD_WEP
Definition: ntddndis.h:336
#define OID_802_11_WEP_STATUS
Definition: ntddndis.h:344
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:343
@ 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:330
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:328
@ 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:324
#define OID_802_11_BSSID
Definition: ntddndis.h:319
#define OID_802_11_FRAGMENTATION_THRESHOLD
Definition: ntddndis.h:327
#define OID_802_11_INFRASTRUCTURE_MODE
Definition: ntddndis.h:326
#define OID_802_11_TX_ANTENNA_SELECTED
Definition: ntddndis.h:331
LONG NDIS_802_11_RSSI
Definition: ntddndis.h:104
#define OID_802_11_TX_POWER_LEVEL
Definition: ntddndis.h:323
#define OID_802_11_DISASSOCIATE
Definition: ntddndis.h:338
#define OID_802_11_AUTHENTICATION_MODE
Definition: ntddndis.h:341
#define L(x)
Definition: ntvdm.h:50
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:837
long LONG
Definition: pedump.c:60
DWORD dwStatus
Definition: mediaobj.idl:95
int wmain()
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:173
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:790
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
NetworkType
Definition: tnetwork.h:8
uint32_t * PULONG
Definition: typedefs.h:59
#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 GetModuleHandle
Definition: winbase.h:3762
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3557
int * PINT
Definition: windef.h:177
#define snprintf
Definition: wintirpc.h:48
static const GUID InterfaceGuid
Definition: wlanapi.c:25
BOOL bScan
Definition: wlanconf.c:23
BOOL bDisconnect
Definition: wlanconf.c:30
BOOL ParseCmdline(int argc, WCHAR *argv[])
Definition: wlanconf.c:853
BOOL OpenWlanAdapter(HANDLE *hAdapter, IP_ADAPTER_INDEX_MAP *IpInfo)
Definition: wlanconf.c:212
VOID DoFormatMessage(DWORD ErrorCode)
Definition: wlanconf.c:32
BOOL WlanDisconnect(HANDLE hAdapter, PIP_ADAPTER_INDEX_MAP IpInfo)
Definition: wlanconf.c:231
BOOL OpenAdapterHandle(DWORD Index, HANDLE *hAdapter, IP_ADAPTER_INDEX_MAP *IpInfo)
Definition: wlanconf.c:102
BOOL WlanScan(HANDLE hAdapter)
Definition: wlanconf.c:704
BOOL WlanConnect(HANDLE hAdapter)
Definition: wlanconf.c:534
BOOL bAdhoc
Definition: wlanconf.c:28
BOOL bConnect
Definition: wlanconf.c:25
HANDLE OpenDriverHandle(VOID)
Definition: wlanconf.c:42
WCHAR * sWepKey
Definition: wlanconf.c:27
WCHAR * sSsid
Definition: wlanconf.c:26
BOOL WlanPrintCurrentStatus(HANDLE hAdapter)
Definition: wlanconf.c:274
static UCHAR CharToHex(WCHAR Char)
Definition: wlanconf.c:259
BOOL IsWlanAdapter(HANDLE hAdapter)
Definition: wlanconf.c:78
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175