Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
7822b854
Commit
7822b854
authored
Dec 12, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Implement the Get/SetComputerName functions.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e2ab5b76
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
221 additions
and
7 deletions
+221
-7
kernelbase.spec
dlls/kernelbase/kernelbase.spec
+6
-6
registry.c
dlls/kernelbase/registry.c
+215
-1
No files found.
dlls/kernelbase/kernelbase.spec
View file @
7822b854
...
@@ -437,8 +437,8 @@
...
@@ -437,8 +437,8 @@
@ stdcall GetCommandLineW()
@ stdcall GetCommandLineW()
@ stdcall GetCompressedFileSizeA(long ptr)
@ stdcall GetCompressedFileSizeA(long ptr)
@ stdcall GetCompressedFileSizeW(long ptr)
@ stdcall GetCompressedFileSizeW(long ptr)
@ stdcall GetComputerNameExA(long ptr ptr)
kernel32.GetComputerNameExA
@ stdcall GetComputerNameExA(long ptr ptr)
@ stdcall GetComputerNameExW(long ptr ptr)
kernel32.GetComputerNameExW
@ stdcall GetComputerNameExW(long ptr ptr)
@ stdcall GetConsoleCP()
@ stdcall GetConsoleCP()
@ stdcall GetConsoleCursorInfo(long ptr)
@ stdcall GetConsoleCursorInfo(long ptr)
@ stdcall GetConsoleInputExeNameA(long ptr)
@ stdcall GetConsoleInputExeNameA(long ptr)
...
@@ -1397,11 +1397,11 @@
...
@@ -1397,11 +1397,11 @@
@ stdcall SetCommMask(long long)
@ stdcall SetCommMask(long long)
@ stdcall SetCommState(long ptr)
@ stdcall SetCommState(long ptr)
@ stdcall SetCommTimeouts(long ptr)
@ stdcall SetCommTimeouts(long ptr)
@ stdcall SetComputerNameA(str)
kernel32.SetComputerNameA
@ stdcall SetComputerNameA(str)
# @ stub SetComputerNameEx2W
# @ stub SetComputerNameEx2W
@ stdcall SetComputerNameExA(long str)
kernel32.SetComputerNameExA
@ stdcall SetComputerNameExA(long str)
@ stdcall SetComputerNameExW(long wstr)
kernel32.SetComputerNameExW
@ stdcall SetComputerNameExW(long wstr)
@ stdcall SetComputerNameW(wstr)
kernel32.SetComputerNameW
@ stdcall SetComputerNameW(wstr)
@ stdcall SetConsoleActiveScreenBuffer(long)
@ stdcall SetConsoleActiveScreenBuffer(long)
@ stdcall SetConsoleCP(long)
@ stdcall SetConsoleCP(long)
@ stdcall SetConsoleCtrlHandler(ptr long) kernel32.SetConsoleCtrlHandler
@ stdcall SetConsoleCtrlHandler(ptr long) kernel32.SetConsoleCtrlHandler
...
...
dlls/kernelbase/registry.c
View file @
7822b854
...
@@ -109,6 +109,8 @@ static struct list reg_mui_cache = LIST_INIT(reg_mui_cache); /* MRU */
...
@@ -109,6 +109,8 @@ static struct list reg_mui_cache = LIST_INIT(reg_mui_cache); /* MRU */
static
unsigned
int
reg_mui_cache_count
;
static
unsigned
int
reg_mui_cache_count
;
#define REG_MUI_CACHE_SIZE 8
#define REG_MUI_CACHE_SIZE 8
#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
/* check if value type needs string conversion (Ansi<->Unicode) */
/* check if value type needs string conversion (Ansi<->Unicode) */
static
inline
BOOL
is_string
(
DWORD
type
)
static
inline
BOOL
is_string
(
DWORD
type
)
{
{
...
@@ -1374,7 +1376,7 @@ static DWORD query_perf_data(const WCHAR *query, DWORD *type, void *data, DWORD
...
@@ -1374,7 +1376,7 @@ static DWORD query_perf_data(const WCHAR *query, DWORD *type, void *data, DWORD
data
=
pdb
+
1
;
data
=
pdb
+
1
;
pdb
->
SystemNameOffset
=
sizeof
(
*
pdb
);
pdb
->
SystemNameOffset
=
sizeof
(
*
pdb
);
pdb
->
SystemNameLength
=
(
data_size
-
sizeof
(
*
pdb
))
/
sizeof
(
WCHAR
);
pdb
->
SystemNameLength
=
(
data_size
-
sizeof
(
*
pdb
))
/
sizeof
(
WCHAR
);
if
(
!
GetComputerName
W
(
data
,
&
pdb
->
SystemNameLength
))
if
(
!
GetComputerName
ExW
(
ComputerNameNetBIOS
,
data
,
&
pdb
->
SystemNameLength
))
return
ERROR_MORE_DATA
;
return
ERROR_MORE_DATA
;
pdb
->
SystemNameLength
++
;
pdb
->
SystemNameLength
++
;
...
@@ -3078,6 +3080,218 @@ BOOL WINAPI DECLSPEC_HOTPATCH DnsHostnameToComputerNameExW( const WCHAR *hostnam
...
@@ -3078,6 +3080,218 @@ BOOL WINAPI DECLSPEC_HOTPATCH DnsHostnameToComputerNameExW( const WCHAR *hostnam
}
}
/***********************************************************************
* GetComputerNameExA (kernelbase.@)
*/
BOOL
WINAPI
GetComputerNameExA
(
COMPUTER_NAME_FORMAT
type
,
char
*
name
,
DWORD
*
len
)
{
BOOL
ret
=
FALSE
;
DWORD
lenA
,
lenW
=
0
;
WCHAR
*
buffer
;
GetComputerNameExW
(
type
,
NULL
,
&
lenW
);
if
(
GetLastError
()
!=
ERROR_MORE_DATA
)
return
FALSE
;
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
lenW
*
sizeof
(
WCHAR
)
)))
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
}
if
(
GetComputerNameExW
(
type
,
buffer
,
&
lenW
))
{
lenA
=
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
lenA
>
*
len
)
{
*
len
=
lenA
;
SetLastError
(
ERROR_MORE_DATA
);
}
else
{
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
name
,
*
len
,
NULL
,
NULL
);
*
len
=
lenA
-
1
;
ret
=
TRUE
;
}
}
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
ret
;
}
/***********************************************************************
* GetComputerNameExW (kernelbase.@)
*/
BOOL
WINAPI
GetComputerNameExW
(
COMPUTER_NAME_FORMAT
type
,
WCHAR
*
name
,
DWORD
*
len
)
{
const
WCHAR
*
keyname
,
*
valuename
;
LRESULT
ret
;
HKEY
key
;
switch
(
type
)
{
case
ComputerNameNetBIOS
:
case
ComputerNamePhysicalNetBIOS
:
keyname
=
L"System
\\
CurrentControlSet
\\
Control
\\
ComputerName
\\
ActiveComputerName"
;
valuename
=
L"ComputerName"
;
break
;
case
ComputerNameDnsHostname
:
case
ComputerNamePhysicalDnsHostname
:
keyname
=
L"System
\\
CurrentControlSet
\\
Services
\\
Tcpip
\\
Parameters"
;
valuename
=
L"Hostname"
;
break
;
case
ComputerNameDnsDomain
:
case
ComputerNamePhysicalDnsDomain
:
keyname
=
L"System
\\
CurrentControlSet
\\
Services
\\
Tcpip
\\
Parameters"
;
valuename
=
L"Domain"
;
break
;
case
ComputerNameDnsFullyQualified
:
case
ComputerNamePhysicalDnsFullyQualified
:
{
WCHAR
buffer
[
256
];
DWORD
size
=
ARRAY_SIZE
(
buffer
);
if
(
!
GetComputerNameExW
(
ComputerNameDnsHostname
,
buffer
,
&
size
))
return
FALSE
;
lstrcatW
(
buffer
,
L"."
);
size
=
ARRAY_SIZE
(
buffer
)
-
lstrlenW
(
buffer
);
if
(
!
GetComputerNameExW
(
ComputerNameDnsDomain
,
buffer
+
lstrlenW
(
buffer
),
&
size
))
return
FALSE
;
size
=
lstrlenW
(
buffer
);
if
(
name
&&
size
<
*
len
)
{
if
(
name
)
lstrcpyW
(
name
,
buffer
);
*
len
=
size
;
return
TRUE
;
}
*
len
=
size
+
1
;
SetLastError
(
ERROR_MORE_DATA
);
return
FALSE
;
}
default:
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
!
(
ret
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
keyname
,
0
,
KEY_READ
,
&
key
)))
{
DWORD
size
=
*
len
*
sizeof
(
WCHAR
);
ret
=
RegQueryValueExW
(
key
,
valuename
,
NULL
,
NULL
,
(
BYTE
*
)
name
,
&
size
);
if
(
!
name
)
ret
=
ERROR_MORE_DATA
;
else
if
(
!
ret
)
size
-=
sizeof
(
WCHAR
);
*
len
=
size
/
sizeof
(
WCHAR
);
RegCloseKey
(
key
);
}
TRACE
(
"-> %lu %s
\n
"
,
ret
,
debugstr_w
(
name
)
);
if
(
ret
)
SetLastError
(
ret
);
return
!
ret
;
}
/***********************************************************************
* SetComputerNameA (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
SetComputerNameA
(
const
char
*
name
)
{
BOOL
ret
;
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
NULL
,
0
);
WCHAR
*
nameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
nameW
,
len
);
ret
=
SetComputerNameExW
(
ComputerNamePhysicalNetBIOS
,
nameW
);
HeapFree
(
GetProcessHeap
(),
0
,
nameW
);
return
ret
;
}
/***********************************************************************
* SetComputerNameW (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
SetComputerNameW
(
const
WCHAR
*
name
)
{
return
SetComputerNameExW
(
ComputerNamePhysicalNetBIOS
,
name
);
}
/***********************************************************************
* SetComputerNameExA (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
SetComputerNameExA
(
COMPUTER_NAME_FORMAT
type
,
const
char
*
name
)
{
BOOL
ret
;
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
NULL
,
0
);
WCHAR
*
nameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
nameW
,
len
);
ret
=
SetComputerNameExW
(
type
,
nameW
);
HeapFree
(
GetProcessHeap
(),
0
,
nameW
);
return
ret
;
}
/***********************************************************************
* SetComputerNameExW (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
SetComputerNameExW
(
COMPUTER_NAME_FORMAT
type
,
const
WCHAR
*
name
)
{
WCHAR
buffer
[
MAX_COMPUTERNAME_LENGTH
+
1
];
DWORD
size
;
HKEY
key
;
LRESULT
ret
;
TRACE
(
"%u %s
\n
"
,
type
,
debugstr_w
(
name
));
switch
(
type
)
{
case
ComputerNameDnsHostname
:
case
ComputerNamePhysicalDnsHostname
:
ret
=
RegCreateKeyExW
(
HKEY_LOCAL_MACHINE
,
L"System
\\
CurrentControlSet
\\
Services
\\
Tcpip
\\
Parameters"
,
0
,
NULL
,
0
,
KEY_ALL_ACCESS
,
NULL
,
&
key
,
NULL
);
if
(
ret
)
break
;
ret
=
RegSetValueExW
(
key
,
L"Hostname"
,
0
,
REG_SZ
,
(
BYTE
*
)
name
,
(
lstrlenW
(
name
)
+
1
)
*
sizeof
(
WCHAR
)
);
RegCloseKey
(
key
);
/* fall through */
case
ComputerNameNetBIOS
:
case
ComputerNamePhysicalNetBIOS
:
/* @@ Wine registry key: HKCU\Software\Wine\Network */
if
(
!
RegOpenKeyExW
(
HKEY_CURRENT_USER
,
L"Software
\\
Wine
\\
Network"
,
0
,
KEY_READ
,
&
key
))
{
BOOL
use_dns
=
TRUE
;
size
=
sizeof
(
buffer
);
if
(
!
RegQueryValueExW
(
key
,
L"UseDnsComputerName"
,
NULL
,
NULL
,
(
BYTE
*
)
buffer
,
&
size
))
use_dns
=
IS_OPTION_TRUE
(
buffer
[
0
]
);
RegCloseKey
(
key
);
if
(
!
use_dns
)
{
ret
=
ERROR_ACCESS_DENIED
;
break
;
}
}
size
=
ARRAY_SIZE
(
buffer
);
if
(
!
DnsHostnameToComputerNameExW
(
name
,
buffer
,
&
size
))
return
FALSE
;
ret
=
RegCreateKeyExW
(
HKEY_LOCAL_MACHINE
,
L"System
\\
CurrentControlSet
\\
Control
\\
ComputerName
\\
ComputerName"
,
0
,
NULL
,
0
,
KEY_ALL_ACCESS
,
NULL
,
&
key
,
NULL
);
if
(
ret
)
break
;
ret
=
RegSetValueExW
(
key
,
L"ComputerName"
,
0
,
REG_SZ
,
(
BYTE
*
)
buffer
,
(
lstrlenW
(
buffer
)
+
1
)
*
sizeof
(
WCHAR
)
);
RegCloseKey
(
key
);
break
;
case
ComputerNameDnsDomain
:
case
ComputerNamePhysicalDnsDomain
:
ret
=
RegCreateKeyExW
(
HKEY_LOCAL_MACHINE
,
L"System
\\
CurrentControlSet
\\
Services
\\
Tcpip
\\
Parameters"
,
0
,
NULL
,
0
,
KEY_ALL_ACCESS
,
NULL
,
&
key
,
NULL
);
if
(
ret
)
break
;
ret
=
RegSetValueExW
(
key
,
L"Domain"
,
0
,
REG_SZ
,
(
BYTE
*
)
name
,
(
lstrlenW
(
name
)
+
1
)
*
sizeof
(
WCHAR
)
);
RegCloseKey
(
key
);
break
;
default:
ret
=
ERROR_INVALID_PARAMETER
;
break
;
}
if
(
ret
)
SetLastError
(
ret
);
return
!
ret
;
}
struct
USKEY
struct
USKEY
{
{
HKEY
HKCUstart
;
/* Start key in CU hive */
HKEY
HKCUstart
;
/* Start key in CU hive */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment