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
60fd03d2
Commit
60fd03d2
authored
Dec 05, 2001
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ntdll functions instead of MultiByteToWideChar/WideCharToMultiByte
to avoid corrupting the last error code.
parent
996c0bff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
79 deletions
+63
-79
registry.c
dlls/advapi32/registry.c
+31
-39
registry.c
memory/registry.c
+32
-40
No files found.
dlls/advapi32/registry.c
View file @
60fd03d2
...
@@ -345,12 +345,11 @@ DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len
...
@@ -345,12 +345,11 @@ DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len
if
(
!
status
)
if
(
!
status
)
{
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
info
->
NameLength
/
sizeof
(
WCHAR
),
DWORD
len
,
cls_len
;
NULL
,
0
,
NULL
,
NULL
);
DWORD
cls_len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
RtlUnicodeToMultiByteSize
(
&
len
,
info
->
Name
,
info
->
NameLength
);
RtlUnicodeToMultiByteSize
(
&
cls_len
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
);
if
(
ft
)
*
ft
=
*
(
FILETIME
*
)
&
info
->
LastWriteTime
;
if
(
ft
)
*
ft
=
*
(
FILETIME
*
)
&
info
->
LastWriteTime
;
if
(
len
>=
*
name_len
||
(
class_len
&&
(
cls_len
>=
*
class_len
)))
if
(
len
>=
*
name_len
||
(
class_len
&&
(
cls_len
>=
*
class_len
)))
...
@@ -358,17 +357,16 @@ DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len
...
@@ -358,17 +357,16 @@ DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len
else
else
{
{
*
name_len
=
len
;
*
name_len
=
len
;
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
info
->
NameLength
/
sizeof
(
WCHAR
),
RtlUnicodeToMultiByteN
(
name
,
len
,
NULL
,
info
->
Name
,
info
->
NameLength
);
name
,
len
,
NULL
,
NULL
);
name
[
len
]
=
0
;
name
[
len
]
=
0
;
if
(
class_len
)
if
(
class_len
)
{
{
*
class_len
=
cls_len
;
*
class_len
=
cls_len
;
if
(
class
)
if
(
class
)
{
{
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
)
,
RtlUnicodeToMultiByteN
(
class
,
cls_len
,
NULL
,
info
->
ClassLength
/
sizeof
(
WCHAR
),
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
class
,
cls_len
,
NULL
,
NULL
);
info
->
ClassLength
);
class
[
cls_len
]
=
0
;
class
[
cls_len
]
=
0
;
}
}
}
}
...
@@ -516,10 +514,7 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
...
@@ -516,10 +514,7 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
if
(
status
)
goto
done
;
if
(
status
)
goto
done
;
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
RtlUnicodeToMultiByteSize
(
&
len
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
);
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
if
(
class_len
)
if
(
class_len
)
{
{
if
(
len
+
1
>
*
class_len
)
status
=
STATUS_BUFFER_OVERFLOW
;
if
(
len
+
1
>
*
class_len
)
status
=
STATUS_BUFFER_OVERFLOW
;
...
@@ -527,10 +522,8 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
...
@@ -527,10 +522,8 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
}
}
if
(
class
&&
!
status
)
if
(
class
&&
!
status
)
{
{
WideCharToMultiByte
(
CP_ACP
,
0
,
RtlUnicodeToMultiByteN
(
class
,
len
,
NULL
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
);
info
->
ClassLength
/
sizeof
(
WCHAR
),
class
,
len
,
NULL
,
NULL
);
class
[
len
]
=
0
;
class
[
len
]
=
0
;
}
}
}
}
...
@@ -679,11 +672,11 @@ DWORD WINAPI RegSetValueExA( HKEY hkey, LPCSTR name, DWORD reserved, DWORD type,
...
@@ -679,11 +672,11 @@ DWORD WINAPI RegSetValueExA( HKEY hkey, LPCSTR name, DWORD reserved, DWORD type,
if
(
is_string
(
type
))
/* need to convert to Unicode */
if
(
is_string
(
type
))
/* need to convert to Unicode */
{
{
DWORD
lenW
=
MultiByteToWideChar
(
CP_ACP
,
0
,
data
,
count
,
NULL
,
0
)
;
DWORD
lenW
;
if
(
!
(
dataW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
lenW
*
sizeof
(
WCHAR
)
)))
RtlMultiByteToUnicodeSize
(
&
lenW
,
data
,
count
);
return
ERROR_OUTOFMEMORY
;
if
(
!
(
dataW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
lenW
)))
return
ERROR_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
data
,
count
,
dataW
,
lenW
);
RtlMultiByteToUnicodeN
(
dataW
,
lenW
,
NULL
,
data
,
count
);
count
=
lenW
*
sizeof
(
WCHAR
)
;
count
=
lenW
;
data
=
(
BYTE
*
)
dataW
;
data
=
(
BYTE
*
)
dataW
;
}
}
...
@@ -878,17 +871,17 @@ DWORD WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWORD
...
@@ -878,17 +871,17 @@ DWORD WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWORD
if
(
is_string
(
info
->
Type
))
if
(
is_string
(
info
->
Type
))
{
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info_size
),
DWORD
len
;
(
total_size
-
info_size
)
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
RtlUnicodeToMultiByteSize
(
&
len
,
(
WCHAR
*
)(
buf_ptr
+
info_size
),
total_size
-
info_size
);
if
(
data
&&
len
)
if
(
data
&&
len
)
{
{
if
(
len
>
*
count
)
status
=
STATUS_BUFFER_OVERFLOW
;
if
(
len
>
*
count
)
status
=
STATUS_BUFFER_OVERFLOW
;
else
else
{
{
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info_size
),
RtlUnicodeToMultiByteN
(
data
,
len
,
NULL
,
(
WCHAR
*
)(
buf_ptr
+
info_size
),
(
total_size
-
info_size
)
/
sizeof
(
WCHAR
),
total_size
-
info_size
);
data
,
len
,
NULL
,
NULL
);
/* if the type is REG_SZ and data is not 0-terminated
/* if the type is REG_SZ and data is not 0-terminated
* and there is enough space in the buffer NT appends a \0 */
* and there is enough space in the buffer NT appends a \0 */
if
(
len
<
*
count
&&
data
[
len
-
1
])
data
[
len
]
=
0
;
if
(
len
<
*
count
&&
data
[
len
-
1
])
data
[
len
]
=
0
;
...
@@ -1104,24 +1097,24 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
...
@@ -1104,24 +1097,24 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
if
(
value
)
if
(
value
)
{
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
info
->
NameLength
/
sizeof
(
WCHAR
),
DWORD
len
;
NULL
,
0
,
NULL
,
NULL
);
RtlUnicodeToMultiByteSize
(
&
len
,
info
->
Name
,
info
->
NameLength
);
if
(
len
>=
*
val_count
)
if
(
len
>=
*
val_count
)
{
{
status
=
STATUS_BUFFER_OVERFLOW
;
status
=
STATUS_BUFFER_OVERFLOW
;
goto
done
;
goto
done
;
}
}
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
info
->
NameLength
/
sizeof
(
WCHAR
),
RtlUnicodeToMultiByteN
(
value
,
len
,
NULL
,
info
->
Name
,
info
->
NameLength
);
value
,
len
,
NULL
,
NULL
);
value
[
len
]
=
0
;
value
[
len
]
=
0
;
*
val_count
=
len
;
*
val_count
=
len
;
}
}
if
(
is_string
(
info
->
Type
))
if
(
is_string
(
info
->
Type
))
{
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info
->
DataOffset
),
DWORD
len
;
(
total_size
-
info
->
DataOffset
)
/
sizeof
(
WCHAR
),
RtlUnicodeToMultiByteSize
(
&
len
,
(
WCHAR
*
)(
buf_ptr
+
info
->
DataOffset
),
NULL
,
0
,
NULL
,
NULL
);
total_size
-
info
->
DataOffset
);
if
(
data
&&
len
)
if
(
data
&&
len
)
{
{
if
(
len
>
*
count
)
if
(
len
>
*
count
)
...
@@ -1129,9 +1122,8 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
...
@@ -1129,9 +1122,8 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
status
=
STATUS_BUFFER_OVERFLOW
;
status
=
STATUS_BUFFER_OVERFLOW
;
goto
done
;
goto
done
;
}
}
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info
->
DataOffset
),
RtlUnicodeToMultiByteN
(
data
,
len
,
NULL
,
(
WCHAR
*
)(
buf_ptr
+
info
->
DataOffset
),
(
total_size
-
info
->
DataOffset
)
/
sizeof
(
WCHAR
),
total_size
-
info
->
DataOffset
);
data
,
len
,
NULL
,
NULL
);
/* if the type is REG_SZ and data is not 0-terminated
/* if the type is REG_SZ and data is not 0-terminated
* and there is enough space in the buffer NT appends a \0 */
* and there is enough space in the buffer NT appends a \0 */
if
(
len
<
*
count
&&
data
[
len
-
1
])
data
[
len
]
=
0
;
if
(
len
<
*
count
&&
data
[
len
-
1
])
data
[
len
]
=
0
;
...
...
memory/registry.c
View file @
60fd03d2
...
@@ -152,12 +152,11 @@ DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len
...
@@ -152,12 +152,11 @@ DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len
if
(
!
status
)
if
(
!
status
)
{
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
info
->
NameLength
/
sizeof
(
WCHAR
),
DWORD
len
,
cls_len
;
NULL
,
0
,
NULL
,
NULL
);
DWORD
cls_len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
RtlUnicodeToMultiByteSize
(
&
len
,
info
->
Name
,
info
->
NameLength
);
RtlUnicodeToMultiByteSize
(
&
cls_len
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
);
if
(
ft
)
*
ft
=
*
(
FILETIME
*
)
&
info
->
LastWriteTime
;
if
(
ft
)
*
ft
=
*
(
FILETIME
*
)
&
info
->
LastWriteTime
;
if
(
len
>=
*
name_len
||
(
class_len
&&
(
cls_len
>=
*
class_len
)))
if
(
len
>=
*
name_len
||
(
class_len
&&
(
cls_len
>=
*
class_len
)))
...
@@ -165,17 +164,16 @@ DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len
...
@@ -165,17 +164,16 @@ DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len
else
else
{
{
*
name_len
=
len
;
*
name_len
=
len
;
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
info
->
NameLength
/
sizeof
(
WCHAR
),
RtlUnicodeToMultiByteN
(
name
,
len
,
NULL
,
info
->
Name
,
info
->
NameLength
);
name
,
len
,
NULL
,
NULL
);
name
[
len
]
=
0
;
name
[
len
]
=
0
;
if
(
class_len
)
if
(
class_len
)
{
{
*
class_len
=
cls_len
;
*
class_len
=
cls_len
;
if
(
class
)
if
(
class
)
{
{
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
)
,
RtlUnicodeToMultiByteN
(
class
,
cls_len
,
NULL
,
info
->
ClassLength
/
sizeof
(
WCHAR
),
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
class
,
cls_len
,
NULL
,
NULL
);
info
->
ClassLength
);
class
[
cls_len
]
=
0
;
class
[
cls_len
]
=
0
;
}
}
}
}
...
@@ -207,7 +205,7 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
...
@@ -207,7 +205,7 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
NTSTATUS
status
;
NTSTATUS
status
;
char
buffer
[
256
],
*
buf_ptr
=
buffer
;
char
buffer
[
256
],
*
buf_ptr
=
buffer
;
KEY_FULL_INFORMATION
*
info
=
(
KEY_FULL_INFORMATION
*
)
buffer
;
KEY_FULL_INFORMATION
*
info
=
(
KEY_FULL_INFORMATION
*
)
buffer
;
DWORD
total_size
;
DWORD
total_size
,
len
;
TRACE
(
"(0x%x,%p,%ld,%p,%p,%p,%p,%p,%p,%p,%p)
\n
"
,
hkey
,
class
,
class_len
?
*
class_len
:
0
,
TRACE
(
"(0x%x,%p,%ld,%p,%p,%p,%p,%p,%p,%p,%p)
\n
"
,
hkey
,
class
,
class_len
?
*
class_len
:
0
,
reserved
,
subkeys
,
max_subkey
,
values
,
max_value
,
max_data
,
security
,
modif
);
reserved
,
subkeys
,
max_subkey
,
values
,
max_value
,
max_data
,
security
,
modif
);
...
@@ -216,6 +214,7 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
...
@@ -216,6 +214,7 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
return
ERROR_INVALID_PARAMETER
;
return
ERROR_INVALID_PARAMETER
;
status
=
NtQueryKey
(
hkey
,
KeyFullInformation
,
buffer
,
sizeof
(
buffer
),
&
total_size
);
status
=
NtQueryKey
(
hkey
,
KeyFullInformation
,
buffer
,
sizeof
(
buffer
),
&
total_size
);
if
(
status
&&
status
!=
STATUS_BUFFER_OVERFLOW
)
goto
done
;
if
(
class
||
class_len
)
if
(
class
||
class_len
)
{
{
...
@@ -229,12 +228,9 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
...
@@ -229,12 +228,9 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
status
=
NtQueryKey
(
hkey
,
KeyFullInformation
,
buf_ptr
,
total_size
,
&
total_size
);
status
=
NtQueryKey
(
hkey
,
KeyFullInformation
,
buf_ptr
,
total_size
,
&
total_size
);
}
}
if
(
!
status
)
if
(
status
)
goto
done
;
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
RtlUnicodeToMultiByteSize
(
&
len
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
);
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
if
(
class_len
)
if
(
class_len
)
{
{
if
(
len
+
1
>
*
class_len
)
status
=
STATUS_BUFFER_OVERFLOW
;
if
(
len
+
1
>
*
class_len
)
status
=
STATUS_BUFFER_OVERFLOW
;
...
@@ -242,17 +238,13 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
...
@@ -242,17 +238,13 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
}
}
if
(
class
&&
!
status
)
if
(
class
&&
!
status
)
{
{
WideCharToMultiByte
(
CP_ACP
,
0
,
RtlUnicodeToMultiByteN
(
class
,
len
,
NULL
,
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
(
WCHAR
*
)(
buf_ptr
+
info
->
ClassOffset
),
info
->
ClassLength
);
info
->
ClassLength
/
sizeof
(
WCHAR
),
class
,
len
,
NULL
,
NULL
);
class
[
len
]
=
0
;
class
[
len
]
=
0
;
}
}
}
}
}
else
status
=
STATUS_SUCCESS
;
if
(
!
status
||
status
==
STATUS_BUFFER_OVERFLOW
)
{
if
(
subkeys
)
*
subkeys
=
info
->
SubKeys
;
if
(
subkeys
)
*
subkeys
=
info
->
SubKeys
;
if
(
max_subkey
)
*
max_subkey
=
info
->
MaxNameLen
;
if
(
max_subkey
)
*
max_subkey
=
info
->
MaxNameLen
;
if
(
max_class
)
*
max_class
=
info
->
MaxClassLen
;
if
(
max_class
)
*
max_class
=
info
->
MaxClassLen
;
...
@@ -260,8 +252,8 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
...
@@ -260,8 +252,8 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
if
(
max_value
)
*
max_value
=
info
->
MaxValueNameLen
;
if
(
max_value
)
*
max_value
=
info
->
MaxValueNameLen
;
if
(
max_data
)
*
max_data
=
info
->
MaxValueDataLen
;
if
(
max_data
)
*
max_data
=
info
->
MaxValueDataLen
;
if
(
modif
)
*
modif
=
*
(
FILETIME
*
)
&
info
->
LastWriteTime
;
if
(
modif
)
*
modif
=
*
(
FILETIME
*
)
&
info
->
LastWriteTime
;
}
done:
if
(
buf_ptr
!=
buffer
)
HeapFree
(
GetProcessHeap
(),
0
,
buf_ptr
);
if
(
buf_ptr
!=
buffer
)
HeapFree
(
GetProcessHeap
(),
0
,
buf_ptr
);
return
RtlNtStatusToDosError
(
status
);
return
RtlNtStatusToDosError
(
status
);
}
}
...
@@ -324,11 +316,11 @@ DWORD WINAPI RegSetValueExA( HKEY hkey, LPCSTR name, DWORD reserved, DWORD type,
...
@@ -324,11 +316,11 @@ DWORD WINAPI RegSetValueExA( HKEY hkey, LPCSTR name, DWORD reserved, DWORD type,
if
(
is_string
(
type
))
/* need to convert to Unicode */
if
(
is_string
(
type
))
/* need to convert to Unicode */
{
{
DWORD
lenW
=
MultiByteToWideChar
(
CP_ACP
,
0
,
data
,
count
,
NULL
,
0
)
;
DWORD
lenW
;
if
(
!
(
dataW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
lenW
*
sizeof
(
WCHAR
)
)))
RtlMultiByteToUnicodeSize
(
&
lenW
,
data
,
count
);
return
ERROR_OUTOFMEMORY
;
if
(
!
(
dataW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
lenW
)))
return
ERROR_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
data
,
count
,
dataW
,
lenW
);
RtlMultiByteToUnicodeN
(
dataW
,
lenW
,
NULL
,
data
,
count
);
count
=
lenW
*
sizeof
(
WCHAR
)
;
count
=
lenW
;
data
=
(
BYTE
*
)
dataW
;
data
=
(
BYTE
*
)
dataW
;
}
}
...
@@ -529,24 +521,24 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
...
@@ -529,24 +521,24 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
if
(
value
)
if
(
value
)
{
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
info
->
NameLength
/
sizeof
(
WCHAR
),
DWORD
len
;
NULL
,
0
,
NULL
,
NULL
);
RtlUnicodeToMultiByteSize
(
&
len
,
info
->
Name
,
info
->
NameLength
);
if
(
len
>=
*
val_count
)
if
(
len
>=
*
val_count
)
{
{
status
=
STATUS_BUFFER_OVERFLOW
;
status
=
STATUS_BUFFER_OVERFLOW
;
goto
done
;
goto
done
;
}
}
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
info
->
NameLength
/
sizeof
(
WCHAR
),
RtlUnicodeToMultiByteN
(
value
,
len
,
NULL
,
info
->
Name
,
info
->
NameLength
);
value
,
len
,
NULL
,
NULL
);
value
[
len
]
=
0
;
value
[
len
]
=
0
;
*
val_count
=
len
;
*
val_count
=
len
;
}
}
if
(
is_string
(
info
->
Type
))
if
(
is_string
(
info
->
Type
))
{
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info
->
DataOffset
),
DWORD
len
;
(
total_size
-
info
->
DataOffset
)
/
sizeof
(
WCHAR
),
RtlUnicodeToMultiByteSize
(
&
len
,
(
WCHAR
*
)(
buf_ptr
+
info
->
DataOffset
),
NULL
,
0
,
NULL
,
NULL
);
total_size
-
info
->
DataOffset
);
if
(
data
&&
len
)
if
(
data
&&
len
)
{
{
if
(
len
>
*
count
)
if
(
len
>
*
count
)
...
@@ -554,9 +546,8 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
...
@@ -554,9 +546,8 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
status
=
STATUS_BUFFER_OVERFLOW
;
status
=
STATUS_BUFFER_OVERFLOW
;
goto
done
;
goto
done
;
}
}
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)(
buf_ptr
+
info
->
DataOffset
),
RtlUnicodeToMultiByteN
(
data
,
len
,
NULL
,
(
WCHAR
*
)(
buf_ptr
+
info
->
DataOffset
),
(
total_size
-
info
->
DataOffset
)
/
sizeof
(
WCHAR
),
total_size
-
info
->
DataOffset
);
data
,
len
,
NULL
,
NULL
);
/* if the type is REG_SZ and data is not 0-terminated
/* if the type is REG_SZ and data is not 0-terminated
* and there is enough space in the buffer NT appends a \0 */
* and there is enough space in the buffer NT appends a \0 */
if
(
len
<
*
count
&&
data
[
len
-
1
])
data
[
len
]
=
0
;
if
(
len
<
*
count
&&
data
[
len
-
1
])
data
[
len
]
=
0
;
...
@@ -569,6 +560,7 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
...
@@ -569,6 +560,7 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
else
memcpy
(
data
,
buf_ptr
+
info
->
DataOffset
,
total_size
-
info
->
DataOffset
);
else
memcpy
(
data
,
buf_ptr
+
info
->
DataOffset
,
total_size
-
info
->
DataOffset
);
}
}
}
}
else
status
=
STATUS_SUCCESS
;
if
(
type
)
*
type
=
info
->
Type
;
if
(
type
)
*
type
=
info
->
Type
;
if
(
count
)
*
count
=
info
->
DataLength
;
if
(
count
)
*
count
=
info
->
DataLength
;
...
...
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