Alexandre Julliard : wineboot: Set the computer name keys.

Alexandre Julliard julliard at winehq.org
Mon Sep 28 14:49:26 CDT 2020


Module: wine
Branch: master
Commit: 6a19b999f7877f5b0052c77d09a41635769ce441
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6a19b999f7877f5b0052c77d09a41635769ce441

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Sep 28 16:20:04 2020 +0200

wineboot: Set the computer name keys.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/wineboot/Makefile.in |  2 +-
 programs/wineboot/wineboot.c  | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/programs/wineboot/Makefile.in b/programs/wineboot/Makefile.in
index 3921fa9644..2552f69990 100644
--- a/programs/wineboot/Makefile.in
+++ b/programs/wineboot/Makefile.in
@@ -1,6 +1,6 @@
 MODULE    = wineboot.exe
 APPMODE   = -mconsole
-IMPORTS   = uuid advapi32
+IMPORTS   = uuid advapi32 ws2_32
 DELAYIMPORTS = shell32 shlwapi version user32 setupapi newdev
 
 EXTRADLLFLAGS = -mno-cygwin
diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index 2f8b7169cf..fa1c459035 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -64,6 +64,7 @@
 #include <ntstatus.h>
 #define WIN32_NO_STATUS
 #include <windows.h>
+#include <ws2tcpip.h>
 #include <winternl.h>
 #include <ddk/wdm.h>
 #include <sddl.h>
@@ -815,6 +816,42 @@ static void create_environment_registry_keys( void )
     RegCloseKey( env_key );
 }
 
+/* create the ComputerName registry keys */
+static void create_computer_name_keys(void)
+{
+    struct addrinfo hints = {0}, *res;
+    char *dot, buffer[256];
+    HKEY key, subkey;
+
+    if (gethostname( buffer, sizeof(buffer) )) return;
+    hints.ai_flags = AI_CANONNAME;
+    if (getaddrinfo( buffer, NULL, &hints, &res )) return;
+    dot = strchr( res->ai_canonname, '.' );
+    if (dot) *dot++ = 0;
+    else dot = res->ai_canonname + strlen(res->ai_canonname);
+    SetComputerNameExA( ComputerNamePhysicalDnsDomain, dot );
+    SetComputerNameExA( ComputerNamePhysicalDnsHostname, res->ai_canonname );
+    freeaddrinfo( res );
+
+    if (RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\ComputerName", &key ))
+        return;
+
+    if (!RegOpenKeyW( key, L"ComputerName", &subkey ))
+    {
+        DWORD type, size = sizeof(buffer);
+
+        if (RegQueryValueExW( subkey, L"ComputerName", NULL, &type, (BYTE *)buffer, &size )) size = 0;
+        RegCloseKey( subkey );
+        if (size && !RegCreateKeyExW( key, L"ActiveComputerName", 0, NULL, REG_OPTION_VOLATILE,
+                                      KEY_ALL_ACCESS, NULL, &subkey, NULL ))
+        {
+            RegSetValueExW( subkey, L"ComputerName", 0, type, (const BYTE *)buffer, size );
+            RegCloseKey( subkey );
+        }
+    }
+    RegCloseKey( key );
+}
+
 static void create_volatile_environment_registry_key(void)
 {
     WCHAR path[MAX_PATH];
@@ -1657,6 +1694,7 @@ int __cdecl main( int argc, char *argv[] )
     create_hardware_registry_keys();
     create_dynamic_registry_keys();
     create_environment_registry_keys();
+    create_computer_name_keys();
     wininit();
     pendingRename();
 




More information about the wine-cvs mailing list