Commit 6d886a52 authored by Martin Wilck's avatar Martin Wilck Committed by Alexandre Julliard

- Allow setting NetBIOS ComputerName through registry.

- Keep old behavior as default, using new config option to change. - Implement SetComputerName(), SetComputerNameEx(), GetComputerNameEx(). - ComputerName initialization moved to kernel32.
parent 40f81e7c
......@@ -12,6 +12,7 @@ DLLMAIN = MAIN_KernelInit
C_SRCS = \
$(TOPOBJDIR)/ole/ole2nls.c \
comm.c \
computername.c \
console.c \
debugger.c \
editline.c \
......
......@@ -663,6 +663,8 @@
@ stdcall SetCommTimeouts(long ptr) SetCommTimeouts
@ stdcall SetComputerNameA(str) SetComputerNameA
@ stdcall SetComputerNameW(wstr) SetComputerNameW
@ stdcall SetComputerNameExA(long str) SetComputerNameExA
@ stdcall SetComputerNameExW(long wstr) SetComputerNameExW
@ stdcall SetConsoleActiveScreenBuffer(long) SetConsoleActiveScreenBuffer
@ stdcall SetConsoleCP(long) SetConsoleCP
@ stdcall SetConsoleCtrlHandler(ptr long) SetConsoleCtrlHandler
......
......@@ -43,6 +43,7 @@
extern void LOCALE_Init(void);
extern BOOL RELAY_Init(void);
extern void COMPUTERNAME_Init(void);
extern int __wine_set_signal_handler(unsigned, int (*)(unsigned));
......@@ -68,6 +69,9 @@ static BOOL process_attach(void)
/* Initialize DOS memory */
if (!DOSMEM_Init(0)) return FALSE;
/* Setup computer name */
COMPUTERNAME_Init();
if ((hModule = LoadLibrary16( "krnl386.exe" )) >= 32)
{
/* Initialize special KERNEL entry points */
......
......@@ -80,7 +80,6 @@ C_SRCS = \
$(TOPOBJDIR)/scheduler/timer.c \
$(TOPOBJDIR)/win32/device.c \
$(TOPOBJDIR)/win32/except.c \
$(TOPOBJDIR)/win32/init.c \
$(TOPOBJDIR)/win32/kernel32.c \
$(TOPOBJDIR)/win32/newfns.c \
$(TOPOBJDIR)/win32/time.c \
......
......@@ -893,7 +893,7 @@ OPTIONAL:
<title>The [WinMM] Section</title>
<para>
[WinMM] is used to define which multimedia drivers have to be loaded. Since
those drivers may depend on the multimedia interfaces available on your sustem
those drivers may depend on the multimedia interfaces available on your system
(OSS, Alsa... to name a few), it's needed to be able to configure which driver
has to be loaded.
</para>
......@@ -931,6 +931,43 @@ OPTIONAL:
</para>
</sect3>
<sect3 id="network-section">
<title>The [Network] Section</title>
<para>
[Network] contains settings related to
networking. Currently there is only one value that can be set.
</para>
<variablelist>
<varlistentry>
<term>UseDnsComputerName</term>
<listitem>
<para>
A boolean setting (default: <literal>Y</literal>)
that affects the way Wine sets the computer name. The computer
name in the Windows world is the so-called <emphasis>NetBIOS name</emphasis>.
It is contained in the <varname>ComputerName</varname> in the registry entry
<varname>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName</varname>.
</para>
<para>
If this option is set to "Y" or missing, Wine will set the
NetBIOS name to the Unix host name of your computer, if
necessary truncated to 31 characters. The Unix hostname is the output
of the shell command <command>hostname</command>, up to and not
including the first dot ('.'). Among other things, this means that
Windows programs running under Wine cannot change the NetBIOS computer name.
</para>
<para>
If this option is set to "N", Wine will use the registry value above
to set the NetBIOS name. Only if the registry entry doesn't exist (usually
only during the first wine startup) it will use the Unix hostname as
usual. Windows applications can change the NetBIOS name. The change
will be effective after a "Reboot", i.e. after restarting Wine.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect3>
<sect3 id="appdefaults-section">
<title>The [AppDefaults] Section</title>
<para>
......
......@@ -268,6 +268,13 @@ WINE REGISTRY Version 2
;; Min number of fragments to prebuffer
;"SndQueueMin" = "12"
[Network]
;; Use the DNS (Unix) host name always as NetBIOS "ComputerName" (boolean, default "Y").
;; Set to N if you need a persistent NetBIOS ComputerName that possibly differs
;; from the Unix host name. You'll need to set ComputerName in
;; HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName, too.
;"UseDnsComputerName" = "N"
;; sample AppDefaults entries
;[AppDefaults\\iexplore.exe\\DllOverrides]
;"shlwapi" = "native"
......
......@@ -303,6 +303,13 @@ booleans: Y/y/T/t/1 are true, N/n/F/f/0 are false.
.br
Defaults are read all, write to home files.
.PP
.B [Network]
.br
.I format: """UseDnsComputerName""=""<boolean>"""
.br
If Y, always override the registry setting for ComputerName
with the Unix hostname.
.PP
.B [AppDefaults\\\\\\\\<appname>\\\\\\\\...]
.PP
This section allows specifying application-specific values for
......
......@@ -1453,9 +1453,12 @@ BOOL WINAPI SetCommBreak(HANDLE);
BOOL WINAPI SetCommMask(HANDLE,DWORD);
BOOL WINAPI SetCommState(HANDLE,LPDCB);
BOOL WINAPI SetCommTimeouts(HANDLE,LPCOMMTIMEOUTS);
BOOL WINAPI SetComputerNameA(LPCSTR);
BOOL WINAPI SetComputerNameW(LPCWSTR);
BOOL WINAPI SetComputerNameA(LPCSTR);
BOOL WINAPI SetComputerNameW(LPCWSTR);
#define SetComputerName WINELIB_NAME_AW(SetComputerName)
BOOL WINAPI SetComputerNameExA(COMPUTER_NAME_FORMAT,LPCSTR);
BOOL WINAPI SetComputerNameExW(COMPUTER_NAME_FORMAT,LPCWSTR);
#define SetComputerNameEx WINELIB_NAME_AW(SetComputerNameEx)
BOOL WINAPI SetDefaultCommConfigA(LPCSTR,LPCOMMCONFIG,DWORD);
BOOL WINAPI SetDefaultCommConfigW(LPCWSTR,LPCOMMCONFIG,DWORD);
#define SetDefaultCommConfig WINELIB_NAME_AW(SetDefaultCommConfig)
......
......@@ -1119,22 +1119,12 @@ static void _init_registry_saving( HKEY hkey_local_machine, HKEY hkey_current_us
*/
static void _allocate_default_keys(void)
{
HKEY hkey;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW, valueW;
WCHAR computer_name[200];
DWORD size = sizeof(computer_name)/sizeof(WCHAR);
static const WCHAR StatDataW[] = {'D','y','n','D','a','t','a','\\',
'P','e','r','f','S','t','a','t','s','\\',
'S','t','a','t','D','a','t','a',0};
static const WCHAR ComputerW[] = {'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','\\',
'C','o','m','p','u','t','e','r','N','a','m','e',0};
static const WCHAR ComputerNameW[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
HKEY hkey;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
TRACE("(void)\n");
......@@ -1147,31 +1137,6 @@ static void _allocate_default_keys(void)
RtlInitUnicodeString( &nameW, StatDataW );
if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) NtClose( hkey );
/* \\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion
* CurrentVersion
* CurrentBuildNumber
* CurrentType
* string RegisteredOwner
* string RegisteredOrganization
*
*/
/* System\\CurrentControlSet\\Services\\SNMP\\Parameters\\RFC1156Agent
* string SysContact
* string SysLocation
* SysServices
*/
if (GetComputerNameW( computer_name, &size ))
{
RtlInitUnicodeString( &nameW, ComputerW );
if (!NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ))
{
RtlInitUnicodeString( &valueW, ComputerNameW );
NtSetValueKey( hkey, &valueW, 0, REG_SZ, computer_name,
(strlenW(computer_name) + 1) * sizeof(WCHAR) );
NtClose(hkey);
}
}
}
#define REG_DONTLOAD -1
......
/*
* Win32 kernel functions
*
* Copyright 1995 Martin von Loewis and Cameron Heide
* 1999 Peter Ganten
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdlib.h>
#include <errno.h>
#include "winnls.h"
#include "winbase.h"
#include "winerror.h"
#include "wine/exception.h"
#include "msvcrt/excpt.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(win32);
/* filter for page-fault exceptions */
static WINE_EXCEPTION_FILTER(page_fault)
{
if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
return EXCEPTION_EXECUTE_HANDLER;
return EXCEPTION_CONTINUE_SEARCH;
}
/***********************************************************************
* GetComputerNameA (KERNEL32.@)
*/
BOOL WINAPI GetComputerNameA(LPSTR name,LPDWORD size)
{
/* At least Win95OSR2 survives if size is not a pointer (NT crashes though) */
BOOL ret;
__TRY
{
char host_name[256];
TRACE("*size = %ld\n", *size);
ret = (gethostname(host_name, sizeof(host_name)) != -1);
if (ret)
{
lstrcpynA(name, host_name, *size);
*size = strlen(name);
}
else
WARN("gethostname: %s\n", strerror(errno));
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
__ENDTRY
TRACE("returning (%ld) %s\n", *size, debugstr_a(name));
return ret;
}
/***********************************************************************
* GetComputerNameW (KERNEL32.@)
*/
BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
{
LPSTR nameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *size);
BOOL ret = GetComputerNameA(nameA,size);
/* FIXME: should set *size in Unicode chars */
if (ret) MultiByteToWideChar( CP_ACP, 0, nameA, -1, name, *size+1 );
HeapFree( GetProcessHeap(), 0, nameA );
return ret;
}
/***********************************************************************
* GetComputerNameExA (KERNEL32.@)
*/
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT type, LPSTR name, LPDWORD size)
{
FIXME("(%d, %p, %p) semi-stub!\n", type, name, size);
return GetComputerNameA(name, size);
}
/***********************************************************************
* GetComputerNameExW (KERNEL32.@)
*/
BOOL WINAPI GetComputerNameExW(COMPUTER_NAME_FORMAT type, LPWSTR name, LPDWORD size)
{
FIXME("(%d, %p, %p) semi-stub!\n", type, name, size);
return GetComputerNameW(name, size);
}
......@@ -287,36 +287,6 @@ DWORD WINAPI GetCompressedFileSizeW(
/******************************************************************************
* SetComputerNameA [KERNEL32.@]
*/
BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
{
BOOL ret;
DWORD len = MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, NULL, 0 );
LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, nameW, len );
ret = SetComputerNameW( nameW );
HeapFree( GetProcessHeap(), 0, nameW );
return ret;
}
/******************************************************************************
* SetComputerNameW [KERNEL32.@]
*
* PARAMS
* lpComputerName [I] Address of new computer name
*
* RETURNS STD
*/
BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
{
FIXME("(%s): stub\n", debugstr_w(lpComputerName));
return TRUE;
}
/******************************************************************************
* CreateIoCompletionPort (KERNEL32.@)
*/
HANDLE WINAPI CreateIoCompletionPort(HANDLE hFileHandle,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment