diff --git a/base/system/winlogon/winlogon.c b/base/system/winlogon/winlogon.c index 68783c828b..60867ff5ed 100644 --- a/base/system/winlogon/winlogon.c +++ b/base/system/winlogon/winlogon.c @@ -13,6 +13,7 @@ #include "winlogon.h" #include +#include /* GLOBALS ******************************************************************/ @@ -311,6 +312,10 @@ WinMain( #endif ULONG HardErrorResponse; MSG Msg; + LONG lError; + HKEY hKey = NULL; + DWORD dwValueSize; + WCHAR szNVHostname[256] = L""; UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); @@ -350,6 +355,75 @@ WinMain( ExitProcess(1); } + /* Now we read the NV Hostname key and copy it to the Hostname key */ + /* First we need to read the NV Hostname */ + lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", + 0, + KEY_QUERY_VALUE, + &hKey); + if (lError != ERROR_SUCCESS) + { + TRACE("RegOpenKeyExW(\"HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters\") failed!(%08lX)\n", lError); + } + + dwValueSize = _countof(szNVHostname); + + lError = RegQueryValueExW(hKey, + L"NV Hostname", + NULL, + NULL, + (LPBYTE)szNVHostname, + &dwValueSize); + if (lError != ERROR_SUCCESS) + { + TRACE("RegQueryKeyExW(\"HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters\") failed!(%08lX)\n", lError); + } + else + { + TRACE("NV Hostname is '%S'.\n", szNVHostname); + } + + RegCloseKey(hKey); + + /* We close the key here and reopen the same one because the winlogon process + * does not have enough privileges to acquire KEY_SET_VALUE for "NV Hostname", + * but it does for "Hostname", so here we can use the KEY_SET_VALUE for it. + */ + + if (szNVHostname[0]) + { + /* Now we need to set the Hostname */ + lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", + 0, + KEY_SET_VALUE, + &hKey); + if (lError != ERROR_SUCCESS) + { + TRACE("RegOpenKeyExW(\"HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters\") failed!(%08lX)\n", lError); + } + else + { + lError = RegSetValueExW(hKey, + L"Hostname", + 0, + REG_SZ, + (LPBYTE)szNVHostname, + (wcslen(szNVHostname)+ 1) * sizeof(WCHAR)); + if (lError != ERROR_SUCCESS) + { + TRACE("RegSetValueEx(\"Hostname\") failed!(%08lX)\n", lError); + } + else + { + TRACE("RegSetValueEx(\"Hostname\") set successfully to '%S'.\n", szNVHostname); + } + } + + RegCloseKey(hKey); + } + LockWorkstation(WLSession); /* Load default keyboard layouts */ diff --git a/dll/win32/netid/netid.c b/dll/win32/netid/netid.c index bcc9ce80c8..39e3e22a70 100644 --- a/dll/win32/netid/netid.c +++ b/dll/win32/netid/netid.c @@ -232,7 +232,7 @@ NetworkPropDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) SetFocus(GetDlgItem(hDlg, 1002)); break; } - else if (!SetComputerName(NewComputerName)) + else if (!SetComputerNameExW(ComputerNamePhysicalDnsHostname, NewComputerName)) { TCHAR szMsgText[MAX_PATH];