From: André Hentschel Subject: kernel32 computername hack Message-Id: <54498163.9020909@dawncrow.de> Date: Fri, 24 Oct 2014 00:29:55 +0200 For https://bugs.winehq.org/show_bug.cgi?id=35578 --- dlls/kernel32/process.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 138273b..ade574c 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -504,14 +504,22 @@ static WCHAR *get_reg_value( HKEY hkey, const WCHAR *name ) */ static void set_additional_environment(void) { + static const WCHAR cn_keyW[] = {'M','a','c','h','i','n','e','\\', + 'S','y','s','t','e','m','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'C','o','m','p','u','t','e','r','N','a','m','e','\\', + 'A','c','t','i','v','e','C','o','m','p','u','t','e','r','N','a','m','e',0}; static const WCHAR profile_keyW[] = {'M','a','c','h','i','n','e','\\', 'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s',' ','N','T','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', 'P','r','o','f','i','l','e','L','i','s','t',0}; + static const WCHAR cn_valueW[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0}; static const WCHAR profiles_valueW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0}; static const WCHAR all_users_valueW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'}; + static const WCHAR cnW[] = {'C','O','M','P','U','T','E','R','N','A','M','E',0}; static const WCHAR allusersW[] = {'A','L','L','U','S','E','R','S','P','R','O','F','I','L','E',0}; OBJECT_ATTRIBUTES attr; UNICODE_STRING nameW; @@ -551,6 +559,19 @@ static void set_additional_environment(void) HeapFree( GetProcessHeap(), 0, all_users_dir ); HeapFree( GetProcessHeap(), 0, profile_dir ); + + /* ComputerName */ + RtlInitUnicodeString( &nameW, cn_keyW ); + if (NtOpenKey( &hkey, KEY_READ, &attr ) == STATUS_SUCCESS) + { + WCHAR *computername = get_reg_value(hkey, cn_valueW); + if (computername) + { + SetEnvironmentVariableW(cnW, computername); + HeapFree( GetProcessHeap(), 0, computername ); + } + NtClose( hkey ); + } } /***********************************************************************