ReactOS 0.4.15-dev-7953-g1f49173
netid.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <winreg.h>
#include <windns.h>
#include <lm.h>
#include <prsht.h>
#include "resource.h"
Include dependency graph for netid.c:

Go to the source code of this file.

Classes

struct  _NETIDDATA
 

Macros

#define WIN32_NO_STATUS
 
#define MAX_COMPUTERDESCRIPTION_LENGTH   255
 
#define MAX_HOSTNAME_LENGTH   63
 
#define MAX_DOMAINNAME_LENGTH   255
 

Typedefs

typedef struct _NETIDDATA NETIDDATA
 
typedef struct _NETIDDATAPNETIDDATA
 

Functions

static INT FormatMessageBox (HWND hDlg, UINT uType, DWORD dwMessage,...)
 
static BOOL GetComputerNames (PNETIDDATA pNetIdData)
 
static BOOL IsUserAdmin (VOID)
 
static BOOL IsValidDomainName (HWND hDlg, UINT uId)
 
static INT_PTR CALLBACK DNSSuffixPropDlgProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static VOID SetRadioBtnState (HWND hDlg, BOOL IsDomain)
 
static BOOL IsValidComputerName (HWND hDlg, UINT uId)
 
static VOID SetFullComputerName (HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
 
static VOID UpdateFullComputerName (HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
 
static VOID UpdateNetbiosName (HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
 
static VOID CheckForChangedNames (_In_ HWND hwndDlg, _In_ PNETIDDATA pNetIdData)
 
static VOID NetworkDlg_OnInitDialog (HWND hDlg, PNETIDDATA pNetIdData)
 
static BOOL NetworkDlg_OnOK (HWND hDlg, PNETIDDATA pNetIdData)
 
static INT_PTR CALLBACK NetworkPropDlgProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static VOID NetIDPage_OnInitDialog (HWND hwndDlg, PNETIDDATA pNetIdData)
 
static LONG NetIDPage_OnApply (HWND hwndDlg)
 
static INT_PTR CALLBACK NetIDPageProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
HPROPSHEETPAGE WINAPI CreateNetIDPropertyPage (VOID)
 
BOOL WINAPI DllMain (IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
 

Variables

static HINSTANCE hDllInstance
 

Macro Definition Documentation

◆ MAX_COMPUTERDESCRIPTION_LENGTH

#define MAX_COMPUTERDESCRIPTION_LENGTH   255

Definition at line 24 of file netid.c.

◆ MAX_DOMAINNAME_LENGTH

#define MAX_DOMAINNAME_LENGTH   255

Definition at line 26 of file netid.c.

◆ MAX_HOSTNAME_LENGTH

#define MAX_HOSTNAME_LENGTH   63

Definition at line 25 of file netid.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file netid.c.

Typedef Documentation

◆ NETIDDATA

◆ PNETIDDATA

Function Documentation

◆ CheckForChangedNames()

static VOID CheckForChangedNames ( _In_ HWND  hwndDlg,
_In_ PNETIDDATA  pNetIdData 
)
static

Definition at line 410 of file netid.c.

413{
414 INT nShow = SW_HIDE;
415
416 if ((wcsicmp(pNetIdData->szOldHostName, pNetIdData->szHostName) != 0) ||
417 (wcsicmp(pNetIdData->szOldDomainName, pNetIdData->szDomainName) != 0))
418 {
419 nShow = SW_SHOW;
420 }
421
422 ShowWindow(GetDlgItem(hwndDlg, IDC_RESTARTICON), nShow);
423 ShowWindow(GetDlgItem(hwndDlg, IDC_RESTARTTEXT), nShow);
424}
#define wcsicmp
Definition: compat.h:15
#define IDC_RESTARTTEXT
Definition: resource.h:22
#define IDC_RESTARTICON
Definition: resource.h:21
int32_t INT
Definition: typedefs.h:58
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:775

Referenced by NetIDPageProc().

◆ CreateNetIDPropertyPage()

HPROPSHEETPAGE WINAPI CreateNetIDPropertyPage ( VOID  )

Definition at line 778 of file netid.c.

779{
780 PROPSHEETPAGE psp = {0};
781
782 psp.dwSize = sizeof(psp);
783 psp.dwFlags = PSP_DEFAULT;
784 psp.hInstance = hDllInstance;
785 psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGECOMPUTER);
786 psp.pfnDlgProc = NetIDPageProc;
787
788 return CreatePropertySheetPage(&psp);
789}
#define IDD_PROPPAGECOMPUTER
Definition: resource.h:12
static INT_PTR CALLBACK NetIDPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: netid.c:707
static HINSTANCE hDllInstance
Definition: netid.c:45
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSP_DEFAULT
Definition: prsht.h:22
#define PROPSHEETPAGE
Definition: prsht.h:389
#define MAKEINTRESOURCE
Definition: winuser.h:591

◆ DllMain()

BOOL WINAPI DllMain ( IN HINSTANCE  hinstDLL,
IN DWORD  dwReason,
IN LPVOID  lpvReserved 
)

@DllMain

Core routine of the Utility Manager's library.

Parameters
[in]hDllInstanceThe entry point instance of the library.
[in]fdwReasonThe reason argument to indicate the motive DllMain is being called.
[in]lpvReservedReserved.
Returns
Returns TRUE when main call initialization has succeeded, FALSE otherwise.

Definition at line 792 of file netid.c.

795{
796 switch (dwReason)
797 {
799 hDllInstance = hinstDLL;
801 break;
802 }
803
804 return TRUE;
805}
DWORD dwReason
Definition: misc.cpp:154
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85

◆ DNSSuffixPropDlgProc()

static INT_PTR CALLBACK DNSSuffixPropDlgProc ( HWND  hDlg,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 228 of file netid.c.

229{
230 PNETIDDATA pNetIdData;
231
232 pNetIdData = (PNETIDDATA)GetWindowLongPtr(hDlg, DWLP_USER);
233
234 switch (Msg)
235 {
236 case WM_INITDIALOG:
237 pNetIdData = (PNETIDDATA)lParam;
238 if (pNetIdData != NULL)
239 {
240 SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pNetIdData);
241
242 SetDlgItemTextW(hDlg, 1011, pNetIdData->szDomainName);
244 SetDlgItemTextW(hDlg, 1013, pNetIdData->szComputerName);
246 }
247 return TRUE;
248
249 case WM_COMMAND:
250 switch (LOWORD(wParam))
251 {
252 case 115:
253 if (HIWORD(wParam) == BN_CLICKED)
254 {
257 }
258 break;
259
260 case 1011:
261 if (HIWORD(wParam) == EN_CHANGE)
262 {
264 pNetIdData->bDomainNameChanged = TRUE;
265 }
266 break;
267
268 case IDOK:
269 if (!IsValidDomainName(hDlg, 1011))
270 {
271 SetFocus(GetDlgItem(hDlg, 1011));
272 break;
273 }
274
275 if (pNetIdData->bDomainNameChanged)
276 GetDlgItemTextW(hDlg, 1011, pNetIdData->szDomainName, ARRAYSIZE(pNetIdData->szDomainName));
277
278 if (pNetIdData->bSyncDomainWithMembershipChanged)
279 {
280 if (SendDlgItemMessage(hDlg, 115, BM_GETCHECK, 0, 0) == BST_CHECKED)
281 pNetIdData->bSyncDomainWithMembership = TRUE;
282 else
283 pNetIdData->bSyncDomainWithMembership = FALSE;
284 }
285
286 EndDialog(hDlg, TRUE);
287 break;
288
289 case IDCANCEL:
290 pNetIdData->bDomainNameChanged = FALSE;
292 EndDialog(hDlg, FALSE);
293 break;
294 }
295 break;
296 }
297
298 return FALSE;
299}
struct @1632 Msg[]
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
struct _NETIDDATA * PNETIDDATA
static BOOL IsValidDomainName(HWND hDlg, UINT uId)
Definition: netid.c:187
#define LOWORD(l)
Definition: pedump.c:82
BOOL bSyncDomainWithMembershipChanged
Definition: netid.c:40
BOOL bDomainNameChanged
Definition: netid.c:39
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH+1]
Definition: netid.c:34
BOOL bSyncDomainWithMembership
Definition: netid.c:35
WCHAR szDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:32
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define HIWORD(l)
Definition: typedefs.h:247
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
UINT_PTR WPARAM
Definition: windef.h:207
#define DWLP_USER
Definition: winuser.h:872
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
#define BM_SETCHECK
Definition: winuser.h:1921
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define BN_CLICKED
Definition: winuser.h:1925
#define SendDlgItemMessage
Definition: winuser.h:5842
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1918
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define EN_CHANGE
Definition: winuser.h:2022

Referenced by NetworkPropDlgProc().

◆ FormatMessageBox()

static INT FormatMessageBox ( HWND  hDlg,
UINT  uType,
DWORD  dwMessage,
  ... 
)
static

Definition at line 49 of file netid.c.

54{
55 WCHAR szTitle[256], szMessage[256], szText[512];
57
59
60 LoadStringW(hDllInstance, dwMessage, szMessage, ARRAYSIZE(szMessage));
61
62 va_start(args, dwMessage);
64 szMessage,
65 0,
66 0,
67 szText,
68 ARRAYSIZE(szText),
69 &args);
70 va_end(args);
71
72 return MessageBoxW(hDlg, szText, szTitle, uType);
73}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
Definition: match.c:390
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:421
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IsValidComputerName(), and IsValidDomainName().

◆ GetComputerNames()

static BOOL GetComputerNames ( PNETIDDATA  pNetIdData)
static

Definition at line 77 of file netid.c.

79{
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}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NERR_Success
Definition: lmerr.h:5
@ NetSetupUnknownStatus
Definition: lmjoin.h:10
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define L(x)
Definition: ntvdm.h:50
LPWSTR JoinName
Definition: netid.c:36
NETSETUP_JOIN_STATUS JoinStatus
Definition: netid.c:37
WCHAR szOldHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:31
WCHAR szOldDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:33
WCHAR szHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:30
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
NET_API_STATUS WINAPI NetGetJoinInformation(_In_ LPCWSTR lpServer, _Out_ LPWSTR *lpNameBuffer, _Out_ PNETSETUP_JOIN_STATUS BufferType)
Definition: wksta_new.c:317

Referenced by NetIDPageProc().

◆ IsUserAdmin()

static BOOL IsUserAdmin ( VOID  )
static

Definition at line 163 of file netid.c.

164{
165 BOOL bIsAdmin;
167 PSID pAdminsSid;
168
169 if (!AllocateAndInitializeSid(&Authority, 2,
172 0, 0, 0, 0, 0, 0,
173 &pAdminsSid))
174 {
175 return FALSE;
176 }
177
178 if (!CheckTokenMembership(NULL, pAdminsSid, &bIsAdmin))
179 bIsAdmin = FALSE;
180 FreeSid(pAdminsSid);
181
182 return bIsAdmin;
183}
BOOL WINAPI CheckTokenMembership(IN HANDLE ExistingTokenHandle, IN PSID SidToCheck, OUT PBOOL IsMember)
Definition: token.c:21
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:674
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

Referenced by Applet(), DevInstallW(), CNetConnection::GetProperties(), NetIDPage_OnInitDialog(), OnInitUserProfileDialog(), and test_mode_generic().

◆ IsValidComputerName()

static BOOL IsValidComputerName ( HWND  hDlg,
UINT  uId 
)
static

Definition at line 323 of file netid.c.

326{
327 WCHAR szHostName[256];
328 DWORD dwError;
329
330 GetWindowText(GetDlgItem(hDlg, uId), szHostName, ARRAYSIZE(szHostName));
331
332 dwError = DnsValidateName_W(szHostName, DnsNameHostnameLabel);
333 if (dwError != ERROR_SUCCESS)
334 {
335 switch (dwError)
336 {
338 if (FormatMessageBox(hDlg, MB_YESNO | MB_ICONWARNING, 10, szHostName) == IDYES)
339 return TRUE;
340 break;
341
344 return FALSE;
345
347 FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1029, szHostName);
348 break;
349
351 FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1030, szHostName);
352 break;
353 }
354
355 return FALSE;
356 }
357
358 return TRUE;
359}
#define ERROR_INVALID_NAME
Definition: compat.h:103
DNS_STATUS WINAPI DnsValidateName_W(PCWSTR name, DNS_NAME_FORMAT format)
Definition: names.c:124
static INT FormatMessageBox(HWND hDlg, UINT uType, DWORD dwMessage,...)
Definition: netid.c:49
@ DnsNameHostnameLabel
Definition: windns.h:147
#define DNS_ERROR_NUMERIC_NAME
Definition: winerror.h:1878
#define DNS_ERROR_NON_RFC_NAME
Definition: winerror.h:1872
#define DNS_ERROR_INVALID_NAME_CHAR
Definition: winerror.h:1877
#define MB_YESNO
Definition: winuser.h:817
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790
#define GetWindowText
Definition: winuser.h:5798
#define MB_ICONWARNING
Definition: winuser.h:786
#define IDYES
Definition: winuser.h:835

Referenced by NetworkDlg_OnOK().

◆ IsValidDomainName()

static BOOL IsValidDomainName ( HWND  hDlg,
UINT  uId 
)
static

Definition at line 187 of file netid.c.

190{
191 WCHAR szDomainName[256];
192 DWORD dwError;
193
194 if (GetDlgItemTextW(hDlg, uId, szDomainName, ARRAYSIZE(szDomainName)) == 0)
195 return TRUE;
196
197 dwError = DnsValidateName_W(szDomainName, DnsNameDomain);
198 if (dwError != ERROR_SUCCESS)
199 {
200 switch (dwError)
201 {
203 if (FormatMessageBox(hDlg, MB_YESNO | MB_ICONWARNING, 7, szDomainName) == IDYES)
204 return TRUE;
205 break;
206
208 FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 8, szDomainName);
209 break;
210
212 FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1031, szDomainName);
213 break;
214
216 FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1032, szDomainName);
217 break;
218 }
219
220 return FALSE;
221 }
222
223 return TRUE;
224}
@ DnsNameDomain
Definition: windns.h:144

Referenced by DNSSuffixPropDlgProc().

◆ NetIDPage_OnApply()

static LONG NetIDPage_OnApply ( HWND  hwndDlg)
static

Definition at line 651 of file netid.c.

653{
654 WCHAR ComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
655 WCHAR NewComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
658 LONG lError;
659
661 L"SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Parameters",
662 0,
664 &KeyHandle);
665 if (lError != ERROR_SUCCESS)
666 return lError;
667
668 GetDlgItemTextW(hwndDlg,
670 NewComputerDescription,
671 ARRAYSIZE(NewComputerDescription));
673 {
674 lError = GetLastError();
675 goto done;
676 }
677
678 dwSize = sizeof(ComputerDescription);
680 L"srvcomment",
681 0,
682 NULL,
683 (PBYTE)ComputerDescription,
684 &dwSize);
685 if (lError != ERROR_SUCCESS && lError != ERROR_FILE_NOT_FOUND)
686 goto done;
687
688 lError = ERROR_SUCCESS;
689 if (wcscmp(ComputerDescription, NewComputerDescription) != 0)
690 {
691 lError = RegSetValueExW(KeyHandle,
692 L"srvcomment",
693 0,
694 REG_SZ,
695 (PBYTE)NewComputerDescription,
696 (wcslen(NewComputerDescription) + 1) * sizeof(WCHAR));
697 }
698
699done:
700 if (KeyHandle != NULL)
702
703 return lError;
704}
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
#define IDC_COMPDESC
Definition: resource.h:14
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define MAX_COMPUTERDESCRIPTION_LENGTH
Definition: netid.c:24
#define KEY_SET_VALUE
Definition: nt_native.h:1017
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by NetIDPageProc().

◆ NetIDPage_OnInitDialog()

static VOID NetIDPage_OnInitDialog ( HWND  hwndDlg,
PNETIDDATA  pNetIdData 
)
static

Definition at line 598 of file netid.c.

601{
602 WCHAR ComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
603 DWORD RegSize = sizeof(ComputerDescription);
605 WCHAR szBuffer[512];
606 LONG lError;
607
608 /* Display computer name and description */
610
612 L"SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Parameters",
613 0,
615 &KeyHandle);
616 if (lError == ERROR_SUCCESS)
617 {
619 L"srvcomment",
620 0,
621 NULL,
622 (LPBYTE)ComputerDescription,
623 &RegSize);
624 if (lError == ERROR_SUCCESS)
625 {
626 ComputerDescription[RegSize / sizeof(WCHAR)] = UNICODE_NULL;
627 SetDlgItemText(hwndDlg, IDC_COMPDESC, ComputerDescription);
628 }
629
631 }
632
633 /* Set the workgroup or domain name */
634 LoadStringW(hDllInstance, (pNetIdData->JoinStatus == NetSetupDomainName)? 6 : 5, szBuffer, ARRAYSIZE(szBuffer));
635 SetDlgItemText(hwndDlg, IDC_WORKGROUPDOMAIN, szBuffer);
636 SetDlgItemText(hwndDlg, IDC_WORKGROUPDOMAIN_NAME, pNetIdData->JoinName);
637
638 /* Show the administrator note and disable controls when the user is not an administator */
639 if (!IsUserAdmin())
640 {
641 LoadStringW(hDllInstance, 1021, szBuffer, ARRAYSIZE(szBuffer));
642 SetDlgItemText(hwndDlg, IDC_MESSAGETEXT, szBuffer);
643
646 }
647}
#define IDC_NETWORK_PROPERTY
Definition: resource.h:19
#define IDC_WORKGROUPDOMAIN
Definition: resource.h:17
#define IDC_MESSAGETEXT
Definition: resource.h:20
#define IDC_NETWORK_ID
Definition: resource.h:18
#define IDC_WORKGROUPDOMAIN_NAME
Definition: resource.h:16
@ NetSetupDomainName
Definition: lmjoin.h:13
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
#define UNICODE_NULL
#define EM_SETLIMITTEXT
Definition: winuser.h:2011
#define SetDlgItemText
Definition: winuser.h:5849

Referenced by NetIDPageProc().

◆ NetIDPageProc()

static INT_PTR CALLBACK NetIDPageProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 707 of file netid.c.

711{
712 PNETIDDATA pNetIdData;
713
714 pNetIdData = (PNETIDDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
715
716 switch (uMsg)
717 {
718 case WM_INITDIALOG:
719 pNetIdData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(NETIDDATA));
720 if (pNetIdData != NULL)
721 {
722 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pNetIdData);
723 GetComputerNames(pNetIdData);
724 SetFullComputerName(hwndDlg, IDC_COMPUTERNAME, pNetIdData);
725 NetIDPage_OnInitDialog(hwndDlg, pNetIdData);
726 pNetIdData->bEnable = TRUE;
727 CheckForChangedNames(hwndDlg, pNetIdData);
728 }
729 return TRUE;
730
731 case WM_NOTIFY:
732 switch (((LPNMHDR)lParam)->code)
733 {
734 case PSN_APPLY:
735 NetIDPage_OnApply(hwndDlg);
736 break;
737 }
738 break;
739
740 case WM_COMMAND:
741 switch (LOWORD(wParam))
742 {
743 case IDC_COMPDESC:
744 if (HIWORD(wParam) == EN_CHANGE && pNetIdData->bEnable == TRUE)
745 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
746 break;
747
751 hwndDlg,
753 (LPARAM)pNetIdData))
754 {
755 UpdateFullComputerName(hwndDlg, IDC_COMPUTERNAME, pNetIdData);
756 CheckForChangedNames(hwndDlg, pNetIdData);
757 }
758 break;
759 }
760 break;
761
762 case WM_DESTROY:
763 if (pNetIdData != NULL)
764 {
765 if (pNetIdData->JoinName != NULL)
766 NetApiBufferFree(pNetIdData->JoinName);
767 HeapFree(GetProcessHeap(), 0, pNetIdData);
768 pNetIdData = NULL;
770 }
771 break;
772 }
773
774 return FALSE;
775}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define IDC_COMPUTERNAME
Definition: resource.h:15
#define IDD_PROPPAGECOMPNAMECHENGE
Definition: resource.h:10
static INT_PTR CALLBACK NetworkPropDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: netid.c:530
static VOID UpdateFullComputerName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:376
static LONG NetIDPage_OnApply(HWND hwndDlg)
Definition: netid.c:651
static VOID SetFullComputerName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:363
static BOOL GetComputerNames(PNETIDDATA pNetIdData)
Definition: netid.c:77
static VOID NetIDPage_OnInitDialog(HWND hwndDlg, PNETIDDATA pNetIdData)
Definition: netid.c:598
static VOID CheckForChangedNames(_In_ HWND hwndDlg, _In_ PNETIDDATA pNetIdData)
Definition: netid.c:410
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define WM_NOTIFY
Definition: richedit.h:61
BOOL bEnable
Definition: netid.c:41
Definition: inflate.c:139
LONG_PTR LPARAM
Definition: windef.h:208
#define DialogBoxParam
Definition: winuser.h:5764
HWND WINAPI GetParent(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by CreateNetIDPropertyPage().

◆ NetworkDlg_OnInitDialog()

static VOID NetworkDlg_OnInitDialog ( HWND  hDlg,
PNETIDDATA  pNetIdData 
)
static

Definition at line 428 of file netid.c.

431{
432 WCHAR MsgText[MAX_PATH * 2];
433
434 if (LoadStringW(hDllInstance, 25, MsgText, ARRAYSIZE(MsgText)))
435 SetDlgItemText(hDlg, 1017, MsgText);
436
438 SetDlgItemText(hDlg, 1002, pNetIdData->szHostName);
439 SetFullComputerName(hDlg, 1001, pNetIdData);
440
441 /* Display the workgroup or domain name */
442 switch (pNetIdData->JoinStatus)
443 {
445 SetDlgItemText(hDlg, 116, pNetIdData->JoinName);
446 SetRadioBtnState(hDlg, TRUE);
447 break;
448
450 SetDlgItemText(hDlg, 1007, pNetIdData->JoinName);
451 SetRadioBtnState(hDlg, FALSE);
452 break;
453
454 default:
455 break;
456 }
457}
#define MAX_PATH
Definition: compat.h:34
@ NetSetupWorkgroupName
Definition: lmjoin.h:12
static VOID SetRadioBtnState(HWND hDlg, BOOL IsDomain)
Definition: netid.c:302
#define MAX_HOSTNAME_LENGTH
Definition: netid.c:25
#define SendMessage
Definition: winuser.h:5843

Referenced by NetworkPropDlgProc().

◆ NetworkDlg_OnOK()

static BOOL NetworkDlg_OnOK ( HWND  hDlg,
PNETIDDATA  pNetIdData 
)
static

Definition at line 461 of file netid.c.

464{
465 WCHAR szMsgText[MAX_PATH], szMsgTitle[MAX_PATH];
467 DWORD dwError;
468
469 if (pNetIdData->bHostNameChanged)
470 {
471 if (!IsValidComputerName(hDlg, 1002))
472 {
473 SetFocus(GetDlgItem(hDlg, 1002));
474 return FALSE;
475 }
476
477 GetWindowText(GetDlgItem(hDlg, 1002), pNetIdData->szHostName, ARRAYSIZE(pNetIdData->szHostName));
478
479 if (!SetComputerNameExW(ComputerNamePhysicalDnsHostname, pNetIdData->szHostName))
480 {
481 LoadStringW(hDllInstance, 4001, szMsgText, ARRAYSIZE(szMsgText));
482 MessageBoxW(hDlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
483 return FALSE;
484 }
485
486 pNetIdData->bHostNameChanged = FALSE;
487 }
488
489 if (pNetIdData->bDomainNameChanged)
490 {
491 if (!SetComputerNameExW(ComputerNamePhysicalDnsDomain, pNetIdData->szDomainName))
492 {
493 /* FIXME: Show error message */
494 return FALSE;
495 }
496
497 pNetIdData->bDomainNameChanged = FALSE;
498 }
499
500 if (pNetIdData->bSyncDomainWithMembershipChanged)
501 {
503 L"SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
504 0,
506 &KeyHandle);
507 if (dwError == ERROR_SUCCESS)
508 {
510 L"SyncDomainWithMembership",
511 0,
512 REG_DWORD,
513 (LPBYTE)&pNetIdData->bSyncDomainWithMembership,
514 sizeof(pNetIdData->bSyncDomainWithMembership));
516 }
517
519 }
520
521 LoadStringW(hDllInstance, 4000, szMsgTitle, ARRAYSIZE(szMsgTitle));
522 LoadStringW(hDllInstance, 24, szMsgText, ARRAYSIZE(szMsgText));
523 MessageBoxW(hDlg, szMsgText, szMsgTitle, MB_OK | MB_ICONINFORMATION);
524
525 return TRUE;
526}
BOOL WINAPI SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPCWSTR lpBuffer)
Definition: compname.c:648
static BOOL IsValidComputerName(HWND hDlg, UINT uId)
Definition: netid.c:323
#define REG_DWORD
Definition: sdbapi.c:596
BOOL bHostNameChanged
Definition: netid.c:38
#define MB_ICONINFORMATION
Definition: winuser.h:802

Referenced by NetworkPropDlgProc().

◆ NetworkPropDlgProc()

static INT_PTR CALLBACK NetworkPropDlgProc ( HWND  hDlg,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 530 of file netid.c.

531{
532 PNETIDDATA pNetIdData;
533
534 pNetIdData = (PNETIDDATA)GetWindowLongPtr(hDlg, DWLP_USER);
535
536 switch (Msg)
537 {
538 case WM_INITDIALOG:
539 pNetIdData = (PNETIDDATA)lParam;
540 if (pNetIdData != NULL)
541 {
542 SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pNetIdData);
543 NetworkDlg_OnInitDialog(hDlg, pNetIdData);
545 }
546 return TRUE;
547
548 case WM_COMMAND:
549 switch (LOWORD(wParam))
550 {
551 case 1002:
552 if (HIWORD(wParam) == EN_CHANGE)
553 {
554 UpdateFullComputerName(hDlg, 1001, pNetIdData);
555 UpdateNetbiosName(hDlg, 1001, pNetIdData);
556 pNetIdData->bHostNameChanged = TRUE;
558 }
559 break;
560
561 case 1008: /* Domain radio button */
562 case 1004: /* Workgroup radio button */
563 if (SendDlgItemMessage(hDlg, 1008, BM_GETCHECK, 0, 0) == BST_CHECKED)
564 SetRadioBtnState(hDlg, TRUE);
565 else
566 SetRadioBtnState(hDlg, FALSE);
567 break;
568
569 case 1003:
572 hDlg,
574 (LPARAM)pNetIdData))
575 {
576 UpdateFullComputerName(hDlg, 1001, pNetIdData);
578 }
579 break;
580
581 case IDOK:
582 if (NetworkDlg_OnOK(hDlg, pNetIdData))
583 EndDialog(hDlg, TRUE);
584 break;
585
586 case IDCANCEL:
587 EndDialog(hDlg, FALSE);
588 break;
589 }
590 break;
591 }
592
593 return FALSE;
594}
#define IDD_PROPPAGEDNSANDNETBIOS
Definition: resource.h:11
static VOID UpdateNetbiosName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:392
static BOOL NetworkDlg_OnOK(HWND hDlg, PNETIDDATA pNetIdData)
Definition: netid.c:461
static VOID NetworkDlg_OnInitDialog(HWND hDlg, PNETIDDATA pNetIdData)
Definition: netid.c:428
static INT_PTR CALLBACK DNSSuffixPropDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: netid.c:228

Referenced by NetIDPageProc().

◆ SetFullComputerName()

static VOID SetFullComputerName ( HWND  hDlg,
UINT  uId,
PNETIDDATA  pNetIdData 
)
static

Definition at line 363 of file netid.c.

367{
368 WCHAR szFullComputerName[512];
369
370 wsprintf(szFullComputerName, L"%s.%s", pNetIdData->szHostName, pNetIdData->szDomainName);
371 SetDlgItemText(hDlg, uId, szFullComputerName);
372}
#define wsprintf
Definition: winuser.h:5865

Referenced by NetIDPageProc(), and NetworkDlg_OnInitDialog().

◆ SetRadioBtnState()

static VOID SetRadioBtnState ( HWND  hDlg,
BOOL  IsDomain 
)
static

Definition at line 302 of file netid.c.

303{
304 SendDlgItemMessage(hDlg, 1008, BM_SETCHECK, (WPARAM)IsDomain, 0);
305 SendDlgItemMessage(hDlg, 1004, BM_SETCHECK, (WPARAM)!IsDomain, 0);
306 EnableWindow(GetDlgItem(hDlg, 116), IsDomain);
307 EnableWindow(GetDlgItem(hDlg, 1007), !IsDomain);
308}

Referenced by NetworkDlg_OnInitDialog(), and NetworkPropDlgProc().

◆ UpdateFullComputerName()

static VOID UpdateFullComputerName ( HWND  hDlg,
UINT  uId,
PNETIDDATA  pNetIdData 
)
static

Definition at line 376 of file netid.c.

380{
381 WCHAR szFullComputerName[512];
382 WCHAR szHostName[256];
383
384 GetWindowText(GetDlgItem(hDlg, 1002), szHostName, ARRAYSIZE(szHostName));
385
386 wsprintf(szFullComputerName, L"%s.%s", szHostName, pNetIdData->szDomainName);
387 SetDlgItemText(hDlg, uId, szFullComputerName);
388}

Referenced by NetIDPageProc(), and NetworkPropDlgProc().

◆ UpdateNetbiosName()

static VOID UpdateNetbiosName ( HWND  hDlg,
UINT  uId,
PNETIDDATA  pNetIdData 
)
static

Definition at line 392 of file netid.c.

396{
397 WCHAR szHostName[256];
399
400 GetWindowText(GetDlgItem(hDlg, 1002), szHostName, ARRAYSIZE(szHostName));
401
402 dwSize = ARRAYSIZE(pNetIdData->szComputerName);
404 pNetIdData->szComputerName,
405 &dwSize);
406}
BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname, LPWSTR computername, LPDWORD size)
Definition: compname.c:735

Referenced by NetworkPropDlgProc().

Variable Documentation

◆ hDllInstance