ReactOS 0.4.17-dev-470-gf9e3448
tcpipconf_notify.c
Go to the documentation of this file.
1#include "precomp.h"
2
3#include <winnls.h>
4#include <winsock.h>
5#include <iphlpapi.h>
6#include <dhcpcsdk.h>
7#include <dhcpcapi.h>
8
9#include <inaddr.h>
10#include <ip2string.h>
11#include <ntstatus.h>
12
13#define IP_STRING_MIN_LENGTH 8 /* 0.0.0.0 + NULL */
14#define IP_STRING_MAX_LENGTH 16 /* xxx.xxx.xxx.xxx + NULL */
15
17
18// KEY: Tcpip\Parameter\{InstanceGuid}\IpAddress | DhcpIpAddress
19// KEY: Tcpip\Parameter\{InstanceGuid}\SubnetMask | DhcpSubnetMask
20// KEY: Tcpip\Parameter\{InstanceGuid}\DefaultGateway | DhcpDefaultGateway
21// KEY: Tcpip\Parameter\{InstanceGuid}\NameServer | DhcpNameServer
22// KEY: Services\NetBT\Parameters\Interfaces\Tcpip_{INSTANCE_GUID}
23
24typedef struct tagIP_ADDR
25{
27 union
28 {
31 } u;
35
36typedef enum
37{
38 METRIC = 1,
40 IPADDR = 3
42
43typedef struct
44{
51
52typedef struct
53{
55
58
60
61typedef struct _AdapterSettings
62{
65
69
76
80
87
89
90 LPWSTR szTCPAllowedPorts; // KEY: Tcpip\Parameter\{InstanceGuid}\TCPAllowedPorts
91 LPWSTR szUDPAllowedPorts; // KEY: Tcpip\Parameter\{InstanceGuid}\UDPAllowedPorts
92 LPWSTR szRawIPAllowedProtocols; // KEY: Tcpip\Parameter\{InstanceGuid}\RawIPAllowedProtocols
96
98
100
101typedef struct
102{
103 const INetCfgComponentControl *lpVtbl;
104 const INetCfgComponentPropertyUi *lpVtblCompPropertyUi;
105 const INetCfgComponentSetup *lpVtblCompSetup;
106 const ITcpipProperties *lpVtblTcpipProperties;
109 INetCfg *pNCfg;
110 INetCfgComponent *pNComp;
111
116
118
119typedef struct
120{
123 WCHAR szIP[16];
126
127typedef struct
128{
131 WCHAR szIP[16];
132 WCHAR szMask[16];
134
135typedef struct
136{
139 WCHAR szIP[16];
141
142typedef struct
143{
148
149typedef struct
150{
155
157{
158 return (TcpipConfNotifyImpl*)((char *)iface - FIELD_OFFSET(TcpipConfNotifyImpl, lpVtblCompPropertyUi));
159}
160
162{
163 return (TcpipConfNotifyImpl*)((char *)iface - FIELD_OFFSET(TcpipConfNotifyImpl, lpVtblCompSetup));
164}
165
167{
168 return (TcpipConfNotifyImpl*)((char *)iface - FIELD_OFFSET(TcpipConfNotifyImpl, lpVtblTcpipProperties));
169}
170
171INT GetSelectedItem(HWND hDlgCtrl);
173VOID InsertColumnToListView(HWND hDlgCtrl, UINT ResId, UINT SubItem, UINT Size);
177
178VOID
179DisplayError(UINT ResTxt, UINT ResTitle, UINT Type)
180{
181 WCHAR szBuffer[300];
182 WCHAR szTitle[100];
183
184 if (LoadStringW(netcfgx_hInstance, ResTxt, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
185 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
186 else
187 szBuffer[0] = L'\0';
188
189 if (LoadStringW(netcfgx_hInstance, ResTitle, szTitle, sizeof(szTitle)/sizeof(WCHAR)))
190 szTitle[(sizeof(szTitle)/sizeof(WCHAR))-1] = L'\0';
191 else
192 szTitle[0] = L'\0';
193
194 MessageBoxW(NULL, szBuffer, szTitle, Type);
195}
196
197static
201 GUID *pAdapterGuid)
202{
203 AdapterSettings *pAdapter;
204
205 pAdapter = This->pAdapterListHead;
206 while (pAdapter)
207 {
208 if (IsEqualGUID(pAdapterGuid, &pAdapter->AdapterGuid))
209 return pAdapter;
210
211 pAdapter = pAdapter->pNext;
212 }
213
214 return NULL;
215}
216
217static
220 AdapterSettings *pAdapter,
221 LPWSTR *ppszIpAddress)
222{
223 PWSTR pszIpAddress, pString;
225 IP_ADDR *pAddr;
227
228 if (pAdapter->NewDhcpEnabled)
229 {
231 }
232 else
233 {
234 dwSize = 0;
235 pAddr = pAdapter->NewIp;
236 while (pAddr != NULL)
237 {
238 dwSize++;
239 pAddr = pAddr->Next;
240 }
241
243 }
244
245 pszIpAddress = CoTaskMemAlloc(dwSize * sizeof(WCHAR));
246 if (pszIpAddress == NULL)
247 return E_OUTOFMEMORY;
248
249 ZeroMemory(pszIpAddress, dwSize * sizeof(WCHAR));
250
251 if (pAdapter->NewDhcpEnabled)
252 {
253 wcscpy(pszIpAddress, L"0.0.0.0");
254 }
255 else
256 {
257 pString = pszIpAddress;
258 pAddr = pAdapter->NewIp;
259 while (pAddr != NULL)
260 {
261 if (pString != pszIpAddress)
262 {
263 *pString = L',';
264 pString++;
265 }
266
267 Address.S_un.S_addr = htonl(pAddr->IpAddress);
269
270 pAddr = pAddr->Next;
271 }
272 }
273
274 *ppszIpAddress = pszIpAddress;
275
276 return S_OK;
277}
278
279static
282 AdapterSettings *pAdapter,
283 LPWSTR *ppszSubnetMask)
284{
285 PWSTR pszSubnetMask, pString;
287 IP_ADDR *pAddr;
289
290 /* Build the SubnetMask string */
291 if (pAdapter->NewDhcpEnabled)
292 {
294 }
295 else
296 {
297 dwSize = 0;
298 pAddr = pAdapter->NewIp;
299 while (pAddr != NULL)
300 {
301 dwSize++;
302 pAddr = pAddr->Next;
303 }
304
306 }
307
308 pszSubnetMask = CoTaskMemAlloc(dwSize * sizeof(WCHAR));
309 if (pszSubnetMask == NULL)
310 return E_OUTOFMEMORY;
311
312 ZeroMemory(pszSubnetMask, dwSize * sizeof(WCHAR));
313
314 if (pAdapter->NewDhcpEnabled)
315 {
316 wcscpy(pszSubnetMask, L"0.0.0.0");
317 }
318 else
319 {
320 pString = pszSubnetMask;
321 pAddr = pAdapter->NewIp;
322 while (pAddr != NULL)
323 {
324 if (pString != pszSubnetMask)
325 {
326 *pString = L',';
327 pString++;
328 }
329
330 Address.S_un.S_addr = htonl(pAddr->u.SubnetMask);
332
333 pAddr = pAddr->Next;
334 }
335 }
336
337 *ppszSubnetMask = pszSubnetMask;
338
339 return S_OK;
340}
341
342static
345 AdapterSettings *pAdapter,
346 LPWSTR *ppszParameters)
347{
348 PWSTR pszParameters, pString;
349 PWSTR pszDefGateway = NULL;
350 PWSTR pszGatewayMetric = NULL;
351 PWSTR pszNameServers = NULL;
352 DWORD dwCount;
353 INT nLength;
354 IP_ADDR *pAddr;
356 HRESULT hr = S_OK;
357
358 /* Format: "DefGw=;GwMetric=;IfMetric=0;DNS=;WINS=;DynamicUpdate=1;NameRegistration=0;" */
359
360 if (ppszParameters == NULL)
361 return E_FAIL;
362
363 *ppszParameters = NULL;
364
365 /* Count Gateway entries */
366 dwCount = 0;
367 pAddr = pAdapter->NewGw;
368 while (pAddr != NULL)
369 {
370 dwCount++;
371 pAddr = pAddr->Next;
372 }
373
374 TRACE("Gateway count: %lu\n", dwCount);
375
376 /* Build Default Gateway string */
377 if (dwCount > 0)
378 {
379 pszDefGateway = CoTaskMemAlloc(dwCount * IP_STRING_MAX_LENGTH * sizeof(WCHAR));
380 if (pszDefGateway == NULL)
381 {
383 goto done;
384 }
385
386 ZeroMemory(pszDefGateway, dwCount * IP_STRING_MAX_LENGTH * sizeof(WCHAR));
387
388 pString = pszDefGateway;
389 pAddr = pAdapter->NewGw;
390 while (pAddr != NULL)
391 {
392 if (pString != pszDefGateway)
393 {
394 *pString = L',';
395 pString++;
396 }
397
398 Address.S_un.S_addr = htonl(pAddr->IpAddress);
400
401 pAddr = pAddr->Next;
402 }
403 }
404
405 TRACE("DefaultGateway %S\n", pszDefGateway);
406
407 /* Build Gateway Metric string */
408 if (dwCount > 0)
409 {
410 pszGatewayMetric = CoTaskMemAlloc(dwCount * 5 * sizeof(WCHAR));
411 if (pszGatewayMetric == NULL)
412 {
414 goto done;
415 }
416
417 ZeroMemory(pszGatewayMetric, dwCount * 5 * sizeof(WCHAR));
418
419 pString = pszGatewayMetric;
420 pAddr = pAdapter->NewGw;
421 while (pAddr != NULL)
422 {
423 if (pString != pszGatewayMetric)
424 {
425 *pString = L',';
426 pString++;
427 }
428
429 nLength = _swprintf(pString, L"%hu", pAddr->u.Metric);
430 pString += nLength;
431
432 pAddr = pAddr->Next;
433 }
434 }
435
436 TRACE("Gateway Metric %S\n", pszGatewayMetric);
437
438 /* Build the DNS string */
439 dwCount = 0;
440 pAddr = pAdapter->NewNs;
441 while (pAddr != NULL)
442 {
443 dwCount++;
444 pAddr = pAddr->Next;
445 }
446
447 TRACE("DNS count: %lu\n", dwCount);
448
449 if (dwCount > 0)
450 {
451 pszNameServers = CoTaskMemAlloc(dwCount * IP_STRING_MAX_LENGTH * sizeof(WCHAR));
452 if (pszNameServers == NULL)
453 {
455 goto done;
456 }
457
458 ZeroMemory(pszNameServers, dwCount * IP_STRING_MAX_LENGTH * sizeof(WCHAR));
459
460 pString = pszNameServers;
461 pAddr = pAdapter->NewNs;
462 while (pAddr != NULL)
463 {
464 if (pString != pszNameServers)
465 {
466 *pString = L',';
467 pString++;
468 }
469
470 Address.S_un.S_addr = htonl(pAddr->IpAddress);
472
473 pAddr = pAddr->Next;
474 }
475 }
476
477 TRACE("Name Servers %S\n", pszNameServers);
478
479 /* Get the Parameters string length */
480 nLength = _scwprintf(L"DefGw=%s;GwMetric=%s;IfMetric=%lu;DNS=%s;DynamicUpdate=%lu;NameRegistration=%lu;",
481 pszDefGateway ? pszDefGateway : L"",
482 pszGatewayMetric ? pszGatewayMetric : L"",
483 pAdapter->NewMetric,
484 pszNameServers ? pszNameServers : L"",
485 pAdapter->NewRegisterAdapterName ? 1 : 0,
486 pAdapter->NewRegistrationEnabled ? 1 : 0);
487
488 TRACE("Param string length %d\n", nLength);
489 if (nLength == -1)
490 {
491 hr = E_FAIL;
492 goto done;
493 }
494
495 /* Allocate the Parameters buffer */
496 pszParameters = CoTaskMemAlloc((nLength + 1) * sizeof(WCHAR));
497 if (pszParameters == NULL)
498 return E_OUTOFMEMORY;
499
500 ZeroMemory(pszParameters, (nLength + 1) * sizeof(WCHAR));
501
502 /* Fill the Parameters buffer */
503 _swprintf(pszParameters,
504 L"DefGw=%s;GwMetric=%s;IfMetric=%lu;DNS=%s;DynamicUpdate=%lu;NameRegistration=%lu;",
505 pszDefGateway ? pszDefGateway : L"",
506 pszGatewayMetric ? pszGatewayMetric : L"",
507 pAdapter->NewMetric,
508 pszNameServers ? pszNameServers : L"",
509 pAdapter->NewRegisterAdapterName ? 1 : 0,
510 pAdapter->NewRegistrationEnabled ? 1 : 0);
511
512 TRACE("Parameters %S\n", pszParameters);
513
514 *ppszParameters = pszParameters;
515
516done:
517 if (pszDefGateway)
518 CoTaskMemFree(pszDefGateway);
519
520 if (pszGatewayMetric)
521 CoTaskMemFree(pszGatewayMetric);
522
523 if (pszNameServers)
524 CoTaskMemFree(pszNameServers);
525
526 return hr;
527}
528
529
530static
531PWSTR
533 PWSTR pszParameters,
534 PWSTR pszParameter)
535{
536 PWSTR pToken, pStart, pEnd, pBuffer;
537 INT length = 0;
538
539 TRACE("ExtractParameterValue(%S, %S)\n", pszParameters, pszParameter);
540
541 pToken = wcsstr(pszParameters, pszParameter);
542 if (pToken == NULL)
543 return NULL;
544
545 pStart = wcschr(pToken, L'=');
546 if (pStart == NULL)
547 return NULL;
548
549 pStart++;
550 pEnd = wcschr(pStart, L';');
551 if (pEnd == NULL)
552 length = wcslen(pStart);
553 else
554 length = pEnd - pStart;
555 TRACE("length %d\n", length);
556
557 if (length == 0)
558 return NULL;
559
560 pBuffer = (PWSTR)CoTaskMemAlloc((length + 1) * sizeof(WCHAR));
561 if (pBuffer)
562 {
563 CopyMemory(pBuffer, pStart, length * sizeof(WCHAR));
565 }
566
567 return pBuffer;
568}
569
570
571/***************************************************************
572 * TCP/IP Filter Dialog
573 *
574 */
575
579 HWND hwndDlg,
580 UINT uMsg,
583)
584{
585 TcpipPortSettings * pPort;
586 UINT Num;
588 LVITEMW li;
589 WCHAR szBuffer[100];
590
591 switch(uMsg)
592 {
593 case WM_INITDIALOG:
594 pPort = (TcpipPortSettings*)lParam;
595 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pPort);
596 if (LoadStringW(netcfgx_hInstance, pPort->ResId, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
597 {
598 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
599 SendDlgItemMessageW(hwndDlg, IDC_PORT_DESC, WM_SETTEXT, 0, (LPARAM)szBuffer);
600 }
601
602 if (pPort->MaxNum == 65536)
604 else
606
607 return TRUE;
608 case WM_COMMAND:
609 if (LOWORD(wParam) == IDCANCEL)
610 {
611 EndDialog(hwndDlg, FALSE);
612 break;
613 }
614 else if (LOWORD(wParam) == IDC_OK)
615 {
616 pPort = (TcpipPortSettings*)GetWindowLongPtr(hwndDlg, DWLP_USER);
617 Num = GetDlgItemInt(hwndDlg, IDC_PORT_VAL, NULL, TRUE);
618 if (Num > pPort->MaxNum || Num == 0)
619 {
620 if (pPort->MaxNum == 65536)
622 else
624
626 break;
627 }
628 if (GetWindowTextW(GetDlgItem(hwndDlg, IDC_PORT_VAL), szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
629 {
630 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
631 ZeroMemory(&find, sizeof(LVFINDINFOW));
632 find.flags = LVFI_STRING;
633 find.psz = szBuffer;
634 if (SendMessageW(pPort->hDlgCtrl, LVM_FINDITEMW, (WPARAM)-1, (LPARAM)&find) == -1)
635 {
636 ZeroMemory(&li, sizeof(LVITEMW));
637 li.mask = LVIF_TEXT;
638 li.iItem = ListView_GetItemCount(pPort->hDlgCtrl);
639 li.pszText = szBuffer;
640 SendMessageW(pPort->hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
641 EndDialog(hwndDlg, TRUE);
642 break;
643 }
646 break;
647 }
648 }
649 }
650 return FALSE;
651}
652
653VOID
654InitFilterListBox(LPWSTR pData, HWND hwndDlg, HWND hDlgCtrl, UINT AllowButton, UINT RestrictButton, UINT AddButton, UINT DelButton)
655{
656 LVITEMW li;
657 LPWSTR pCur;
658 INT iItem;
659
660 if (!pData || !_wtoi(pData))
661 {
662 CheckDlgButton(hwndDlg, AllowButton, BST_CHECKED);
664 EnableWindow(GetDlgItem(hwndDlg, DelButton), FALSE);
665 return;
666 }
667
668 pCur = pData;
669 memset(&li, 0x0, sizeof(LVITEMW));
670 li.mask = LVIF_TEXT;
671 iItem = 0;
672
673 while(pCur[0])
674 {
675 li.pszText = pCur;
676 li.iItem = iItem;
677 SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
678 iItem++;
679 pCur += wcslen(pCur) + 1;
680 }
681
682 if (!iItem)
683 CheckDlgButton(hwndDlg, AllowButton, BST_CHECKED);
684 else
685 CheckDlgButton(hwndDlg, RestrictButton, BST_CHECKED);
686}
687
688LPWSTR
690 HWND hDlgCtrl,
692{
693 INT iCount, iIndex;
694 LVITEMW li;
697 WCHAR szBuffer[10];
698
699 iCount = ListView_GetItemCount(hDlgCtrl);
700 if (!iCount)
701 {
702 pData = (LPWSTR)CoTaskMemAlloc(3 * sizeof(WCHAR));
703 if (!pData)
704 return NULL;
705 pData[0] = L'0';
706 pData[1] = L'\0';
707 pData[2] = L'\0';
708 *Size = 3 * sizeof(WCHAR);
709 return pData;
710 }
711
712 pData = CoTaskMemAlloc((6 * iCount + 1) * sizeof(WCHAR));
713 if (!pData)
714 return NULL;
715
716 pCur = pData;
717 dwSize = 0;
718 for(iIndex = 0; iIndex < iCount; iIndex++)
719 {
720 ZeroMemory(&li, sizeof(LVITEMW));
721 li.mask = LVIF_TEXT;
722 li.iItem = iIndex;
723 li.pszText = szBuffer;
724 li.cchTextMax = sizeof(szBuffer) /sizeof(WCHAR);
725 if (SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li))
726 {
727 wcscpy(pCur, szBuffer);
728 dwSize += wcslen(szBuffer) + 1;
729 pCur += wcslen(szBuffer) + 1;
730 }
731 }
732 pCur[0] = L'\0';
733 *Size = (dwSize+1) * sizeof(WCHAR);
734 return pData;
735}
736
737static
738VOID
740 HWND hwndDlg,
741 HWND hDlgCtrl,
742 UINT MaxItem,
743 UINT ResId)
744{
746
747 Port.MaxNum = MaxItem;
748 Port.hDlgCtrl = hDlgCtrl;
749 Port.ResId = ResId;
750
752}
753
754static
755VOID
757 HWND hDlgCtrl)
758{
759 INT iIndex = GetSelectedItem(hDlgCtrl);
760
761 if (iIndex != -1)
762 {
763 (void)ListView_DeleteItem(hDlgCtrl, iIndex);
764 return;
765 }
767}
768
772 HWND hwndDlg,
773 UINT uMsg,
776)
777{
778 TcpipConfNotifyImpl *pContext;
779
780 switch(uMsg)
781 {
782 case WM_INITDIALOG:
783 pContext = (TcpipConfNotifyImpl*)lParam;
787 if (pContext->pCurrentAdapter)
788 {
794 }
795 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
796 return TRUE;
797 case WM_COMMAND:
798 if (HIWORD(wParam) == BN_CLICKED)
799 {
800 switch (LOWORD(wParam))
801 {
804 {
809 }
810 break;
811 case IDC_TCP_RESTRICT:
813 {
818 }
819 break;
822 {
827 }
828 break;
829 case IDC_UDP_RESTRICT:
831 {
836 }
837 break;
838 case IDC_IP_ALLOW_ALL:
840 {
845 }
846 break;
847 case IDC_IP_RESTRICT:
849 {
854 }
855 break;
856 case IDC_USE_FILTER:
859
860 break;
861 }
862 }
863 switch(LOWORD(wParam))
864 {
865 case IDC_OK:
866 pContext = (TcpipConfNotifyImpl*)GetWindowLongPtr(hwndDlg, DWLP_USER);
868 {
869 pContext->pTcpIpSettings->EnableSecurityFilters = TRUE;
870 pContext->pCurrentAdapter->szTCPAllowedPorts = CreateFilterList(GetDlgItem(hwndDlg, IDC_TCP_LIST), &pContext->pCurrentAdapter->TCPSize);
871 pContext->pCurrentAdapter->szUDPAllowedPorts = CreateFilterList(GetDlgItem(hwndDlg, IDC_UDP_LIST), &pContext->pCurrentAdapter->UDPSize);
872 pContext->pCurrentAdapter->szRawIPAllowedProtocols = CreateFilterList(GetDlgItem(hwndDlg, IDC_IP_LIST), &pContext->pCurrentAdapter->RawIPSize);
873 }
874 else
875 {
876 pContext->pTcpIpSettings->EnableSecurityFilters = FALSE;
877 if (pContext->pCurrentAdapter->szTCPAllowedPorts)
878 {
879 CoTaskMemFree(pContext->pCurrentAdapter->szTCPAllowedPorts);
880 pContext->pCurrentAdapter->szTCPAllowedPorts = NULL;
881 pContext->pCurrentAdapter->TCPSize = 0;
882 }
883 if (pContext->pCurrentAdapter->szUDPAllowedPorts)
884 {
885 CoTaskMemFree(pContext->pCurrentAdapter->szUDPAllowedPorts);
886 pContext->pCurrentAdapter->szUDPAllowedPorts = NULL;
887 pContext->pCurrentAdapter->UDPSize = 0;
888 }
889 if (pContext->pCurrentAdapter->szRawIPAllowedProtocols)
890 {
891 CoTaskMemFree(pContext->pCurrentAdapter->szRawIPAllowedProtocols);
892 pContext->pCurrentAdapter->szRawIPAllowedProtocols = NULL;
893 pContext->pCurrentAdapter->RawIPSize = 0;
894 }
895 }
896 EndDialog(hwndDlg, (INT_PTR)TRUE);
897 break;
898 case IDCANCEL:
899 EndDialog(hwndDlg, FALSE);
900 break;
901 case IDC_TCP_ADD:
902 AddItem(hwndDlg, GetDlgItem(hwndDlg, IDC_TCP_LIST), 65536, IDS_TCP_PORTS);
903 break;
904 case IDC_TCP_DEL:
906 break;
907 case IDC_UDP_ADD:
908 AddItem(hwndDlg, GetDlgItem(hwndDlg, IDC_UDP_LIST), 65536, IDS_UDP_PORTS);
909 break;
910 case IDC_UDP_DEL:
912 break;
913 case IDC_IP_ADD:
914 AddItem(hwndDlg, GetDlgItem(hwndDlg, IDC_IP_LIST), 256, IDS_IP_PROTO);
915 break;
916 case IDC_IP_DEL:
917 DelItem(GetDlgItem(hwndDlg, IDC_IP_LIST));
918 break;
919 default:
920 break;
921 }
922 default:
923 break;
924 }
925
926 return FALSE;
927}
928
929
932{
933 PROPSHEETPAGEW ppage;
934
935 memset(&ppage, 0x0, sizeof(PROPSHEETPAGEW));
936 ppage.dwSize = sizeof(PROPSHEETPAGEW);
937 ppage.dwFlags = PSP_DEFAULT;
938 ppage.u.pszTemplate = resname;
939 ppage.pfnDlgProc = dlgproc;
940 ppage.lParam = lParam;
942 if (szTitle)
943 {
944 ppage.dwFlags |= PSP_USETITLE;
945 ppage.pszTitle = szTitle;
946 }
947 return CreatePropertySheetPageW(&ppage);
948}
949
950/***************************************************************
951 * TCP/IP Advanced Option Dialog
952 *
953 */
954
955VOID
957 HWND hwndDlg,
959{
960 WCHAR szText[500];
961 /* store context */
963
964 if (LoadStringW(netcfgx_hInstance, IDS_TCPFILTER, szText, sizeof(szText)/sizeof(WCHAR)))
965 {
966 szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
967 if (SendDlgItemMessageW(hwndDlg, IDC_OPTLIST, LB_ADDSTRING, 0, (LPARAM)szText) != LB_ERR)
969 }
970
971 if (LoadStringW(netcfgx_hInstance, IDS_TCPFILTERDESC, szText, sizeof(szText)/sizeof(WCHAR)))
972 {
973 szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
974 SendDlgItemMessageW(hwndDlg, IDC_OPTDESC, WM_SETTEXT, 0, (LPARAM)szText);
975 }
976}
977
978
979
983 HWND hwndDlg,
984 UINT uMsg,
987)
988{
991
992 switch(uMsg)
993 {
994 case WM_INITDIALOG:
996 This = (TcpipConfNotifyImpl*)page->lParam;
998 return TRUE;
999 case WM_COMMAND:
1000 if (LOWORD(wParam) == IDC_OPTPROP)
1001 {
1004 GetParent(hwndDlg),
1006 (LPARAM)GetWindowLongPtr(hwndDlg, DWLP_USER));
1007 break;
1008 }
1009 }
1010 return FALSE;
1011}
1012
1013VOID
1015 HWND hDlgCtrl,
1016 UINT ResId,
1017 UINT SubItem,
1018 UINT Size)
1019{
1020 WCHAR szBuffer[200];
1021 LVCOLUMNW lc;
1022
1023 if (!LoadStringW(netcfgx_hInstance, ResId, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1024 return;
1025
1026 memset(&lc, 0, sizeof(LV_COLUMN) );
1028 lc.iSubItem = SubItem;
1029 lc.fmt = LVCFMT_FIXED_WIDTH;
1030 lc.cx = Size;
1031 lc.cchTextMax = wcslen(szBuffer);
1032 lc.pszText = szBuffer;
1033
1034 (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, SubItem, (LPARAM)&lc);
1035}
1036
1037VOID
1039 HWND hDlgCtrl,
1040 IP_ADDR * pAddr,
1041 BOOL bSubMask)
1042{
1043 WCHAR szBuffer[70];
1044 DWORD dwIpAddr;
1045 UINT itemCount = 0;
1046 LVITEMW li;
1047
1048 while(pAddr)
1049 {
1050 ZeroMemory(&li, sizeof(li));
1051 li.mask = LVIF_TEXT;
1052 li.iItem = itemCount;
1053 li.iSubItem = 0;
1054 dwIpAddr = pAddr->IpAddress;
1055 _swprintf(szBuffer, L"%lu.%lu.%lu.%lu",
1056 FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr), THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
1057
1058 li.pszText = szBuffer;
1059 li.iItem = SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
1060 if (li.iItem != -1)
1061 {
1062 if (bSubMask)
1063 {
1064 dwIpAddr = pAddr->u.SubnetMask;
1065 _swprintf(szBuffer, L"%lu.%lu.%lu.%lu",
1066 FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr), THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
1067 }
1068 else
1069 {
1070 if (pAddr->u.Metric)
1071 _swprintf(szBuffer, L"%u", pAddr->u.Metric);
1072 else
1073 LoadStringW(netcfgx_hInstance, IDS_AUTOMATIC, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));
1074 }
1075
1076 li.mask = LVIF_TEXT;
1077 li.iSubItem = 1;
1078 li.pszText = szBuffer;
1079 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
1080 }
1081 itemCount++;
1082 pAddr = pAddr->Next;
1083 }
1084}
1085
1086VOID
1088 HWND hwndDlg,
1090{
1091 RECT rect;
1092 LVITEMW li;
1093 WCHAR szBuffer[100];
1094
1098
1099 if (This->pCurrentAdapter->NewDhcpEnabled)
1100 {
1101 if (LoadStringW(netcfgx_hInstance, IDS_DHCPACTIVE, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1102 {
1103 ZeroMemory(&li, sizeof(LVITEMW));
1104 li.mask = LVIF_TEXT;
1105 li.pszText = szBuffer;
1107 }
1109 }
1110 else
1111 {
1112 InsertIpAddressToListView(GetDlgItem(hwndDlg, IDC_IPLIST), This->pCurrentAdapter->NewIp, TRUE);
1113 }
1114
1117
1121
1122 InsertIpAddressToListView(GetDlgItem(hwndDlg, IDC_GWLIST), This->pCurrentAdapter->NewGw, FALSE);
1123
1126
1128 if (This->pCurrentAdapter->NewMetric)
1129 {
1131 SetDlgItemInt(hwndDlg, IDC_IFMETRIC, This->pCurrentAdapter->NewMetric, FALSE);
1132 }
1133 else
1134 {
1137 }
1138}
1139
1140INT_PTR
1143 HWND hwndDlg,
1144 UINT uMsg,
1145 WPARAM wParam,
1147)
1148{
1149 WCHAR szBuffer[70];
1150 TcpipGwSettings *pGwSettings;
1151 DWORD dwIpAddr;
1152 LPNMIPADDRESS lpnmipa;
1154
1155 switch(uMsg)
1156 {
1157 case WM_INITDIALOG:
1158 pGwSettings = (TcpipGwSettings *)lParam;
1160
1165
1166 if (pGwSettings->bAdd)
1167 {
1168 if (LoadStringW(netcfgx_hInstance, IDS_ADD, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1169 {
1170 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1171 SendDlgItemMessageW(hwndDlg, IDC_OK, WM_SETTEXT, 0, (LPARAM)szBuffer);
1172 }
1173 EnableWindow(GetDlgItem(hwndDlg, IDC_OK), FALSE);
1175 }
1176 else
1177 {
1178 if (LoadStringW(netcfgx_hInstance, IDS_MOD, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1179 {
1180 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1181 SendDlgItemMessageW(hwndDlg, IDC_OK, WM_SETTEXT, 0, (LPARAM)szBuffer);
1182 }
1183
1185
1186 if (pGwSettings->Metric)
1187 {
1188 SetDlgItemInt(hwndDlg, IDC_GWMETRIC, pGwSettings->Metric, FALSE);
1191 }
1192 else
1193 {
1197 }
1198 }
1199 return TRUE;
1200 case WM_COMMAND:
1202 {
1204 {
1208 }
1209 else
1210 {
1213 }
1214 break;
1215 }
1216 else if (LOWORD(wParam) == IDCANCEL)
1217 {
1218 EndDialog(hwndDlg, FALSE);
1219 break;
1220 }
1221 else if (LOWORD(wParam) == IDC_OK)
1222 {
1223 if (SendDlgItemMessageW(hwndDlg, IDC_IPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
1224 {
1225 pGwSettings = (TcpipGwSettings*)GetWindowLongPtr(hwndDlg, DWLP_USER);
1226 SendDlgItemMessageW(hwndDlg, IDC_IPADDR, WM_GETTEXT, 16, (LPARAM)pGwSettings->szIP);
1227
1228 ZeroMemory(&find, sizeof(LVFINDINFOW));
1229 find.flags = LVFI_STRING;
1230 find.psz = pGwSettings->szIP;
1231
1233 pGwSettings->Metric = GetDlgItemInt(hwndDlg, IDC_GWMETRIC, NULL, FALSE);
1234 else
1235 pGwSettings->Metric = 0;
1236
1237
1238 if (SendMessageW(pGwSettings->hDlgCtrl, LVM_FINDITEMW, (WPARAM)-1, (LPARAM)&find) == -1)
1239 {
1240 EndDialog(hwndDlg, TRUE);
1241 break;
1242 }
1243 if (!pGwSettings->bAdd)
1244 {
1245 EndDialog(hwndDlg, FALSE);
1246 break;
1247 }
1249 }
1250 break;
1251 }
1252 break;
1253 case WM_NOTIFY:
1254 lpnmipa = (LPNMIPADDRESS) lParam;
1255 if (lpnmipa->hdr.code == IPN_FIELDCHANGED)
1256 {
1257 if (lpnmipa->hdr.idFrom == IDC_IPADDR)
1258 {
1259 if (SendDlgItemMessageW(hwndDlg, IDC_IPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
1260 EnableWindow(GetDlgItem(hwndDlg, IDC_OK), TRUE);
1261 }
1262 }
1263 break;
1264 }
1265 return FALSE;
1266}
1267
1268BOOL
1270{
1271 LVITEMW li;
1272 WCHAR szBuffer[30];
1273 BOOL bRet;
1274
1275 ZeroMemory(&li, sizeof(LVITEMW));
1276 li.mask = LVIF_TEXT;
1277 li.cchTextMax = 16;
1278 li.pszText = pGwSettings->szIP;
1279 li.iItem = Index;
1280
1281 if (!SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li))
1282 return FALSE;
1283 li.pszText = szBuffer;
1284 li.cchTextMax = 30;
1285 li.iSubItem = 1;
1286
1287 bRet = SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li);
1288 if (bRet)
1289 {
1290 pGwSettings->Metric = _wtoi(szBuffer);
1291 }
1292
1293 return bRet;
1294}
1295
1296INT_PTR
1299 HWND hwndDlg,
1300 UINT uMsg,
1301 WPARAM wParam,
1303)
1304{
1305 LPNMIPADDRESS lpnmipa;
1306 DWORD dwIpAddr;
1307 TcpipIpSettings *pIpSettings;
1308 WCHAR szBuffer[50];
1310 LRESULT lResult;
1311
1312 switch(uMsg)
1313 {
1314 case WM_INITDIALOG:
1315 pIpSettings = (TcpipIpSettings*)lParam;
1317
1326
1327 if (pIpSettings->bAdd)
1328 {
1329 if (LoadStringW(netcfgx_hInstance, IDS_ADD, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1330 {
1331 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1332 SendDlgItemMessageW(hwndDlg, IDC_OK, WM_SETTEXT, 0, (LPARAM)szBuffer);
1333 }
1334 EnableWindow(GetDlgItem(hwndDlg, IDC_OK), FALSE);
1335 }
1336 else
1337 {
1338 if (LoadStringW(netcfgx_hInstance, IDS_MOD, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1339 {
1340 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1341 SendDlgItemMessageW(hwndDlg, IDC_OK, WM_SETTEXT, 0, (LPARAM)szBuffer);
1342 }
1343
1346 }
1347 return TRUE;
1348 case WM_NOTIFY:
1349 lpnmipa = (LPNMIPADDRESS) lParam;
1350 if (lpnmipa->hdr.code == IPN_FIELDCHANGED)
1351 {
1352 if (lpnmipa->hdr.idFrom == IDC_IPADDR)
1353 {
1354 if (SendDlgItemMessageW(hwndDlg, IDC_IPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
1355 {
1356 if (dwIpAddr <= MAKEIPADDRESS(127, 255, 255, 255))
1358 else if (dwIpAddr <= MAKEIPADDRESS(191, 255, 255, 255))
1360 else if (dwIpAddr <= MAKEIPADDRESS(223, 255, 255, 255))
1361 SendDlgItemMessageW(hwndDlg, IDC_SUBNETMASK, IPM_SETADDRESS, 0, (LPARAM)MAKEIPADDRESS(255, 255, 255, 0));
1362 EnableWindow(GetDlgItem(hwndDlg, IDC_OK), TRUE);
1363 }
1364 }
1365 }
1366 break;
1367 case WM_COMMAND:
1368 if (LOWORD(wParam) == IDC_OK)
1369 {
1370 pIpSettings = (TcpipIpSettings*)GetWindowLongPtr(hwndDlg, DWLP_USER);
1371 SendDlgItemMessageW(hwndDlg, IDC_IPADDR, WM_GETTEXT, 16, (LPARAM)pIpSettings->szIP);
1372 SendDlgItemMessageW(hwndDlg, IDC_SUBNETMASK, WM_GETTEXT, 16, (LPARAM)pIpSettings->szMask);
1373
1374 ZeroMemory(&find, sizeof(LVFINDINFOW));
1375 find.flags = LVFI_STRING;
1376 find.psz = pIpSettings->szIP;
1377 lResult = SendMessageW(pIpSettings->hDlgCtrl, LVM_FINDITEMW, (WPARAM)-1, (LPARAM)&find);
1378
1379 if (lResult == -1)
1380 {
1381 EndDialog(hwndDlg, TRUE);
1382 break;
1383 }
1384 else if (!pIpSettings->bAdd)
1385 {
1386 EndDialog(hwndDlg, FALSE);
1387 break;
1388 }
1390 break;
1391 }
1392 else if (LOWORD(wParam) == IDCANCEL)
1393 {
1394 EndDialog(hwndDlg, FALSE);
1395 }
1396 break;
1397 }
1398 return FALSE;
1399}
1400
1401BOOL
1403 LPWSTR szName)
1404{
1405 UINT Index;
1407
1408 for(Index = 0; Index < Length; Index++)
1409 if (iswalnum(szName[Index]) == 0 && szName[Index] != '.' && szName[Index] != '-')
1410 return FALSE;
1411
1412 return TRUE;
1413}
1414
1415INT_PTR
1418 HWND hwndDlg,
1419 UINT uMsg,
1420 WPARAM wParam,
1422)
1423{
1424 WCHAR szBuffer[100];
1425 TcpipSuffixSettings * pSettings;
1426 LRESULT lLength;
1427
1428 switch(uMsg)
1429 {
1430 case WM_INITDIALOG:
1431 pSettings = (TcpipSuffixSettings*)lParam;
1432 if (!pSettings->bAdd)
1433 {
1434 SendDlgItemMessageW(hwndDlg, IDC_SUFFIX, WM_SETTEXT, 0, (LPARAM)pSettings->Suffix);
1435 if (LoadStringW(netcfgx_hInstance, IDS_MOD, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1436 {
1437 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1438 SendDlgItemMessageW(hwndDlg, IDC_OK, WM_SETTEXT, 0, (LPARAM)szBuffer);
1439 }
1440 CoTaskMemFree(pSettings->Suffix);
1441 pSettings->Suffix = NULL;
1442 }
1443 else
1444 {
1445 if (LoadStringW(netcfgx_hInstance, IDS_ADD, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1446 {
1447 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1448 SendDlgItemMessageW(hwndDlg, IDC_OK, WM_SETTEXT, 0, (LPARAM)szBuffer);
1449 }
1450 }
1451 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pSettings);
1452 return TRUE;
1453 case WM_COMMAND:
1454 if (LOWORD(wParam) == IDCANCEL)
1455 {
1456 EndDialog(hwndDlg, FALSE);
1457 break;
1458 }
1459 else if (LOWORD(wParam) == IDC_OK)
1460 {
1461 lLength = SendDlgItemMessageW(hwndDlg, IDC_SUFFIX, WM_GETTEXTLENGTH, 0, 0);
1462 if (lLength)
1463 {
1464 pSettings = (TcpipSuffixSettings*) GetWindowLongPtr(hwndDlg, DWLP_USER);
1465 pSettings->Suffix = (LPWSTR)CoTaskMemAlloc((lLength + 1)* sizeof(WCHAR));
1466 if (pSettings->Suffix)
1467 {
1468 SendDlgItemMessageW(hwndDlg, IDC_SUFFIX, WM_GETTEXT, lLength + 1, (LPARAM)pSettings->Suffix);
1469 if (SendMessageW(pSettings->hDlgCtrl, LB_FINDSTRING, 0, (LPARAM)pSettings->Suffix) != LB_ERR)
1470 {
1472 CoTaskMemFree(pSettings->Suffix);
1473 pSettings->Suffix = NULL;
1474 break;
1475 }
1476
1477 if (!VerifyDNSSuffix(pSettings->Suffix))
1478 {
1480 CoTaskMemFree(pSettings->Suffix);
1481 pSettings->Suffix = NULL;
1482 break;
1483 }
1484 EndDialog(hwndDlg, TRUE);
1485 }
1486 }
1487 break;
1488 }
1489 }
1490 return FALSE;
1491}
1492
1493
1494INT
1496{
1497 LVITEMW li;
1498 UINT iItemCount, iIndex;
1499
1500 iItemCount = ListView_GetItemCount(hDlgCtrl);
1501 if (!iItemCount)
1502 return -1;
1503
1504 for (iIndex = 0; iIndex < iItemCount; iIndex++)
1505 {
1506 ZeroMemory(&li, sizeof(LVITEMW));
1507 li.mask = LVIF_STATE;
1508 li.stateMask = (UINT)-1;
1509 li.iItem = iIndex;
1510 if (SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li))
1511 {
1512 if (li.state & LVIS_SELECTED)
1513 return iIndex;
1514 }
1515 }
1516 return -1;
1517}
1518
1519
1520BOOL
1522{
1523 LVITEMW li;
1524
1525 ZeroMemory(&li, sizeof(LVITEMW));
1526 li.mask = LVIF_TEXT;
1527 li.cchTextMax = 16;
1528 li.pszText = pIpSettings->szIP;
1529 li.iItem = Index;
1530
1531 if (!SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li))
1532 return FALSE;
1533
1534 ZeroMemory(&li, sizeof(LVITEMW));
1535 li.mask = LVIF_TEXT;
1536 li.cchTextMax = 16;
1537 li.pszText = pIpSettings->szMask;
1538 li.iSubItem = 1;
1539 li.iItem = Index;
1540
1541 return SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li);
1542}
1543
1544VOID
1546{
1547 LVITEMW li;
1548
1549 memset(&li, 0x0, sizeof(LVITEMW));
1550 li.iItem = GetSelectedItem(hDlgCtrl);
1551 if (li.iItem < 0)
1552 {
1554 SetFocus(hDlgCtrl);
1555 }
1556 else
1557 {
1558 (void)ListView_DeleteItem(hDlgCtrl, li.iItem);
1559 }
1560}
1561
1562UINT
1564 WCHAR * szBuffer)
1565{
1566 DWORD dwIpAddr = 0;
1567 INT Val;
1568 UINT Index = 3;
1569 LPWSTR pLast = szBuffer;
1570 LPWSTR pNext = szBuffer;
1571
1572
1573 while((pNext = wcschr(pNext, L'.')))
1574 {
1575 pNext[0] = L'\0';
1576 Val = _wtoi(pLast);
1577 dwIpAddr |= (Val << Index * 8);
1578 Index--;
1579 pNext++;
1580 pLast = pNext;
1581 }
1582 dwIpAddr |= _wtoi(pLast);
1583
1584 return dwIpAddr;
1585}
1586
1587UINT
1589 char * sBuffer)
1590{
1591 WCHAR szIp[16];
1592
1593 if (MultiByteToWideChar(CP_ACP, 0, sBuffer, -1, szIp, 16))
1594 {
1595 szIp[15] = L'\0';
1596 return GetIpAddressFromStringW(szIp);
1597 }
1598 return (UINT)-1;
1599}
1600
1601
1602VOID
1604{
1605 IP_ADDR *pNext;
1606
1607 if (!pAddr)
1608 return;
1609
1610 while(pAddr)
1611 {
1612 pNext = pAddr->Next;
1614 pAddr = pNext;
1615 }
1616}
1617
1618BOOL
1619GetListViewItem(HWND hDlgCtrl, UINT Index, UINT SubIndex, WCHAR * szBuffer, UINT BufferSize)
1620{
1621 LVITEMW li;
1622
1623 ZeroMemory(&li, sizeof(LVITEMW));
1624 li.mask = LVIF_TEXT;
1625 li.pszText = szBuffer;
1626 li.iItem = Index;
1627 li.iSubItem = SubIndex;
1628 li.cchTextMax = BufferSize;
1629 return SendMessageW(hDlgCtrl, LVM_GETITEMW, 0, (LPARAM)&li);
1630}
1631
1632VOID
1634 HWND hDlgCtrl,
1636 BOOL bSubmask)
1637{
1638 WCHAR szBuffer[30];
1639
1640 INT iIndex, iCount;
1641 IP_ADDR *pCur, *pLast;
1642
1643 iCount = ListView_GetItemCount(hDlgCtrl);
1644 if (!iCount)
1645 {
1646 return;
1647 }
1648
1649 pLast = NULL;
1650 for(iIndex = 0; iIndex < iCount; iIndex++)
1651 {
1652 if (GetListViewItem(hDlgCtrl, iIndex, 0, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1653 {
1654 pCur = (IP_ADDR*)CoTaskMemAlloc(sizeof(IP_ADDR));
1655 if (!pCur)
1656 break;
1657 ZeroMemory(pCur, sizeof(IP_ADDR));
1658
1659 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1660 pCur->IpAddress = GetIpAddressFromStringW(szBuffer);
1661
1662 if (GetListViewItem(hDlgCtrl, iIndex, 1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR) ))
1663 {
1664 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1665 if (bSubmask)
1666 pCur->u.SubnetMask = GetIpAddressFromStringW(szBuffer);
1667 else
1668 pCur->u.Metric = _wtoi(szBuffer);
1669 }
1670
1671 if (!pLast)
1672 {
1673 if (bSubmask)
1674 This->pCurrentAdapter->NewIp = pCur;
1675 else
1676 This->pCurrentAdapter->NewGw = pCur;
1677 }
1678 else
1679 {
1680 pLast->Next = pCur;
1681 }
1682
1683 pLast = pCur;
1684 }
1685 }
1686}
1687
1688
1689INT_PTR
1692 HWND hwndDlg,
1693 UINT uMsg,
1694 WPARAM wParam,
1696)
1697{
1700 INT_PTR res;
1701 WCHAR szBuffer[200];
1702 LPPSHNOTIFY lppsn;
1704 TcpipIpSettings Ip;
1705
1706 LVITEMW li;
1707
1708 switch(uMsg)
1709 {
1710 case WM_INITDIALOG:
1712 This = (TcpipConfNotifyImpl*)page->lParam;
1715 return TRUE;
1716 case WM_NOTIFY:
1717 lppsn = (LPPSHNOTIFY) lParam;
1718 if (lppsn->hdr.code == LVN_ITEMCHANGED)
1719 {
1721 BOOL bEnable;
1722
1723 if (lplv->hdr.idFrom == IDC_IPLIST)
1724 {
1726
1727 bEnable = ((lplv->uNewState & LVIS_SELECTED) != 0) &&
1728 (!This->pCurrentAdapter->NewDhcpEnabled);
1729
1732 }
1733 else if (lplv->hdr.idFrom == IDC_GWLIST)
1734 {
1735 bEnable = ((lplv->uNewState & LVIS_SELECTED) != 0);
1736
1739 }
1740 }
1741 else if (lppsn->hdr.code == PSN_KILLACTIVE)
1742 {
1744 if (!This->pCurrentAdapter->NewDhcpEnabled && ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_IPLIST)) == 0)
1745 {
1748 return TRUE;
1749 }
1750
1752 {
1754 if ((val < 1) || (val > 9999))
1755 {
1758 return TRUE;
1759 }
1760 }
1761 }
1762 else if (lppsn->hdr.code == PSN_APPLY)
1763 {
1765 FreeIPAddr(This->pCurrentAdapter->NewGw);
1766 This->pCurrentAdapter->NewGw = NULL;
1767 FreeIPAddr(This->pCurrentAdapter->NewIp);
1768 This->pCurrentAdapter->NewIp = NULL;
1771
1773 This->pCurrentAdapter->NewMetric = 0;
1774 else
1775 This->pCurrentAdapter->NewMetric = GetDlgItemInt(hwndDlg, IDC_IFMETRIC, NULL, FALSE);
1776
1778 return TRUE;
1779 }
1780 break;
1781 case WM_COMMAND:
1783 {
1786 else
1788 }
1789 else if (LOWORD(wParam) == IDC_IPADD)
1790 {
1791 Ip.bAdd = TRUE;
1792 Ip.hDlgCtrl = GetDlgItem(hwndDlg, IDC_IPLIST);
1794 if (res)
1795 {
1796 memset(&li, 0x0, sizeof(LVITEMW));
1797 li.mask = LVIF_TEXT | LVIF_PARAM;
1798 li.iItem = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_IPLIST));
1799 li.pszText = Ip.szIP;
1800 li.iItem = SendDlgItemMessageW(hwndDlg, IDC_IPLIST, LVM_INSERTITEMW, 0, (LPARAM)&li);
1801 if (li.iItem != -1)
1802 {
1803 li.mask = LVIF_TEXT;
1804 li.iSubItem = 1;
1805 li.pszText = Ip.szMask;
1807 }
1808 }
1809 }
1810 else if (LOWORD(wParam) == IDC_IPMOD)
1811 {
1812 memset(&li, 0x0, sizeof(LVITEMW));
1813 li.iItem = GetSelectedItem(GetDlgItem(hwndDlg, IDC_IPLIST));
1814 if (li.iItem < 0)
1815 {
1816 /* no item selected */
1818 SetFocus(GetDlgItem(hwndDlg, IDC_IPLIST));
1819 break;
1820 }
1821 Ip.bAdd = FALSE;
1822 Ip.hDlgCtrl = GetDlgItem(hwndDlg, IDC_IPLIST);
1823 if (GetIPListEntry(GetDlgItem(hwndDlg, IDC_IPLIST), li.iItem, &Ip))
1824 {
1826 if (res)
1827 {
1828 li.mask = LVIF_TEXT;
1829 li.pszText = Ip.szIP;
1831 li.pszText = Ip.szMask;
1832 li.iSubItem = 1;
1834 }
1835 }
1836 }
1837 else if (LOWORD(wParam) == IDC_IPDEL)
1838 {
1840 break;
1841 }
1842 else if (LOWORD(wParam) == IDC_GWADD)
1843 {
1844 Gw.bAdd = TRUE;
1845 Gw.hDlgCtrl = GetDlgItem(hwndDlg, IDC_GWLIST);
1847 if (res)
1848 {
1849 memset(&li, 0x0, sizeof(LVITEMW));
1850 li.mask = LVIF_TEXT;
1851 li.iItem = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_GWLIST));
1852 li.pszText = Gw.szIP;
1853 li.iItem = SendDlgItemMessageW(hwndDlg, IDC_GWLIST, LVM_INSERTITEMW, 0, (LPARAM)&li);
1854 if (li.iItem >= 0)
1855 {
1856 if (Gw.Metric)
1857 {
1858 _swprintf(szBuffer, L"%u", Gw.Metric);
1859 li.iSubItem = 1;
1860 li.pszText = szBuffer;
1862 }
1863 else
1864 {
1865 if (LoadStringW(netcfgx_hInstance, IDS_AUTOMATIC, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1866 {
1867 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1868 li.iSubItem = 1;
1869 li.pszText = szBuffer;
1871 }
1872 }
1873 }
1874 }
1875 break;
1876 }
1877 else if (LOWORD(wParam) == IDC_GWMOD)
1878 {
1879 memset(&li, 0x0, sizeof(LVITEMW));
1880 li.iItem = GetSelectedItem(GetDlgItem(hwndDlg, IDC_GWLIST));
1881 if (li.iItem < 0)
1882 {
1883 /* no item selected */
1885 SetFocus(GetDlgItem(hwndDlg, IDC_GWLIST));
1886 break;
1887 }
1888 if (GetGWListEntry(GetDlgItem(hwndDlg, IDC_GWLIST), li.iItem, &Gw))
1889 {
1890 Gw.bAdd = FALSE;
1891 Gw.hDlgCtrl = GetDlgItem(hwndDlg, IDC_GWLIST);
1893 if (res)
1894 {
1895 li.mask = LVIF_TEXT;
1896 li.pszText = Gw.szIP;
1898 if (Gw.Metric)
1899 {
1900 _swprintf(szBuffer, L"%u", Gw.Metric);
1901 li.iSubItem = 1;
1902 li.pszText = szBuffer;
1904 }
1905 else
1906 {
1907 if (LoadStringW(netcfgx_hInstance, IDS_AUTOMATIC, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1908 {
1909 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1910 li.iSubItem = 1;
1911 li.pszText = szBuffer;
1913 }
1914 }
1915 }
1916 }
1917 break;
1918 }
1919 else if (LOWORD(wParam) == IDC_GWDEL)
1920 {
1922 break;
1923 }
1924 break;
1925 }
1926 return FALSE;
1927}
1928
1929INT_PTR
1932 HWND hwndDlg,
1933 UINT uMsg,
1934 WPARAM wParam,
1936)
1937{
1938 TcpipDnsSettings * pSettings;
1939 WCHAR szBuffer[100];
1940 DWORD dwIpAddr;
1941 LPNMIPADDRESS lpnmipa;
1942
1943 switch(uMsg)
1944 {
1945 case WM_INITDIALOG:
1946 pSettings = (TcpipDnsSettings*)lParam;
1948 if (!pSettings->bAdd)
1949 {
1950 if (LoadStringW(netcfgx_hInstance, IDS_MOD, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1951 {
1952 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1953 SendDlgItemMessageW(hwndDlg, IDC_OK, WM_SETTEXT, 0, (LPARAM)szBuffer);
1954 }
1955 SendDlgItemMessageW(hwndDlg, IDC_IPADDR, WM_SETTEXT, 0, (LPARAM)pSettings->szIP);
1956 EnableWindow(GetDlgItem(hwndDlg, IDC_OK), TRUE);
1957 }
1958 else
1959 {
1960 if (LoadStringW(netcfgx_hInstance, IDS_ADD, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
1961 {
1962 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
1963 SendDlgItemMessageW(hwndDlg, IDC_OK, WM_SETTEXT, 0, (LPARAM)szBuffer);
1964 }
1965 EnableWindow(GetDlgItem(hwndDlg, IDC_OK), FALSE);
1966 }
1967 return TRUE;
1968 case WM_COMMAND:
1969 if (LOWORD(wParam) == IDCANCEL)
1970 {
1971 EndDialog(hwndDlg, FALSE);
1972 break;
1973 }
1974 else if (LOWORD(wParam) == IDC_OK)
1975 {
1976 pSettings = (TcpipDnsSettings*)GetWindowLongPtr(hwndDlg, DWLP_USER);
1977 SendDlgItemMessageW(hwndDlg, IDC_IPADDR, WM_GETTEXT, 16, (LPARAM)pSettings->szIP);
1978 if (SendMessageW(pSettings->hDlgCtrl, LB_FINDSTRING, 0, (LPARAM)pSettings->szIP) == LB_ERR)
1979 {
1980 if (pSettings->bAdd)
1981 SendMessageW(pSettings->hDlgCtrl, LB_ADDSTRING, 0, (LPARAM)pSettings->szIP);
1982 EndDialog(hwndDlg, TRUE);
1983 break;
1984 }
1985 if (!pSettings->bAdd)
1986 {
1987 EndDialog(hwndDlg, FALSE);
1988 break;
1989 }
1991 break;
1992 }
1993 break;
1994 case WM_NOTIFY:
1995 lpnmipa = (LPNMIPADDRESS) lParam;
1996 if (lpnmipa->hdr.code == IPN_FIELDCHANGED)
1997 {
1998 if (lpnmipa->hdr.idFrom == IDC_IPADDR)
1999 {
2000 if (SendDlgItemMessageW(hwndDlg, IDC_IPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
2001 EnableWindow(GetDlgItem(hwndDlg, IDC_OK), TRUE);
2002 }
2003 }
2004 break;
2005 }
2006 return FALSE;
2007}
2008
2009
2010
2011VOID
2013 HWND hwndDlg,
2015{
2016 WCHAR szBuffer[200];
2017 LPWSTR pFirst, pSep, pList;
2018 IP_ADDR * pAddr;
2019 DWORD dwIpAddr;
2020
2021 /* insert DNS addresses */
2022 pAddr = This->pCurrentAdapter->NewNs;
2023 while(pAddr)
2024 {
2025 dwIpAddr = pAddr->IpAddress;
2026 _swprintf(szBuffer, L"%lu.%lu.%lu.%lu",
2027 FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr), THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
2028
2029 SendDlgItemMessageW(hwndDlg, IDC_DNSADDRLIST, LB_ADDSTRING, 0, (LPARAM)szBuffer);
2030 pAddr = pAddr->Next;
2031 }
2033
2034 if (This->pCurrentAdapter->NewRegisterAdapterName)
2036 else
2038
2039 if (This->pCurrentAdapter->NewRegistrationEnabled)
2041
2042 if (This->pCurrentAdapter->szDomain[0])
2043 SendDlgItemMessageW(hwndDlg, IDC_SUFFIX, WM_SETTEXT, 0, (LPARAM)szBuffer);
2044
2045 if (This->pTcpIpSettings->UseDomainNameDevolution)
2047
2048 if (!This->pTcpIpSettings->szSearchList || (wcslen(This->pTcpIpSettings->szSearchList) == 0))
2049 {
2052
2053 return;
2054 }
2055
2056 pList = This->pTcpIpSettings->szSearchList;
2057 if (wcslen(pList))
2058 {
2059 pFirst = pList;
2060 do
2061 {
2062 pSep = wcschr(pFirst, L',');
2063 if (pSep)
2064 {
2065 pSep[0] = L'\0';
2067 pFirst = pSep + 1;
2068 pSep[0] = L',';
2069 }
2070 else
2071 {
2073 break;
2074 }
2075 }while(TRUE);
2076
2080 }
2081}
2082
2083VOID
2084ToggleUpDown(HWND hwndDlg, HWND hDlgCtrl, UINT UpButton, UINT DownButton, UINT ModButton, UINT DelButton)
2085{
2086 LRESULT lResult, lCount;
2087
2088 lResult = SendMessageW(hDlgCtrl, LB_GETCURSEL, 0, 0);
2089 lCount = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
2090 if (lResult != LB_ERR)
2091 {
2092 if (lResult == 0)
2093 EnableWindow(GetDlgItem(hwndDlg, UpButton), FALSE);
2094 else
2095 EnableWindow(GetDlgItem(hwndDlg, UpButton), TRUE);
2096
2097 if (lResult < lCount -1)
2098 EnableWindow(GetDlgItem(hwndDlg, DownButton), TRUE);
2099 else
2100 EnableWindow(GetDlgItem(hwndDlg, DownButton), FALSE);
2101 }
2102
2103 if (lCount)
2104 {
2105 EnableWindow(GetDlgItem(hwndDlg, ModButton), TRUE);
2106 EnableWindow(GetDlgItem(hwndDlg, DelButton), TRUE);
2107 }
2108 else
2109 {
2110 EnableWindow(GetDlgItem(hwndDlg, ModButton), FALSE);
2111 EnableWindow(GetDlgItem(hwndDlg, DelButton), FALSE);
2112 EnableWindow(GetDlgItem(hwndDlg, UpButton), FALSE);
2113 EnableWindow(GetDlgItem(hwndDlg, DownButton), FALSE);
2114 }
2115}
2116
2117VOID
2119 HWND hDlgCtrl,
2120 INT pos)
2121{
2122 WCHAR szBuffer[100];
2123 LRESULT lResult;
2124
2125 lResult = SendMessageW(hDlgCtrl, LB_GETCURSEL, 0, 0);
2126 if (lResult != LB_ERR)
2127 {
2128 if (SendMessageW(hDlgCtrl, LB_GETTEXTLEN, (WPARAM)lResult, 0) < sizeof(szBuffer)/sizeof(WCHAR) - 1)
2129 {
2130 if (SendMessageW(hDlgCtrl, LB_GETTEXT, (WPARAM)lResult, (LPARAM)szBuffer) != LB_ERR)
2131 {
2132 SendMessageW(hDlgCtrl, LB_DELETESTRING, (WPARAM)lResult, 0);
2133 SendMessageW(hDlgCtrl, LB_INSERTSTRING, (WPARAM)lResult + pos, (LPARAM)szBuffer);
2134 SendMessageW(hDlgCtrl, LB_SETCURSEL, (WPARAM)lResult + pos, 0);
2135 }
2136 }
2137 }
2138}
2139VOID
2141 HWND hDlgCtrl)
2142{
2143 LRESULT lResult, lCount;
2144
2145 lResult = SendMessageW(hDlgCtrl, LB_GETCURSEL, 0, 0);
2146 if (lResult != LB_ERR)
2147 {
2148 SendMessageW(hDlgCtrl, LB_DELETESTRING, (WPARAM)lResult, 0);
2149 lCount = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
2150 if (lResult + 1 < lCount)
2151 SendMessageW(hDlgCtrl, LB_SETCURSEL, (WPARAM)lResult, 0);
2152 else
2153 SendMessageW(hDlgCtrl, LB_SETCURSEL, (WPARAM)lCount-1, 0);
2154 }
2155}
2156
2157LPWSTR
2159 HWND hDlgCtrl)
2160{
2161 DWORD dwSize;
2162 INT iCount, iIndex;
2163 INT_PTR lResult;
2164 LPWSTR pszSearchList, pItem;
2165
2166 iCount = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
2167 if (!iCount || iCount == LB_ERR)
2168 return NULL; //BUGBUG
2169
2170 dwSize = 0;
2171
2172 for (iIndex = 0; iIndex < iCount; iIndex++)
2173 {
2174 lResult = SendMessageW(hDlgCtrl, LB_GETTEXTLEN, iIndex, 0);
2175 if (lResult == LB_ERR)
2176 return NULL;
2177
2178 dwSize += lResult + 1;
2179 }
2180
2181 pszSearchList = (LPWSTR)CoTaskMemAlloc((dwSize + 1) * sizeof(WCHAR));
2182 if (!pszSearchList)
2183 return NULL;
2184
2185 pItem = pszSearchList;
2186 for (iIndex = 0; iIndex < iCount; iIndex++)
2187 {
2188 lResult = SendMessageW(hDlgCtrl, LB_GETTEXT, iIndex, (LPARAM)pItem);
2189 if (lResult == LB_ERR)
2190 {
2191 CoTaskMemFree(pszSearchList);
2192 return NULL;
2193 }
2194 dwSize -= lResult + 1;
2195 pItem += wcslen(pItem);
2196 if (iIndex != iCount -1)
2197 {
2198 pItem[0] = L',';
2199 pItem++;
2200 }
2201 }
2202 pItem[0] = L'\0';
2203 return pszSearchList;
2204}
2205
2206VOID
2208 HWND hDlgCtrl,
2210{
2211 INT iCount, iIndex;
2212 WCHAR Ip[16];
2213 IP_ADDR *pCur, *pLast;
2214
2215 FreeIPAddr(This->pCurrentAdapter->NewNs);
2216 This->pCurrentAdapter->NewNs = NULL;
2217
2218 iCount = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
2219 if (!iCount || iCount == LB_ERR)
2220 {
2221 return;
2222 }
2223
2224 pLast = NULL;
2225 for(iIndex = 0; iIndex < iCount; iIndex++)
2226 {
2227 if (SendMessageW(hDlgCtrl, LB_GETTEXT, iIndex, (LPARAM)Ip) == LB_ERR)
2228 break;
2229
2230 pCur = CoTaskMemAlloc(sizeof(IP_ADDR));
2231 if (!pCur)
2232 break;
2233 ZeroMemory(pCur, sizeof(IP_ADDR));
2234 pCur->IpAddress = GetIpAddressFromStringW(Ip);
2235
2236 if (!pLast)
2237 This->pCurrentAdapter->NewNs = pCur;
2238 else
2239 pLast->Next = pCur;
2240
2241 pLast = pCur;
2242 pCur = pCur->Next;
2243 }
2244}
2245
2246INT_PTR
2249 HWND hwndDlg,
2250 UINT uMsg,
2251 WPARAM wParam,
2253)
2254{
2257 TcpipDnsSettings Dns;
2258 LRESULT lIndex, lLength;
2259 TcpipSuffixSettings Suffix;
2260 LPPSHNOTIFY lppsn;
2261 WCHAR szSuffix[100];
2262 WCHAR szFormat[200];
2263 WCHAR szBuffer[300];
2264
2265
2266 switch(uMsg)
2267 {
2268 case WM_INITDIALOG:
2270 This = (TcpipConfNotifyImpl*)page->lParam;
2275 return TRUE;
2276 case WM_NOTIFY:
2277 lppsn = (LPPSHNOTIFY) lParam;
2278 if (lppsn->hdr.code == PSN_KILLACTIVE)
2279 {
2280 if (IsDlgButtonChecked(hwndDlg, IDC_SELSUFFIX) == BST_CHECKED &&
2282 {
2285 return TRUE;
2286 }
2287 if (SendDlgItemMessageW(hwndDlg, IDC_SUFFIX, WM_GETTEXT, sizeof(szSuffix)/sizeof(WCHAR), (LPARAM)szSuffix))
2288 {
2289 szSuffix[(sizeof(szSuffix)/sizeof(WCHAR))-1] = L'\0';
2290 if (VerifyDNSSuffix(szSuffix) == FALSE)
2291 {
2292 if (LoadStringW(netcfgx_hInstance, IDS_DNS_SUFFIX, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
2293 {
2294 szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0';
2295 _swprintf(szBuffer, szFormat, szSuffix);
2296 if (LoadStringW(netcfgx_hInstance, IDS_TCPIP, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
2297 szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0';
2298 else
2299 szFormat[0] = L'\0';
2300
2301 MessageBoxW(hwndDlg, szBuffer, szFormat, MB_ICONWARNING);
2303 SetFocus(GetDlgItem(hwndDlg, IDC_SUFFIX));
2304 return TRUE;
2305 }
2306 }
2307 }
2308 }
2309 else if (lppsn->hdr.code == PSN_APPLY)
2310 {
2312
2315 {
2316 CoTaskMemFree(This->pTcpIpSettings->szSearchList);
2317 This->pTcpIpSettings->szSearchList = NULL;
2319 This->pTcpIpSettings->UseDomainNameDevolution = TRUE;
2320 else
2321 This->pTcpIpSettings->UseDomainNameDevolution = FALSE;
2322 }
2323 else
2324 {
2325 CoTaskMemFree(This->pTcpIpSettings->szSearchList);
2326 This->pTcpIpSettings->szSearchList = NULL;
2327 This->pTcpIpSettings->UseDomainNameDevolution = FALSE;
2328 This->pTcpIpSettings->szSearchList = GetListViewEntries(GetDlgItem(hwndDlg, IDC_DNSSUFFIXLIST));
2329 }
2330
2332 {
2333 This->pCurrentAdapter->NewRegisterAdapterName = TRUE;
2335 This->pCurrentAdapter->NewRegistrationEnabled = TRUE;
2336 else
2337 This->pCurrentAdapter->NewRegistrationEnabled = FALSE;
2338 }
2339 else
2340 {
2341 This->pCurrentAdapter->NewRegisterAdapterName = FALSE;
2342 This->pCurrentAdapter->NewRegistrationEnabled = FALSE;
2343 }
2344 }
2345 break;
2346 case WM_COMMAND:
2348 {
2350 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2351 break;
2352 }
2354 {
2356 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2357 break;
2358 }
2359 else if (LOWORD(wParam) == IDC_PRIMSUFFIX && HIWORD(wParam) == BN_CLICKED)
2360 {
2362 {
2370 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2371 }
2372 }
2373 else if (LOWORD(wParam) == IDC_SELSUFFIX && HIWORD(wParam) == BN_CLICKED)
2374 {
2376 {
2380 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2381 }
2382 break;
2383 }
2384 else if (LOWORD(wParam) == IDC_REGSUFFIX && HIWORD(wParam) == BN_CLICKED)
2385 {
2388 else
2390 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2391 }
2392 else if (LOWORD(wParam) == IDC_DNSADDRUP && HIWORD(wParam) == BN_CLICKED)
2393 {
2394 MoveItem(GetDlgItem(hwndDlg, IDC_DNSADDRLIST), -1);
2397 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2398 break;
2399 }
2401 {
2402 MoveItem(GetDlgItem(hwndDlg, IDC_DNSADDRLIST), 1);
2405 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2406 break;
2407 }
2409 {
2410 MoveItem(GetDlgItem(hwndDlg, IDC_DNSSUFFIXLIST), -1);
2413 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2414 break;
2415 }
2417 {
2421 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2422 break;
2423 }
2424 else if (LOWORD(wParam) == IDC_DNSADDRDEL && HIWORD(wParam) == BN_CLICKED)
2425 {
2429 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2430 break;
2431 }
2433 {
2437 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2438 break;
2439 }
2440 else if (LOWORD(wParam) == IDC_DNSADDRADD && HIWORD(wParam) == BN_CLICKED)
2441 {
2442 Dns.bAdd = TRUE;
2443 Dns.hDlgCtrl = GetDlgItem(hwndDlg, IDC_DNSADDRLIST);
2445 {
2447 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2448 }
2449 break;
2450 }
2451 else if (LOWORD(wParam) == IDC_DNSADDRMOD && HIWORD(wParam) == BN_CLICKED)
2452 {
2453 lIndex = SendDlgItemMessage(hwndDlg, IDC_DNSADDRLIST, LB_GETCURSEL, 0, 0);
2454 if (lIndex != LB_ERR)
2455 {
2456 Dns.bAdd = FALSE;
2457 Dns.hDlgCtrl = GetDlgItem(hwndDlg, IDC_DNSADDRLIST);
2460 {
2462 SendDlgItemMessageW(hwndDlg, IDC_DNSADDRLIST, LB_INSERTSTRING, lIndex, (LPARAM)Dns.szIP);
2463 SendDlgItemMessageW(hwndDlg, IDC_DNSADDRLIST, LB_SETCURSEL, lIndex, 0);
2465 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2466 }
2467 }
2468 break;
2469 }
2471 {
2472 Suffix.bAdd = TRUE;
2473 Suffix.hDlgCtrl = GetDlgItem(hwndDlg, IDC_DNSSUFFIXLIST);
2474 Suffix.Suffix = NULL;
2476 {
2478 lIndex = SendDlgItemMessageW(hwndDlg, IDC_DNSSUFFIXLIST, LB_ADDSTRING, 0, (LPARAM)Suffix.Suffix);
2479 if (lIndex != LB_ERR)
2482 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2483 CoTaskMemFree(Suffix.Suffix);
2484 }
2485 break;
2486 }
2488 {
2489 lIndex = SendDlgItemMessage(hwndDlg, IDC_DNSSUFFIXLIST, LB_GETCURSEL, 0, 0);
2490 if (lIndex != LB_ERR)
2491 {
2492 Suffix.bAdd = FALSE;
2493 Suffix.hDlgCtrl = GetDlgItem(hwndDlg, IDC_DNSSUFFIXLIST);
2494 lLength = SendMessageW(Suffix.hDlgCtrl, LB_GETTEXTLEN, lIndex, 0);
2495 if (lLength != LB_ERR)
2496 {
2497 Suffix.Suffix = (LPWSTR)CoTaskMemAlloc((lLength + 1) * sizeof(WCHAR));
2498 if (Suffix.Suffix)
2499 {
2500 SendMessageW(Suffix.hDlgCtrl, LB_GETTEXT, lIndex, (LPARAM)Suffix.Suffix);
2501 Suffix.Suffix[lLength] = L'\0';
2503 {
2504 if (Suffix.Suffix)
2505 {
2507 SendDlgItemMessageW(hwndDlg, IDC_DNSSUFFIXLIST, LB_INSERTSTRING, lIndex, (LPARAM)Suffix.Suffix);
2510 CoTaskMemFree(Suffix.Suffix);
2511 }
2513 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2514 }
2515 }
2516 }
2517 }
2518 break;
2519 }
2520 }
2521 return FALSE;
2522}
2523
2524static int CALLBACK
2526{
2527 // NOTE: This callback is needed to set large icon correctly.
2528 HICON hIcon;
2529 switch (uMsg)
2530 {
2531 case PSCB_INITIALIZED:
2532 {
2534 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
2535 break;
2536 }
2537 }
2538 return 0;
2539}
2540
2541VOID
2543 HWND hwndDlg,
2545{
2546 PROPSHEETHEADERW pinfo;
2547 HPROPSHEETPAGE hppages[3];
2548 WCHAR szBuffer[100];
2549
2553
2554
2555 if (LoadStringW(netcfgx_hInstance, IDS_TCPIP, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
2556 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
2557 else
2558 szBuffer[0] = L'\0';
2559
2560 ZeroMemory(&pinfo, sizeof(PROPSHEETHEADERW));
2561 pinfo.dwSize = sizeof(PROPSHEETHEADERW);
2562 pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE | PSH_NOAPPLYNOW |
2564 pinfo.u3.phpage = hppages;
2565 pinfo.nPages = 3;
2566 pinfo.hwndParent = hwndDlg;
2568 pinfo.pszCaption = szBuffer;
2570 pinfo.pfnCallback = PropSheetProc;
2571
2573 if (PropertySheetW(&pinfo) > 0)
2574 {
2576 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2577 }
2578}
2579
2580INT_PTR
2582 HWND hwndDlg,
2584 BOOL bApply)
2585{
2586 DWORD dwAddr;
2587
2589 {
2590 if (SendDlgItemMessageW(hwndDlg, IDC_ALTIPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwAddr) != 4)
2591 {
2592 if (bApply)
2593 {
2596 return E_FAIL;
2597 }
2598 }
2599
2600 if (SendDlgItemMessageW(hwndDlg, IDC_ALTSUBNETMASK, IPM_GETADDRESS, 0, (LPARAM)&dwAddr) != 4)
2601 {
2602 if (bApply)
2604 if (SendDlgItemMessageW(hwndDlg, IDC_ALTIPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwAddr) == 4)
2605 {
2606 if (dwAddr <= MAKEIPADDRESS(127, 255, 255, 255))
2607 dwAddr = MAKEIPADDRESS(255, 0, 0, 0);
2608 else if (dwAddr <= MAKEIPADDRESS(191, 255, 255, 255))
2609 dwAddr = MAKEIPADDRESS(255, 255, 0, 0);
2610 else if (dwAddr <= MAKEIPADDRESS(223, 255, 255, 255))
2611 dwAddr = MAKEIPADDRESS(255, 255, 255, 0);
2612
2614 }
2615 if (bApply)
2616 {
2618 return E_FAIL;
2619 }
2620 }
2621
2622 if (SendDlgItemMessageW(hwndDlg, IDC_ALTIPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwAddr) == 4)
2623 This->pCurrentAdapter->AltConfig.IpAddress = dwAddr;
2624
2625 if (SendDlgItemMessageW(hwndDlg, IDC_ALTSUBNETMASK, IPM_GETADDRESS, 0, (LPARAM)&dwAddr) == 4)
2626 This->pCurrentAdapter->AltConfig.SubnetMask = dwAddr;
2627
2628 if (SendDlgItemMessageW(hwndDlg, IDC_ALTDEFGATEWAY, IPM_GETADDRESS, 0, (LPARAM)&dwAddr) == 4)
2629 This->pCurrentAdapter->AltConfig.DefaultGateway = dwAddr;
2630
2631 if (SendDlgItemMessageW(hwndDlg, IDC_ALTDNS1, IPM_GETADDRESS, 0, (LPARAM)&dwAddr) == 4)
2632 This->pCurrentAdapter->AltConfig.DnsServer1 = dwAddr;
2633
2634 if (SendDlgItemMessageW(hwndDlg, IDC_ALTDNS2, IPM_GETADDRESS, 0, (LPARAM)&dwAddr) == 4)
2635 This->pCurrentAdapter->AltConfig.DnsServer2 = dwAddr;
2636 }
2637 else
2638 {
2639 ZeroMemory(&This->pCurrentAdapter->AltConfig, sizeof(AlternateConfiguration));
2640 }
2641
2642 return S_OK;
2643}
2644
2645
2646
2647HRESULT
2649 HWND hwndDlg,
2651{
2656
2661
2666
2671
2676
2677 if (This->pCurrentAdapter->AltConfig.IpAddress == 0)
2678 {
2685 }
2686 else
2687 {
2689
2690 /* Set ip address */
2691 if (This->pCurrentAdapter->AltConfig.IpAddress)
2692 SendDlgItemMessageW(hwndDlg, IDC_ALTIPADDR, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->AltConfig.IpAddress);
2693
2694 /* Set subnet mask */
2695 if (This->pCurrentAdapter->AltConfig.SubnetMask)
2696 SendDlgItemMessageW(hwndDlg, IDC_ALTSUBNETMASK, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->AltConfig.SubnetMask);
2697
2698 /* Set default gateway */
2699 if (This->pCurrentAdapter->AltConfig.DefaultGateway)
2700 SendDlgItemMessageW(hwndDlg, IDC_ALTDEFGATEWAY, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->AltConfig.DefaultGateway);
2701
2702 /* Set primary dns server */
2703 if (This->pCurrentAdapter->AltConfig.DnsServer1)
2704 SendDlgItemMessageW(hwndDlg, IDC_ALTDNS1, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->AltConfig.DnsServer1);
2705
2706 /* Set secondary dns server */
2707 if (This->pCurrentAdapter->AltConfig.DnsServer2)
2708 SendDlgItemMessageW(hwndDlg, IDC_ALTDNS2, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->AltConfig.DnsServer2);
2709 }
2710
2711 return S_OK;
2712}
2713
2714INT_PTR
2717 HWND hwndDlg,
2718 UINT uMsg,
2719 WPARAM wParam,
2720 LPARAM lParam)
2721{
2724 LPNMIPADDRESS lpnmipa;
2725 LPPSHNOTIFY lppsn;
2726
2727 switch (uMsg)
2728 {
2729 case WM_INITDIALOG:
2730 {
2732 This = (TcpipConfNotifyImpl*)page->lParam;
2735 return TRUE;
2736 }
2737 case WM_NOTIFY:
2738 lppsn = (LPPSHNOTIFY) lParam;
2739 lpnmipa = (LPNMIPADDRESS) lParam;
2740 if (lpnmipa->hdr.code == IPN_FIELDCHANGED)
2741 {
2742 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2743 if (lpnmipa->hdr.idFrom == IDC_ALTIPADDR)
2744 {
2745 DWORD dwIpAddr;
2746
2747 if (SendDlgItemMessageW(hwndDlg, IDC_ALTIPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
2748 {
2749 if (dwIpAddr <= MAKEIPADDRESS(127, 255, 255, 255))
2751 else if (dwIpAddr <= MAKEIPADDRESS(191, 255, 255, 255))
2753 else if (dwIpAddr <= MAKEIPADDRESS(223, 255, 255, 255))
2755 }
2756 }
2757 }
2758 else if (lppsn->hdr.code == PSN_APPLY)
2759 {
2763 else
2765
2766 return TRUE;
2767 }
2768 break;
2769
2770 case WM_COMMAND:
2771 {
2772 switch (LOWORD(wParam))
2773 {
2774 case IDC_ALTAPIPA:
2775 case IDC_ALTSTATIC:
2776 {
2777 if (HIWORD(wParam) == BN_CLICKED)
2778 {
2779 BOOL bStatic = (IsDlgButtonChecked(hwndDlg, IDC_ALTSTATIC) == BST_CHECKED);
2780 if (bStatic)
2781 {
2787 }
2788
2789 EnableWindow(GetDlgItem(hwndDlg, IDC_ALTIPADDR), bStatic);
2790 EnableWindow(GetDlgItem(hwndDlg, IDC_ALTSUBNETMASK), bStatic);
2791 EnableWindow(GetDlgItem(hwndDlg, IDC_ALTDEFGATEWAY), bStatic);
2792 EnableWindow(GetDlgItem(hwndDlg, IDC_ALTDNS1), bStatic);
2793 EnableWindow(GetDlgItem(hwndDlg, IDC_ALTDNS2), bStatic);
2794
2795 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2796 }
2797 break;
2798 }
2799 }
2800 break;
2801 }
2802 }
2803 return FALSE;
2804}
2805
2806VOID
2808 HWND hDlg,
2810{
2811 HPROPSHEETPAGE hpage;
2812
2814 if (!hpage)
2815 return;
2816
2817 SendMessageW(hDlg, PSM_INSERTPAGE, 1, (LPARAM)hpage);
2818}
2819
2820INT_PTR
2822 HWND hwndDlg,
2824 BOOL bApply)
2825{
2826 DWORD dwIpAddr;
2827
2828 if (IsDlgButtonChecked(hwndDlg, IDC_NODHCP) == BST_CHECKED)
2829 {
2830 This->pCurrentAdapter->NewDhcpEnabled = FALSE;
2831
2832 if (SendDlgItemMessageW(hwndDlg, IDC_IPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) != 4)
2833 {
2834 if (bApply)
2835 {
2837 SetFocus(GetDlgItem(hwndDlg, IDC_IPADDR));
2838 return E_FAIL;
2839 }
2840 }
2841 if (!This->pCurrentAdapter->NewIp)
2842 {
2843 This->pCurrentAdapter->NewIp = (IP_ADDR*)CoTaskMemAlloc(sizeof(IP_ADDR));
2844 if (!This->pCurrentAdapter->NewIp)
2845 return E_OUTOFMEMORY;
2846 ZeroMemory(This->pCurrentAdapter->NewIp, sizeof(IP_ADDR));
2847 }
2848 This->pCurrentAdapter->NewIp->IpAddress = dwIpAddr;
2849
2850 if (SendDlgItemMessageW(hwndDlg, IDC_SUBNETMASK, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) != 4)
2851 {
2852 if (bApply)
2854 if (SendDlgItemMessageW(hwndDlg, IDC_IPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
2855 {
2856 if (dwIpAddr <= MAKEIPADDRESS(127, 255, 255, 255))
2857 dwIpAddr = MAKEIPADDRESS(255, 0, 0, 0);
2858 else if (dwIpAddr <= MAKEIPADDRESS(191, 255, 255, 255))
2859 dwIpAddr = MAKEIPADDRESS(255, 255, 0, 0);
2860 else if (dwIpAddr <= MAKEIPADDRESS(223, 255, 255, 255))
2861 dwIpAddr = MAKEIPADDRESS(255, 255, 255, 0);
2862
2864 }
2865 if (bApply)
2866 {
2868 return E_FAIL;
2869 }
2870 }
2871 /* store subnetmask */
2872 This->pCurrentAdapter->NewIp->u.SubnetMask = dwIpAddr;
2873
2874 if (SendDlgItemMessageW(hwndDlg, IDC_DEFGATEWAY, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
2875 {
2876 if (!This->pCurrentAdapter->NewGw)
2877 {
2878 This->pCurrentAdapter->NewGw = (IP_ADDR*)CoTaskMemAlloc(sizeof(IP_ADDR));
2879 if (!This->pCurrentAdapter->NewGw)
2880 return E_OUTOFMEMORY;
2881 ZeroMemory(This->pCurrentAdapter->NewGw, sizeof(IP_ADDR));
2882 }
2883
2884 /* store default gateway */
2885 This->pCurrentAdapter->NewGw->IpAddress = dwIpAddr;
2886 }
2887 }
2888 else
2889 {
2890 This->pCurrentAdapter->NewDhcpEnabled = TRUE;
2891
2892 /* Delete all configured ip addresses */
2893 if (This->pCurrentAdapter->NewIp)
2894 {
2895 IP_ADDR * pNextIp = This->pCurrentAdapter->NewIp->Next;
2896 CoTaskMemFree(This->pCurrentAdapter->NewIp);
2897 This->pCurrentAdapter->NewIp = pNextIp;
2898 }
2899
2900 /* Delete all configured gateway addresses */
2901 if (This->pCurrentAdapter->NewGw)
2902 {
2903 IP_ADDR * pNextGw = This->pCurrentAdapter->NewGw->Next;
2904 CoTaskMemFree(This->pCurrentAdapter->NewGw);
2905 This->pCurrentAdapter->NewGw = pNextGw;
2906 }
2907 }
2908
2910 {
2911 This->pCurrentAdapter->DnsDhcpEnabled = FALSE;
2912
2913 BOOL bSkip = FALSE;
2914 if (SendDlgItemMessageW(hwndDlg, IDC_DNS1, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
2915 {
2916 if (!This->pCurrentAdapter->NewNs)
2917 {
2918 This->pCurrentAdapter->NewNs = (IP_ADDR*)CoTaskMemAlloc(sizeof(IP_ADDR));
2919 if (!This->pCurrentAdapter->NewNs)
2920 return E_OUTOFMEMORY;
2921 ZeroMemory(This->pCurrentAdapter->NewNs, sizeof(IP_ADDR));
2922 }
2923 This->pCurrentAdapter->NewNs->IpAddress = dwIpAddr;
2924 }
2925 else if (This->pCurrentAdapter->NewNs)
2926 {
2927 IP_ADDR *pTemp = This->pCurrentAdapter->NewNs->Next;
2928
2929 CoTaskMemFree(This->pCurrentAdapter->NewNs);
2930 This->pCurrentAdapter->NewNs = pTemp;
2931 bSkip = TRUE;
2932 }
2933
2934 if (SendDlgItemMessageW(hwndDlg, IDC_DNS2, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
2935 {
2936 if (!This->pCurrentAdapter->NewNs || bSkip)
2937 {
2938 if (!This->pCurrentAdapter->NewNs)
2939 {
2940 This->pCurrentAdapter->NewNs = (IP_ADDR*)CoTaskMemAlloc(sizeof(IP_ADDR));
2941 if (!This->pCurrentAdapter->NewNs)
2942 return E_OUTOFMEMORY;
2943 ZeroMemory(This->pCurrentAdapter->NewNs, sizeof(IP_ADDR));
2944 }
2945 This->pCurrentAdapter->NewNs->IpAddress = dwIpAddr;
2946 }
2947 else if (!This->pCurrentAdapter->NewNs->Next)
2948 {
2949 This->pCurrentAdapter->NewNs->Next = (IP_ADDR*)CoTaskMemAlloc(sizeof(IP_ADDR));
2950 if (!This->pCurrentAdapter->NewNs->Next)
2951 return E_OUTOFMEMORY;
2952 ZeroMemory(This->pCurrentAdapter->NewNs->Next, sizeof(IP_ADDR));
2953 This->pCurrentAdapter->NewNs->Next->IpAddress = dwIpAddr;
2954 }
2955 else
2956 {
2957 This->pCurrentAdapter->NewNs->Next->IpAddress = dwIpAddr;
2958 }
2959 }
2960 else
2961 {
2962 if (This->pCurrentAdapter->NewNs && This->pCurrentAdapter->NewNs->Next)
2963 {
2964 if (This->pCurrentAdapter->NewNs->Next->Next)
2965 {
2966 IP_ADDR *pTemp = This->pCurrentAdapter->NewNs->Next->Next;
2967 CoTaskMemFree(This->pCurrentAdapter->NewNs->Next);
2968 This->pCurrentAdapter->NewNs->Next = pTemp;
2969 }
2970 else
2971 {
2972 CoTaskMemFree(This->pCurrentAdapter->NewNs->Next);
2973 This->pCurrentAdapter->NewNs->Next = NULL;
2974 }
2975 }
2976 }
2977 }
2978 else
2979 {
2980 This->pCurrentAdapter->DnsDhcpEnabled = TRUE;
2981
2982 /* Delete all configured name server addresses */
2983 if (This->pCurrentAdapter->NewNs)
2984 {
2985 IP_ADDR * pNextNs = This->pCurrentAdapter->NewNs->Next;
2986 CoTaskMemFree(This->pCurrentAdapter->NewNs);
2987 This->pCurrentAdapter->NewNs = pNextNs;
2988 }
2989 }
2990
2991 return S_OK;
2992}
2993
2994HRESULT
2996 HWND hwndDlg,
2998{
3003
3008
3013
3018
3023
3024 if (This->pCurrentAdapter == NULL)
3025 return E_FAIL;
3026
3027 if (This->pCurrentAdapter->NewDhcpEnabled)
3028 {
3034 }
3035 else
3036 {
3038
3039 if (This->pCurrentAdapter->NewIp)
3040 {
3041 /* set current ip address */
3042 SendDlgItemMessageA(hwndDlg, IDC_IPADDR, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->NewIp->IpAddress);
3043 /* set current hostmask */
3044 SendDlgItemMessageA(hwndDlg, IDC_SUBNETMASK, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->NewIp->u.SubnetMask);
3045 }
3046
3047 if (This->pCurrentAdapter->NewGw && This->pCurrentAdapter->NewGw->IpAddress)
3048 {
3049 /* set current gateway */
3050 SendDlgItemMessageA(hwndDlg, IDC_DEFGATEWAY, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->NewGw->IpAddress);
3051 }
3052 }
3053
3054 if (This->pCurrentAdapter->DnsDhcpEnabled)
3055 {
3059 }
3060 else
3061 {
3065 if (This->pCurrentAdapter->NewNs)
3066 {
3067 SendDlgItemMessageW(hwndDlg, IDC_DNS1, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->NewNs->IpAddress);
3068 if (This->pCurrentAdapter->NewNs->Next)
3069 {
3070 SendDlgItemMessageW(hwndDlg, IDC_DNS2, IPM_SETADDRESS, 0, (LPARAM)This->pCurrentAdapter->NewNs->Next->IpAddress);
3071 }
3072 else
3073 {
3075 }
3076 }
3077 else
3078 {
3081 }
3082 }
3083
3084 return S_OK;
3085}
3086
3087INT_PTR
3090 HWND hwndDlg,
3091 UINT uMsg,
3092 WPARAM wParam,
3094)
3095{
3098 LPNMIPADDRESS lpnmipa;
3099 LPPSHNOTIFY lppsn;
3100 DWORD dwIpAddr;
3101
3102
3103 switch(uMsg)
3104 {
3105 case WM_INITDIALOG:
3107 This = (TcpipConfNotifyImpl*)page->lParam;
3108 if (This->pCurrentAdapter)
3111 return TRUE;
3112 case WM_NOTIFY:
3113 lppsn = (LPPSHNOTIFY) lParam;
3114 lpnmipa = (LPNMIPADDRESS) lParam;
3115 if (lpnmipa->hdr.code == IPN_FIELDCHANGED)
3116 {
3117 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
3118 if (lpnmipa->hdr.idFrom == IDC_IPADDR)
3119 {
3120 if (SendDlgItemMessageW(hwndDlg, IDC_IPADDR, IPM_GETADDRESS, 0, (LPARAM)&dwIpAddr) == 4)
3121 {
3122 if (dwIpAddr <= MAKEIPADDRESS(127, 255, 255, 255))
3124 else if (dwIpAddr <= MAKEIPADDRESS(191, 255, 255, 255))
3126 else if (dwIpAddr <= MAKEIPADDRESS(223, 255, 255, 255))
3127 SendDlgItemMessageW(hwndDlg, IDC_SUBNETMASK, IPM_SETADDRESS, 0, (LPARAM)MAKEIPADDRESS(255, 255, 255, 0));
3128 }
3129 }
3130 }
3131 else if (lppsn->hdr.code == PSN_APPLY)
3132 {
3136 else
3138
3139 return TRUE;
3140 }
3141 break;
3142 case WM_COMMAND:
3143 if (HIWORD(wParam) == BN_CLICKED)
3144 {
3145 switch (LOWORD(wParam))
3146 {
3147 case IDC_USEDHCP:
3148 if (SendMessageW(GetParent(hwndDlg), PSM_INDEXTOID, 1, 0) == 0)
3149 {
3150 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
3159 }
3160 break;
3161 case IDC_NODHCP:
3162 if (SendMessageW(GetParent(hwndDlg), PSM_INDEXTOID, 1, 0) != 0)
3163 {
3164 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
3169 {
3171 }
3176 SendMessageW(GetParent(hwndDlg), PSM_REMOVEPAGE, 1, 0);
3177 }
3178 break;
3179 case IDC_AUTODNS:
3180 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
3185 break;
3186 case IDC_FIXEDDNS:
3187 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
3190 break;
3191 case IDC_ADVANCED:
3193 break;
3194 }
3195 break;
3196 }
3197 default:
3198 break;
3199
3200 }
3201 return FALSE;
3202}
3203
3204VOID
3207{
3208 AdapterSettings *pAdapter;
3209 IP_ADDR *NextIp;
3210
3211 if (This == NULL)
3212 return;
3213
3214 if (This->pTcpIpSettings)
3215 {
3216 if (This->pTcpIpSettings->szSearchList)
3217 CoTaskMemFree(This->pTcpIpSettings->szSearchList);
3218
3219 CoTaskMemFree(This->pTcpIpSettings);
3220 }
3221
3222 while (This->pAdapterListHead)
3223 {
3224 pAdapter = This->pAdapterListHead;
3225
3226 /* Free IpAdresses */
3227 while (pAdapter->NewIp)
3228 {
3229 NextIp = pAdapter->NewIp->Next;
3230 CoTaskMemFree(pAdapter->NewIp);
3231 pAdapter->NewIp = NextIp;
3232 }
3233
3234 while (pAdapter->OldIp)
3235 {
3236 NextIp = pAdapter->OldIp->Next;
3237 CoTaskMemFree(pAdapter->OldIp);
3238 pAdapter->OldIp = NextIp;
3239 }
3240
3241 /* Free Gateways */
3242 while (pAdapter->NewGw)
3243 {
3244 NextIp = pAdapter->NewGw->Next;
3245 CoTaskMemFree(pAdapter->NewGw);
3246 pAdapter->NewGw = NextIp;
3247 }
3248
3249 while (pAdapter->OldGw)
3250 {
3251 NextIp = pAdapter->OldGw->Next;
3252 CoTaskMemFree(pAdapter->OldGw);
3253 pAdapter->OldGw = NextIp;
3254 }
3255
3256 /* Free NameServers */
3257 while (pAdapter->NewNs)
3258 {
3259 NextIp = pAdapter->NewNs->Next;
3260 CoTaskMemFree(pAdapter->NewNs);
3261 pAdapter->NewNs = NextIp;
3262 }
3263
3264 while (pAdapter->OldNs)
3265 {
3266 NextIp = pAdapter->OldNs->Next;
3267 CoTaskMemFree(pAdapter->OldNs);
3268 pAdapter->OldNs = NextIp;
3269 }
3270
3271 if (pAdapter->szTCPAllowedPorts)
3273
3274 if (pAdapter->szUDPAllowedPorts)
3276
3277 if (pAdapter->szRawIPAllowedProtocols)
3279
3280
3281 This->pAdapterListHead = pAdapter->pNext;
3282 CoTaskMemFree(pAdapter);
3283 }
3284
3285 This->pAdapterListTail = NULL;
3286 This->pCurrentAdapter = NULL;
3287}
3288
3289static
3290BOOL
3292 AdapterSettings *pAdapter)
3293{
3294 IP_ADDR *pNew, *pOld;
3295 BOOL Changed = FALSE;
3296
3297 pNew = pAdapter->NewIp;
3298 pOld = pAdapter->OldIp;
3299 while (pNew && pOld)
3300 {
3301 if ((pNew->IpAddress != pOld->IpAddress) ||
3302 (pNew->u.SubnetMask != pOld->u.SubnetMask))
3303 {
3304 Changed = TRUE;
3305 break;
3306 }
3307
3308 pNew = pNew->Next;
3309 pOld = pOld->Next;
3310 }
3311
3312 if (Changed == FALSE)
3313 {
3314 if (((pNew == NULL) && (pOld != NULL)) ||
3315 ((pNew != NULL) && (pOld == NULL)))
3316 Changed = TRUE;
3317 }
3318
3319 return Changed;
3320}
3321
3322static
3323BOOL
3325 AdapterSettings *pAdapter)
3326{
3327 IP_ADDR *pNew, *pOld;
3328 BOOL Changed = FALSE;
3329
3330 pNew = pAdapter->NewGw;
3331 pOld = pAdapter->OldGw;
3332 while (pNew && pOld)
3333 {
3334 if ((pNew->IpAddress != pOld->IpAddress) ||
3335 (pNew->u.Metric != pOld->u.Metric))
3336 {
3337 Changed = TRUE;
3338 break;
3339 }
3340
3341 pNew = pNew->Next;
3342 pOld = pOld->Next;
3343 }
3344
3345 if (Changed == FALSE)
3346 {
3347 if (((pNew == NULL) && (pOld != NULL)) ||
3348 ((pNew != NULL) && (pOld == NULL)))
3349 Changed = TRUE;
3350 }
3351
3352 return Changed;
3353}
3354
3355static
3356BOOL
3358 AdapterSettings *pAdapter)
3359{
3360 IP_ADDR *pNew, *pOld;
3361 BOOL Changed = FALSE;
3362
3363 pNew = pAdapter->NewNs;
3364 pOld = pAdapter->OldNs;
3365 while (pNew && pOld)
3366 {
3367 if (pNew->IpAddress != pOld->IpAddress)
3368 {
3369 Changed = TRUE;
3370 break;
3371 }
3372
3373 pNew = pNew->Next;
3374 pOld = pOld->Next;
3375 }
3376
3377 if (Changed == FALSE)
3378 {
3379 if (((pNew == NULL) && (pOld != NULL)) ||
3380 ((pNew != NULL) && (pOld == NULL)))
3381 Changed = TRUE;
3382 }
3383
3384 return Changed;
3385}
3386
3387/***************************************************************
3388 * INetCfgComponentPropertyUi interface
3389 */
3390
3391HRESULT
3392WINAPI
3394 INetCfgComponentPropertyUi *iface,
3395 REFIID iid,
3396 LPVOID *ppvObj)
3397{
3398 TRACE("INetCfgComponentPropertyUi_fnQueryInterface()\n");
3400 return INetCfgComponentControl_QueryInterface((INetCfgComponentControl*)This, iid, ppvObj);
3401}
3402
3403ULONG
3404WINAPI
3406 INetCfgComponentPropertyUi *iface)
3407{
3408 TRACE("INetCfgComponentPropertyUi_fnAddRef()\n");
3410 return INetCfgComponentControl_AddRef((INetCfgComponentControl*)This);
3411}
3412
3413ULONG
3414WINAPI
3416 INetCfgComponentPropertyUi *iface)
3417{
3418 TRACE("INetCfgComponentPropertyUi_fnRelease()\n");
3420 return INetCfgComponentControl_Release((INetCfgComponentControl*)This);
3421}
3422
3423HRESULT
3424WINAPI
3426 INetCfgComponentPropertyUi * iface,
3428{
3429 TRACE("INetCfgComponentPropertyUi_fnQueryPropertyUi()\n");
3430 return S_OK;
3431}
3432
3433HRESULT
3434WINAPI
3436 INetCfgComponentPropertyUi * iface,
3438{
3439 TRACE("INetCfgComponentPropertyUi_fnSetContext()\n");
3440 INetLanConnectionUiInfo * pLanInfo;
3441 GUID Guid;
3442 LPOLESTR pAdapterName = NULL;
3443 AdapterSettings *pAdapter = NULL;
3444 HRESULT hr;
3446
3447 if (!iface || !pUnkReserved)
3448 return E_POINTER;
3449
3450 if (pUnkReserved)
3451 {
3452 hr = IUnknown_QueryInterface(pUnkReserved, &IID_INetLanConnectionUiInfo, (LPVOID*)&pLanInfo);
3453 if (FAILED(hr))
3454 return hr;
3455
3457
3458 IUnknown_Release(pUnkReserved);
3459
3460 StringFromCLSID(&Guid, &pAdapterName);
3461
3462 pAdapter = This->pAdapterListHead;
3463 while (pAdapter)
3464 {
3465 if (!_wcsicmp(pAdapter->AdapterName, pAdapterName))
3466 {
3467 This->pCurrentAdapter = pAdapter;
3468 break;
3469 }
3470 pAdapter = pAdapter->pNext;
3471 }
3472
3473 CoTaskMemFree(pAdapterName);
3474 }
3475 else
3476 {
3477 This->pCurrentAdapter = NULL;
3478 }
3479
3480 This->pUnknown = pUnkReserved;
3481
3482 return S_OK;
3483}
3484
3485LPWSTR
3487{
3488 DWORD dwSize;
3489 LPWSTR pData;
3490
3492 return NULL;
3493
3495 if (!pData)
3496 return NULL;
3497
3499 {
3501 return NULL;
3502 }
3503 *Size = dwSize;
3504 return pData;
3505}
3506
3507HRESULT
3510{
3511 TcpipSettings *pSettings;
3512 HKEY hKey = NULL;
3513 DWORD dwSize, dwVal;
3514 HRESULT hr = S_OK;
3515
3516 pSettings = (TcpipSettings*)CoTaskMemAlloc(sizeof(TcpipSettings));
3517 if (!pSettings)
3518 return E_FAIL;
3519
3520 ZeroMemory(pSettings, sizeof(TcpipSettings));
3521
3522 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
3523 {
3524 hr = E_FAIL;
3525 goto done;
3526 }
3527
3528 dwSize = sizeof(DWORD);
3529 RegQueryValueExW(hKey, L"UseDomainNameDevolution", NULL, NULL, (LPBYTE)&pSettings->UseDomainNameDevolution, &dwSize);
3530
3531 dwSize = 0;
3532 RegQueryValueExW(hKey, L"SearchList", NULL, NULL, NULL, &dwSize);
3533 if (dwSize)
3534 {
3536 if (pSettings->szSearchList)
3537 {
3538 if (RegQueryValueExW(hKey, L"SearchList", NULL, NULL, (LPBYTE)pSettings->szSearchList, &dwSize) != ERROR_SUCCESS)
3539 {
3540 CoTaskMemFree(pSettings->szSearchList);
3541 pSettings->szSearchList = NULL;
3542 }
3543 }
3544 }
3545
3546 dwSize = sizeof(DWORD);
3547 if (RegQueryValueExW(hKey, L"EnableSecurityFilters", NULL, NULL, (LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
3548 pSettings->EnableSecurityFilters = dwVal;
3549
3550done:
3551 if (hKey)
3553
3554 if (hr == S_OK)
3555 {
3556 This->pTcpIpSettings = pSettings;
3557 }
3558 else
3559 {
3560 CoTaskMemFree(pSettings);
3561 }
3562
3563 return hr;
3564}
3565
3566HRESULT
3568 HKEY hAdapterKey,
3569 AdapterSettings *pAdapter)
3570{
3571 PWSTR pszBuffer1 = NULL, pszBuffer2 = NULL, pStart1, pStart2, pEnd1, pEnd2;
3572 DWORD dwSize;
3573 IN_ADDR Address, SubnetMask;
3574 IP_ADDR *pNewAddrEntry, *pOldAddrEntry, *pNewLast = NULL, *pOldLast = NULL;
3575 HRESULT hr = S_OK;
3577
3578 TRACE("LoadAddressSettings()\n");
3579
3580 dwSize = 0;
3581 RegQueryValueExW(hAdapterKey, L"IpAddress", NULL, NULL, NULL, &dwSize);
3582 if (dwSize == 0)
3583 return S_OK;
3584
3585 pszBuffer1 = CoTaskMemAlloc(dwSize);
3586 if (pszBuffer1 == NULL)
3587 {
3588 hr = E_OUTOFMEMORY;
3589 goto done;
3590 }
3591
3592 if (RegQueryValueExW(hAdapterKey, L"IpAddress", NULL, NULL, (PBYTE)pszBuffer1, &dwSize) != ERROR_SUCCESS)
3593 {
3594 hr = E_FAIL;
3595 goto done;
3596 }
3597
3598 dwSize = 0;
3599 RegQueryValueExW(hAdapterKey, L"SubnetMask", NULL, NULL, NULL, &dwSize);
3600 if (dwSize == 0)
3601 return S_OK;
3602
3603 pszBuffer2 = CoTaskMemAlloc(dwSize);
3604 if (pszBuffer2 == NULL)
3605 {
3606 hr = E_OUTOFMEMORY;
3607 goto done;
3608 }
3609
3610 if (RegQueryValueExW(hAdapterKey, L"SubnetMask", NULL, NULL, (PBYTE)pszBuffer2, &dwSize) != ERROR_SUCCESS)
3611 {
3612 hr = E_FAIL;
3613 goto done;
3614 }
3615
3616 pStart1 = pszBuffer1;
3617 pStart2 = pszBuffer2;
3618 for (;;)
3619 {
3620 TRACE("Start1: %S\n", pStart1);
3621 TRACE("Start2: %S\n", pStart2);
3622 Status = RtlIpv4StringToAddressW(pStart1, TRUE, (LPCWSTR *)&pEnd1, &Address);
3623 if (Status != 0)
3624 {
3625 ERR("RtlIpv4StringToAddressW Status 0x%08lx\n", Status);
3626 hr = E_FAIL;
3627 break;
3628 }
3629
3630 TRACE("Adress: %lx\n", Address.S_un.S_addr);
3631
3632 Status = RtlIpv4StringToAddressW(pStart2, TRUE, (LPCWSTR *)&pEnd2, &SubnetMask);
3633 if (Status != 0)
3634 {
3635 ERR("RtlIpv4StringToAddressW Status 0x%08lx\n", Status);
3636 hr = E_FAIL;
3637 break;
3638 }
3639
3640 TRACE("SubnetMask: %lx\n", SubnetMask.S_un.S_addr);
3641
3642 pNewAddrEntry = CoTaskMemAlloc(sizeof(IP_ADDR));
3643 if (pNewAddrEntry)
3644 {
3645 ZeroMemory(pNewAddrEntry, sizeof(IP_ADDR));
3646 pNewAddrEntry->IpAddress = ntohl(Address.S_un.S_addr);
3647 pNewAddrEntry->u.SubnetMask = ntohl(SubnetMask.S_un.S_addr);;
3648
3649 if (!pNewLast)
3650 pAdapter->NewIp = pNewAddrEntry;
3651 else
3652 pNewLast->Next = pNewAddrEntry;
3653
3654 pNewLast = pNewAddrEntry;
3655 }
3656
3657 pOldAddrEntry = CoTaskMemAlloc(sizeof(IP_ADDR));
3658 if (pOldAddrEntry)
3659 {
3660 ZeroMemory(pOldAddrEntry, sizeof(IP_ADDR));
3661 pOldAddrEntry->IpAddress = ntohl(Address.S_un.S_addr);
3662 pOldAddrEntry->u.SubnetMask = ntohl(SubnetMask.S_un.S_addr);;
3663
3664 if (!pOldLast)
3665 pAdapter->OldIp = pOldAddrEntry;
3666 else
3667 pOldLast->Next = pOldAddrEntry;
3668
3669 pOldLast = pOldAddrEntry;
3670 }
3671
3672 pStart1 = pEnd1 + 1;
3673 pStart2 = pEnd2 + 1;
3674
3675 if ((*pStart1 == UNICODE_NULL) || (*pStart2 == UNICODE_NULL))
3676 break;
3677 }
3678
3679done:
3680 if (pszBuffer1)
3681 CoTaskMemFree(pszBuffer1);
3682
3683 if (pszBuffer2)
3684 CoTaskMemFree(pszBuffer2);
3685
3686 return hr;
3687}
3688
3689
3690HRESULT
3692 HKEY hAdapterKey,
3693 AdapterSettings *pAdapter)
3694{
3695 PWSTR pszBuffer1 = NULL, pszBuffer2 = NULL, pStart1, pStart2, pEnd1, pEnd2;
3696 DWORD dwSize, dwMetric;
3698 IP_ADDR *pNewAddrEntry, *pOldAddrEntry, *pNewLast = NULL, *pOldLast = NULL;
3699 HRESULT hr = S_OK;
3701
3702 TRACE("LoadGatewaySettings()\n");
3703
3704 dwSize = 0;
3705 RegQueryValueExW(hAdapterKey, L"DefaultGateway", NULL, NULL, NULL, &dwSize);
3706 if (dwSize == 0)
3707 return S_OK;
3708
3709 pszBuffer1 = CoTaskMemAlloc(dwSize);
3710 if (pszBuffer1 == NULL)
3711 {
3712 hr = E_OUTOFMEMORY;
3713 goto done;
3714 }
3715
3716 if (RegQueryValueExW(hAdapterKey, L"DefaultGateway", NULL, NULL, (PBYTE)pszBuffer1, &dwSize) != ERROR_SUCCESS)
3717 {
3718 hr = E_FAIL;
3719 goto done;
3720 }
3721
3722 dwSize = 0;
3723 RegQueryValueExW(hAdapterKey, L"DefaultGatewayMetric", NULL, NULL, NULL, &dwSize);
3724 if (dwSize == 0)
3725 return S_OK;
3726
3727 pszBuffer2 = CoTaskMemAlloc(dwSize);
3728 if (pszBuffer2 == NULL)
3729 {
3730 hr = E_OUTOFMEMORY;
3731 goto done;
3732 }
3733
3734 if (RegQueryValueExW(hAdapterKey, L"DefaultGatewayMetric", NULL, NULL, (PBYTE)pszBuffer2, &dwSize) != ERROR_SUCCESS)
3735 {
3736 hr = E_FAIL;
3737 goto done;
3738 }
3739
3740 pStart1 = pszBuffer1;
3741 pStart2 = pszBuffer2;
3742 for (;;)
3743 {
3744 TRACE("Start1: %S\n", pStart1);
3745 TRACE("Start2: %S\n", pStart2);
3746 Status = RtlIpv4StringToAddressW(pStart1, TRUE, (LPCWSTR *)&pEnd1, &Address);
3747 if (Status != 0)
3748 {
3749 ERR("RtlIpv4StringToAddressW Status 0x%08lx\n", Status);
3750 hr = E_FAIL;
3751 break;
3752 }
3753
3754 TRACE("Adress: %lx\n", Address.S_un.S_addr);
3755
3756 dwMetric = wcstoul(pStart2, &pEnd2, 10);
3757 if (dwMetric > 9999)
3758 dwMetric = 9999;
3759
3760 TRACE("Metric: %lu\n", dwMetric);
3761
3762 pNewAddrEntry = CoTaskMemAlloc(sizeof(IP_ADDR));
3763 if (pNewAddrEntry)
3764 {
3765 ZeroMemory(pNewAddrEntry, sizeof(IP_ADDR));
3766 pNewAddrEntry->IpAddress = ntohl(Address.S_un.S_addr);
3767 pNewAddrEntry->u.Metric = (USHORT)dwMetric;
3768
3769 if (!pNewLast)
3770 pAdapter->NewGw = pNewAddrEntry;
3771 else
3772 pNewLast->Next = pNewAddrEntry;
3773
3774 pNewLast = pNewAddrEntry;
3775 }
3776
3777 pOldAddrEntry = CoTaskMemAlloc(sizeof(IP_ADDR));
3778 if (pOldAddrEntry)
3779 {
3780 ZeroMemory(pOldAddrEntry, sizeof(IP_ADDR));
3781 pOldAddrEntry->IpAddress = ntohl(Address.S_un.S_addr);
3782 pOldAddrEntry->u.Metric = (USHORT)dwMetric;
3783
3784 if (!pOldLast)
3785 pAdapter->OldGw = pOldAddrEntry;
3786 else
3787 pOldLast->Next = pOldAddrEntry;
3788
3789 pOldLast = pOldAddrEntry;
3790 }
3791
3792 pStart1 = pEnd1 + 1;
3793 pStart2 = pEnd2 + 1;
3794
3795 if ((*pStart1 == UNICODE_NULL) || (*pStart2 == UNICODE_NULL))
3796 break;
3797 }
3798
3799done:
3800 if (pszBuffer1)
3801 CoTaskMemFree(pszBuffer1);
3802
3803 if (pszBuffer2)
3804 CoTaskMemFree(pszBuffer2);
3805
3806 return hr;
3807}
3808
3809
3810HRESULT
3812 HKEY hAdapterKey,
3813 AdapterSettings *pAdapter)
3814{
3815 PWSTR pszBuffer = NULL, pStart, pEnd;
3816 DWORD dwSize;
3818 IP_ADDR *pNewAddrEntry, *pOldAddrEntry, *pNewLast = NULL, *pOldLast = NULL;
3819 HRESULT hr = S_OK;
3821
3822 dwSize = 0;
3823 RegQueryValueExW(hAdapterKey, L"NameServer", NULL, NULL, NULL, &dwSize);
3824 if (dwSize == 0)
3825 return S_OK;
3826
3827 pszBuffer = CoTaskMemAlloc(dwSize);
3828 if (pszBuffer == NULL)
3829 {
3830 hr = E_OUTOFMEMORY;
3831 goto done;
3832 }
3833
3834 if (RegQueryValueExW(hAdapterKey, L"NameServer", NULL, NULL, (PBYTE)pszBuffer, &dwSize) != ERROR_SUCCESS)
3835 {
3836 hr = E_FAIL;
3837 goto done;
3838 }
3839
3840 pStart = pszBuffer;
3841 for (;;)
3842 {
3843 Status = RtlIpv4StringToAddressW(pStart, TRUE, (LPCWSTR *)&pEnd, &Address);
3844 if (Status != 0)
3845 {
3846 ERR("RtlIpv4StringToAddressW Status 0x%08lx\n", Status);
3847 hr = E_FAIL;
3848 break;
3849 }
3850
3851 TRACE("Adress: %lx\n", Address.S_un.S_addr);
3852
3853 pNewAddrEntry = CoTaskMemAlloc(sizeof(IP_ADDR));
3854 if (pNewAddrEntry)
3855 {
3856 ZeroMemory(pNewAddrEntry, sizeof(IP_ADDR));
3857 pNewAddrEntry->IpAddress = ntohl(Address.S_un.S_addr);
3858
3859 if (!pNewLast)
3860 pAdapter->NewNs = pNewAddrEntry;
3861 else
3862 pNewLast->Next = pNewAddrEntry;
3863
3864 pNewLast = pNewAddrEntry;
3865 }
3866
3867 pOldAddrEntry = CoTaskMemAlloc(sizeof(IP_ADDR));
3868 if (pOldAddrEntry)
3869 {
3870 ZeroMemory(pOldAddrEntry, sizeof(IP_ADDR));
3871 pOldAddrEntry->IpAddress = ntohl(Address.S_un.S_addr);
3872
3873 if (!pOldLast)
3874 pAdapter->OldNs = pOldAddrEntry;
3875 else
3876 pOldLast->Next = pOldAddrEntry;
3877
3878 pOldLast = pOldAddrEntry;
3879 }
3880
3881 if (*pEnd == UNICODE_NULL)
3882 break;
3883
3884 pStart = pEnd + 1;
3885 }
3886
3887done:
3888 if (pszBuffer)
3889 CoTaskMemFree(pszBuffer);
3890
3891 return hr;
3892}
3893
3894HRESULT
3897 LPOLESTR pAdapterName,
3898 IP_ADAPTER_INFO *pAdapterInfo)
3899{
3900 AdapterSettings *pAdapter;
3901 HKEY hAdapterKey = NULL, hConfigKey;
3902 WCHAR szKeyName[200];
3903 DWORD dwSize;
3904 HRESULT hr = S_OK;
3905
3906 TRACE("LoadAdapterSettings()\n");
3907
3908 pAdapter = (AdapterSettings*)CoTaskMemAlloc(sizeof(AdapterSettings));
3909 if (!pAdapter)
3910 return E_FAIL;
3911
3912 ZeroMemory(pAdapter, sizeof(AdapterSettings));
3913
3914 _swprintf(szKeyName, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%s", pAdapterName);
3915 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKeyName, 0, KEY_READ, &hAdapterKey) != ERROR_SUCCESS)
3916 {
3917 hr = E_FAIL;
3918 goto done;
3919 }
3920
3921 wcscpy(pAdapter->AdapterName, pAdapterName);
3922 CLSIDFromString(pAdapter->AdapterName, &pAdapter->AdapterGuid);
3923
3924 pAdapter->OldDhcpEnabled = pAdapterInfo->DhcpEnabled;
3925 pAdapter->NewDhcpEnabled = pAdapterInfo->DhcpEnabled;
3926 pAdapter->Index = pAdapterInfo->Index;
3927
3928 if (!pAdapterInfo->DhcpEnabled)
3929 {
3930 hr = LoadAddressSetings(hAdapterKey, pAdapter);
3931 if (FAILED(hr))
3932 goto done;
3933 }
3934
3935 hr = LoadGatewaySettings(hAdapterKey, pAdapter);
3936 if (FAILED(hr))
3937 goto done;
3938
3939 hr = LoadNameServerSettings(hAdapterKey, pAdapter);
3940 if (FAILED(hr))
3941 goto done;
3942
3943 pAdapter->DnsDhcpEnabled = (pAdapter->NewDhcpEnabled && (pAdapter->NewNs == NULL));
3944
3945 /* InterfaceMetric */
3946 dwSize = sizeof(DWORD);
3947 if (RegQueryValueExW(hAdapterKey, L"InterfaceMetric", NULL, NULL, (LPBYTE)&pAdapter->NewMetric, &dwSize) != ERROR_SUCCESS)
3948 pAdapter->NewMetric = 0;
3949 pAdapter->OldMetric = pAdapter->NewMetric;
3950
3951 /* DNS */
3952 dwSize = sizeof(DWORD);
3953 RegQueryValueExW(hAdapterKey, L"RegisterAdapterName", NULL, NULL, (LPBYTE)&pAdapter->NewRegisterAdapterName, &dwSize);
3954 pAdapter->OldRegisterAdapterName = pAdapter->NewRegisterAdapterName;
3955
3956 dwSize = sizeof(DWORD);
3957 RegQueryValueExW(hAdapterKey, L"RegistrationEnabled", NULL, NULL, (LPBYTE)&pAdapter->NewRegistrationEnabled, &dwSize);
3958 pAdapter->OldRegistrationEnabled = pAdapter->NewRegistrationEnabled;
3959
3960 dwSize = sizeof(pAdapter->szDomain);
3961 RegQueryValueExW(hAdapterKey, L"Domain", NULL, NULL, (LPBYTE)pAdapter->szDomain, &dwSize);
3962
3963 /* Filter */
3964 pAdapter->szTCPAllowedPorts = LoadTcpFilterSettingsFromRegistry(hAdapterKey, L"TCPAllowedPorts", &pAdapter->TCPSize);
3965 pAdapter->szUDPAllowedPorts = LoadTcpFilterSettingsFromRegistry(hAdapterKey, L"UDPAllowedPorts", &pAdapter->UDPSize);
3966 pAdapter->szRawIPAllowedProtocols = LoadTcpFilterSettingsFromRegistry(hAdapterKey, L"RawIPAllowedProtocols", &pAdapter->RawIPSize);
3967
3968 if (This->pAdapterListHead == NULL)
3969 {
3970 This->pAdapterListHead = pAdapter;
3971 This->pAdapterListTail = pAdapter;
3972 }
3973 else
3974 {
3975 This->pAdapterListTail->pNext = pAdapter;
3976 pAdapter->pPrev = This->pAdapterListTail;
3977 This->pAdapterListTail = pAdapter;
3978 }
3979
3980 /* Read the alternate configuration, if available */
3981 dwSize = 0;
3982 RegQueryValueExW(hAdapterKey, L"ActiveConfigurations", NULL, NULL, NULL, &dwSize);
3983 if (dwSize)
3984 {
3985 _swprintf(szKeyName, L"SYSTEM\\CurrentControlSet\\Services\\DHCP\\Configurations\\Alternate_%s", pAdapterName);
3986 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKeyName, 0, KEY_READ, &hConfigKey) == ERROR_SUCCESS)
3987 {
3989 RegQueryValueExW(hConfigKey, L"Options", NULL, NULL, (LPBYTE)&pAdapter->AltConfig, &dwSize);
3990 RegCloseKey(hConfigKey);
3991 }
3992 }
3993
3994done:
3995 if (hAdapterKey)
3996 RegCloseKey(hAdapterKey);
3997
3998 return hr;
3999}
4000
4001
4002HRESULT
4004{
4005 DWORD dwSize;
4006 WCHAR szBuffer[50];
4007 IP_ADAPTER_INFO *pCurrentAdapter;
4008 IP_ADAPTER_INFO *pInfo = NULL;
4009 HRESULT hr = S_OK;
4010
4011 if (This->pAdapterListHead)
4012 return S_OK;
4013
4014 dwSize = 0;
4016 return E_FAIL;
4017
4018 pInfo = CoTaskMemAlloc(dwSize);
4019 if (!pInfo)
4020 return E_FAIL;
4021
4022 if (GetAdaptersInfo(pInfo, &dwSize) != ERROR_SUCCESS)
4023 {
4024 CoTaskMemFree(pInfo);
4025 return E_FAIL;
4026 }
4027
4029
4030 pCurrentAdapter = pInfo;
4031 while (pCurrentAdapter)
4032 {
4033 szBuffer[0] = L'\0';
4034 if (MultiByteToWideChar(CP_ACP, 0, pCurrentAdapter->AdapterName, -1, szBuffer, sizeof(szBuffer)/sizeof(szBuffer[0])))
4035 {
4036 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
4037 }
4038
4039 TRACE("Adapter: %S\n", szBuffer);
4040
4042 szBuffer,
4043 pCurrentAdapter);
4044
4045 pCurrentAdapter = pCurrentAdapter->Next;
4046 }
4047
4048 CoTaskMemFree(pInfo);
4049
4050 if (FAILED(hr))
4051 {
4053 }
4054
4055 return hr;
4056}
4057
4058HRESULT
4059WINAPI
4061 INetCfgComponentPropertyUi * iface,
4062 DWORD *pdwDefPages,
4063 BYTE **pahpspPrivate,
4064 UINT *pcPages,
4066 LPCWSTR *pszStartPage)
4067{
4068 TRACE("INetCfgComponentPropertyUi_fnMergePropPages()\n");
4069 HPROPSHEETPAGE * hppages;
4070 UINT NumPages;
4072
4073 if (This->pCurrentAdapter->NewDhcpEnabled)
4074 NumPages = 2;
4075 else
4076 NumPages = 1;
4077
4078 hppages = (HPROPSHEETPAGE*) CoTaskMemAlloc(sizeof(HPROPSHEETPAGE) * NumPages);
4079 if (!hppages)
4080 return E_FAIL;
4081
4083 if (!hppages[0])
4084 {
4085 CoTaskMemFree(hppages);
4086 return E_FAIL;
4087 }
4088 if (NumPages == 2)
4089 {
4091 if (!hppages[1])
4092 {
4093 DestroyPropertySheetPage(hppages[0]);
4094 CoTaskMemFree(hppages);
4095 return E_FAIL;
4096 }
4097 }
4098
4099 *pahpspPrivate = (BYTE*)hppages;
4100 *pcPages = NumPages;
4101
4102 return S_OK;
4103}
4104
4105HRESULT
4106WINAPI
4108 INetCfgComponentPropertyUi * iface,
4109 HWND hwndDlg)
4110{
4111 TRACE("INetCfgComponentPropertyUi_fnValidateProperties()\n");
4112 return S_OK;
4113}
4114
4115HRESULT
4116WINAPI
4118 INetCfgComponentPropertyUi * iface)
4119{
4120 TRACE("INetCfgComponentPropertyUi_fnApplyProperties()\n");
4121 return S_OK;
4122}
4123
4124HRESULT
4125WINAPI
4127 INetCfgComponentPropertyUi * iface)
4128{
4129 TRACE("INetCfgComponentPropertyUi_fnCancelProperties()\n");
4130 return S_OK;
4131}
4132
4133static const INetCfgComponentPropertyUiVtbl vt_NetCfgComponentPropertyUi =
4134{
4144};
4145
4146/***************************************************************
4147 * INetCfgComponentControl interface
4148 */
4149
4150HRESULT
4151WINAPI
4153 INetCfgComponentControl *iface,
4154 REFIID iid,
4155 LPVOID *ppvObj)
4156{
4157 TRACE("INetCfgComponentControl_fnQueryInterface()\n");
4159
4160 *ppvObj = NULL;
4161
4162 if (IsEqualIID (iid, &IID_IUnknown) ||
4164 {
4165 *ppvObj = This;
4167 return S_OK;
4168 }
4170 {
4171 *ppvObj = (LPVOID*)&This->lpVtblCompPropertyUi;
4173 return S_OK;
4174 }
4175 else if (IsEqualIID(iid, &IID_INetCfgComponentSetup))
4176 {
4177 *ppvObj = (LPVOID*)&This->lpVtblCompSetup;
4179 return S_OK;
4180 }
4181 else if (IsEqualIID(iid, &IID_ITcpipProperties))
4182 {
4183 *ppvObj = (LPVOID*)&This->lpVtblTcpipProperties;
4185 return S_OK;
4186 }
4187
4188 return E_NOINTERFACE;
4189}
4190
4191ULONG
4192WINAPI
4194 INetCfgComponentControl *iface)
4195{
4196 TRACE("INetCfgComponentControl_fnAddRef()\n");
4198 ULONG refCount = InterlockedIncrement(&This->ref);
4199
4200 return refCount;
4201}
4202
4203ULONG
4204WINAPI
4206 INetCfgComponentControl *iface)
4207{
4208 TRACE("INetCfgComponentControl_fnRelease()\n");
4210 ULONG refCount = InterlockedDecrement(&This->ref);
4211
4212 if (!refCount)
4213 {
4216 }
4217 return refCount;
4218}
4219
4220HRESULT
4221WINAPI
4223 INetCfgComponentControl *iface,
4224 INetCfgComponent *pIComp,
4225 INetCfg *pINetCfg,
4226 BOOL fInstalling)
4227{
4228 TRACE("INetCfgComponentControl_fnInitialize()\n");
4230 HRESULT hr;
4231
4232 This->pNCfg = pINetCfg;
4233 This->pNComp = pIComp;
4234
4235 hr = Initialize(This);
4236 if (FAILED(hr))
4237 {
4238 ERR("INetCfgComponentControl_fnInitialize failed\n");
4239 return hr;
4240 }
4241
4242 TRACE("INetCfgComponentControl_fnInitialize success\n");
4243
4244 return S_OK;
4245}
4246
4247static
4248LPWSTR
4250{
4251 LPWSTR pStr, pRet;
4252 DWORD dwSize, dwIpAddr;
4253 WCHAR szBuffer[30];
4254 IP_ADDR *pTemp = pAddr;
4255
4256
4257 dwSize = 0;
4258 while(pTemp)
4259 {
4260 if (Type == IPADDR)
4261 {
4262 dwIpAddr = pTemp->IpAddress;
4263 _swprintf(szBuffer, L"%lu.%lu.%lu.%lu",
4264 FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr), THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
4265 }else if (Type == SUBMASK)
4266 {
4267 dwIpAddr = pTemp->u.SubnetMask;
4268 _swprintf(szBuffer, L"%lu.%lu.%lu.%lu",
4269 FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr), THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
4270 }
4271 else if (Type == METRIC)
4272 {
4273 _swprintf(szBuffer, L"%u", pTemp->u.Metric);
4274 }
4275
4276 dwSize += wcslen(szBuffer) + 1;
4277 pTemp = pTemp->Next;
4278 }
4279
4280 if (!dwSize)
4281 return NULL;
4282
4283 pStr = pRet = CoTaskMemAlloc((dwSize+1) * sizeof(WCHAR));
4284 if(!pStr)
4285 return NULL;
4286
4287 pTemp = pAddr;
4288 while(pTemp)
4289 {
4290 if (Type == IPADDR)
4291 {
4292 dwIpAddr = pTemp->IpAddress;
4293 _swprintf(pStr, L"%lu.%lu.%lu.%lu",
4294 FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr), THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
4295 }else if (Type == SUBMASK)
4296 {
4297 dwIpAddr = pTemp->u.SubnetMask;
4298 _swprintf(pStr, L"%lu.%lu.%lu.%lu",
4299 FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr), THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
4300 }
4301 else if (Type == METRIC)
4302 {
4303 _swprintf(pStr, L"%u", pTemp->u.Metric);
4304 }
4305
4306 if (bComma)
4307 {
4308 pStr += wcslen(pStr);
4309 if (pTemp->Next)
4310 {
4311 pStr[0] = L',';
4312 pStr++;
4313 }
4314 }
4315 else
4316 {
4317 pStr += wcslen(pStr) + 1;
4318 }
4319 pTemp = pTemp->Next;
4320 }
4321 pStr[0] = L'\0';
4322 *Size = (dwSize+1) * sizeof(WCHAR);
4323 return pRet;
4324}
4325
4326
4327HRESULT
4328WINAPI
4330 INetCfgComponentControl * iface)
4331{
4332 HKEY hKey;
4333 WCHAR szBuffer[200];
4334 LPOLESTR pStr;
4335 DWORD dwSize;
4336 AdapterSettings *pAdapter;
4337
4338 TRACE("INetCfgComponentControl_fnApplyRegistryChanges()\n");
4339
4341
4342 if (This->pTcpIpSettings)
4343 {
4344 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
4345 {
4346 RegSetValueExW(hKey, L"UseDomainNameDevolution", 0, REG_DWORD, (LPBYTE)&This->pTcpIpSettings->UseDomainNameDevolution, sizeof(DWORD));
4347 RegSetValueExW(hKey, L"SearchList", 0, REG_SZ, (LPBYTE)This->pTcpIpSettings->szSearchList,
4348 (wcslen(This->pTcpIpSettings->szSearchList) + 1) * sizeof(WCHAR));
4349 RegSetValueExW(hKey, L"EnableSecurityFilters", 0, REG_DWORD,
4350 (LPBYTE)&This->pTcpIpSettings->EnableSecurityFilters, sizeof(DWORD));
4351
4353 }
4354 }
4355
4356 pAdapter = This->pAdapterListHead;
4357 while (pAdapter)
4358 {
4359 _swprintf(szBuffer, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%s", pAdapter->AdapterName);
4360
4362 {
4363 if (pAdapter->NewMetric != pAdapter->OldMetric)
4364 {
4365 if (pAdapter->NewMetric)
4366 RegSetValueExW(hKey, L"InterfaceMetric", 0, REG_DWORD, (LPBYTE)&pAdapter->NewMetric, sizeof(DWORD));
4367 else
4368 RegDeleteValueW(hKey, L"InterfaceMetric");
4369 }
4370
4371 if (pAdapter->NewRegisterAdapterName != pAdapter->OldRegisterAdapterName)
4372 RegSetValueExW(hKey, L"RegisterAdapterName", 0, REG_DWORD, (LPBYTE)&pAdapter->NewRegisterAdapterName, sizeof(DWORD));
4373
4374 if (pAdapter->NewRegistrationEnabled != pAdapter->OldRegistrationEnabled)
4375 RegSetValueExW(hKey, L"RegistrationEnabled", 0, REG_DWORD, (LPBYTE)&pAdapter->NewRegistrationEnabled, sizeof(DWORD));
4376
4377 RegSetValueExW(hKey, L"Domain", 0, REG_SZ, (LPBYTE)pAdapter->szDomain,
4378 (wcslen(pAdapter->szDomain) + 1) * sizeof(WCHAR));
4379
4380 if ((pAdapter->NewDhcpEnabled != pAdapter->OldDhcpEnabled) ||
4381 IpAddressesChanged(pAdapter))
4382 {
4383 RegSetValueExW(hKey, L"EnableDHCP", 0, REG_DWORD, (LPBYTE)&pAdapter->NewDhcpEnabled, sizeof(DWORD));
4384 if (pAdapter->NewDhcpEnabled)
4385 {
4386 RegSetValueExW(hKey, L"IPAddress", 0, REG_MULTI_SZ, (LPBYTE)L"0.0.0.0\0", 9 * sizeof(WCHAR));
4387 RegSetValueExW(hKey, L"SubnetMask", 0, REG_MULTI_SZ, (LPBYTE)L"0.0.0.0\0", 9 * sizeof(WCHAR));
4388 }
4389 else
4390 {
4391 pStr = CreateMultiSzString(pAdapter->NewIp, IPADDR, &dwSize, FALSE);
4392 if (pStr)
4393 {
4394 RegSetValueExW(hKey, L"IPAddress", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
4395 CoTaskMemFree(pStr);
4396 }
4397
4398 pStr = CreateMultiSzString(pAdapter->NewIp, SUBMASK, &dwSize, FALSE);
4399 if (pStr)
4400 {
4401 RegSetValueExW(hKey, L"SubnetMask", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
4402 CoTaskMemFree(pStr);
4403 }
4404 }
4405 }
4406
4407 if (GatewaysChanged(pAdapter))
4408 {
4409 if (pAdapter->NewGw)
4410 {
4411 pStr = CreateMultiSzString(pAdapter->NewGw, IPADDR, &dwSize, FALSE);
4412 if (pStr)
4413 {
4414 RegSetValueExW(hKey, L"DefaultGateway", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
4415 CoTaskMemFree(pStr);
4416 }
4417
4418 pStr = CreateMultiSzString(pAdapter->NewGw, METRIC, &dwSize, FALSE);
4419 if (pStr)
4420 {
4421 RegSetValueExW(hKey, L"DefaultGatewayMetric", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
4422 CoTaskMemFree(pStr);
4423 }
4424 }
4425 else
4426 {
4427 RegSetValueExW(hKey, L"DefaultGateway", 0, REG_MULTI_SZ, (LPBYTE)L"", 1 * sizeof(WCHAR));
4428 RegSetValueExW(hKey, L"DefaultGatewayMetric", 0, REG_MULTI_SZ, (LPBYTE)L"\0", sizeof(WCHAR) * 2);
4429 }
4430 }
4431
4432 if (NameServersChanged(pAdapter))
4433 {
4434 if (!pAdapter->NewNs)
4435 {
4436 RegDeleteValueW(hKey, L"NameServer");
4437 }
4438 else
4439 {
4440 pStr = CreateMultiSzString(pAdapter->NewNs, IPADDR, &dwSize, TRUE);
4441 if (pStr)
4442 {
4443 RegSetValueExW(hKey, L"NameServer", 0, REG_SZ, (LPBYTE)pStr, dwSize);
4444 //RegDeleteValueW(hKey, L"DhcpNameServer");
4445 CoTaskMemFree(pStr);
4446 }
4447 }
4448 }
4449
4450#if 0
4451 if (pCurrentConfig->pFilter)
4452 {
4453 if (pCurrentConfig->pFilter->szTCPAllowedPorts)
4454 {
4455 RegSetValueExW(hKey, L"TCPAllowedPorts", 0, REG_MULTI_SZ,
4456 (LPBYTE)pCurrentConfig->pFilter->szTCPAllowedPorts,
4457 pCurrentConfig->pFilter->TCPSize);
4458 }
4459 if (pCurrentConfig->pFilter->szUDPAllowedPorts)
4460 {
4461 RegSetValueExW(hKey, L"UDPAllowedPorts", 0, REG_MULTI_SZ,
4462 (LPBYTE)pCurrentConfig->pFilter->szUDPAllowedPorts,
4463 pCurrentConfig->pFilter->UDPSize);
4464 }
4465 if (pCurrentConfig->pFilter->szRawIPAllowedProtocols)
4466 {
4467 RegSetValueExW(hKey, L"RawIPAllowedProtocols", 0, REG_MULTI_SZ,
4468 (LPBYTE)pCurrentConfig->pFilter->szRawIPAllowedProtocols,
4469 pCurrentConfig->pFilter->IPSize);
4470 }
4471 }
4472#endif
4473
4474#if 0
4475 if (!RtlEqualMemory(&pCurrentConfig->AltConfig, &pOldConfig->AltConfig, sizeof(AlternateConfiguration)))
4476 {
4477 if (pCurrentConfig->AltConfig.IpAddress == 0)
4478 {
4479 RegDeleteValueW(hKey, L"ActiveConfigurations");
4480 }
4481 else
4482 {
4483 HKEY hConfigKey;
4484
4485 dwSize = (wcslen(L"Alternate_") + wcslen(pAdapterName) + 2) * sizeof(WCHAR);
4486 pStr = CoTaskMemAlloc(dwSize);
4487 if (pStr)
4488 {
4489 ZeroMemory(pStr, dwSize);
4490 _swprintf(pStr, L"Alternate_%s", pAdapterName);
4491 RegSetValueExW(hKey, L"ActiveConfigurations", 0, REG_MULTI_SZ, (LPBYTE)pStr, dwSize);
4492 CoTaskMemFree(pStr);
4493 }
4494
4495 _swprintf(szBuffer, L"SYSTEM\\CurrentControlSet\\Services\\DHCP\\Configurations\\Alternate_%s", pAdapterName);
4496 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, szBuffer, 0, NULL, 0, KEY_WRITE, NULL, &hConfigKey, NULL) == ERROR_SUCCESS)
4497 {
4498 RegSetValueExW(hConfigKey, L"Options", 0, REG_BINARY, (LPBYTE)&pCurrentConfig->AltConfig, sizeof(AlternateConfiguration));
4499 RegCloseKey(hConfigKey);
4500 }
4501 }
4502 }
4503#endif
4504
4506 }
4507
4508 pAdapter = pAdapter->pNext;
4509 }
4510
4511 return S_OK;
4512}
4513
4514HRESULT
4515WINAPI
4517 INetCfgComponentControl *iface,
4518 INetCfgPnpReconfigCallback *pICallback)
4519{
4520 ULONG NTEInstance;
4521 DWORD DhcpApiVersion;
4522 DWORD dwSize;
4523 AdapterSettings *pAdapter;
4524
4525 TRACE("INetCfgComponentControl_fnApplyPnpChanges()\n");
4526
4528
4529 pAdapter = This->pAdapterListHead;
4530 while (pAdapter)
4531 {
4532 if (pAdapter->NewDhcpEnabled != pAdapter->OldDhcpEnabled)
4533 {
4534 if (pAdapter->NewDhcpEnabled)
4535 {
4536 /* Static IP --> DHCP */
4537
4538 /* Delete this adapter's current IP address */
4539 DeleteIPAddress(pAdapter->OldIp->NTEContext);
4540 }
4541 else
4542 {
4543 /* DHCP --> Static IP */
4544
4545 /* Open the DHCP API if DHCP is enabled */
4546 if (DhcpCApiInitialize(&DhcpApiVersion) == NO_ERROR)
4547 {
4548 /* We have to tell DHCP about this */
4550 htonl(pAdapter->NewIp->IpAddress),
4551 htonl(pAdapter->NewIp->u.SubnetMask));
4552
4553 /* Close the API */
4555 }
4556 }
4557 }
4558 else
4559 {
4560 if (IpAddressesChanged(pAdapter))
4561 {
4562 /* Static IP --> Static IP */
4563
4564 /* Delete this adapter's current static IP address */
4565 DeleteIPAddress(pAdapter->OldIp->NTEContext);
4566
4567 /* Add the static IP address via the standard IPHLPAPI function */
4568 AddIPAddress(htonl(pAdapter->NewIp->IpAddress),
4569 htonl(pAdapter->NewIp->u.SubnetMask),
4570 pAdapter->Index,
4571 &pAdapter->NewIp->NTEContext,
4572 &NTEInstance);
4573 }
4574 }
4575
4576 if ((pAdapter->NewDhcpEnabled != pAdapter->OldDhcpEnabled) ||
4577 IpAddressesChanged(pAdapter) ||
4578 GatewaysChanged(pAdapter))
4579 {
4580 /* Delete all default routes for this adapter */
4581 dwSize = 0;
4583 {
4584 DWORD Index;
4586 if (pIpForwardTable)
4587 {
4588 if (GetIpForwardTable(pIpForwardTable, &dwSize, FALSE) == NO_ERROR)
4589 {
4590 for (Index = 0; Index < pIpForwardTable->dwNumEntries; Index++)
4591 {
4592 if (pIpForwardTable->table[Index].dwForwardIfIndex == pAdapter->Index &&
4593 pIpForwardTable->table[Index].dwForwardDest == 0)
4594 {
4595 DeleteIpForwardEntry(&pIpForwardTable->table[Index]);
4596 }
4597 }
4598 }
4599 CoTaskMemFree(pIpForwardTable);
4600 }
4601 }
4602
4603 if (pAdapter->NewGw)
4604 {
4605 MIB_IPFORWARDROW RouterMib;
4606 ZeroMemory(&RouterMib, sizeof(MIB_IPFORWARDROW));
4607
4608 RouterMib.dwForwardMetric1 = 1;
4609 RouterMib.dwForwardIfIndex = pAdapter->Index;
4610 RouterMib.dwForwardNextHop = htonl(pAdapter->NewGw->IpAddress);
4611
4612 //TODO
4613 // add multiple gw addresses when required
4614 CreateIpForwardEntry(&RouterMib);
4615 }
4616 }
4617
4618#if 0
4619 /* Notify the DHCP client of the changed alternate configuration */
4620 if (!RtlEqualMemory(&pCurrentConfig->AltConfig, &pOldConfig->AltConfig, sizeof(AlternateConfiguration)))
4621 {
4622 HMODULE hDhcpModule = LoadLibraryW(L"dhcpcsvc.dll");
4623 if (hDhcpModule)
4624 {
4625 PDHCPFALLBACKREFRESHPARAMS pFunc = (PDHCPFALLBACKREFRESHPARAMS)GetProcAddress(hDhcpModule, "DhcpFallbackRefreshParams");
4626 (pFunc)(pAdapter->AdapterName);
4627
4628 FreeLibrary(hDhcpModule);
4629 }
4630 }
4631#endif
4632
4633 /* Notify the dnscache service if the name server list changed */
4634 if (NameServersChanged(pAdapter))
4635 {
4636 SC_HANDLE hManager, hService;
4638
4639 TRACE("Notify the dnscache service!\n");
4640
4642 if (hManager)
4643 {
4644 hService = OpenServiceW(hManager, L"Dnscache", SERVICE_PAUSE_CONTINUE);
4645 if (hService)
4646 {
4648 CloseServiceHandle(hService);
4649 }
4650
4651 CloseServiceHandle(hManager);
4652 }
4653 }
4654
4655 pAdapter = pAdapter->pNext;
4656 }
4657
4658 return S_OK;
4659}
4660
4661HRESULT
4662WINAPI
4664 INetCfgComponentControl * iface)
4665{
4666 TRACE("INetCfgComponentControl_fnCancelChanges()\n");
4667 return S_OK;
4668}
4669
4670static const INetCfgComponentControlVtbl vt_NetCfgComponentControl =
4671{
4679};
4680
4681
4682/***************************************************************
4683 * INetCfgComponentSetup interface
4684 */
4685
4686HRESULT
4687WINAPI
4689 INetCfgComponentSetup *iface,
4690 REFIID iid,
4691 LPVOID *ppvObj)
4692{
4693 TRACE("INetCfgComponentSetup_fnQueryInterface()\n");
4695 return INetCfgComponentControl_QueryInterface((INetCfgComponentControl*)This, iid, ppvObj);
4696}
4697
4698ULONG
4699WINAPI
4701 INetCfgComponentSetup *iface)
4702{
4703 TRACE("INetCfgComponentSetup_fnAddRef()\n");
4705 return INetCfgComponentControl_AddRef((INetCfgComponentControl*)This);
4706}
4707
4708ULONG
4709WINAPI
4711 INetCfgComponentSetup *iface)
4712{
4713 TRACE("INetCfgComponentSetup_fnRelease()\n");
4715 return INetCfgComponentControl_Release((INetCfgComponentControl*)This);
4716}
4717
4718HRESULT
4719WINAPI
4721 INetCfgComponentSetup *iface,
4722 DWORD dwSetupFlags)
4723{
4724 TRACE("INetCfgComponentSetup_fnInstall()\n");
4725 return S_OK;
4726}
4727
4728HRESULT
4729WINAPI
4731 INetCfgComponentSetup *iface,
4732 DWORD dwSetupFlags,
4733 DWORD dwUpgradeFromBuildNo)
4734{
4735 TRACE("INetCfgComponentSetup_fnUpgrade()\n");
4736 return S_OK;
4737}
4738
4739HRESULT
4740WINAPI
4742 INetCfgComponentSetup *iface,
4743 LPCWSTR pszwAnswerFile,
4744 LPCWSTR pszwAnswerSections)
4745{
4746 TRACE("INetCfgComponentSetup_fnReadAnswerFile()\n");
4747 return S_OK;
4748}
4749
4750HRESULT
4751WINAPI
4753 INetCfgComponentSetup *iface)
4754{
4755 TRACE("INetCfgComponentSetup_fnRemoving()\n");
4756 return S_OK;
4757}
4758
4759static const INetCfgComponentSetupVtbl vt_NetCfgComponentSetup =
4760{
4768};
4769
4770
4771/***************************************************************
4772 * ITcpipProperties interface
4773 */
4774
4775HRESULT
4776WINAPI
4778 ITcpipProperties *iface,
4779 REFIID iid,
4780 LPVOID *ppvObj)
4781{
4782 TRACE("ITcpipProperties_fnQueryInterface()\n");
4784 return INetCfgComponentControl_QueryInterface((INetCfgComponentControl*)This, iid, ppvObj);
4785}
4786
4787ULONG
4788WINAPI
4790 ITcpipProperties *iface)
4791{
4792 TRACE("ITcpipProperties_fnAddRef()\n");
4794 return INetCfgComponentControl_AddRef((INetCfgComponentControl*)This);
4795}
4796
4797ULONG
4798WINAPI
4800 ITcpipProperties *iface)
4801{
4802 TRACE("ITcpipProperties_fnRelease()\n");
4804 return INetCfgComponentControl_Release((INetCfgComponentControl*)This);
4805}
4806
4807HRESULT
4808WINAPI
4810 ITcpipProperties *iface,
4811 GUID *pAdapterName,
4812 PTCPIP_PROPERTIES *ppProperties)
4813{
4814 AdapterSettings *pAdapter;
4815 PTCPIP_PROPERTIES pProperties;
4816 PWSTR pszIpAddress = NULL;
4817 PWSTR pszSubnetMask = NULL;
4818 PWSTR pszParameters = NULL;
4819 PWSTR pPtr;
4820 DWORD dwSize;
4821 HRESULT hr = S_OK;
4822
4823 TRACE("ITcpipProperties_fnUnknown1(%s %p)\n", wine_dbgstr_guid(pAdapterName), ppProperties);
4825
4826 pAdapter = GetAdapterByGuid(This, pAdapterName);
4827 if (pAdapter == NULL)
4828 return E_FAIL;
4829
4830 /* Build the IpAddress string */
4831 hr = BuildIpAddressString(pAdapter, &pszIpAddress);
4832 if (FAILED(hr))
4833 goto done;
4834
4835 TRACE("DHCP: %lu\n", pAdapter->NewDhcpEnabled);
4836 TRACE("IpAddress string: %S\n", pszIpAddress);
4837
4838 /* Build the Parameters string */
4839 hr = BuildSubnetMaskString(pAdapter, &pszSubnetMask);
4840 if (FAILED(hr))
4841 goto done;
4842
4843 TRACE("SubnetMask string: %S\n", pszSubnetMask);
4844
4845 /* Build the Parameters string */
4846 hr = BuildParametersString(pAdapter, &pszParameters);
4847 if (FAILED(hr))
4848 goto done;
4849
4850 TRACE("Parameters string: %S\n", pszParameters);
4851
4852 dwSize = sizeof(TCPIP_PROPERTIES) +
4853 ((wcslen(pszIpAddress) + 1) * sizeof(WCHAR)) +
4854 ((wcslen(pszSubnetMask) + 1) * sizeof(WCHAR)) +
4855 ((wcslen(pszParameters) + 1) * sizeof(WCHAR));
4856
4857 pProperties = CoTaskMemAlloc(dwSize);
4858 if (pProperties == NULL)
4859 {
4860 hr = E_OUTOFMEMORY;
4861 goto done;
4862 }
4863
4864 ZeroMemory(pProperties, dwSize);
4865
4866 pProperties->dwDhcp = (pAdapter->NewDhcpEnabled) ? DWORD_MAX : 0;
4867
4868 pPtr = (PWSTR)(pProperties + 1);
4869
4870 pProperties->pszIpAddress = pPtr;
4871 wcscpy(pProperties->pszIpAddress, pszIpAddress);
4872 pPtr += (wcslen(pszIpAddress) + 1);
4873
4874 pProperties->pszSubnetMask = pPtr;
4875 wcscpy(pProperties->pszSubnetMask, pszSubnetMask);
4876 pPtr += (wcslen(pszSubnetMask) + 1);
4877
4878 pProperties->pszParameters = pPtr;
4879 wcscpy(pProperties->pszParameters, pszParameters);
4880
4881 *ppProperties = pProperties;
4882
4883done:
4884 if (pszIpAddress)
4885 CoTaskMemFree(pszIpAddress);
4886
4887 if (pszSubnetMask)
4888 CoTaskMemFree(pszSubnetMask);
4889
4890 if (pszParameters)
4891 CoTaskMemFree(pszParameters);
4892
4893 return hr;
4894}
4895
4896HRESULT
4897WINAPI
4899 ITcpipProperties *iface,
4900 GUID *pAdapterName,
4901 PTCPIP_PROPERTIES pProperties)
4902{
4903 AdapterSettings *pAdapter;
4904 IN_ADDR IpAddress, SubnetMask, Gateway, Dns;
4905 PWSTR pszGateway = NULL, pszMetric = NULL, pszDns = NULL;
4906 DWORD dwMetric;
4907 LPCWSTR Term;
4909 HRESULT hr = S_OK;
4910
4911 TRACE("ITcpipProperties_fnUnknown2(%s %p)\n", wine_dbgstr_guid(pAdapterName), pProperties);
4912
4913 if (pProperties)
4914 {
4915 ERR("pProperties->dwDhcp %lu\n", pProperties->dwDhcp);
4916 ERR("pProperties->pszIpAddress %S\n", pProperties->pszIpAddress);
4917 ERR("pProperties->pszSubnetMask %S\n", pProperties->pszSubnetMask);
4918 ERR("pProperties->pszParameters %S\n", pProperties->pszParameters);
4919 }
4920
4922
4923 pAdapter = GetAdapterByGuid(This, pAdapterName);
4924 if (pAdapter == NULL)
4925 return E_FAIL;
4926
4927 pAdapter->NewDhcpEnabled = (pProperties->dwDhcp != 0);
4928 if (pAdapter->NewDhcpEnabled)
4929 {
4930 TRACE("DHCP\n");
4931 pAdapter->NewIp->IpAddress = 0;
4932 pAdapter->NewIp->u.SubnetMask = 0;
4933 }
4934 else
4935 {
4936 TRACE("STATIC\n");
4938 TRUE,
4939 &Term,
4940 &IpAddress);
4941 if (Status != 0 /*STATUS_SUCCESS*/)
4942 {
4943 hr = E_FAIL;
4944 goto done;
4945 }
4946
4947 TRACE("IP Address: %u.%u.%u.%u\n",
4948 IpAddress.S_un.S_un_b.s_b1, IpAddress.S_un.S_un_b.s_b2, IpAddress.S_un.S_un_b.s_b3, IpAddress.S_un.S_un_b.s_b4);
4949
4951 TRUE,
4952 &Term,
4953 &SubnetMask);
4954 if (Status != 0 /*STATUS_SUCCESS*/)
4955 {
4956 hr = E_FAIL;
4957 goto done;
4958 }
4959
4960 TRACE("Subnet Mask: %u.%u.%u.%u\n",
4961 SubnetMask.S_un.S_un_b.s_b1, SubnetMask.S_un.S_un_b.s_b2, SubnetMask.S_un.S_un_b.s_b3, SubnetMask.S_un.S_un_b.s_b4);
4962
4963 TRACE("pAdapter->NewIp %p\n", pAdapter->NewIp);
4964 if (pAdapter->NewIp == NULL)
4965 {
4966 pAdapter->NewIp = CoTaskMemAlloc(sizeof(IP_ADDR));
4967 if (pAdapter->NewIp == NULL)
4968 {
4969 hr = E_OUTOFMEMORY;
4970 goto done;
4971 }
4972
4973 ZeroMemory(pAdapter->NewIp, sizeof(IP_ADDR));
4974 }
4975
4976 pAdapter->NewIp->IpAddress = ntohl(IpAddress.S_un.S_addr);
4977 pAdapter->NewIp->u.SubnetMask = ntohl(SubnetMask.S_un.S_addr);
4978 }
4979
4980 /* Parse pszParameters */
4981 pszGateway = ExtractParameterValue(pProperties->pszParameters, L"DefGw");
4982 pszMetric = ExtractParameterValue(pProperties->pszParameters, L"GwMetric");
4983 if (pszGateway != NULL && pszMetric != NULL)
4984 {
4985 TRACE("Gateway: %S\n", pszGateway);
4986 TRACE("Metric: %S\n", pszMetric);
4987 if ((wcslen(pszGateway) == 0) && (wcslen(pszMetric) == 0))
4988 {
4989 FIXME("Delete Gateway and Metric!\n");
4990 }
4991 else
4992 {
4994 TRUE,
4995 &Term,
4996 &Gateway);
4997 if (Status != 0 /*STATUS_SUCCESS*/)
4998 {
4999 hr = E_FAIL;
5000 goto done;
5001 }
5002
5003 TRACE("Gateway: %u.%u.%u.%u\n",
5004 Gateway.S_un.S_un_b.s_b1, Gateway.S_un.S_un_b.s_b2, Gateway.S_un.S_un_b.s_b3, Gateway.S_un.S_un_b.s_b4);
5005
5006 TRACE("pAdapter->NewGw %p\n", pAdapter->NewGw);
5007 if (pAdapter->NewGw == NULL)
5008 {
5009 pAdapter->NewGw = CoTaskMemAlloc(sizeof(IP_ADDR));
5010 if (pAdapter->NewGw == NULL)
5011 {
5012 hr = E_OUTOFMEMORY;
5013 goto done;
5014 }
5015
5016 ZeroMemory(pAdapter->NewGw, sizeof(IP_ADDR));
5017 }
5018
5019 pAdapter->NewGw->IpAddress = ntohl(Gateway.S_un.S_addr);
5020
5021 dwMetric = wcstoul(pszMetric, (PWSTR*)&Term, 10);
5022 if (dwMetric > 9999)
5023 dwMetric = 9999;
5024 pAdapter->NewGw->u.Metric = (USHORT)dwMetric;
5025 }
5026 }
5027
5028 pszDns = ExtractParameterValue(pProperties->pszParameters, L"DNS");
5029 if (pszDns)
5030 {
5031 TRACE("DNS: %S\n", pszDns);
5032 if (wcslen(pszDns) == 0)
5033 {
5034 FIXME("Delete DNS!\n");
5035 }
5036 else
5037 {
5039 TRUE,
5040 &Term,
5041 &Dns);
5042 if (Status != 0 /*STATUS_SUCCESS*/)
5043 {
5044 hr = E_FAIL;
5045 goto done;
5046 }
5047
5048 TRACE("Dns: %u.%u.%u.%u\n",
5049 Dns.S_un.S_un_b.s_b1, Dns.S_un.S_un_b.s_b2, Dns.S_un.S_un_b.s_b3, Dns.S_un.S_un_b.s_b4);
5050
5051 TRACE("pAdapter->NewNs %p\n", pAdapter->NewNs);
5052 if (pAdapter->NewNs == NULL)
5053 {
5054 pAdapter->NewNs = CoTaskMemAlloc(sizeof(IP_ADDR));
5055 if (pAdapter->NewNs == NULL)
5056 {
5057 hr = E_OUTOFMEMORY;
5058 goto done;
5059 }
5060
5061 ZeroMemory(pAdapter->NewNs, sizeof(IP_ADDR));
5062 }
5063
5064 pAdapter->NewNs->IpAddress = ntohl(Dns.S_un.S_addr);
5065 }
5066 }
5067
5068 /*
5069 TODO:
5070 IfMetric
5071 DynamicUpdate
5072 NameRegistration
5073 */
5074
5075 if (This->pNComp)
5076 ((INetCfgComponentImpl *)(This->pNComp))->pItem->bChanged = TRUE;
5077
5078done:
5079 if (pszGateway)
5080 CoTaskMemFree(pszGateway);
5081 if (pszMetric)
5082 CoTaskMemFree(pszMetric);
5083 if (pszDns)
5084 CoTaskMemFree(pszDns);
5085
5086 return hr;
5087}
5088
5089static const ITcpipPropertiesVtbl vt_TcpipProperties =
5090{
5096};
5097
5098HRESULT
5099WINAPI
5101{
5103
5104 if (!ppv)
5105 return E_POINTER;
5106
5108 if (!This)
5109 return E_OUTOFMEMORY;
5110
5111 This->ref = 1;
5112 This->lpVtbl = (const INetCfgComponentControl*)&vt_NetCfgComponentControl;
5113 This->lpVtblCompPropertyUi = (const INetCfgComponentPropertyUi*)&vt_NetCfgComponentPropertyUi;
5114 This->lpVtblCompSetup = (const INetCfgComponentSetup*)&vt_NetCfgComponentSetup;
5115 This->lpVtblTcpipProperties = (const ITcpipProperties*)&vt_TcpipProperties;
5116 This->pNCfg = NULL;
5117 This->pUnknown = NULL;
5118 This->pNComp = NULL;
5119 This->pTcpIpSettings = NULL;
5120 This->pAdapterListHead = NULL;
5121 This->pAdapterListTail = NULL;
5122 This->pCurrentAdapter = NULL;
5123
5124 if (!SUCCEEDED (INetCfgComponentControl_QueryInterface ((INetCfgComponentControl*)This, riid, ppv)))
5125 {
5126 INetCfgComponentControl_Release((INetCfgComponentControl*)This);
5127 return E_NOINTERFACE;
5128 }
5129
5130 INetCfgComponentControl_Release((INetCfgComponentControl*)This);
5131 return S_OK;
5132}
Type
Definition: Type.h:7
#define __inline
Definition: _wctype.cpp:15
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define IDC_OK
Definition: resource.h:59
static void AddButton(HWND hwndToolBar, int nImage, int nCommand)
Definition: wordpad.c:155
static SERVICE_STATUS ServiceStatus
Definition: browser.c:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
#define RegCloseKey(hKey)
Definition: registry.h:49
#define DWORD_MAX
Definition: cfgmgr32.h:61
RECT rect
Definition: combotst.c:67
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static HWND hwndParent
Definition: cryptui.c:299
static TAGID TAGID find
Definition: db.cpp:156
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define BufferSize
Definition: mmc.h:75
HRESULT hr
Definition: delayimp.cpp:582
#define DLGPROC
Definition: maze.c:62
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD APIENTRY DhcpCApiInitialize(_Out_ LPDWORD Version)
Definition: dhcpcsvc.c:213
DWORD APIENTRY DhcpStaticRefreshParams(DWORD AdapterIndex, DWORD Address, DWORD Netmask)
Definition: dhcpcsvc.c:719
VOID APIENTRY DhcpCApiCleanup(VOID)
Definition: dhcpcsvc.c:227
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDS_METRIC
Definition: resource.h:77
#define IDC_ADVANCED
Definition: resource.h:11
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
HRESULT WINAPI StringFromCLSID(REFCLSID clsid, LPOLESTR *str)
Definition: combase.c:1515
HRESULT WINAPI CLSIDFromString(LPCOLESTR str, LPCLSID clsid)
Definition: combase.c:1470
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
Definition: propsheet.c:3086
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2916
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3155
#define wcschr
Definition: compat.h:17
#define CP_ACP
Definition: compat.h:109
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define CALLBACK
Definition: compat.h:35
#define MultiByteToWideChar
Definition: compat.h:110
#define LoadLibraryW(x)
Definition: compat.h:747
_ACRTIMP int __cdecl _scwprintf(const wchar_t *,...)
Definition: wcs.c:1678
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2917
_ACRTIMP int __cdecl _wtoi(const wchar_t *)
Definition: wcs.c:2778
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
Definition: wcs.c:2998
HINSTANCE netcfgx_hInstance
Definition: netcfgx.c:15
#define IDC_ALTDNS2
Definition: resource.h:40
#define IDC_NODHCP
Definition: resource.h:24
#define IDS_TCPFILTERDESC
Definition: resource.h:110
#define IDC_IPDEL
Definition: resource.h:45
#define IDS_DISABLE_FILTER
Definition: resource.h:128
#define IDC_GWADD
Definition: resource.h:47
#define IDC_IP_RESTRICT
Definition: resource.h:91
#define IDC_DNS1
Definition: resource.h:30
#define IDC_DNSADDRMOD
Definition: resource.h:61
#define IDD_TCPIP_ADVOPT_DLG
Definition: resource.h:12
#define IDC_OPTLIST
Definition: resource.h:76
#define IDC_DNSSUFFIXLIST
Definition: resource.h:66
#define IDS_PROT_RANGE
Definition: resource.h:126
#define IDS_TCP_PORTS
Definition: resource.h:122
#define IDD_TCPIPADDIP_DLG
Definition: resource.h:14
#define IDC_PORT_VAL
Definition: resource.h:97
#define IDC_IP_DEL
Definition: resource.h:94
#define IDC_DNSSUFFIXUP
Definition: resource.h:67
#define IDC_DNSSUFFIXDEL
Definition: resource.h:71
#define IDC_GWDEL
Definition: resource.h:49
#define IDC_IP_ALLOW_ALL
Definition: resource.h:90
#define IDS_SUBMASK
Definition: resource.h:113
#define IDS_DUP_GW
Definition: resource.h:134
#define IDC_DNSSUFFIXDOWN
Definition: resource.h:68
#define IDS_NOITEMSEL
Definition: resource.h:118
#define IDD_TCPIP_ALTCF_DLG
Definition: resource.h:9
#define IDC_USEDHCP
Definition: resource.h:23
#define IDC_SUBNETMASK
Definition: resource.h:26
#define IDC_FIXEDDNS
Definition: resource.h:29
#define IDD_TCPIP_FILTER_DLG
Definition: resource.h:13
#define IDC_SUFFIX
Definition: resource.h:72
#define IDD_TCPIPDNS_DLG
Definition: resource.h:16
#define IDC_IPLIST
Definition: resource.h:42
#define IDC_OPTPROP
Definition: resource.h:77
#define IDC_ALTSTATIC
Definition: resource.h:35
#define IDC_USESUFFIX
Definition: resource.h:74
#define IDC_DNSADDRADD
Definition: resource.h:60
#define IDC_USE_FILTER
Definition: resource.h:95
#define IDC_IP_LIST
Definition: resource.h:92
#define IDD_TCPIPGW_DLG
Definition: resource.h:15
#define IDC_AUTODNS
Definition: resource.h:28
#define IDD_TCPIP_ADVIP_DLG
Definition: resource.h:10
#define IDC_UDP_LIST
Definition: resource.h:87
#define IDS_IP_PROTO
Definition: resource.h:124
#define IDC_TCP_RESTRICT
Definition: resource.h:81
#define IDC_GWMOD
Definition: resource.h:48
#define IDS_AUTOMATIC
Definition: resource.h:117
#define IDC_DNS2
Definition: resource.h:31
#define IDC_TCP_ADD
Definition: resource.h:83
#define IDS_DHCPACTIVE
Definition: resource.h:116
#define IDS_TCPIP
Definition: resource.h:119
#define IDC_ALTIPADDR
Definition: resource.h:36
#define IDC_ALTDNS1
Definition: resource.h:39
#define IDC_DEFGATEWAY
Definition: resource.h:27
#define IDC_UDP_DEL
Definition: resource.h:89
#define IDC_IP_ADD
Definition: resource.h:93
#define IDS_DOMAIN_SUFFIX
Definition: resource.h:130
#define IDC_DNSADDRDEL
Definition: resource.h:62
#define IDS_UDP_PORTS
Definition: resource.h:123
#define IDC_UDP_ALLOW_ALL
Definition: resource.h:85
#define IDC_TCP_ALLOW_ALL
Definition: resource.h:80
#define IDC_DNSADDRUP
Definition: resource.h:58
#define IDS_NO_SUBMASK_SET
Definition: resource.h:109
#define IDS_TCPFILTER
Definition: resource.h:111
#define IDS_DUP_NUMBER
Definition: resource.h:127
#define IDC_GWMETRICTXT
Definition: resource.h:53
#define IDC_REGSUFFIX
Definition: resource.h:73
#define IDC_PRIMSUFFIX
Definition: resource.h:63
#define IDS_NO_SUFFIX
Definition: resource.h:129
#define IDC_ALTAPIPA
Definition: resource.h:34
#define IDS_METRIC_RANGE
Definition: resource.h:135
#define IDC_GWMETRIC
Definition: resource.h:54
#define IDC_GWAUTOMETRIC
Definition: resource.h:52
#define IDD_TCPIP_BASIC_DLG
Definition: resource.h:8
#define IDS_GATEWAY
Definition: resource.h:114
#define IDD_TCPIPSUFFIX_DLG
Definition: resource.h:17
#define IDS_PORT_RANGE
Definition: resource.h:125
#define IDC_IPADD
Definition: resource.h:43
#define IDC_IPMOD
Definition: resource.h:44
#define IDD_TCPIP_ADVDNS_DLG
Definition: resource.h:11
#define IDC_ALTSUBNETMASK
Definition: resource.h:37
#define IDC_TCP_LIST
Definition: resource.h:82
#define IDS_ADD
Definition: resource.h:120
#define IDC_UDP_ADD
Definition: resource.h:88
#define IDS_DUP_IPADDR
Definition: resource.h:133
#define IDC_UDP_RESTRICT
Definition: resource.h:86
#define IDC_SELSUFFIX
Definition: resource.h:65
#define IDS_MOD
Definition: resource.h:121
#define IDC_IPADDR
Definition: resource.h:25
#define IDI_NETWORK
Definition: resource.h:4
#define IDS_DUP_SUFFIX
Definition: resource.h:132
#define IDC_DNSADDRDOWN
Definition: resource.h:59
#define IDS_IPADDR
Definition: resource.h:112
#define IDC_PORT_DESC
Definition: resource.h:96
#define IDS_DNS_SUFFIX
Definition: resource.h:131
#define IDS_NO_IPADDR_SET
Definition: resource.h:108
#define IDC_OPTDESC
Definition: resource.h:78
#define IDC_IFAUTOMETRIC
Definition: resource.h:50
#define IDC_DNSADDRLIST
Definition: resource.h:57
#define IDC_TOPPRIMSUFFIX
Definition: resource.h:64
#define IDC_GWLIST
Definition: resource.h:46
#define IDC_TCP_DEL
Definition: resource.h:84
#define IDC_IFMETRIC
Definition: resource.h:51
#define IDD_TCPIP_PORT_DLG
Definition: resource.h:18
#define IDC_DNSSUFFIXMOD
Definition: resource.h:70
#define IDC_DNSSUFFIXADD
Definition: resource.h:69
#define IDC_ALTDEFGATEWAY
Definition: resource.h:38
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxChildList * pList
PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER pAddr
FxString * pString
SINGLE_LIST_ENTRY * pCur
FxAutoRegKey hKey
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
Status
Definition: gdiplustypes.h:24
GLuint res
Definition: glext.h:9613
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint GLfloat * val
Definition: glext.h:7180
unsigned int UINT
Definition: sysinfo.c:13
CPPORT Port[4]
Definition: headless.c:38
#define Gw
Definition: i386-dis.c:364
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
DWORD WINAPI AddIPAddress(IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
Definition: iphlpapi_main.c:67
DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSize, BOOL bOrder)
DWORD WINAPI DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute)
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
DWORD WINAPI CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute)
DWORD WINAPI DeleteIPAddress(ULONG NTEContext)
struct _MIB_IPFORWARDTABLE * PMIB_IPFORWARDTABLE
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
#define REG_SZ
Definition: layer.c:22
if(dx< 0)
Definition: linetemp.h:194
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define ZeroMemory
Definition: minwinbase.h:31
#define CopyMemory
Definition: minwinbase.h:29
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
#define ntohl(x)
Definition: module.h:205
#define htonl(x)
Definition: module.h:214
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
static HICON
Definition: imagelist.c:80
static IUnknown * pUnkReserved
Definition: asmenum.c:33
HICON hIcon
Definition: msconfig.c:44
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
NTSYSAPI PWSTR NTAPI RtlIpv4AddressToStringW(_In_ const struct in_addr *Addr, _Out_writes_(16) PWCHAR S)
NTSYSAPI NTSTATUS NTAPI RtlIpv4StringToAddressW(_In_ PCWSTR String, _In_ BOOLEAN Strict, _Out_ PCWSTR *Terminator, _Out_ struct in_addr *Addr)
Definition: network.c:385
EXTERN_C const IID IID_INetCfgComponentPropertyUi
Definition: netcfgn.h:88
EXTERN_C const IID IID_INetCfgComponentControl
Definition: netcfgn.h:57
EXTERN_C const IID IID_INetLanConnectionUiInfo
Definition: netcfgn.h:234
#define INetCfgComponentControl_QueryInterface(p, a, b)
Definition: netcfgn.h:48
#define INetCfgComponentControl_Release(p)
Definition: netcfgn.h:50
EXTERN_C const IID IID_INetCfgComponentSetup
Definition: netcfgn.h:165
#define INetCfgComponentControl_AddRef(p)
Definition: netcfgn.h:49
#define INetLanConnectionUiInfo_GetDeviceGuid(p, a)
Definition: netcfgn.h:231
struct _TCPIP_PROPERTIES TCPIP_PROPERTIES
EXTERN_C const IID IID_ITcpipProperties
Definition: netcfgn_undoc.h:25
#define REG_BINARY
Definition: nt_native.h:1499
#define KEY_READ
Definition: nt_native.h:1026
#define REG_MULTI_SZ
Definition: nt_native.h:1504
#define KEY_WRITE
Definition: nt_native.h:1034
#define DWORD
Definition: nt_native.h:44
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define LOWORD(l)
Definition: pedump.c:82
BYTE * PBYTE
Definition: pedump.c:66
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
static const WCHAR szName[]
Definition: powrprof.c:45
#define PSH_PROPTITLE
Definition: prsht.h:40
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSNRET_INVALID
Definition: prsht.h:130
#define PSM_REMOVEPAGE
Definition: prsht.h:166
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSP_USETITLE
Definition: prsht.h:26
#define PSP_DEFAULT
Definition: prsht.h:22
#define PSN_KILLACTIVE
Definition: prsht.h:116
#define PSN_APPLY
Definition: prsht.h:117
struct _PROPSHEETPAGEW PROPSHEETPAGEW
#define PSNRET_NOERROR
Definition: prsht.h:129
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define PSH_USEICONID
Definition: prsht.h:42
#define PSCB_INITIALIZED
Definition: prsht.h:75
struct _PROPSHEETHEADERW PROPSHEETHEADERW
struct _PSHNOTIFY * LPPSHNOTIFY
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
#define FOURTH_IPADDRESS(x)
Definition: commctrl.h:4496
struct tagNMIPADDRESS * LPNMIPADDRESS
#define MAKEIPADDRESS(b1, b2, b3, b4)
Definition: commctrl.h:4491
#define FIRST_IPADDRESS(x)
Definition: commctrl.h:4493
#define LVFI_STRING
Definition: commctrl.h:2442
#define LVIF_STATE
Definition: commctrl.h:2317
#define MAKEIPRANGE(low, high)
Definition: commctrl.h:4489
#define LVM_FINDITEMW
Definition: commctrl.h:2471
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define LVM_SETITEMW
Definition: commctrl.h:2402
#define IPM_SETADDRESS
Definition: commctrl.h:4471
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2312
#define IPN_FIELDCHANGED
Definition: commctrl.h:4482
#define SECOND_IPADDRESS(x)
Definition: commctrl.h:4494
#define LVIS_SELECTED
Definition: commctrl.h:2324
#define LVIF_PARAM
Definition: commctrl.h:2316
struct tagNMLISTVIEW * LPNMLISTVIEW
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2637
#define LVIF_TEXT
Definition: commctrl.h:2314
#define LVCF_FMT
Definition: commctrl.h:2591
#define THIRD_IPADDRESS(x)
Definition: commctrl.h:4495
#define LVCF_SUBITEM
Definition: commctrl.h:2594
#define IPM_CLEARADDRESS
Definition: commctrl.h:4470
#define IPM_GETADDRESS
Definition: commctrl.h:4472
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2416
#define LVN_ITEMCHANGED
Definition: commctrl.h:3136
#define LVM_INSERTITEMW
Definition: commctrl.h:2409
#define LVCF_TEXT
Definition: commctrl.h:2593
#define LVM_GETITEMW
Definition: commctrl.h:2395
#define IPM_SETRANGE
Definition: commctrl.h:4473
#define LV_COLUMN
Definition: commctrl.h:2552
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define SERVICE_CONTROL_PARAMCHANGE
Definition: winsvc.h:47
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define SERVICE_PAUSE_CONTINUE
Definition: winsvc.h:65
ULONG IPADDR
Definition: rassapi.h:53
PVOID pBuffer
#define WM_NOTIFY
Definition: richedit.h:61
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2107
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:622
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2199
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
#define REG_DWORD
Definition: sdbapi.c:615
#define iswalnum(_c)
Definition: ctype.h:671
wcscpy
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:171
#define LoadStringW
Definition: utils.h:64
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
AdapterSettings * pAdapterListHead
TcpipSettings * pTcpIpSettings
INetCfgComponent * pNComp
const ITcpipProperties * lpVtblTcpipProperties
AdapterSettings * pCurrentAdapter
const INetCfgComponentControl * lpVtbl
const INetCfgComponentSetup * lpVtblCompSetup
const INetCfgComponentPropertyUi * lpVtblCompPropertyUi
AdapterSettings * pAdapterListTail
DWORD UseDomainNameDevolution
DWORD EnableSecurityFilters
AlternateConfiguration AltConfig
LPWSTR szRawIPAllowedProtocols
struct _AdapterSettings * pNext
struct _AdapterSettings * pPrev
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:42
char AdapterName[MAX_ADAPTER_NAME_LENGTH+4]
Definition: iptypes.h:44
UINT DhcpEnabled
Definition: iptypes.h:50
DWORD dwForwardNextHop
Definition: ipmib.h:74
DWORD dwForwardMetric1
Definition: ipmib.h:88
IF_INDEX dwForwardIfIndex
Definition: ipmib.h:75
DWORD dwForwardDest
Definition: ipmib.h:71
DWORD dwNumEntries
Definition: ipmib.h:97
MIB_IPFORWARDROW table[1]
Definition: ipmib.h:98
HINSTANCE hInstance
Definition: prsht.h:296
DWORD dwSize
Definition: prsht.h:293
DWORD dwFlags
Definition: prsht.h:294
LPCWSTR pszIcon
Definition: prsht.h:299
HWND hwndParent
Definition: prsht.h:295
PFNPROPSHEETCALLBACK pfnCallback
Definition: prsht.h:311
HPROPSHEETPAGE * phpage
Definition: prsht.h:309
LPCWSTR pszCaption
Definition: prsht.h:301
DLGPROC pfnDlgProc
Definition: prsht.h:226
DWORD dwSize
Definition: prsht.h:214
DWORD dwFlags
Definition: prsht.h:215
LPARAM lParam
Definition: prsht.h:227
LPCWSTR pszTemplate
Definition: prsht.h:218
LPCWSTR pszTitle
Definition: prsht.h:225
HINSTANCE hInstance
Definition: prsht.h:216
NMHDR hdr
Definition: prsht.h:330
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:641
Definition: tcpip.h:126
u_long S_addr
Definition: tcpip.h:131
struct in_addr::@1123::@1124 S_un_b
union in_addr::@1123 S_un
Definition: module.h:576
union tagIP_ADDR::@548 u
struct tagIP_ADDR * Next
int cchTextMax
Definition: commctrl.h:2573
LPWSTR pszText
Definition: commctrl.h:2572
UINT_PTR idFrom
Definition: winuser.h:3266
UINT code
Definition: winuser.h:3267
UINT uNewState
Definition: commctrl.h:3041
LONG right
Definition: windef.h:108
LONG left
Definition: windef.h:106
INT_PTR CALLBACK TcpipFilterSettingsDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
HPROPSHEETPAGE InitializePropertySheetPage(LPWSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
HRESULT WINAPI INetCfgComponentPropertyUi_fnCancelProperties(INetCfgComponentPropertyUi *iface)
HRESULT WINAPI ITcpipProperties_fnQueryInterface(ITcpipProperties *iface, REFIID iid, LPVOID *ppvObj)
struct tagIP_ADDR IP_ADDR
HRESULT WINAPI INetCfgComponentPropertyUi_fnMergePropPages(INetCfgComponentPropertyUi *iface, DWORD *pdwDefPages, BYTE **pahpspPrivate, UINT *pcPages, HWND hwndParent, LPCWSTR *pszStartPage)
#define IP_STRING_MAX_LENGTH
UINT GetIpAddressFromStringW(WCHAR *szBuffer)
static HRESULT BuildIpAddressString(AdapterSettings *pAdapter, LPWSTR *ppszIpAddress)
VOID DisplayError(UINT ResTxt, UINT ResTitle, UINT Type)
static BOOL NameServersChanged(AdapterSettings *pAdapter)
VOID InitializeTcpipAdvancedIpDlg(HWND hwndDlg, TcpipConfNotifyImpl *This)
HRESULT WINAPI INetCfgComponentControl_fnQueryInterface(INetCfgComponentControl *iface, REFIID iid, LPVOID *ppvObj)
HRESULT LoadAdapterSettings(TcpipConfNotifyImpl *This, LPOLESTR pAdapterName, IP_ADAPTER_INFO *pAdapterInfo)
VOID FreeIPAddr(IP_ADDR *pAddr)
LPWSTR LoadTcpFilterSettingsFromRegistry(HKEY hKey, LPCWSTR szName, LPDWORD Size)
VOID InsertIpAddressToListView(HWND hDlgCtrl, IP_ADDR *pAddr, BOOL bSubMask)
VOID StoreIPSettings(HWND hDlgCtrl, TcpipConfNotifyImpl *This, BOOL bSubmask)
VOID LaunchAdvancedTcpipSettings(HWND hwndDlg, TcpipConfNotifyImpl *This)
LPWSTR CreateFilterList(HWND hDlgCtrl, LPDWORD Size)
VOID DeleteItemFromList(HWND hDlgCtrl)
BOOL GetGWListEntry(HWND hDlgCtrl, INT Index, TcpipGwSettings *pGwSettings)
struct _AdapterSettings AdapterSettings
ULONG WINAPI ITcpipProperties_fnAddRef(ITcpipProperties *iface)
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
VOID AddAlternativeDialog(HWND hDlg, TcpipConfNotifyImpl *This)
HRESULT WINAPI INetCfgComponentPropertyUi_fnQueryPropertyUi(INetCfgComponentPropertyUi *iface, IUnknown *pUnkReserved)
static VOID DelItem(HWND hDlgCtrl)
static __inline LPTcpipConfNotifyImpl impl_from_ITcpipProperties(ITcpipProperties *iface)
HRESULT InitializeTcpipAltDlgCtrls(HWND hwndDlg, TcpipConfNotifyImpl *This)
ULONG WINAPI INetCfgComponentSetup_fnAddRef(INetCfgComponentSetup *iface)
UINT GetIpAddressFromStringA(char *sBuffer)
INT_PTR CALLBACK TcpipAdvancedDnsDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
HRESULT LoadTcpipSettings(TcpipConfNotifyImpl *This)
COPY_TYPE
@ METRIC
@ SUBMASK
static BOOL IpAddressesChanged(AdapterSettings *pAdapter)
static const ITcpipPropertiesVtbl vt_TcpipProperties
HRESULT WINAPI INetCfgComponentControl_fnCancelChanges(INetCfgComponentControl *iface)
HRESULT WINAPI INetCfgComponentSetup_fnInstall(INetCfgComponentSetup *iface, DWORD dwSetupFlags)
HRESULT WINAPI INetCfgComponentControl_fnInitialize(INetCfgComponentControl *iface, INetCfgComponent *pIComp, INetCfg *pINetCfg, BOOL fInstalling)
BOOL VerifyDNSSuffix(LPWSTR szName)
static HRESULT BuildParametersString(AdapterSettings *pAdapter, LPWSTR *ppszParameters)
VOID InsertColumnToListView(HWND hDlgCtrl, UINT ResId, UINT SubItem, UINT Size)
VOID FreeSettings(TcpipConfNotifyImpl *This)
HRESULT InitializeTcpipBasicDlgCtrls(HWND hwndDlg, TcpipConfNotifyImpl *This)
VOID MoveItem(HWND hDlgCtrl, INT pos)
HRESULT WINAPI INetCfgComponentControl_fnApplyPnpChanges(INetCfgComponentControl *iface, INetCfgPnpReconfigCallback *pICallback)
#define IP_STRING_MIN_LENGTH
static PWSTR ExtractParameterValue(PWSTR pszParameters, PWSTR pszParameter)
INT GetSelectedItem(HWND hDlgCtrl)
HRESULT WINAPI INetCfgComponentSetup_fnUpgrade(INetCfgComponentSetup *iface, DWORD dwSetupFlags, DWORD dwUpgradeFromBuildNo)
HRESULT WINAPI INetCfgComponentSetup_fnRemoving(INetCfgComponentSetup *iface)
ULONG WINAPI INetCfgComponentPropertyUi_fnAddRef(INetCfgComponentPropertyUi *iface)
INT_PTR CALLBACK TcpipFilterPortDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
DWORD(WINAPI * PDHCPFALLBACKREFRESHPARAMS)(PWSTR pAdapterName)
ULONG WINAPI INetCfgComponentSetup_fnRelease(INetCfgComponentSetup *iface)
BOOL GetListViewItem(HWND hDlgCtrl, UINT Index, UINT SubIndex, WCHAR *szBuffer, UINT BufferSize)
HRESULT WINAPI INetCfgComponentPropertyUi_fnApplyProperties(INetCfgComponentPropertyUi *iface)
HRESULT WINAPI INetCfgComponentPropertyUi_fnSetContext(INetCfgComponentPropertyUi *iface, IUnknown *pUnkReserved)
VOID RemoveItem(HWND hDlgCtrl)
static BOOL GatewaysChanged(AdapterSettings *pAdapter)
static LPWSTR CreateMultiSzString(IP_ADDR *pAddr, COPY_TYPE Type, LPDWORD Size, BOOL bComma)
INT_PTR CALLBACK TcpipAddSuffixDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK TcpipAdvancedOptDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
INT_PTR StoreTcpipBasicSettings(HWND hwndDlg, TcpipConfNotifyImpl *This, BOOL bApply)
HRESULT WINAPI INetCfgComponentPropertyUi_fnValidateProperties(INetCfgComponentPropertyUi *iface, HWND hwndDlg)
HRESULT WINAPI INetCfgComponentPropertyUi_fnQueryInterface(INetCfgComponentPropertyUi *iface, REFIID iid, LPVOID *ppvObj)
static HRESULT BuildSubnetMaskString(AdapterSettings *pAdapter, LPWSTR *ppszSubnetMask)
ULONG WINAPI INetCfgComponentPropertyUi_fnRelease(INetCfgComponentPropertyUi *iface)
HRESULT WINAPI INetCfgComponentSetup_fnReadAnswerFile(INetCfgComponentSetup *iface, LPCWSTR pszwAnswerFile, LPCWSTR pszwAnswerSections)
HRESULT LoadGatewaySettings(HKEY hAdapterKey, AdapterSettings *pAdapter)
static AdapterSettings * GetAdapterByGuid(TcpipConfNotifyImpl *This, GUID *pAdapterGuid)
static const INetCfgComponentSetupVtbl vt_NetCfgComponentSetup
static const INetCfgComponentControlVtbl vt_NetCfgComponentControl
VOID InitializeTcpipAdvancedDNSDlg(HWND hwndDlg, TcpipConfNotifyImpl *This)
HRESULT WINAPI ITcpipProperties_fnUnknown1(ITcpipProperties *iface, GUID *pAdapterName, PTCPIP_PROPERTIES *ppProperties)
INT_PTR CALLBACK TcpipAdvancedIpDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
INT_PTR StoreTcpipAlternateSettings(HWND hwndDlg, TcpipConfNotifyImpl *This, BOOL bApply)
VOID InitFilterListBox(LPWSTR pData, HWND hwndDlg, HWND hDlgCtrl, UINT AllowButton, UINT RestrictButton, UINT AddButton, UINT DelButton)
VOID StoreDNSSettings(HWND hDlgCtrl, TcpipConfNotifyImpl *This)
INT_PTR CALLBACK TcpipAltConfDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
VOID ToggleUpDown(HWND hwndDlg, HWND hDlgCtrl, UINT UpButton, UINT DownButton, UINT ModButton, UINT DelButton)
HRESULT WINAPI INetCfgComponentSetup_fnQueryInterface(INetCfgComponentSetup *iface, REFIID iid, LPVOID *ppvObj)
INT_PTR CALLBACK TcpipAddDNSDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
VOID InitializeTcpipAdvancedOptDlg(HWND hwndDlg, TcpipConfNotifyImpl *This)
HRESULT LoadNameServerSettings(HKEY hAdapterKey, AdapterSettings *pAdapter)
static const INetCfgComponentPropertyUiVtbl vt_NetCfgComponentPropertyUi
ULONG WINAPI INetCfgComponentControl_fnRelease(INetCfgComponentControl *iface)
static __inline LPTcpipConfNotifyImpl impl_from_INetCfgComponentSetup(INetCfgComponentSetup *iface)
HRESULT LoadAddressSetings(HKEY hAdapterKey, AdapterSettings *pAdapter)
INT_PTR CALLBACK TcpipAddIpDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
HRESULT WINAPI TcpipConfigNotify_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
ULONG WINAPI INetCfgComponentControl_fnAddRef(INetCfgComponentControl *iface)
HRESULT WINAPI INetCfgComponentControl_fnApplyRegistryChanges(INetCfgComponentControl *iface)
LPWSTR GetListViewEntries(HWND hDlgCtrl)
BOOL GetIPListEntry(HWND hDlgCtrl, INT Index, TcpipIpSettings *pIpSettings)
INT_PTR CALLBACK TcpipAdvGwDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
HRESULT WINAPI ITcpipProperties_fnUnknown2(ITcpipProperties *iface, GUID *pAdapterName, PTCPIP_PROPERTIES pProperties)
INT_PTR CALLBACK TcpipBasicDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
static __inline LPTcpipConfNotifyImpl impl_from_INetCfgComponentPropertyUi(INetCfgComponentPropertyUi *iface)
struct TcpipConfNotifyImpl * LPTcpipConfNotifyImpl
ULONG WINAPI ITcpipProperties_fnRelease(ITcpipProperties *iface)
#define ICON_BIG
Definition: tnclass.cpp:51
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * PCWSTR
Definition: typedefs.h:57
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
#define AddItem
Definition: userenv.h:209
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
WINBASEAPI _In_ DWORD nLength
Definition: wincon.h:682
_In_ BOOL bEnable
Definition: winddi.h:3426
#define WINAPI
Definition: msvc.h:6
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:307
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_POINTER
Definition: winerror.h:3480
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define LB_ERR
Definition: winuser.h:2468
#define LB_GETCOUNT
Definition: winuser.h:2067
#define WM_GETTEXTLENGTH
Definition: winuser.h:1647
#define EM_LIMITTEXT
Definition: winuser.h:2029
#define DWLP_USER
Definition: winuser.h:883
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDCANCEL
Definition: winuser.h:842
#define LB_GETTEXT
Definition: winuser.h:2085
#define BST_UNCHECKED
Definition: winuser.h:199
#define WM_COMMAND
Definition: winuser.h:1768
#define WM_GETTEXT
Definition: winuser.h:1646
#define WM_INITDIALOG
Definition: winuser.h:1767
#define LB_ADDSTRING
Definition: winuser.h:2060
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_ICONERROR
Definition: winuser.h:798
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define WM_SETTEXT
Definition: winuser.h:1645
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define LB_RESETCONTENT
Definition: winuser.h:2091
#define LB_DELETESTRING
Definition: winuser.h:2061
HWND WINAPI SetFocus(_In_opt_ HWND)
#define LB_FINDSTRING
Definition: winuser.h:2063
#define LB_INSERTSTRING
Definition: winuser.h:2089
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define MB_OK
Definition: winuser.h:801
#define LB_GETTEXTLEN
Definition: winuser.h:2086
#define MB_ICONWARNING
Definition: winuser.h:797
HWND WINAPI GetParent(_In_ HWND)
#define LBN_SELCHANGE
Definition: winuser.h:2111
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define DWLP_MSGRESULT
Definition: winuser.h:881
#define MB_ICONINFORMATION
Definition: winuser.h:813
#define BN_CLICKED
Definition: winuser.h:1954
#define LB_SETCURSEL
Definition: winuser.h:2099
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define LB_GETCURSEL
Definition: winuser.h:2068
#define SendDlgItemMessage
Definition: winuser.h:6008
LRESULT WINAPI SendDlgItemMessageA(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2444
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define BM_GETCHECK
Definition: winuser.h:1947
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
static void Initialize()
Definition: xlate.c:212
unsigned char BYTE
Definition: xxhash.c:193