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
4fe6460a
Commit
4fe6460a
authored
May 09, 2019
by
Akihiro Sagawa
Committed by
Alexandre Julliard
May 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Return required buffer size in RegLoadMUIString.
Signed-off-by:
Akihiro Sagawa
<
sagawa.aki@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
2d9a7cd3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
registry.c
dlls/advapi32/registry.c
+8
-2
registry.c
dlls/advapi32/tests/registry.c
+6
-8
No files found.
dlls/advapi32/registry.c
View file @
4fe6460a
...
...
@@ -3112,7 +3112,7 @@ LSTATUS WINAPI RegOpenUserClassesRoot(
* avoid importing user32, which is higher level than advapi32. Helper for
* RegLoadMUIString.
*/
static
LONG
load_string
(
HINSTANCE
hModule
,
UINT
resId
,
LPWSTR
pwszBuffer
,
INT
cMaxChars
)
static
LONG
load_string
(
HINSTANCE
hModule
,
UINT
resId
,
LPWSTR
pwszBuffer
,
INT
cMaxChars
,
UINT
*
reqChars
)
{
HGLOBAL
hMemory
;
HRSRC
hResource
;
...
...
@@ -3133,6 +3133,7 @@ static LONG load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cM
/* Strings are length-prefixed. Lowest nibble of resId is an index. */
idxString
=
resId
&
0xf
;
while
(
idxString
--
)
pString
+=
*
pString
+
1
;
*
reqChars
=
*
pString
+
1
;
/* If no buffer is given, return here. */
if
(
!
pwszBuffer
)
return
ERROR_MORE_DATA
;
...
...
@@ -3221,6 +3222,8 @@ LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer
result
=
ERROR_SUCCESS
;
if
(
*
pwszExpandedBuffer
!=
'@'
)
{
/* '@' is the prefix for resource based string entries. */
lstrcpynW
(
pwszBuffer
,
pwszExpandedBuffer
,
cbBuffer
/
sizeof
(
WCHAR
));
if
(
pcbData
)
*
pcbData
=
(
strlenW
(
pwszExpandedBuffer
)
+
1
)
*
sizeof
(
WCHAR
);
}
else
{
WCHAR
*
pComma
=
strrchrW
(
pwszExpandedBuffer
,
','
),
*
pNewBuffer
;
const
WCHAR
backslashW
[]
=
{
'\\'
,
0
};
...
...
@@ -3264,7 +3267,10 @@ LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer
hModule
=
LoadLibraryExW
(
pwszTempBuffer
,
NULL
,
LOAD_LIBRARY_AS_DATAFILE
|
LOAD_LIBRARY_AS_IMAGE_RESOURCE
);
if
(
hModule
)
{
result
=
load_string
(
hModule
,
uiStringId
,
pwszBuffer
,
cbBuffer
/
sizeof
(
WCHAR
));
DWORD
reqChars
;
result
=
load_string
(
hModule
,
uiStringId
,
pwszBuffer
,
cbBuffer
/
sizeof
(
WCHAR
),
&
reqChars
);
if
(
pcbData
&&
(
result
==
ERROR_SUCCESS
||
result
==
ERROR_MORE_DATA
))
*
pcbData
=
reqChars
*
sizeof
(
WCHAR
);
FreeLibrary
(
hModule
);
}
else
...
...
dlls/advapi32/tests/registry.c
View file @
4fe6460a
...
...
@@ -3892,7 +3892,7 @@ static void test_RegLoadMUIString(void)
size
=
0xdeadbeef
;
ret
=
pRegLoadMUIStringW
(
hkey
,
tz_valueW
,
NULL
,
0
,
&
size
,
0
,
NULL
);
ok
(
ret
==
ERROR_MORE_DATA
,
"got %d, expected ERROR_MORE_DATA
\n
"
,
ret
);
todo_wine
ok
(
size
==
text_size
,
"got %u, expected %u
\n
"
,
size
,
text_size
);
ok
(
size
==
text_size
,
"got %u, expected %u
\n
"
,
size
,
text_size
);
memset
(
bufW
,
0xff
,
sizeof
(
bufW
));
ret
=
pRegLoadMUIStringW
(
hkey
,
tz_valueW
,
bufW
,
sizeof
(
WCHAR
)
+
1
,
&
size
,
0
,
NULL
);
...
...
@@ -3903,7 +3903,7 @@ static void test_RegLoadMUIString(void)
memset
(
bufW
,
0xff
,
sizeof
(
bufW
));
ret
=
pRegLoadMUIStringW
(
hkey
,
tz_valueW
,
bufW
,
sizeof
(
WCHAR
)
*
2
,
&
size
,
0
,
NULL
);
todo_wine
ok
(
ret
==
ERROR_MORE_DATA
,
"got %d, expected ERROR_MORE_DATA
\n
"
,
ret
);
todo_wine
ok
(
size
==
text_size
||
broken
(
size
==
text_size
+
sizeof
(
WCHAR
)
/* vista */
),
ok
(
size
==
text_size
||
broken
(
size
==
text_size
+
sizeof
(
WCHAR
)
/* vista */
),
"got %u, expected %u
\n
"
,
size
,
text_size
);
todo_wine
ok
(
bufW
[
0
]
==
0xffff
,
"got 0x%04x, expected 0xffff
\n
"
,
bufW
[
0
]);
...
...
@@ -3911,9 +3911,8 @@ static void test_RegLoadMUIString(void)
memset
(
bufW
,
0xff
,
sizeof
(
bufW
));
ret
=
pRegLoadMUIStringW
(
hkey
,
tz_valueW
,
bufW
,
ARRAY_SIZE
(
bufW
),
&
size
,
0
,
NULL
);
ok
(
ret
==
ERROR_SUCCESS
,
"got %d, expected ERROR_SUCCESS
\n
"
,
ret
);
todo_wine
ok
(
size
==
text_size
,
"got %u, expected %u
\n
"
,
size
,
text_size
);
size
=
min
(
size
,
sizeof
(
bufW
));
todo_wine
ok
(
!
memcmp
(
textW
,
bufW
,
size
),
"got %s, expected %s
\n
"
,
ok
(
size
==
text_size
,
"got %u, expected %u
\n
"
,
size
,
text_size
);
ok
(
!
memcmp
(
textW
,
bufW
,
size
),
"got %s, expected %s
\n
"
,
wine_dbgstr_wn
(
bufW
,
size
/
sizeof
(
WCHAR
)),
wine_dbgstr_wn
(
textW
,
text_size
/
sizeof
(
WCHAR
)));
ret
=
pRegLoadMUIStringA
(
hkey
,
tz_value
,
buf
,
ARRAY_SIZE
(
buf
),
&
size
,
0
,
NULL
);
...
...
@@ -3926,9 +3925,8 @@ static void test_RegLoadMUIString(void)
memset
(
bufW
,
0xff
,
sizeof
(
bufW
));
ret
=
pRegLoadMUIStringW
(
hkey
,
tz_valueW
,
bufW
,
ARRAY_SIZE
(
bufW
),
&
size
,
0
,
sysdirW
);
ok
(
ret
==
ERROR_SUCCESS
,
"got %d, expected ERROR_SUCCESS
\n
"
,
ret
);
todo_wine
ok
(
size
==
text_size
,
"got %u, expected %u
\n
"
,
size
,
text_size
);
size
=
min
(
size
,
sizeof
(
bufW
));
todo_wine
ok
(
!
memcmp
(
textW
,
bufW
,
size
),
"got %s, expected %s
\n
"
,
ok
(
size
==
text_size
,
"got %u, expected %u
\n
"
,
size
,
text_size
);
ok
(
!
memcmp
(
textW
,
bufW
,
size
),
"got %s, expected %s
\n
"
,
wine_dbgstr_wn
(
bufW
,
size
/
sizeof
(
WCHAR
)),
wine_dbgstr_wn
(
textW
,
text_size
/
sizeof
(
WCHAR
)));
ret
=
pRegLoadMUIStringA
(
hkey
,
tz_value
,
buf
,
ARRAY_SIZE
(
buf
),
&
size
,
0
,
sysdir
);
...
...
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