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)
...
@@ -316,23 +316,33 @@ BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
DWORD
len
=
sizeof
(
buf
);
DWORD
len
=
sizeof
(
buf
);
LPWSTR
theName
=
(
LPWSTR
)
(
buf
+
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
));
LPWSTR
theName
=
(
LPWSTR
)
(
buf
+
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
));
NTSTATUS
st
=
STATUS_INVALID_PARAMETER
;
NTSTATUS
st
=
STATUS_INVALID_PARAMETER
;
DWORD
err
=
ERROR_SUCCESS
;
TRACE
(
"%p %p
\n
"
,
name
,
size
);
TRACE
(
"%p %p
\n
"
,
name
,
size
);
_init_attr
(
&
attr
,
&
nameW
);
_init_attr
(
&
attr
,
&
nameW
);
RtlInitUnicodeString
(
&
nameW
,
ComputerW
);
RtlInitUnicodeString
(
&
nameW
,
ComputerW
);
if
(
(
st
=
NtOpenKey
(
&
hkey
,
KEY_READ
,
&
attr
)
)
!=
STATUS_SUCCESS
)
if
(
(
st
=
NtOpenKey
(
&
hkey
,
KEY_READ
,
&
attr
)
)
!=
STATUS_SUCCESS
)
{
err
=
RtlNtStatusToDosError
(
st
);
goto
out
;
goto
out
;
}
attr
.
RootDirectory
=
hkey
;
attr
.
RootDirectory
=
hkey
;
RtlInitUnicodeString
(
&
nameW
,
ActiveComputerNameW
);
RtlInitUnicodeString
(
&
nameW
,
ActiveComputerNameW
);
if
(
(
st
=
NtOpenKey
(
&
hsubkey
,
KEY_READ
,
&
attr
)
)
!=
STATUS_SUCCESS
)
if
(
(
st
=
NtOpenKey
(
&
hsubkey
,
KEY_READ
,
&
attr
)
)
!=
STATUS_SUCCESS
)
{
err
=
RtlNtStatusToDosError
(
st
);
goto
out
;
goto
out
;
}
RtlInitUnicodeString
(
&
nameW
,
ComputerNameW
);
RtlInitUnicodeString
(
&
nameW
,
ComputerNameW
);
if
(
(
st
=
NtQueryValueKey
(
hsubkey
,
&
nameW
,
KeyValuePartialInformation
,
buf
,
len
,
&
len
)
)
if
(
(
st
=
NtQueryValueKey
(
hsubkey
,
&
nameW
,
KeyValuePartialInformation
,
buf
,
len
,
&
len
)
)
!=
STATUS_SUCCESS
)
!=
STATUS_SUCCESS
)
{
err
=
RtlNtStatusToDosError
(
st
);
goto
out
;
goto
out
;
}
len
=
(
len
-
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
))
/
sizeof
(
WCHAR
)
-
1
;
len
=
(
len
-
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
))
/
sizeof
(
WCHAR
)
-
1
;
TRACE
(
"ComputerName is %s (length %u)
\n
"
,
debugstr_w
(
theName
),
len
);
TRACE
(
"ComputerName is %s (length %u)
\n
"
,
debugstr_w
(
theName
),
len
);
...
@@ -340,25 +350,24 @@ BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
...
@@ -340,25 +350,24 @@ BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
if
(
*
size
<
len
+
1
)
if
(
*
size
<
len
+
1
)
{
{
*
size
=
len
+
1
;
*
size
=
len
+
1
;
st
=
STATUS_MORE_ENTRIES
;
err
=
ERROR_BUFFER_OVERFLOW
;
}
}
else
else
{
{
memcpy
(
name
,
theName
,
len
*
sizeof
(
WCHAR
)
);
memcpy
(
name
,
theName
,
len
*
sizeof
(
WCHAR
)
);
name
[
len
]
=
0
;
name
[
len
]
=
0
;
*
size
=
len
;
*
size
=
len
;
st
=
STATUS_SUCCESS
;
}
}
out:
out:
NtClose
(
hsubkey
);
NtClose
(
hsubkey
);
NtClose
(
hkey
);
NtClose
(
hkey
);
if
(
st
==
STATUS
_SUCCESS
)
if
(
err
==
ERROR
_SUCCESS
)
return
TRUE
;
return
TRUE
;
else
else
{
{
SetLastError
(
RtlNtStatusToDosError
(
st
)
);
SetLastError
(
err
);
WARN
(
"Status %u reading computer name from registry
\n
"
,
st
);
WARN
(
"Status %u reading computer name from registry
\n
"
,
st
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -383,7 +392,7 @@ BOOL WINAPI GetComputerNameA(LPSTR name, LPDWORD size)
...
@@ -383,7 +392,7 @@ BOOL WINAPI GetComputerNameA(LPSTR name, LPDWORD size)
if
(
*
size
<
len
)
if
(
*
size
<
len
)
{
{
*
size
=
len
;
*
size
=
len
;
SetLastError
(
ERROR_
MORE_DATA
);
SetLastError
(
ERROR_
BUFFER_OVERFLOW
);
ret
=
FALSE
;
ret
=
FALSE
;
}
}
else
else
...
@@ -415,7 +424,11 @@ BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT type, LPSTR name, LPDWORD si
...
@@ -415,7 +424,11 @@ BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT type, LPSTR name, LPDWORD si
{
{
case
ComputerNameNetBIOS
:
case
ComputerNameNetBIOS
:
case
ComputerNamePhysicalNetBIOS
:
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
ComputerNameDnsHostname
:
case
ComputerNamePhysicalDnsHostname
:
case
ComputerNamePhysicalDnsHostname
:
ret
=
dns_hostname
(
buf
,
&
len
);
ret
=
dns_hostname
(
buf
,
&
len
);
...
@@ -468,7 +481,10 @@ BOOL WINAPI GetComputerNameExW( COMPUTER_NAME_FORMAT type, LPWSTR name, LPDWORD
...
@@ -468,7 +481,10 @@ BOOL WINAPI GetComputerNameExW( COMPUTER_NAME_FORMAT type, LPWSTR name, LPDWORD
{
{
case
ComputerNameNetBIOS
:
case
ComputerNameNetBIOS
:
case
ComputerNamePhysicalNetBIOS
:
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
ComputerNameDnsHostname
:
case
ComputerNamePhysicalDnsHostname
:
case
ComputerNamePhysicalDnsHostname
:
ret
=
dns_hostname
(
buf
,
&
len
);
ret
=
dns_hostname
(
buf
,
&
len
);
...
...
dlls/kernel32/tests/environ.c
View file @
49c5bd03
...
@@ -330,7 +330,6 @@ static void test_GetComputerName(void)
...
@@ -330,7 +330,6 @@ static void test_GetComputerName(void)
size
=
0
;
size
=
0
;
ret
=
GetComputerNameA
((
LPSTR
)
0xdeadbeef
,
&
size
);
ret
=
GetComputerNameA
((
LPSTR
)
0xdeadbeef
,
&
size
);
error
=
GetLastError
();
error
=
GetLastError
();
todo_wine
ok
(
!
ret
&&
error
==
ERROR_BUFFER_OVERFLOW
,
"GetComputerNameA should have failed with ERROR_BUFFER_OVERFLOW instead of %d
\n
"
,
error
);
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 */
/* Only Vista returns the computer name length as documented in the MSDN */
...
@@ -362,7 +361,6 @@ static void test_GetComputerName(void)
...
@@ -362,7 +361,6 @@ static void test_GetComputerName(void)
win_skip
(
"GetComputerNameW is not implemented
\n
"
);
win_skip
(
"GetComputerNameW is not implemented
\n
"
);
else
else
{
{
todo_wine
ok
(
!
ret
&&
error
==
ERROR_BUFFER_OVERFLOW
,
"GetComputerNameW should have failed with ERROR_BUFFER_OVERFLOW instead of %d
\n
"
,
error
);
ok
(
!
ret
&&
error
==
ERROR_BUFFER_OVERFLOW
,
"GetComputerNameW should have failed with ERROR_BUFFER_OVERFLOW instead of %d
\n
"
,
error
);
size
++
;
/* nul terminating character */
size
++
;
/* nul terminating character */
nameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
nameW
[
0
]));
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