Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
49c5bd03
Commit
49c5bd03
authored
Aug 22, 2010
by
Alexandre Goujon
Committed by
Alexandre Julliard
Aug 23, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix GetComputerName errors.
parent
53aef28e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
9 deletions
+23
-9
computername.c
dlls/kernel32/computername.c
+23
-7
environ.c
dlls/kernel32/tests/environ.c
+0
-2
No files found.
dlls/kernel32/computername.c
View file @
49c5bd03
...
...
@@ -316,23 +316,33 @@ BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
DWORD
len
=
sizeof
(
buf
);
LPWSTR
theName
=
(
LPWSTR
)
(
buf
+
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
));
NTSTATUS
st
=
STATUS_INVALID_PARAMETER
;
DWORD
err
=
ERROR_SUCCESS
;
TRACE
(
"%p %p
\n
"
,
name
,
size
);
_init_attr
(
&
attr
,
&
nameW
);
RtlInitUnicodeString
(
&
nameW
,
ComputerW
);
if
(
(
st
=
NtOpenKey
(
&
hkey
,
KEY_READ
,
&
attr
)
)
!=
STATUS_SUCCESS
)
{
err
=
RtlNtStatusToDosError
(
st
);
goto
out
;
}
attr
.
RootDirectory
=
hkey
;
RtlInitUnicodeString
(
&
nameW
,
ActiveComputerNameW
);
if
(
(
st
=
NtOpenKey
(
&
hsubkey
,
KEY_READ
,
&
attr
)
)
!=
STATUS_SUCCESS
)
{
err
=
RtlNtStatusToDosError
(
st
);
goto
out
;
}
RtlInitUnicodeString
(
&
nameW
,
ComputerNameW
);
if
(
(
st
=
NtQueryValueKey
(
hsubkey
,
&
nameW
,
KeyValuePartialInformation
,
buf
,
len
,
&
len
)
)
!=
STATUS_SUCCESS
)
{
err
=
RtlNtStatusToDosError
(
st
);
goto
out
;
}
len
=
(
len
-
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
))
/
sizeof
(
WCHAR
)
-
1
;
TRACE
(
"ComputerName is %s (length %u)
\n
"
,
debugstr_w
(
theName
),
len
);
...
...
@@ -340,25 +350,24 @@ BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
if
(
*
size
<
len
+
1
)
{
*
size
=
len
+
1
;
st
=
STATUS_MORE_ENTRIES
;
err
=
ERROR_BUFFER_OVERFLOW
;
}
else
{
memcpy
(
name
,
theName
,
len
*
sizeof
(
WCHAR
)
);
name
[
len
]
=
0
;
*
size
=
len
;
st
=
STATUS_SUCCESS
;
}
out:
NtClose
(
hsubkey
);
NtClose
(
hkey
);
if
(
st
==
STATUS
_SUCCESS
)
if
(
err
==
ERROR
_SUCCESS
)
return
TRUE
;
else
{
SetLastError
(
RtlNtStatusToDosError
(
st
)
);
SetLastError
(
err
);
WARN
(
"Status %u reading computer name from registry
\n
"
,
st
);
return
FALSE
;
}
...
...
@@ -383,7 +392,7 @@ BOOL WINAPI GetComputerNameA(LPSTR name, LPDWORD size)
if
(
*
size
<
len
)
{
*
size
=
len
;
SetLastError
(
ERROR_
MORE_DATA
);
SetLastError
(
ERROR_
BUFFER_OVERFLOW
);
ret
=
FALSE
;
}
else
...
...
@@ -415,7 +424,11 @@ BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT type, LPSTR name, LPDWORD si
{
case
ComputerNameNetBIOS
:
case
ComputerNamePhysicalNetBIOS
:
return
GetComputerNameA
(
name
,
size
);
ret
=
GetComputerNameA
(
name
,
size
);
if
(
!
ret
&&
GetLastError
()
==
ERROR_BUFFER_OVERFLOW
)
SetLastError
(
ERROR_MORE_DATA
);
return
ret
;
case
ComputerNameDnsHostname
:
case
ComputerNamePhysicalDnsHostname
:
ret
=
dns_hostname
(
buf
,
&
len
);
...
...
@@ -468,7 +481,10 @@ BOOL WINAPI GetComputerNameExW( COMPUTER_NAME_FORMAT type, LPWSTR name, LPDWORD
{
case
ComputerNameNetBIOS
:
case
ComputerNamePhysicalNetBIOS
:
return
GetComputerNameW
(
name
,
size
);
ret
=
GetComputerNameW
(
name
,
size
);
if
(
!
ret
&&
GetLastError
()
==
ERROR_BUFFER_OVERFLOW
)
SetLastError
(
ERROR_MORE_DATA
);
return
ret
;
case
ComputerNameDnsHostname
:
case
ComputerNamePhysicalDnsHostname
:
ret
=
dns_hostname
(
buf
,
&
len
);
...
...
dlls/kernel32/tests/environ.c
View file @
49c5bd03
...
...
@@ -330,7 +330,6 @@ static void test_GetComputerName(void)
size
=
0
;
ret
=
GetComputerNameA
((
LPSTR
)
0xdeadbeef
,
&
size
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
&&
error
==
ERROR_BUFFER_OVERFLOW
,
"GetComputerNameA should have failed with ERROR_BUFFER_OVERFLOW instead of %d
\n
"
,
error
);
/* Only Vista returns the computer name length as documented in the MSDN */
...
...
@@ -362,7 +361,6 @@ static void test_GetComputerName(void)
win_skip
(
"GetComputerNameW is not implemented
\n
"
);
else
{
todo_wine
ok
(
!
ret
&&
error
==
ERROR_BUFFER_OVERFLOW
,
"GetComputerNameW should have failed with ERROR_BUFFER_OVERFLOW instead of %d
\n
"
,
error
);
size
++
;
/* nul terminating character */
nameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
nameW
[
0
]));
...
...
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