[KERNEL32] Fix SetComputerNameExW (#1583)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Mon, 27 May 2019 07:18:38 +0000 (16:18 +0900)
committerGitHub <noreply@github.com>
Mon, 27 May 2019 07:18:38 +0000 (16:18 +0900)
Based on @Doug-Lyons's patch. CORE-16058

dll/win32/kernel32/client/compname.c

index cfe9df5..c2efa30 100644 (file)
@@ -592,6 +592,8 @@ WINAPI
 SetComputerNameExW(COMPUTER_NAME_FORMAT NameType,
                    LPCWSTR lpBuffer)
 {
 SetComputerNameExW(COMPUTER_NAME_FORMAT NameType,
                    LPCWSTR lpBuffer)
 {
+    BOOL ret1, ret2;
+
     if (!IsValidComputerName(NameType, lpBuffer))
     {
         SetLastError(ERROR_INVALID_PARAMETER);
     if (!IsValidComputerName(NameType, lpBuffer))
     {
         SetLastError(ERROR_INVALID_PARAMETER);
@@ -607,10 +609,16 @@ SetComputerNameExW(COMPUTER_NAME_FORMAT NameType,
                                              lpBuffer);
 
         case ComputerNamePhysicalDnsHostname:
                                              lpBuffer);
 
         case ComputerNamePhysicalDnsHostname:
-            return SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
+            ret1 = SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
                                              L"\\Services\\Tcpip\\Parameters",
                                              L"\\Services\\Tcpip\\Parameters",
-                                             L"Hostname",
+                                             L"NV Hostname",
+                                             lpBuffer);
+
+            ret2 = SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
+                                             L"\\Control\\ComputerName\\ComputerName",
+                                             L"ComputerName",
                                              lpBuffer);
                                              lpBuffer);
+            return (ret1 && ret2);
 
         case ComputerNamePhysicalNetBIOS:
             return SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
 
         case ComputerNamePhysicalNetBIOS:
             return SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"