ReactOS  0.4.15-dev-318-g99b52df
netid.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS System Control Panel Applet
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/win32/netid/netid.c
5  * PURPOSE: Network ID Page
6  * COPYRIGHT: Thomas Weidenmueller <w3seek@reactos.org>
7  * Dmitry Chapyshev <dmitry@reactos.org>
8  *
9  */
10 
11 #define WIN32_NO_STATUS
12 #include <stdarg.h>
13 #include <windef.h>
14 #include <winbase.h>
15 #include <winuser.h>
16 #include <winreg.h>
17 #include <windns.h>
18 #include <lm.h>
19 #include <prsht.h>
20 
21 #include "resource.h"
22 
23 
24 #define MAX_COMPUTERDESCRIPTION_LENGTH 255
25 #define MAX_HOSTNAME_LENGTH 63
26 #define MAX_DOMAINNAME_LENGTH 255
27 
28 typedef struct _NETIDDATA
29 {
43 
44 
46 
47 static
48 INT
50  HWND hDlg,
51  UINT uType,
52  DWORD dwMessage,
53  ...)
54 {
55  WCHAR szTitle[256], szMessage[256], szText[512];
56  va_list args = NULL;
57 
59 
60  LoadStringW(hDllInstance, dwMessage, szMessage, ARRAYSIZE(szMessage));
61 
62  va_start(args, dwMessage);
64  szMessage,
65  0,
66  0,
67  szText,
69  &args);
70  va_end(args);
71 
72  return MessageBoxW(hDlg, szText, szTitle, uType);
73 }
74 
75 static
76 BOOL
78  PNETIDDATA pNetIdData)
79 {
81  DWORD dwSize;
82  DWORD dwError;
83 
85  L"SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
86  0,
88  &KeyHandle);
89  if (dwError == ERROR_SUCCESS)
90  {
91  dwSize = sizeof(pNetIdData->szHostName);
93  L"NV HostName",
94  0,
95  NULL,
96  (LPBYTE)&pNetIdData->szHostName,
97  &dwSize);
98 
99  dwSize = sizeof(pNetIdData->szOldHostName);
101  L"HostName",
102  0,
103  NULL,
104  (LPBYTE)&pNetIdData->szOldHostName,
105  &dwSize);
106 
107  dwSize = sizeof(pNetIdData->szDomainName);
109  L"NV Domain",
110  0,
111  NULL,
112  (LPBYTE)&pNetIdData->szDomainName,
113  &dwSize);
114 
115  dwSize = sizeof(pNetIdData->szOldDomainName);
117  L"Domain",
118  0,
119  NULL,
120  (LPBYTE)&pNetIdData->szOldDomainName,
121  &dwSize);
122 
123  dwSize = sizeof(pNetIdData->bSyncDomainWithMembership);
125  L"SyncDomainWithMembership",
126  0,
127  NULL,
128  (LPBYTE)&pNetIdData->bSyncDomainWithMembership,
129  &dwSize))
130  pNetIdData->bSyncDomainWithMembership = TRUE;
131 
133  }
134 
136  L"SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName",
137  0,
139  &KeyHandle);
140  if (dwError == ERROR_SUCCESS)
141  {
142  dwSize = sizeof(pNetIdData->szComputerName);
144  L"ComputerName",
145  0,
146  NULL,
147  (LPBYTE)&pNetIdData->szComputerName,
148  &dwSize);
149 
151  }
152 
153  if (NetGetJoinInformation(NULL, &pNetIdData->JoinName, &pNetIdData->JoinStatus) != NERR_Success)
154  {
155  pNetIdData->JoinName = NULL;
156  pNetIdData->JoinStatus = NetSetupUnknownStatus;
157  }
158 
159  return TRUE;
160 }
161 
162 static BOOL
164 {
166  PSID pAdminsSid = NULL;
167  HANDLE hToken = NULL;
168  PTOKEN_GROUPS pGroups = NULL;
169  BOOL bIsAdmin = FALSE;
170  DWORD dwSize, i;
171 
173  DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
174  &pAdminsSid))
175  return FALSE;
176 
178  TOKEN_QUERY,
179  &hToken))
180  goto done;
181 
182  dwSize = 0;
183  GetTokenInformation(hToken,
184  TokenGroups,
185  NULL,
186  0,
187  &dwSize);
188  if (dwSize == 0)
189  goto done;
190 
191  pGroups = HeapAlloc(GetProcessHeap(), 0, dwSize);
192  if (pGroups == NULL)
193  goto done;
194 
195  if (!GetTokenInformation(hToken,
196  TokenGroups,
197  pGroups,
198  dwSize,
199  &dwSize))
200  goto done;
201 
202  for (i = 0; i < pGroups->GroupCount; i++)
203  {
204  if (EqualSid(pGroups->Groups[i].Sid, pAdminsSid))
205  {
206  bIsAdmin = TRUE;
207  break;
208  }
209  }
210 
211 done:
212  if (pGroups != NULL)
213  HeapFree(GetProcessHeap(), 0, pGroups);
214 
215  if (hToken != NULL)
216  CloseHandle(hToken);
217 
218  if (pAdminsSid != NULL)
219  FreeSid(pAdminsSid);
220 
221  return bIsAdmin;
222 }
223 
224 static
225 BOOL
227  HWND hDlg,
228  UINT uId)
229 {
230  WCHAR szDomainName[256];
231  DWORD dwError;
232 
233  if (GetDlgItemTextW(hDlg, uId, szDomainName, ARRAYSIZE(szDomainName)) == 0)
234  return TRUE;
235 
236  dwError = DnsValidateName_W(szDomainName, DnsNameDomain);
237  if (dwError != ERROR_SUCCESS)
238  {
239  switch (dwError)
240  {
242  if (FormatMessageBox(hDlg, MB_YESNO | MB_ICONWARNING, 7, szDomainName) == IDYES)
243  return TRUE;
244  break;
245 
246  case ERROR_INVALID_NAME:
247  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 8, szDomainName);
248  break;
249 
251  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1031, szDomainName);
252  break;
253 
255  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1032, szDomainName);
256  break;
257  }
258 
259  return FALSE;
260  }
261 
262  return TRUE;
263 }
264 
265 static
268 {
269  PNETIDDATA pNetIdData;
270 
271  pNetIdData = (PNETIDDATA)GetWindowLongPtr(hDlg, DWLP_USER);
272 
273  switch (Msg)
274  {
275  case WM_INITDIALOG:
276  pNetIdData = (PNETIDDATA)lParam;
277  if (pNetIdData != NULL)
278  {
279  SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pNetIdData);
280 
281  SetDlgItemTextW(hDlg, 1011, pNetIdData->szDomainName);
282  SendDlgItemMessage(hDlg, 115, BM_SETCHECK, (WPARAM)pNetIdData->bSyncDomainWithMembership, 0);
283  SetDlgItemTextW(hDlg, 1013, pNetIdData->szComputerName);
285  }
286  return TRUE;
287 
288  case WM_COMMAND:
289  switch (LOWORD(wParam))
290  {
291  case 115:
292  if (HIWORD(wParam) == BN_CLICKED)
293  {
294  EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
296  }
297  break;
298 
299  case 1011:
300  if (HIWORD(wParam) == EN_CHANGE)
301  {
302  EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
303  pNetIdData->bDomainNameChanged = TRUE;
304  }
305  break;
306 
307  case IDOK:
308  if (!IsValidDomainName(hDlg, 1011))
309  {
310  SetFocus(GetDlgItem(hDlg, 1011));
311  break;
312  }
313 
314  if (pNetIdData->bDomainNameChanged)
315  GetDlgItemTextW(hDlg, 1011, pNetIdData->szDomainName, ARRAYSIZE(pNetIdData->szDomainName));
316 
317  if (pNetIdData->bSyncDomainWithMembershipChanged)
318  {
319  if (SendDlgItemMessage(hDlg, 115, BM_GETCHECK, 0, 0) == BST_CHECKED)
320  pNetIdData->bSyncDomainWithMembership = TRUE;
321  else
322  pNetIdData->bSyncDomainWithMembership = FALSE;
323  }
324 
325  EndDialog(hDlg, TRUE);
326  break;
327 
328  case IDCANCEL:
329  pNetIdData->bDomainNameChanged = FALSE;
331  EndDialog(hDlg, FALSE);
332  break;
333  }
334  break;
335  }
336 
337  return FALSE;
338 }
339 
340 static VOID
341 SetRadioBtnState(HWND hDlg, BOOL IsDomain)
342 {
343  SendDlgItemMessage(hDlg, 1008, BM_SETCHECK, (WPARAM)IsDomain, 0);
344  SendDlgItemMessage(hDlg, 1004, BM_SETCHECK, (WPARAM)!IsDomain, 0);
345  EnableWindow(GetDlgItem(hDlg, 116), IsDomain);
346  EnableWindow(GetDlgItem(hDlg, 1007), !IsDomain);
347 }
348 
349 #if 0
350 static VOID
351 DisableControls(HWND hDlg)
352 {
353  EnableWindow(GetDlgItem(hDlg, 1008), FALSE);
354  EnableWindow(GetDlgItem(hDlg, 1004), FALSE);
355  EnableWindow(GetDlgItem(hDlg, 116), FALSE);
356  EnableWindow(GetDlgItem(hDlg, 1007), FALSE);
357 }
358 #endif
359 
360 static
361 BOOL
363  HWND hDlg,
364  UINT uId)
365 {
366  WCHAR szHostName[256];
367  DWORD dwError;
368 
369  GetWindowText(GetDlgItem(hDlg, uId), szHostName, ARRAYSIZE(szHostName));
370 
371  dwError = DnsValidateName_W(szHostName, DnsNameHostnameLabel);
372  if (dwError != ERROR_SUCCESS)
373  {
374  switch (dwError)
375  {
377  if (FormatMessageBox(hDlg, MB_YESNO | MB_ICONWARNING, 10, szHostName) == IDYES)
378  return TRUE;
379  break;
380 
381  case ERROR_INVALID_NAME:
382  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 11);
383  return FALSE;
384 
386  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1029, szHostName);
387  break;
388 
390  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1030, szHostName);
391  break;
392  }
393 
394  return FALSE;
395  }
396 
397  return TRUE;
398 }
399 
400 static
401 VOID
403  HWND hDlg,
404  UINT uId,
405  PNETIDDATA pNetIdData)
406 {
407  WCHAR szFullComputerName[512];
408 
409  wsprintf(szFullComputerName, L"%s.%s", pNetIdData->szHostName, pNetIdData->szDomainName);
410  SetDlgItemText(hDlg, uId, szFullComputerName);
411 }
412 
413 static
414 VOID
416  HWND hDlg,
417  UINT uId,
418  PNETIDDATA pNetIdData)
419 {
420  WCHAR szFullComputerName[512];
421  WCHAR szHostName[256];
422 
423  GetWindowText(GetDlgItem(hDlg, 1002), szHostName, ARRAYSIZE(szHostName));
424 
425  wsprintf(szFullComputerName, L"%s.%s", szHostName, pNetIdData->szDomainName);
426  SetDlgItemText(hDlg, uId, szFullComputerName);
427 }
428 
429 static
430 VOID
432  HWND hDlg,
433  UINT uId,
434  PNETIDDATA pNetIdData)
435 {
436  WCHAR szHostName[256];
437  DWORD dwSize;
438 
439  GetWindowText(GetDlgItem(hDlg, 1002), szHostName, ARRAYSIZE(szHostName));
440 
441  dwSize = ARRAYSIZE(pNetIdData->szComputerName);
442  DnsHostnameToComputerNameW(szHostName,
443  pNetIdData->szComputerName,
444  &dwSize);
445 }
446 
447 static
448 VOID
450  _In_ HWND hwndDlg,
451  _In_ PNETIDDATA pNetIdData)
452 {
453  INT nShow = SW_HIDE;
454 
455  if ((wcsicmp(pNetIdData->szOldHostName, pNetIdData->szHostName) != 0) ||
456  (wcsicmp(pNetIdData->szOldDomainName, pNetIdData->szDomainName) != 0))
457  {
458  nShow = SW_SHOW;
459  }
460 
461  ShowWindow(GetDlgItem(hwndDlg, IDC_RESTARTICON), nShow);
462  ShowWindow(GetDlgItem(hwndDlg, IDC_RESTARTTEXT), nShow);
463 }
464 
465 static
466 VOID
468  HWND hDlg,
469  PNETIDDATA pNetIdData)
470 {
471  WCHAR MsgText[MAX_PATH * 2];
472 
473  if (LoadStringW(hDllInstance, 25, MsgText, ARRAYSIZE(MsgText)))
474  SetDlgItemText(hDlg, 1017, MsgText);
475 
477  SetDlgItemText(hDlg, 1002, pNetIdData->szHostName);
478  SetFullComputerName(hDlg, 1001, pNetIdData);
479 
480  /* Display the workgroup or domain name */
481  switch (pNetIdData->JoinStatus)
482  {
483  case NetSetupDomainName:
484  SetDlgItemText(hDlg, 116, pNetIdData->JoinName);
485  SetRadioBtnState(hDlg, TRUE);
486  break;
487 
489  SetDlgItemText(hDlg, 1007, pNetIdData->JoinName);
490  SetRadioBtnState(hDlg, FALSE);
491  break;
492 
493  default:
494  break;
495  }
496 }
497 
498 static
499 BOOL
501  HWND hDlg,
502  PNETIDDATA pNetIdData)
503 {
504  WCHAR szMsgText[MAX_PATH], szMsgTitle[MAX_PATH];
505  HKEY KeyHandle;
506  DWORD dwError;
507 
508  if (pNetIdData->bHostNameChanged)
509  {
510  if (!IsValidComputerName(hDlg, 1002))
511  {
512  SetFocus(GetDlgItem(hDlg, 1002));
513  return FALSE;
514  }
515 
516  GetWindowText(GetDlgItem(hDlg, 1002), pNetIdData->szHostName, ARRAYSIZE(pNetIdData->szHostName));
517 
518  if (!SetComputerNameExW(ComputerNamePhysicalDnsHostname, pNetIdData->szHostName))
519  {
520  LoadStringW(hDllInstance, 4001, szMsgText, ARRAYSIZE(szMsgText));
521  MessageBoxW(hDlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
522  return FALSE;
523  }
524 
525  pNetIdData->bHostNameChanged = FALSE;
526  }
527 
528  if (pNetIdData->bDomainNameChanged)
529  {
530  if (!SetComputerNameExW(ComputerNamePhysicalDnsDomain, pNetIdData->szDomainName))
531  {
532  /* FIXME: Show error message */
533  return FALSE;
534  }
535 
536  pNetIdData->bDomainNameChanged = FALSE;
537  }
538 
539  if (pNetIdData->bSyncDomainWithMembershipChanged)
540  {
542  L"SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
543  0,
545  &KeyHandle);
546  if (dwError == ERROR_SUCCESS)
547  {
549  L"SyncDomainWithMembership",
550  0,
551  REG_DWORD,
552  (LPBYTE)&pNetIdData->bSyncDomainWithMembership,
553  sizeof(pNetIdData->bSyncDomainWithMembership));
555  }
556 
558  }
559 
560  LoadStringW(hDllInstance, 4000, szMsgTitle, ARRAYSIZE(szMsgTitle));
561  LoadStringW(hDllInstance, 24, szMsgText, ARRAYSIZE(szMsgText));
562  MessageBoxW(hDlg, szMsgText, szMsgTitle, MB_OK | MB_ICONINFORMATION);
563 
564  return TRUE;
565 }
566 
567 static
570 {
571  PNETIDDATA pNetIdData;
572 
573  pNetIdData = (PNETIDDATA)GetWindowLongPtr(hDlg, DWLP_USER);
574 
575  switch (Msg)
576  {
577  case WM_INITDIALOG:
578  pNetIdData = (PNETIDDATA)lParam;
579  if (pNetIdData != NULL)
580  {
581  SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pNetIdData);
582  NetworkDlg_OnInitDialog(hDlg, pNetIdData);
584  }
585  return TRUE;
586 
587  case WM_COMMAND:
588  switch (LOWORD(wParam))
589  {
590  case 1002:
591  if (HIWORD(wParam) == EN_CHANGE)
592  {
593  UpdateFullComputerName(hDlg, 1001, pNetIdData);
594  UpdateNetbiosName(hDlg, 1001, pNetIdData);
595  pNetIdData->bHostNameChanged = TRUE;
596  EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
597  }
598  break;
599 
600  case 1008: /* Domain radio button */
601  case 1004: /* Workgroup radio button */
602  if (SendDlgItemMessage(hDlg, 1008, BM_GETCHECK, 0, 0) == BST_CHECKED)
603  SetRadioBtnState(hDlg, TRUE);
604  else
605  SetRadioBtnState(hDlg, FALSE);
606  break;
607 
608  case 1003:
611  hDlg,
613  (LPARAM)pNetIdData))
614  {
615  UpdateFullComputerName(hDlg, 1001, pNetIdData);
616  EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
617  }
618  break;
619 
620  case IDOK:
621  if (NetworkDlg_OnOK(hDlg, pNetIdData))
622  EndDialog(hDlg, TRUE);
623  break;
624 
625  case IDCANCEL:
626  EndDialog(hDlg, FALSE);
627  break;
628  }
629  break;
630  }
631 
632  return FALSE;
633 }
634 
635 static
636 VOID
638  HWND hwndDlg,
639  PNETIDDATA pNetIdData)
640 {
641  WCHAR ComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
642  DWORD RegSize = sizeof(ComputerDescription);
643  HKEY KeyHandle;
644  WCHAR szBuffer[512];
645  LONG lError;
646 
647  /* Display computer name and description */
649 
651  L"SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Parameters",
652  0,
654  &KeyHandle);
655  if (lError == ERROR_SUCCESS)
656  {
657  lError = RegQueryValueExW(KeyHandle,
658  L"srvcomment",
659  0,
660  NULL,
661  (LPBYTE)ComputerDescription,
662  &RegSize);
663  if (lError == ERROR_SUCCESS)
664  {
665  ComputerDescription[RegSize / sizeof(WCHAR)] = UNICODE_NULL;
666  SetDlgItemText(hwndDlg, IDC_COMPDESC, ComputerDescription);
667  }
668 
670  }
671 
672  /* Set the workgroup or domain name */
673  LoadStringW(hDllInstance, (pNetIdData->JoinStatus == NetSetupDomainName)? 6 : 5, szBuffer, ARRAYSIZE(szBuffer));
674  SetDlgItemText(hwndDlg, IDC_WORKGROUPDOMAIN, szBuffer);
675  SetDlgItemText(hwndDlg, IDC_WORKGROUPDOMAIN_NAME, pNetIdData->JoinName);
676 
677  /* Show the administrator note and disable controls when the user is not an administator */
678  if (!IsUserAdmin())
679  {
680  LoadStringW(hDllInstance, 1021, szBuffer, ARRAYSIZE(szBuffer));
681  SetDlgItemText(hwndDlg, IDC_MESSAGETEXT, szBuffer);
682 
685  }
686 }
687 
688 static
689 LONG
691  HWND hwndDlg)
692 {
693  WCHAR ComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
694  WCHAR NewComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
695  HKEY KeyHandle = NULL;
696  DWORD dwSize;
697  LONG lError;
698 
700  L"SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Parameters",
701  0,
703  &KeyHandle);
704  if (lError != ERROR_SUCCESS)
705  return lError;
706 
707  GetDlgItemTextW(hwndDlg,
708  IDC_COMPDESC,
709  NewComputerDescription,
710  ARRAYSIZE(NewComputerDescription));
711  if (GetLastError() != ERROR_SUCCESS)
712  {
713  lError = GetLastError();
714  goto done;
715  }
716 
717  dwSize = sizeof(ComputerDescription);
718  lError = RegQueryValueExW(KeyHandle,
719  L"srvcomment",
720  0,
721  NULL,
722  (PBYTE)ComputerDescription,
723  &dwSize);
724  if (lError != ERROR_SUCCESS && lError != ERROR_FILE_NOT_FOUND)
725  goto done;
726 
727  lError = ERROR_SUCCESS;
728  if (wcscmp(ComputerDescription, NewComputerDescription) != 0)
729  {
730  lError = RegSetValueExW(KeyHandle,
731  L"srvcomment",
732  0,
733  REG_SZ,
734  (PBYTE)NewComputerDescription,
735  (wcslen(NewComputerDescription) + 1) * sizeof(WCHAR));
736  }
737 
738 done:
739  if (KeyHandle != NULL)
741 
742  return lError;
743 }
744 
745 static INT_PTR CALLBACK
747  IN UINT uMsg,
748  IN WPARAM wParam,
749  IN LPARAM lParam)
750 {
751  PNETIDDATA pNetIdData;
752 
753  pNetIdData = (PNETIDDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
754 
755  switch (uMsg)
756  {
757  case WM_INITDIALOG:
758  pNetIdData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(NETIDDATA));
759  if (pNetIdData != NULL)
760  {
761  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pNetIdData);
762  GetComputerNames(pNetIdData);
763  SetFullComputerName(hwndDlg, IDC_COMPUTERNAME, pNetIdData);
764  NetIDPage_OnInitDialog(hwndDlg, pNetIdData);
765  pNetIdData->bEnable = TRUE;
766  CheckForChangedNames(hwndDlg, pNetIdData);
767  }
768  return TRUE;
769 
770  case WM_NOTIFY:
771  switch (((LPNMHDR)lParam)->code)
772  {
773  case PSN_APPLY:
774  NetIDPage_OnApply(hwndDlg);
775  break;
776  }
777  break;
778 
779  case WM_COMMAND:
780  switch (LOWORD(wParam))
781  {
782  case IDC_COMPDESC:
783  if (HIWORD(wParam) == EN_CHANGE && pNetIdData->bEnable == TRUE)
784  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
785  break;
786 
790  hwndDlg,
792  (LPARAM)pNetIdData))
793  {
794  UpdateFullComputerName(hwndDlg, IDC_COMPUTERNAME, pNetIdData);
795  CheckForChangedNames(hwndDlg, pNetIdData);
796  }
797  break;
798  }
799  break;
800 
801  case WM_DESTROY:
802  if (pNetIdData != NULL)
803  {
804  if (pNetIdData->JoinName != NULL)
805  NetApiBufferFree(pNetIdData->JoinName);
806  HeapFree(GetProcessHeap(), 0, pNetIdData);
807  pNetIdData = NULL;
809  }
810  break;
811  }
812 
813  return FALSE;
814 }
815 
818 {
819  PROPSHEETPAGE psp = {0};
820 
821  psp.dwSize = sizeof(psp);
822  psp.dwFlags = PSP_DEFAULT;
823  psp.hInstance = hDllInstance;
824  psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGECOMPUTER);
825  psp.pfnDlgProc = NetIDPageProc;
826 
827  return CreatePropertySheetPage(&psp);
828 }
829 
830 BOOL WINAPI
832  IN DWORD dwReason,
834 {
835  switch (dwReason)
836  {
837  case DLL_PROCESS_ATTACH:
838  hDllInstance = hinstDLL;
839  DisableThreadLibraryCalls(hinstDLL);
840  break;
841  }
842 
843  return TRUE;
844 }
struct @1608 Msg[]
BOOL WINAPI DllMain(IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
Definition: netid.c:831
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IN
Definition: typedefs.h:39
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:407
#define IDC_NETWORK_PROPERTY
Definition: resource.h:19
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDYES
Definition: winuser.h:829
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define IDD_PROPPAGECOMPUTER
Definition: resource.h:12
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define IDC_MESSAGETEXT
Definition: resource.h:20
#define MAX_DOMAINNAME_LENGTH
Definition: netid.c:26
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:708
#define EM_SETLIMITTEXT
Definition: winuser.h:1993
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:402
#define DNS_ERROR_NON_RFC_NAME
Definition: winerror.h:1872
#define CALLBACK
Definition: compat.h:27
static VOID NetworkDlg_OnInitDialog(HWND hDlg, PNETIDDATA pNetIdData)
Definition: netid.c:467
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
struct _NETIDDATA NETIDDATA
NETSETUP_JOIN_STATUS JoinStatus
Definition: netid.c:37
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
UINT_PTR WPARAM
Definition: windef.h:207
static LONG NetIDPage_OnApply(HWND hwndDlg)
Definition: netid.c:690
#define SendDlgItemMessage
Definition: winuser.h:5817
BOOL bSyncDomainWithMembershipChanged
Definition: netid.c:40
#define PSN_APPLY
Definition: prsht.h:117
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT_PTR
Definition: typedefs.h:63
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
static VOID UpdateFullComputerName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:415
Definition: match.c:390
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:57
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
DNS_STATUS WINAPI DnsValidateName_W(PCWSTR name, DNS_NAME_FORMAT format)
Definition: names.c:124
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH+1]
Definition: netid.c:34
static IN DWORD IN LPVOID lpvReserved
#define MB_ICONWARNING
Definition: winuser.h:780
#define GetWindowText
Definition: winuser.h:5773
#define NERR_Success
Definition: lmerr.h:5
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
DWORD dwReason
Definition: misc.cpp:154
#define IDC_WORKGROUPDOMAIN_NAME
Definition: resource.h:16
BOOL bEnable
Definition: netid.c:41
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define va_end(ap)
Definition: acmsvcex.h:90
#define MB_YESNO
Definition: winuser.h:811
#define UNICODE_NULL
static const WCHAR szText[]
Definition: dialog.c:139
BOOL bDomainNameChanged
Definition: netid.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:577
#define IDC_COMPDESC
Definition: resource.h:14
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
smooth NULL
Definition: ftsmooth.c:416
#define IDC_RESTARTTEXT
Definition: resource.h:22
LONG_PTR LPARAM
Definition: windef.h:208
static INT_PTR CALLBACK DNSSuffixPropDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: netid.c:267
char * va_list
Definition: acmsvcex.h:78
#define BM_GETCHECK
Definition: winuser.h:1900
#define IDC_WORKGROUPDOMAIN
Definition: resource.h:17
#define SW_SHOW
Definition: winuser.h:769
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static HINSTANCE hDllInstance
Definition: netid.c:45
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:526
#define CreatePropertySheetPage
Definition: prsht.h:399
#define WM_DESTROY
Definition: winuser.h:1591
BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname, LPWSTR computername, LPDWORD size)
Definition: compname.c:686
BOOL bHostNameChanged
Definition: netid.c:38
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:4895
#define IDC_NETWORK_ID
Definition: resource.h:18
#define PSP_DEFAULT
Definition: prsht.h:22
#define BM_SETCHECK
Definition: winuser.h:1903
NET_API_STATUS WINAPI NetGetJoinInformation(_In_ LPCWSTR lpServer, _Out_ LPWSTR *lpNameBuffer, _Out_ PNETSETUP_JOIN_STATUS BufferType)
Definition: wksta_new.c:317
#define MAX_HOSTNAME_LENGTH
Definition: netid.c:25
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:553
#define TOKEN_QUERY
Definition: setypes.h:874
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR szHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:30
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
static BOOL IsValidComputerName(HWND hDlg, UINT uId)
Definition: netid.c:362
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:6
#define IDC_RESTARTICON
Definition: resource.h:21
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID NetIDPage_OnInitDialog(HWND hwndDlg, PNETIDDATA pNetIdData)
Definition: netid.c:637
#define SetDlgItemText
Definition: winuser.h:5824
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define IDD_PROPPAGECOMPNAMECHENGE
Definition: resource.h:10
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define DialogBoxParam
Definition: winuser.h:5739
#define IDC_COMPUTERNAME
Definition: resource.h:15
static INT_PTR CALLBACK NetIDPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: netid.c:746
static const WCHAR L[]
Definition: oid.c:1250
#define DWLP_USER
Definition: winuser.h:866
#define MB_ICONERROR
Definition: winuser.h:781
static VOID SetFullComputerName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:402
#define WM_COMMAND
Definition: winuser.h:1722
#define wcsicmp
Definition: string.h:1152
static VOID SetRadioBtnState(HWND hDlg, BOOL IsDomain)
Definition: netid.c:341
WCHAR szOldDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:33
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
static VOID CheckForChangedNames(_In_ HWND hwndDlg, _In_ PNETIDDATA pNetIdData)
Definition: netid.c:449
#define _In_
Definition: no_sal2.h:204
#define MAX_COMPUTERDESCRIPTION_LENGTH
Definition: netid.c:24
static INT_PTR CALLBACK NetworkPropDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: netid.c:569
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
HWND WINAPI GetParent(_In_ HWND)
HPROPSHEETPAGE WINAPI CreateNetIDPropertyPage(VOID)
Definition: netid.c:817
WCHAR szOldHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:31
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
static BOOL NetworkDlg_OnOK(HWND hDlg, PNETIDDATA pNetIdData)
Definition: netid.c:500
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]
Definition: setypes.h:964
struct _NETIDDATA * PNETIDDATA
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define va_start(ap, A)
Definition: acmsvcex.h:91
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define MB_OK
Definition: winuser.h:784
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static BOOL GetComputerNames(PNETIDDATA pNetIdData)
Definition: netid.c:77
#define BST_CHECKED
Definition: winuser.h:197
#define IDD_PROPPAGEDNSANDNETBIOS
Definition: resource.h:11
#define DNS_ERROR_INVALID_NAME_CHAR
Definition: winerror.h:1877
$ULONG GroupCount
Definition: setypes.h:960
#define SendMessage
Definition: winuser.h:5818
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define ERROR_INVALID_NAME
Definition: compat.h:93
#define GetWindowLongPtr
Definition: treelist.c:73
static VOID UpdateNetbiosName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:431
BOOL bSyncDomainWithMembership
Definition: netid.c:35
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define DNS_ERROR_NUMERIC_NAME
Definition: winerror.h:1878
#define wsprintf
Definition: winuser.h:5840
#define REG_DWORD
Definition: sdbapi.c:596
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:624
BYTE * PBYTE
Definition: pedump.c:66
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
LPWSTR JoinName
Definition: netid.c:36
#define LOWORD(l)
Definition: pedump.c:82
static BOOL IsValidDomainName(HWND hDlg, UINT uId)
Definition: netid.c:226
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:403
BOOL WINAPI SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPCWSTR lpBuffer)
Definition: compname.c:602
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define PROPSHEETPAGE
Definition: prsht.h:389
#define WM_NOTIFY
Definition: richedit.h:61
enum _NETSETUP_JOIN_STATUS NETSETUP_JOIN_STATUS
WCHAR szDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:32
static INT FormatMessageBox(HWND hDlg, UINT uType, DWORD dwMessage,...)
Definition: netid.c:49
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:553
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22
#define EN_CHANGE
Definition: winuser.h:2004