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
726027d6
Commit
726027d6
authored
Nov 08, 2023
by
Paul Gofman
Committed by
Alexandre Julliard
Nov 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Return empty string from LoadStringW() if resource is not found.
parent
a3287287
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
6 deletions
+34
-6
resource.c
dlls/user32/resource.c
+7
-6
resource.c
dlls/user32/tests/resource.c
+27
-0
No files found.
dlls/user32/resource.c
View file @
726027d6
...
@@ -161,12 +161,13 @@ INT WINAPI DECLSPEC_HOTPATCH LoadStringW( HINSTANCE instance, UINT resource_id,
...
@@ -161,12 +161,13 @@ INT WINAPI DECLSPEC_HOTPATCH LoadStringW( HINSTANCE instance, UINT resource_id,
if
(
buffer
==
NULL
)
if
(
buffer
==
NULL
)
return
0
;
return
0
;
/* Use loword (incremented by 1) as resourceid */
if
(
!
(
hrsrc
=
FindResourceW
(
instance
,
MAKEINTRESOURCEW
((
LOWORD
(
resource_id
)
>>
4
)
+
1
),
(
LPWSTR
)
RT_STRING
))
||
hrsrc
=
FindResourceW
(
instance
,
MAKEINTRESOURCEW
((
LOWORD
(
resource_id
)
>>
4
)
+
1
),
!
(
hmem
=
LoadResource
(
instance
,
hrsrc
)))
(
LPWSTR
)
RT_STRING
);
{
if
(
!
hrsrc
)
return
0
;
TRACE
(
"Failed to load string.
\n
"
);
hmem
=
LoadResource
(
instance
,
hrsrc
);
if
(
buflen
>
0
)
buffer
[
0
]
=
0
;
if
(
!
hmem
)
return
0
;
return
0
;
}
p
=
LockResource
(
hmem
);
p
=
LockResource
(
hmem
);
string_num
=
resource_id
&
0x000f
;
string_num
=
resource_id
&
0x000f
;
...
...
dlls/user32/tests/resource.c
View file @
726027d6
...
@@ -120,6 +120,33 @@ static void test_LoadStringW(void)
...
@@ -120,6 +120,33 @@ static void test_LoadStringW(void)
winetest_pop_context
();
winetest_pop_context
();
}
}
}
}
/* Test missing resource. */
SetLastError
(
0xdeadbeef
);
memset
(
returnedstringw
,
0xcc
,
sizeof
(
returnedstringw
));
length1
=
LoadStringW
(
hInst
,
0xdeadbeef
,
returnedstringw
,
ARRAY_SIZE
(
returnedstringw
));
ok
(
!
length1
,
"got %d.
\n
"
,
length1
);
ok
(
GetLastError
()
==
ERROR_RESOURCE_NAME_NOT_FOUND
||
broken
(
GetLastError
()
==
ERROR_MUI_FILE_NOT_FOUND
)
/* Win7 */
,
"got %lu.
\n
"
,
GetLastError
());
ok
(
!
returnedstringw
[
0
],
"got %#x.
\n
"
,
returnedstringw
[
0
]);
ok
(
returnedstringw
[
1
]
==
0xcccc
,
"got %#x.
\n
"
,
returnedstringw
[
1
]);
SetLastError
(
0xdeadbeef
);
memset
(
returnedstringw
,
0xcc
,
sizeof
(
returnedstringw
));
length1
=
LoadStringW
(
hInst
,
0xdeadbeef
,
returnedstringw
,
0
);
ok
(
!
length1
,
"got %d.
\n
"
,
length1
);
ok
(
GetLastError
()
==
ERROR_RESOURCE_NAME_NOT_FOUND
||
broken
(
GetLastError
()
==
ERROR_MUI_FILE_NOT_LOADED
)
/* Win7 */
,
"got %lu.
\n
"
,
GetLastError
());
ok
(
returnedstringw
[
0
]
==
0xcccc
,
"got %#x.
\n
"
,
returnedstringw
[
1
]);
SetLastError
(
0xdeadbeef
);
memset
(
returnedstringw
,
0xcc
,
sizeof
(
returnedstringw
));
length1
=
LoadStringW
(
hInst
,
0xdeadbeef
,
returnedstringw
,
1
);
ok
(
!
length1
,
"got %d.
\n
"
,
length1
);
ok
(
GetLastError
()
==
ERROR_RESOURCE_NAME_NOT_FOUND
||
broken
(
GetLastError
()
==
ERROR_MUI_FILE_NOT_LOADED
)
/* Win7 */
,
"got %lu.
\n
"
,
GetLastError
());
ok
(
!
returnedstringw
[
0
],
"got %#x.
\n
"
,
returnedstringw
[
0
]);
ok
(
returnedstringw
[
1
]
==
0xcccc
,
"got %#x.
\n
"
,
returnedstringw
[
1
]);
}
}
static
void
test_LoadStringA
(
void
)
static
void
test_LoadStringA
(
void
)
...
...
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